/* ──────────────────────────────────────────────────────────────
   The Bigger Picture · stories
   One 9:16 frame. Progress is a line that travels round its edge.
   ────────────────────────────────────────────────────────────── */

.stories {
  height: 100svh;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center; justify-items: center;
  overflow: hidden;
}

.stage {
  grid-column: 2;
  position: relative;
  width: var(--stage-w); height: var(--stage-h);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--g-950); color: #fff;
  box-shadow: 0 24px 60px rgba(20, 20, 30, .22);
  isolation: isolate;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}

/* Phones: the frame is the screen. */
@media (max-width: 600px), (max-aspect-ratio: 10/16) {
  :root { --stage-h: 100svh; --stage-w: 100vw; --radius: 0px; }
  .stories { grid-template-columns: 1fr; }
  .stage { grid-column: 1; }
  .side, .keys { display: none !important; }
}

/* ───────────── media ───────────── */

.stage__media, .stage__video, .stage__poster, .stage__shade, .stage__pause { position: absolute; inset: 0; }
.stage__video iframe, .stage__video > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.stage__video { pointer-events: none; }
.stage.is-direct .stage__video { pointer-events: auto; }
.stage.is-direct .tapzone { display: none; }

.stage__poster {
  background: var(--g-950) center / cover no-repeat;
  transition: opacity .35s ease;
}
.stage__poster.is-hidden { opacity: 0; }
.stage__poster::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.07) 50%, transparent 70%) 0 0 / 250% 100%;
  animation: sheen 1.4s linear infinite;
}
.stage__poster.is-still::after, .stage__poster.is-hidden::after { animation: none; opacity: 0; }
@keyframes sheen { from { background-position: 120% 0; } to { background-position: -130% 0; } }

.stage__shade {
  z-index: 1; pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.62), rgba(0,0,0,0) 22%),
    linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,0) 38%);
}

.stage__pause {
  z-index: 2; pointer-events: none;
  display: grid; place-items: center;
  background: rgba(0,0,0,.72);
  opacity: 0; transition: opacity .18s ease;
}
.stage__pause span { font-weight: 600; font-size: 16px; color: var(--g-300); }
.stage.is-paused .stage__pause { opacity: 1; }

/* ───────────── tap zones ───────────── */

.tapzone { position: absolute; top: 0; bottom: 0; z-index: 3; cursor: pointer; }
.tapzone--back { left: 0; width: 30%; }
.tapzone--next { right: 0; width: 70%; }

/* ───────────── progress: the trace ───────────── */

.trace { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; overflow: visible; }
.trace rect { fill: none; stroke-width: 3; }
.trace__rail { stroke: rgba(255,255,255,.2); }
.trace__line { stroke: url(#trace-grad); stroke-dasharray: 1; stroke-dashoffset: 1; stroke-linecap: butt; }

/* ───────────── head ───────────── */

.story-head, .story-foot, .pill, .stage__notice, .sent { position: absolute; z-index: 5; }

.story-head {
  top: 0; left: 0; right: 0;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) 18px 0 20px;
  pointer-events: none;
}
.story-head > * { pointer-events: auto; }

.ticks { grid-column: 1; display: flex; gap: 5px; align-items: center; height: 14px; pointer-events: none; }
.ticks li { width: 18px; height: 3px; background: rgba(255,255,255,.28); transition: background-color .3s, width .3s var(--ease); }
.ticks li { border-radius: 2px; }
.ticks li.is-done { background: #fff; }
.ticks li.is-now { background: linear-gradient(90deg, #8fb0ff, #d9a8f5); width: 30px; }

.who { grid-column: 1; display: flex; align-items: baseline; gap: 10px; margin-top: 8px; min-width: 0; pointer-events: none; }
.who__name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 8px rgba(0,0,0,.5); }
.who__tag { flex: none; font-weight: 600; font-size: 12.5px; padding: 2px 8px; background: #fff; color: #000; border-radius: 999px; }

.story-head__tools { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 2px; align-self: start; margin-top: -6px; }
.icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.icon svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 4px rgba(0,0,0,.5)); }
#btn-sound .on { display: none; }
#btn-sound[aria-pressed='true'] .on { display: inline; }
#btn-sound[aria-pressed='true'] .off { display: none; }
#btn-pause .play { display: none; fill: #fff; stroke: none; }
#btn-pause[aria-pressed='true'] .play { display: inline; }
#btn-pause[aria-pressed='true'] .pause { display: none; }
@media (hover: hover) { .icon:hover { background: rgba(255,255,255,.14); } }

/* ───────────── foot ───────────── */

.story-foot {
  left: 0; right: 0; bottom: 0;
  padding: 0 18px calc(20px + env(safe-area-inset-bottom));
  display: grid; gap: 12px;
  pointer-events: none;
}
.story-foot > * { pointer-events: auto; }
.caption { font-size: 16px; line-height: 1.35; max-width: 30ch; text-shadow: 0 1px 10px rgba(0,0,0,.6); pointer-events: none; }

.cta {
  justify-self: start;
  min-height: 44px; padding: 0 20px;
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 16px;
  background: #fff; color: #000; border-radius: 999px;
  transition: background-color .2s, color .2s, box-shadow .2s, transform .2s var(--ease);
}
.cta::after { content: '+'; font-family: var(--f-text); font-weight: 400; font-size: 20px; line-height: 1; transition: transform .3s var(--ease); }
.cta[aria-pressed='true'] { background: transparent; color: #fff; box-shadow: inset 0 0 0 1.5px #fff; }
.cta[aria-pressed='true']::after { content: '✓'; font-size: 15px; }
.cta:active { transform: scale(.96); }

.foot-row { display: flex; align-items: center; gap: 8px; }
.reply { flex: 1; position: relative; min-width: 0; }
.reply input {
  width: 100%; height: 46px; padding: 0 48px 0 18px;
  background: rgba(0,0,0,.25); border: 1.5px solid rgba(255,255,255,.7); border-radius: 999px;
  font-size: 16px; color: #fff;
  transition: border-color .2s, background-color .2s;
}
.reply input::placeholder { color: rgba(255,255,255,.75); }
.reply input:focus { border-color: #fff; background: rgba(0,0,0,.6); outline: none; }
.reply input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.reply__send {
  position: absolute; right: 4px; top: 4px; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; background: #fff;
  opacity: 0; transform: scale(.6); pointer-events: none;
  transition: opacity .18s, transform .25s var(--ease);
}
.reply__send svg { width: 20px; height: 20px; fill: none; stroke: #000; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.reply.has-text .reply__send { opacity: 1; transform: none; pointer-events: auto; }

.like { flex: none; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; }
.like svg { width: 30px; height: 30px; fill: transparent; stroke: #fff; stroke-width: 1.7; stroke-linejoin: round; transition: fill .15s; filter: drop-shadow(0 1px 4px rgba(0,0,0,.5)); }
.like[aria-pressed='true'] svg { fill: #fff; }
.like.is-pop svg { animation: pop .45s var(--ease); }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.35) rotate(-8deg); } 100% { transform: scale(1); } }

/* The reply, leaving. */
.sent {
  left: 18px; bottom: calc(128px + env(safe-area-inset-bottom)); max-width: 72%;
  padding: 9px 14px; background: #fff; color: #000; border-radius: 16px 16px 16px 4px;
  font-size: 15px; line-height: 1.3; overflow-wrap: anywhere;
  opacity: 0; pointer-events: none;
}
.sent.is-flying { animation: fly 1.7s var(--ease) both; }
@keyframes fly { 0% { opacity: 0; transform: translateY(14px) scale(.9); } 14% { opacity: 1; transform: none; } 70% { opacity: 1; transform: translateY(-6px); } 100% { opacity: 0; transform: translateY(-34px); } }

/* ───────────── notices ───────────── */

.pill { top: calc(74px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); }
.pill button { min-height: 36px; padding: 0 16px; background: rgba(0,0,0,.72); box-shadow: inset 0 0 0 1px rgba(255,255,255,.6); border-radius: 999px; font-weight: 600; font-size: 14px; color: #fff; white-space: nowrap; }

.stage__notice {
  left: 50%; top: 42%; transform: translate(-50%, -50%);
  width: max-content; max-width: 80%; text-align: center;
  display: grid; justify-items: center; gap: 12px;
}
.stage__notice p { font-size: 14px; color: var(--g-200); text-shadow: 0 1px 8px rgba(0,0,0,.7); }
.stage__note {
  position: absolute; z-index: 5; left: 20px; right: 20px; top: calc(78px + env(safe-area-inset-top));
  font-size: 12.5px; line-height: 1.4; color: var(--g-200); text-shadow: 0 1px 8px rgba(0,0,0,.7); max-width: 34ch;
}

/* ───────────── story change ───────────── */

.stage.is-swapping .story-head .who,
.stage.is-swapping .story-foot { opacity: 0; transform: translateX(calc(var(--dir, 1) * 16px)); }
.story-head .who, .story-foot { transition: opacity .22s ease, transform .3s var(--ease); }

/* ───────────── desktop extras ───────────── */

.side {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--white); box-shadow: inset 0 0 0 1px #9b9892;
  transition: box-shadow .2s, transform .25s var(--ease);
}
.side svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side--back { grid-column: 1; justify-self: end; margin-right: 22px; }
.side--next { grid-column: 3; justify-self: start; margin-left: 22px; }
@media (hover: hover) { .side:hover { box-shadow: inset 0 0 0 1px var(--ink), 0 3px 0 var(--ink); transform: translateY(-2px); } }
.keys {
  position: absolute; left: 24px; bottom: 20px;
  font-size: 13px; color: var(--muted);
}
@media (max-width: 900px) { .keys { display: none; } }
