/* ============================================================================
   Deck framework — engine
   Slide engine layout, idle-CPU guard, reveal, cover frame, nav chrome, overview,
   TOC, theme toggle. Reads semantic tokens only (see a theme's theme.css); never
   a theme's own names. Load order: engine → components → theme → talk → presenter.
   ============================================================================ */


* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); overflow: hidden; overflow-wrap: break-word; }

/* ── Deck engine ── */
.deck { height: 100dvh; overflow-y: auto; scroll-snap-type: y mandatory; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.slide {
  height: 100dvh; scroll-snap-align: start; overflow: hidden; position: relative;
  display: flex; flex-direction: column; justify-content: center;
  padding: clamp(30px, 5vh, 64px) clamp(30px, 7vw, 120px);
  isolation: isolate;
}
.slide > * { position: relative; z-index: 2; }

/* ── Idle-CPU guard: animations only tick on the slide that is on screen ──
   All 23 slides live in the DOM at once, and most of this deck's decorative
   animations are `infinite`. Without this rule they all repaint for the whole
   talk — on a machine with hardware acceleration off, that alone can saturate
   the CPU. `.is-live` (set by SlideEngine.update()) is the ONE current slide;
   note that `.visible` is useless here because it is never removed once set.
   One blanket rule rather than 22 edits, so animations added later are covered
   automatically. */
.slide:not(.is-live) *,
.slide:not(.is-live) *::before,
.slide:not(.is-live) *::after { animation-play-state: paused !important; }

/* reveal animation */
.slide { opacity: 0; transform: translateY(34px) scale(0.985); transition: opacity .6s cubic-bezier(.16,1,.3,1), transform .6s cubic-bezier(.16,1,.3,1); }
.slide.visible { opacity: 1; transform: none; }
.slide .reveal { opacity: 0; transform: translateY(18px); transition: opacity .5s cubic-bezier(.16,1,.3,1), transform .5s cubic-bezier(.16,1,.3,1); }
.slide.visible .reveal { opacity: 1; transform: none; }
.slide.visible .reveal:nth-child(1){transition-delay:.06s}
.slide.visible .reveal:nth-child(2){transition-delay:.14s}
.slide.visible .reveal:nth-child(3){transition-delay:.22s}
.slide.visible .reveal:nth-child(4){transition-delay:.30s}
.slide.visible .reveal:nth-child(5){transition-delay:.38s}
.slide.visible .reveal:nth-child(6){transition-delay:.46s}
.slide.visible .reveal:nth-child(7){transition-delay:.54s}
@media (prefers-reduced-motion: reduce) { .slide, .slide .reveal { opacity: 1 !important; transform: none !important; transition: none !important; } }

/* ── Cover frame: the talk supplies the hero (canvas, fallback) behind it ── */
.slide--cover { padding: 0; justify-content: center; align-items: flex-start; }
.slide--cover .veil { position: absolute; inset: 0; z-index: 1; background: var(--veil); }
.cover-inner { position: relative; z-index: 2; padding: clamp(30px, 5vh, 64px) clamp(36px, 8vw, 130px); }

/* ── Nav chrome ── */
.deck-progress { position: fixed; top: 0; left: 0; height: 3px; background: var(--accent); z-index: 100; transition: width .3s ease; pointer-events: none; }
/* No backdrop-filter here on purpose. This pill is `position: fixed`, so it sits
   over every slide for the whole talk, and a blurred backdrop has to be re-blurred
   by the compositor whenever anything behind it repaints — the one always-present
   element paying that cost on all 23 slides. A more opaque background reads the
   same at this size. Overlay panels (overview/TOC) keep their blur: they are
   transient, and the deck is idle while they are open. */
.deck-dots { position: fixed; right: clamp(10px, 1.8vw, 22px); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 100; background: color-mix(in srgb, var(--bg) 88%, transparent); padding: 8px 6px; border-radius: 20px; }
.deck-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .3; border: none; padding: 0; cursor: pointer; transition: opacity .2s, transform .2s; }
.deck-dot:hover { opacity: .6; }
.deck-dot.active { opacity: 1; transform: scale(1.5); background: var(--accent); }
.deck-counter { position: fixed; bottom: clamp(10px, 1.8vh, 22px); right: clamp(10px, 1.8vw, 22px); font-family: var(--font-mono); font-size: 12px; color: var(--muted); z-index: 100; font-variant-numeric: tabular-nums; }
/* Wraps rather than nowrap: the hint list grew when the presenter keys were added,
   and at 11px mono it is wider than a phone viewport — with body overflow hidden and
   a centring translate, nowrap clips it at BOTH ends. */
.deck-hints { position: fixed; bottom: clamp(10px, 1.8vh, 22px); left: 50%; transform: translateX(-50%); font-family: var(--font-mono); font-size: 11px; color: var(--muted); opacity: .6; z-index: 100; transition: opacity .5s ease; max-width: min(92vw, 760px); text-align: center; line-height: 1.6; }
.deck-hints.faded { opacity: 0; pointer-events: none; }

/* ── Presenter cues ──
   Cues now live in cues.js, not in this document, so there is nothing left to leak
   onto the projector. These rules stay as cheap insurance in case an <aside> is
   ever reintroduced, and the print rule is still load-bearing for .pnotes/.pmsg/.pv
   — a PDF export must never carry presenter chrome. */
.notes { display: none; }
@media print { .notes, .pnotes, .pmsg, .pv { display: none !important; } }

/* ── Dot hover-labels: reveal "07 · Title" so no counting is needed ── */
.deck-dot { position: relative; }
.deck-dot__label {
  position: absolute; right: calc(100% + 12px); top: 50%;
  transform: translateY(-50%) translateX(5px);
  white-space: nowrap; font-family: var(--font-mono); font-size: 11px; line-height: 1;
  color: var(--text-strong); background: color-mix(in srgb, var(--bg) 88%, transparent);
  border: 1px solid var(--line); padding: 5px 9px; border-radius: 6px;
  pointer-events: none; opacity: 0;
  transition: opacity .16s ease, transform .16s ease;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.deck-dot__label b { color: var(--accent); font-weight: 600; }
.deck-dot:hover .deck-dot__label,
.deck-dot:focus-visible .deck-dot__label { opacity: 1; transform: translateY(-50%) translateX(0); }

/* ── Toggle buttons for the overlays (bottom-left) ── */
.deck-tools { position: fixed; left: clamp(10px, 1.8vw, 22px); bottom: clamp(10px, 1.8vh, 22px); display: flex; gap: 8px; z-index: 100; }
.deck-tools button {
  width: 34px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 55%, transparent); color: var(--muted);
  cursor: pointer; font-size: 15px; line-height: 1; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transition: color .15s, border-color .15s;
}
.deck-tools button:hover { color: var(--text-strong); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ── Overview grid (O): contact-sheet of all slides ── */
.deck-overview {
  position: fixed; inset: 0; z-index: 400; display: none; overflow-y: auto;
  padding: clamp(20px, 4vh, 48px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.deck-overview.open { display: block; }
.deck-overview__head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: clamp(14px, 2.4vh, 26px); }
.deck-overview__title { font-family: var(--font-display); font-size: clamp(20px, 2.6vw, 30px); color: var(--text-strong); }
.deck-overview__hint { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.deck-overview__grid {
  display: grid; gap: clamp(10px, 1.4vw, 16px);
  grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 18vw, 220px), 1fr));
}
.deck-ov-cell {
  display: flex; flex-direction: column; gap: 7px; min-height: 92px;
  text-align: left; cursor: pointer; font: inherit; color: inherit;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 14px 15px;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.deck-ov-cell:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--surface-2); }
.deck-ov-cell.active { border-color: var(--accent); background: var(--surface-2); }
.deck-ov-cell__num { font-family: var(--font-mono); font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }
.deck-ov-cell.active .deck-ov-cell__num::after { content: ' · current'; color: var(--muted); }
.deck-ov-cell__title { font-family: var(--font-display); font-size: clamp(15px, 1.5vw, 19px); color: var(--text-strong); line-height: 1.2; }
.deck-ov-cell__sec { margin-top: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); letter-spacing: .02em; }

/* ── TOC drawer (T): left slide-in list ── */
.deck-scrim {
  position: fixed; inset: 0; z-index: 390; opacity: 0; pointer-events: none;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  transition: opacity .28s ease;
}
.deck-scrim.open { opacity: 1; pointer-events: auto; }
.deck-toc {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 400; width: min(340px, 82vw);
  display: flex; flex-direction: column; padding: clamp(16px, 3vh, 26px) 0;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 8px 0 40px rgba(0, 0, 0, .28);
  transform: translateX(-102%); transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
.deck-toc.open { transform: translateX(0); }
.deck-toc__head { padding: 0 clamp(18px, 2.4vw, 26px) 12px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.deck-toc__list { flex: 1; overflow-y: auto; }
.deck-toc__item {
  display: flex; align-items: baseline; gap: 12px; width: 100%; text-align: left;
  padding: 9px clamp(18px, 2.4vw, 26px); border: none; border-left: 2px solid transparent;
  background: none; cursor: pointer; color: var(--muted); font: inherit;
  transition: background .14s, color .14s;
}
.deck-toc__item:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); color: var(--text-strong); }
.deck-toc__item.active { color: var(--text-strong); border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.deck-toc__num { min-width: 20px; font-family: var(--font-mono); font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }
.deck-toc__label { font-family: var(--font-body); font-size: 14px; line-height: 1.3; }
.theme-toggle { position: fixed; top: 14px; right: 14px; z-index: 300; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.theme-toggle:hover { color: var(--text-strong); }

/* ── Responsive ── */
@media (max-width: 860px) {
  /* safe: a slide taller than the phone starts at its top instead of
     centring past it, where the overflow above could not be scrolled to */
  .slide { overflow-y: auto; justify-content: safe center; }
  /* the end of a slide that scrolls clears the fixed chrome at the bottom
     (contents buttons, counter, a talk's corner widgets) */
  .slide { padding-bottom: max(clamp(30px, 5vh, 64px), 96px); }
}
/* a phone: the dots sat over the slides' right edge, and the counter and the
   contents button already say where you are */
@media (max-width: 600px) { .deck-dots { display: none; } }
/* keyboard hints mean nothing on a touch screen, and wrapped over the buttons */
@media (hover: none) and (pointer: coarse) { .deck-hints { display: none; } }
