/* ============================================================================
   components.css — pieces reused across chapters
   ========================================================================== */

/* -- Chapter header ------------------------------------------------------- */

.ch-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  margin-bottom: var(--chapter-gap);
}

.ch-head__meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
}

.ch-head__index {
  font-family: var(--font-mono);
  font-size: clamp(2.5rem, 1.5rem + 3.4vw, 5rem);
  font-weight: var(--weight-semibold);
  line-height: 0.8;
  letter-spacing: -0.04em;
  color: var(--page-accent-text);
  opacity: 0.9;
}

[data-theme="light"] .ch-head__index {
  color: var(--navy-900);
  opacity: 0.14;
}

/* -- Chip ----------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--page-border);
  background: var(--page-surface);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.02em;
  color: var(--page-fg);
}

.chip__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--yellow-500);
  flex: none;
}

/* -- Stats ---------------------------------------------------------------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
}

.stat {
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  border: 1px solid var(--page-border);
  background: var(--page-surface);
}

.stat__num {
  display: flex;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: clamp(2rem, 1.4rem + 2.1vw, 3rem);
  font-weight: var(--weight-semibold);
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--page-fg);
  font-variant-numeric: tabular-nums;
}

.stat__num small {
  font-size: 0.5em;
  font-weight: var(--weight-semibold);
  margin-left: 1px;
  color: var(--page-accent-text);
}

[data-theme="light"] .stat__num small { color: var(--yellow-700); }

.stat__lbl {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--page-fg);
}

.stat__sub {
  margin-top: 2px;
  font-size: var(--text-xs);
  color: var(--page-muted);
}

/* -- Check list ----------------------------------------------------------- */

.check-list {
  display: grid;
  gap: var(--space-3);
}

.check-list li {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  font-size: var(--fs-body);
  color: var(--page-body);
}

.check-list svg {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  color: var(--page-accent-text);
}

[data-theme="light"] .check-list svg { color: var(--yellow-700); }

.check-list strong {
  display: block;
  color: var(--page-fg);
  font-weight: var(--weight-semibold);
}

/* -- Phone frame ---------------------------------------------------------- */

.phone {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin-inline: auto;
  aspect-ratio: 9 / 19.5;
  padding: 10px;
  border-radius: 40px;
  background: linear-gradient(160deg, #232C6B, #070F3C);
  /* The device is navy and so are half the chapters — the outer ring is what
     keeps it from dissolving into the background. */
  box-shadow:
    0 0 0 1px var(--page-border),
    var(--page-shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.phone::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 84px;
  height: 20px;
  border-radius: var(--radius-full);
  background: #050c33;
  z-index: 3;
}

.phone__screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 31px;
  overflow: hidden;
  background: var(--navy-900);
}

.phone__screen video,
.phone__screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-caption {
  margin-top: var(--space-4);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--page-muted);
}

/* -- Laptop frame ---------------------------------------------------------
   The PNG is a bezel with a transparent screen cut-out, so the media sits
   behind it. Screen rect measured off the artwork (348x192): left 10.92%,
   top 4.167%, width 78.161%, height 84.896%.                              */

.laptop {
  position: relative;
  width: 100%;
  margin-inline: auto;
  aspect-ratio: 348 / 192;
}

.laptop__screen {
  position: absolute;
  left: 10.92%;
  top: 4.167%;
  width: 78.161%;
  height: 84.896%;
  overflow: hidden;
  /* The clip is a screen recording of a white UI — letterbox in white so the
     bars read as page whitespace rather than as bars. */
  background: #FFFFFF;
}

/* contain, not cover: the recording is 1.945:1 inside a 1.669:1 bezel, so
   cover would crop ~14% off each side — exactly where the hub's logo and
   hotline sit. Full width matters more than filling the height. */
.laptop__screen video,
.laptop__screen img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.laptop__bezel {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* Upscaled from 348px of source art — keep the edges from going mushy. */
  image-rendering: auto;
  filter: drop-shadow(0 18px 34px rgba(0, 10, 64, 0.28));
}

/* -- Media tile (9:16 creator video) -------------------------------------- */

.tile {
  position: relative;
  display: block;
  aspect-ratio: 9 / 16;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--navy-900);
  box-shadow: var(--page-shadow);
  transition: transform var(--dur-base) var(--ease-out-power3);
}

.tile:hover { transform: translateY(-3px); }

.tile video,
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile__veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 10, 64, 0.78) 0%, transparent 46%);
  pointer-events: none;
}

.tile__brand {
  position: absolute;
  left: 10px;
  bottom: 10px;
  right: 10px;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--white);
  text-shadow: 0 1px 4px rgba(0, 10, 64, 0.6);
}

.tile__play {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: rgba(255, 199, 0, 0.92);
  color: var(--navy-900);
}

.tile__play svg { width: 12px; height: 12px; }

/* -- Sound toggle ----------------------------------------------------------
   Browsers only let a clip autoplay while it is muted, so every clip starts
   silent. Clips whose audio is part of the pitch — the AI hosts talking —
   get this button as the way in, whether they sit in a tile or in a phone.
   It anchors to the media frame, so both wrappers are already positioned.
   media.js unhides it; without JS the videos never mount, so a dead control
   would be worse than none. */

.sound-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: rgba(0, 10, 64, 0.58);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--white);
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-out-power3),
              color var(--dur-base) var(--ease-out-power3),
              transform var(--dur-base) var(--ease-out-power3);
}

.sound-toggle[hidden] { display: none; }

.sound-toggle svg { width: 15px; height: 15px; }

.sound-toggle:hover { transform: scale(1.08); }

/* Sound on reads as the accent state — it is the one tile currently talking. */
.sound-toggle[aria-pressed="true"] {
  background: var(--yellow-500);
  color: var(--navy-900);
}

/* The phone's screen is inset behind a 10px bezel and a notch, so the button
   sits a little further in than it does on a flat tile. */
.phone__screen .sound-toggle { top: 14px; right: 14px; }

.sound-toggle .icon-on { display: none; }
.sound-toggle[aria-pressed="true"] .icon-on { display: block; }
.sound-toggle[aria-pressed="true"] .icon-off { display: none; }

/* -- Creator card (tile + attribution) ------------------------------------ */

.creator-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.creator-card__title {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.35;
  color: var(--page-fg);
}

.creator-card__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--page-muted);
}

.creator-card__handle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.creator-card__views {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  color: var(--page-fg);
}

.creator-card__views svg { width: 12px; height: 12px; opacity: 0.7; }

/* -- Horizontal rail (scroll-snap) ---------------------------------------- */

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(154px, 1fr);
  gap: var(--space-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  padding-bottom: var(--space-4);
  margin-inline: calc(var(--gutter-sm) * -1);
  padding-inline: var(--gutter-sm);
}

.rail > * { scroll-snap-align: start; }

@media (min-width: 768px) {
  .rail {
    grid-auto-flow: row;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: visible;
    margin-inline: 0;
    padding-inline: 0;
  }
}

.rail-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.rail-label h3 {
  font-family: var(--font-sans);
  font-size: var(--fs-h4);
  font-weight: var(--weight-bold);
  color: var(--page-fg);
}

.rail-label p {
  font-size: var(--text-sm);
  color: var(--page-muted);
}

/* -- Link with arrow ------------------------------------------------------ */

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--page-fg);
  border-bottom: 2px solid var(--yellow-500);
  padding-bottom: 2px;
  transition: gap var(--dur-base) var(--ease-out-power3);
}

.link-arrow:hover { gap: var(--space-3); }
