/*
 * Type scale follows standard presentation-legibility guidance (readable
 * from the back of a room / on a shared screen, not just up close):
 *   - body/bullet text: floor ~1.45rem (~23px), never below ~1.3rem even
 *     for "secondary" content — no fine print carrying real information.
 *   - headings: ~2-2.75rem, titles: ~3-4rem.
 *   - only true labels (eyebrows, kickers, timestamps) go below body size.
 *
 * Color system: white / orange / dark-grey, same hues throughout — no new
 * colors are introduced. Depth (shadows, --accent-2 gradients) and angular
 * "esports HUD" motifs (clipped corners, corner brackets, diagonal cuts)
 * layer polish on top without changing what white/orange/grey each mean.
 * Dark greys are tonal variants of the one "dark grey" for layering (bg vs.
 * surface vs. border), not a separate color. --item-1..5 are an optional
 * palette for per-item decorative accents (gallery/timeline-h/stat cards)
 * where a bit of color variety helps scanning — never used for text,
 * links, or nav.
 *
 * Typography: --font-display (angular/tech) for headings, kickers, and
 * numeric callouts; --font-body for everything readers actually read.
 */
:root {
  --bg: #262626;
  --surface: #3a3a3a;
  --surface-raised: #454545;
  --border: #545454;
  --text: #c9c9c9;
  --text-dim: #969696;
  --accent: #ff8a08;
  --accent-soft: rgba(255, 138, 8, 0.14);

  --item-1: #ff8a08;
  --item-2: #2ec4b6;
  --item-3: #3a86ff;
  --item-4: #ff5d73;
  --item-5: #ffbe0b;

  --fs-label: clamp(0.9rem, 1vw, 1.05rem);
  --fs-heading: clamp(2.1rem, 3vw, 2.8rem);
  --fs-body: clamp(1.7rem, 1.3vw, 2.15rem);
  --fs-body-secondary: clamp(1.45rem, 1.1vw, 1.7rem);
  --lh-body: 1.45;

  --font-display: "Chakra Petch", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;

  --accent-2: #cc6f06;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

#deck {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#deck-header {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

#deck-title {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-size: 0.9rem;
  text-transform: uppercase;
}

#slide-counter {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Letterbox frame: fills the remaining space between header/nav and centers
 * the fixed-16:9 stage inside it, with bars (background) on whichever axis
 * doesn't match the window's own aspect ratio. */
#stage-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

/* The stage itself: always exactly 16:9, regardless of window shape. Height
 * fills the frame and width is derived from it via aspect-ratio; if that
 * would overflow the frame's width, max-width takes over and the height is
 * re-derived from it instead (standard CSS aspect-ratio + max-size behavior). */
#slides-viewport {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  height: 100%;
  width: auto;
  max-width: 100%;
}

/* Corner brackets: a subtle esports/HUD framing device around the stage. */
#slides-viewport::before,
#slides-viewport::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border: solid var(--accent);
  opacity: 0.5;
  pointer-events: none;
  z-index: 5;
}
#slides-viewport::before {
  top: 14px;
  left: 14px;
  border-width: 3px 0 0 3px;
}
#slides-viewport::after {
  bottom: 14px;
  right: 14px;
  border-width: 0 3px 3px 0;
}

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
  padding: 4.5vh 8vw;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 0;
  transform: translateX(0);
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0.28s;
}

.slide-lottie {
  position: absolute;
  top: 5%;
  right: 4%;
  width: clamp(150px, 18vw, 250px);
  height: clamp(100px, 13vw, 165px);
  opacity: 0.72;
  pointer-events: none;
  z-index: 0;
}

.slide-lottie svg,
.component-lottie svg {
  display: block;
  width: 100%;
  height: 100%;
}

.component-lottie {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 44px;
  height: 30px;
  opacity: 0.62;
  pointer-events: none;
}

.slide--model3d {
  padding: 0;
  overflow: hidden;
}

.slide.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

/* Outgoing slide during a nav transition: fades + slides opposite the nav direction. */
.slide.is-leaving {
  visibility: visible;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
.slide.is-leaving.dir-next {
  transform: translateX(-36px);
}
.slide.is-leaving.dir-prev {
  transform: translateX(36px);
}

.slide--divider,
.slide--section {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: var(--bg);
  overflow: hidden;
}

/* Diagonal cut-corner wedges — angular "title card" motif over the gradient. */
.slide--divider::before,
.slide--section::before,
.slide--divider::after,
.slide--section::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: 0.07;
  pointer-events: none;
}
.slide--divider::before,
.slide--section::before {
  clip-path: polygon(0 100%, 32% 100%, 58% 0, 0 0);
}
.slide--divider::after,
.slide--section::after {
  clip-path: polygon(100% 0, 100% 100%, 68% 100%, 90% 0);
}

.slide-divider-title,
.tpl-section-title {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--bg);
}

.slide-divider-source {
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--bg);
  opacity: 0.7;
  font-family: "Consolas", monospace;
}

/* ---- Slide templates ----------------------------------------------------
 * Selected per "## Heading {tag}" — see templates-guide.md
 * for the full catalog with examples of each tag.
 */

/* title: big heading + subtitle, centered */
.slide--title {
  align-items: center;
  justify-content: center;
  text-align: center;
}
.tpl-title h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 4.6vw, 3.8rem);
  margin: 0 0 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tpl-subtitle {
  font-size: clamp(1.3rem, 1.8vw, 1.6rem);
  color: var(--text-dim);
  margin: 0;
}

/* title-only: single big heading, nothing else */
.slide--title-only {
  align-items: center;
  justify-content: center;
  text-align: center;
}
.tpl-title-only h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

/* quote: large centered pull-quote */
.slide--quote {
  align-items: center;
  justify-content: center;
  text-align: center;
}
.tpl-quote blockquote {
  margin: 0;
  border: none;
  background: none;
  padding: 0;
  max-width: 46ch;
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}
.tpl-quote blockquote::before {
  content: "\201C";
  color: var(--accent);
}
.tpl-quote blockquote::after {
  content: "\201D";
  color: var(--accent);
}

/* text: plain flowing text, no bullet-heavy styling */
.tpl-text {
  max-width: 72ch;
}

/* image / text-image / video / text-video */
.tpl-image,
.tpl-video,
.tpl-text-image-media {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.tpl-image img,
.tpl-text-image-media img,
.tpl-video video,
.tpl-text-image-media video {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #000;
}
.tpl-image-caption {
  margin: 14px auto 0;
  color: var(--text-dim);
  text-align: center;
}
.tpl-text-image {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: center;
  flex: 1 1 auto;
}

/* text-video: full-control layout — title/body top-aligned in the left
 * column so the video's top edge lines up with the title's top, instead of
 * both columns being vertically centered against each other. */
.tpl-text-video {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
  flex: 1 1 auto;
}
.tpl-text-video-media {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.tpl-text-video-media video {
  width: auto;
  max-width: 100%;
  max-height: 48vh;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
}

.tpl-3-column {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 16px;
  align-items: start;
  flex: 1 1 auto;
}

/* Header (eyebrow + heading) spans the full 3-column width, above the
 * text/video/video row — instead of living inside the text column only. */
.tpl-3-column-header {
  grid-column: 1 / -1;
}

.tpl-3-column-text {
  min-width: 0;
}

.tpl-3-column-media {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.tpl-3-column-media video,
.tpl-3-column-media img {
  width: 100%;
  height: auto;
  max-height: 48vh;
  border: 0px solid var(--border);
  border-radius: 8px;
  object-fit: contain;
}

.tpl-media-label {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--fs-label);
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* model3d: full-bleed canvas with caption overlay */
.tpl-model3d {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}
.tpl-model3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}
.tpl-model3d-canvas:active {
  cursor: grabbing;
}
.tpl-model3d-caption {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: rgba(38, 38, 38, 0.82);
  backdrop-filter: blur(6px);
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text-dim);
  font-size: var(--fs-body-secondary);
  line-height: var(--lh-body);
  max-width: 40ch;
  pointer-events: none;
}
.tpl-model3d-caption p {
  margin: 0;
}

/* two-content / comparison: side-by-side columns from ### headers */
.tpl-two-content,
.tpl-comparison {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 24px;
}
.tpl-col h3 {
  margin: 0 0 12px;
  font-size: clamp(1.05rem, 1.3vw, 1.25rem);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.tpl-comparison .tpl-col {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* timeline: vertical rundown of time-blocks */
.tpl-timeline {
  border-left: 2px solid var(--border);
  padding-left: 24px;
  max-width: 68ch;
}
.tpl-timeline-item {
  position: relative;
  padding-bottom: 14px;
}
.tpl-timeline-item::before {
  content: "";
  position: absolute;
  left: -29px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.tpl-timeline-marker {
  font-family: "Consolas", monospace;
  font-size: var(--fs-label);
  color: var(--accent);
  margin-bottom: 2px;
}
.tpl-timeline-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-body);
  margin-bottom: 4px;
}
.tpl-timeline-content .slide-body,
.tpl-timeline-content p,
.tpl-timeline-content ul,
.tpl-timeline-content ol {
  font-size: var(--fs-body-secondary);
  line-height: var(--lh-body);
  color: var(--text-dim);
  margin: 0 0 4px;
}

/* timeline-horizontal: same data as timeline, laid out as cards in a row —
 * for a handful of milestone-sized entries instead of a long vertical list */
.tpl-timeline-h {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  align-items: start;
}
.tpl-timeline-h-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  --card-accent: var(--accent);
}
/* Clipped corner ribbon replaces the old flat top border-accent. */
.tpl-timeline-h-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  background: var(--card-accent);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.tpl-timeline-h-item:nth-child(5n + 1) {
  --card-accent: var(--item-1);
}
.tpl-timeline-h-item:nth-child(5n + 2) {
  --card-accent: var(--item-2);
}
.tpl-timeline-h-item:nth-child(5n + 3) {
  --card-accent: var(--item-3);
}
.tpl-timeline-h-item:nth-child(5n + 4) {
  --card-accent: var(--item-4);
}
.tpl-timeline-h-item:nth-child(5n + 5) {
  --card-accent: var(--item-5);
}
.tpl-timeline-h-item .tpl-timeline-title {
  font-size: var(--fs-body);
  margin-bottom: 10px;
}
.tpl-timeline-h-item .tpl-timeline-content p,
.tpl-timeline-h-item .tpl-timeline-content ul,
.tpl-timeline-h-item .tpl-timeline-content ol {
  font-size: var(--fs-body-secondary);
  line-height: var(--lh-body);
  color: var(--text-dim);
  margin: 0 0 6px;
}

/* gallery: grid of image+caption cards. Column count is fixed (not
 * auto-fit) — set inline per-slide by slides.js from the "{gallery:N}" tag
 * param, or a default that wraps into multiple rows. */
.tpl-gallery {
  display: grid;
  gap: 14px;
}
.tpl-gallery-card {
  display: flex;
  flex-direction: column;
}
.tpl-gallery-card {
  position: relative;
  --card-accent: var(--accent);
}
/* Clipped corner ribbon over the image, replacing the old flat top border-accent. */
.tpl-gallery-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  background: var(--card-accent);
  clip-path: polygon(0 0, 100% 0, 0 100%);
  z-index: 1;
}
.tpl-gallery-card img,
.tpl-gallery-placeholder {
  width: 100%;
  aspect-ratio: 16 / 8;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface);
  margin-bottom: 6px;
  box-shadow: var(--shadow-sm);
}
/* Per-card accent, cycling through the item palette so a grid of
 * placeholder tiles (no real photo yet) still reads as distinct entries. */
.tpl-gallery-card:nth-child(5n + 1) {
  --card-accent: var(--item-1);
}
.tpl-gallery-card:nth-child(5n + 2) {
  --card-accent: var(--item-2);
}
.tpl-gallery-card:nth-child(5n + 3) {
  --card-accent: var(--item-3);
}
.tpl-gallery-card:nth-child(5n + 4) {
  --card-accent: var(--item-4);
}
.tpl-gallery-card:nth-child(5n + 5) {
  --card-accent: var(--item-5);
}
.tpl-gallery-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-body-secondary);
}
.tpl-gallery-caption {
  color: var(--text-dim);
  font-size: var(--fs-label);
  margin-top: 2px;
}

/* image-compare: a few images shown full-size and uncropped, side by side
 * (e.g. photo vs. 3D simulation) — unlike gallery, no fixed aspect-ratio
 * crop box, so portrait or otherwise irregular photos aren't cut off. */
.tpl-image-compare {
  display: flex;
  flex-direction: row;
  gap: 24px;
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
}
.tpl-image-compare-card {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
}
.tpl-image-compare-card img {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
}
.tpl-image-compare-card .tpl-gallery-title {
  text-align: center;
}
.tpl-image-compare-card .tpl-gallery-caption {
  text-align: center;
}

/* stats: grid of number tiles */
.tpl-stats-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.tpl-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 20px;
}
.tpl-stat-tile {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: center;
  overflow: hidden;
  --card-accent: var(--accent);
}
/* Clipped corner ribbon replaces the old flat top border-accent. */
.tpl-stat-tile::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  background: var(--card-accent);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.tpl-stat-tile:nth-child(5n + 1) {
  --card-accent: var(--item-1);
}
.tpl-stat-tile:nth-child(5n + 2) {
  --card-accent: var(--item-2);
}
.tpl-stat-tile:nth-child(5n + 3) {
  --card-accent: var(--item-3);
}
.tpl-stat-tile:nth-child(5n + 4) {
  --card-accent: var(--item-4);
}
.tpl-stat-tile:nth-child(5n + 5) {
  --card-accent: var(--item-5);
}
.tpl-stat-value {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.4vw, 1.7rem);
  font-weight: 700;
  color: var(--text);
}
.tpl-stat-label {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: var(--fs-body-secondary);
}

.slide-eyebrow {
  display: block;
  width: 100%;
  font-family: var(--font-display);
  color: var(--accent);
  font-weight: 600;
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.slide-heading {
  font-family: var(--font-display);
  font-size: var(--fs-heading);
  margin: 0 0 18px;
  font-weight: 700;
}

/* Shared prose styling: applies to the default content body (.slide-body)
 * AND every other template's text container (.slide-prose) — two-content
 * columns, image captions, text-image copy — so none of them silently
 * fall back to unstyled browser defaults. */
.slide-body,
.slide-prose {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  max-width: 68ch;
}

.slide-body p,
.slide-prose p {
  margin: 0 0 10px;
}

.visual-impact {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-top: 26px;
  padding: 18px 22px;
  border-left: 6px solid var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), transparent);
}

.visual-impact strong {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  line-height: 0.95;
  color: var(--accent);
}

.visual-impact span {
  color: var(--text-dim);
  font-size: var(--fs-body-secondary);
}

/* Defensive default: an inline ![]() dropped into prose (e.g. a two-content
 * column) shouldn't render at native size and blow out the layout. For an
 * actual side-by-side text+image slide, use the "text-image" template
 * instead — it sizes and positions the image properly. */
.slide-body img,
.slide-prose img {
  max-width: 100%;
  max-height: 40vh;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.slide-body ul,
.slide-body ol,
.slide-prose ul,
.slide-prose ol {
  margin: 0 0 10px;
  padding-left: 1.3em;
}

.slide-body li,
.slide-prose li {
  margin-bottom: 5px;
}

.slide-body blockquote,
.slide-prose blockquote {
  margin: 0 0 18px;
  padding: 10px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-dim);
}

.slide-body code,
.slide-prose code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
}

.slide-body h3,
.slide-body h4,
.slide-prose h3,
.slide-prose h4 {
  margin: 20px 0 8px;
  color: var(--text);
  font-size: 1.05em;
}

.slide-body a,
.slide-prose a {
  color: var(--accent);
}

.slide-body em,
.slide-prose em {
  color: var(--text-dim);
  font-style: italic;
}

.slide-body hr,
.slide-prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Wide tables (e.g. sponsorship pricing) shouldn't be squeezed by the
 * default prose max-width — let the slide body go full width and let the
 * table itself scroll horizontally if it's still too wide. */
.slide-body:has(table),
.slide-prose:has(table) {
  max-width: none;
}

/* A real <table> (not display:block on its parts, which breaks column
 * alignment between rows) wrapped in a scrollable div — only the table
 * itself scrolls horizontally if it's too wide, never the whole slide. */
.md-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: 0 0 16px;
}

table {
  border-collapse: collapse;
  width: max-content;
  max-width: 100%;
  font-size: 1.1rem;
}

th,
td {
  border: 1px solid var(--border);
  padding: 6px 14px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--surface);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.82em;
  letter-spacing: 0.03em;
}

.slide-loading {
  margin: auto;
  color: var(--text-dim);
}

#deck-nav {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 28px;
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex: 0 0 auto;
}

#deck-nav button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

#deck-nav button:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

#progress {
  flex: 1 1 auto;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.2s ease;
}

#toc-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 85vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

#deck.toc-open #toc-panel {
  transform: translateX(0);
}

#toc-panel h3 {
  margin: 0 0 14px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

#toc-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
}

#toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#toc-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 8px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}

#toc-list button:hover {
  background: var(--bg);
  color: var(--accent);
}

#toc-list button.toc-divider {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
  margin-top: 10px;
}

#toc-list button.toc-slide {
  padding-left: 18px;
  color: var(--text-dim);
}

#toc-list button.is-current {
  position: relative;
  padding-left: 16px;
  color: var(--accent);
  font-weight: 600;
}
#toc-list button.is-current::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 20%, 100% 80%, 0 100%);
}

@media (max-width: 640px) {
  .slide {
    padding: 4vh 6vw;
  }
}

/* menu: grid of clickable table-of-contents cards. Each card jumps to the
 * slide whose heading matches its data-goto-heading (wired in slides.js).
 * Column count fixed inline per-slide from the "{menu:N}" tag param. */
.tpl-menu {
  display: grid;
  gap: 14px;
}
.tpl-menu-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 40px 16px 16px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  --card-accent: var(--accent);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
/* Clipped corner ribbon replaces the old flat top border-accent. */
.tpl-menu-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  background: var(--card-accent);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.tpl-menu-card:hover,
.tpl-menu-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  outline: none;
}
.tpl-menu-card:nth-child(5n + 1) {
  --card-accent: var(--item-1);
}
.tpl-menu-card:nth-child(5n + 2) {
  --card-accent: var(--item-2);
}
.tpl-menu-card:nth-child(5n + 3) {
  --card-accent: var(--item-3);
}
.tpl-menu-card:nth-child(5n + 4) {
  --card-accent: var(--item-4);
}
.tpl-menu-card:nth-child(5n + 5) {
  --card-accent: var(--item-5);
}
.tpl-menu-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-body-secondary);
}
.tpl-menu-caption {
  color: var(--text-dim);
  font-size: var(--fs-label);
  line-height: 1.4;
}
.tpl-menu-arrow {
  position: absolute;
  right: 14px;
  top: 14px;
  color: var(--text-dim);
  transition: color 0.15s ease, transform 0.15s ease;
}
.tpl-menu-card:hover .tpl-menu-arrow,
.tpl-menu-card:focus-visible .tpl-menu-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

/* PDF / print export styles ------------------------------------------------
 * The "Download PDF" button opens the browser print dialog. These rules
 * make every slide fill one printed page so "Save as PDF" produces a
 * slide-per-page deck. */

.tpl-model3d-print-snapshot {
  display: none;
}

@media print {
  @page {
    size: landscape;
    margin: 0;
  }

  body {
    background: var(--bg) !important;
    color: var(--text) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #deck-header,
  #deck-nav,
  #toc-panel {
    display: none !important;
  }

  #deck {
    height: auto;
    display: block;
  }

  #stage-frame {
    position: static;
    display: block;
    overflow: visible;
    height: auto;
    background: none;
  }

  #slides-viewport {
    position: static;
    overflow: visible;
    height: auto;
    width: auto;
    max-width: none;
    aspect-ratio: auto;
  }

  .slide {
    position: relative;
    inset: auto;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto;
    transform: none !important;
    display: flex;
    width: 100vw;
    height: 100vh;
    page-break-after: always;
    break-after: page;
    overflow: hidden;
  }

  .slide:last-child {
    page-break-after: auto;
  }

  /* Model3D slides: hide the live WebGL canvas and show the captured
   * snapshot image (if the current slide is a 3D model when PDF is made). */
  .slide--model3d {
    padding: 0;
  }

  .tpl-model3d {
    position: absolute;
    inset: 0;
  }

  .tpl-model3d-print-snapshot {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--bg);
  }

  .tpl-model3d-canvas {
    display: none !important;
  }

  .tpl-model3d-caption {
    position: absolute;
    bottom: 20px;
    left: 20px;
  }
}
