/* ============================================================
   Techtok Missies — scene.css (#460)
   The short story at the top of a round (js/scene.js), in two layouts
   we can test against each other:
     .is-card    a picture card at the top of the normal question
                 screen. Built from the game's own pieces: white card,
                 Crasher's dark bubble on the right, everyone else in a
                 white bubble, the yellow "Verder" in the sticky bar.
     .is-cinema  the story fills the screen like a video; at the pause
                 the picture freezes and the question screen slides up
                 over its lower half.
   Phone first in both: lines never sit on top of faces.
   ============================================================ */

.scene {
  margin-bottom: 16px;
  animation: slideup 0.35s ease both;
}

/* ---------- the picture ---------- */
.scene-stage {
  position: relative;
  border-radius: var(--r-lg);
  border: 3px solid var(--white);
  background: var(--bg-blue);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  /* Safari: keeps the rounded corners clipping the moving picture */
  isolation: isolate;
}

.scene-canvas {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  cursor: pointer;
}

/* The picture's "world": sized to cover the frame, moved by the camera
   (scene.js layout). Effects inside it are placed in % of the picture. */
.scene-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  transition: transform 1.1s cubic-bezier(0.45, 0, 0.2, 1);
}

.scene-plate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.scene-plate.is-on {
  opacity: 1;
  animation: scene-drift 9s ease-out both;
}

@keyframes scene-drift {
  from { transform: scale(1.06); }
  to { transform: scale(1); }
}

/* Story-style progress: one thin bar per line, at the top of the picture */
.scene-bars {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  z-index: 6;
  display: flex;
  gap: 4px;
  pointer-events: none;
}

.scene-bars span {
  flex: 1;
  height: 4px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.5);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(13, 6, 91, 0.25);
}

.scene-bars i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--white);
  transition-property: width;
  transition-timing-function: linear;
}

.scene-bars span.done i {
  width: 100%;
  transition: none;
}

/* ---------- Crasher, floating over the picture ---------- */
.scene-crasher {
  position: absolute;
  z-index: 5;
  width: 21%;
  right: -24%;
  top: 14%;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(13, 6, 91, 0.35));
  transition: right 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.25), top 0.55s ease, width 0.4s ease, opacity 0.3s ease;
}

.scene-crasher svg {
  display: block;
  width: 100%;
  height: auto;
}

.scene-crasher.is-on { opacity: 1; }
.scene-crasher.pos-peek { right: 6%; top: 16%; animation: scene-float 2.6s ease-in-out infinite; }
.scene-crasher.pos-corner { right: 4%; top: 12%; width: 18%; animation: scene-float 2.2s ease-in-out infinite; }
.scene-crasher.pos-laugh { right: 7%; top: 12%; animation: scene-laugh 0.32s ease-in-out infinite alternate; }
.scene-crasher.pos-sulk { right: 4%; top: auto; bottom: 6%; width: 16%; opacity: 0.95; }
/* top left, for a picture whose right side is busy (#464) */
.scene-crasher.pos-left { right: auto; left: 5%; top: 12%; width: 19%; animation: scene-float 2.4s ease-in-out infinite; }

/* Card layout: Crasher talks in the chat under the picture, with his own
   face there, so a second Crasher on the picture only repeated him and
   covered part of the drawing (faces included). He floats over the
   picture in cinema only, where there is no chat. */
.scene.is-card .scene-crasher { display: none; }

/* talking: a little bob while his voice plays */
.scene-crasher.is-talking svg { animation: talkbob 0.5s ease-in-out infinite; }

@keyframes scene-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6%) rotate(2deg); }
}

@keyframes scene-laugh {
  from { transform: translateY(-3%) rotate(-4deg) scale(1.04); }
  to { transform: translateY(3%) rotate(4deg) scale(1.04); }
}

/* ---------- effects ---------- */
/* A finger tapping the phone in the picture */
.scene-tap {
  position: absolute;
  z-index: 4;
  width: 11%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 12px rgba(13, 6, 91, 0.35);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
}

.scene-tap.is-on { animation: scene-tap 1.1s ease both; }

@keyframes scene-tap {
  0% { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  45% { transform: translate(-50%, -50%) scale(0.82); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* Alarm: a soft red pulse (well under three flashes a second) + a shake */
.scene-tint {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: rgba(255, 92, 122, 0);
  pointer-events: none;
}

.scene-stage.fx-alarm .scene-tint { animation: scene-alarm 0.8s ease-in-out infinite alternate; }
.scene-stage.fx-alarm .scene-canvas { animation: scene-shake 0.45s ease-in-out 3; }

@keyframes scene-alarm {
  from { background: rgba(255, 92, 122, 0.06); }
  to { background: rgba(255, 92, 122, 0.3); }
}

@keyframes scene-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1.2%, 0.8%) rotate(-0.4deg); }
  50% { transform: translate(1%, -0.8%) rotate(0.4deg); }
  75% { transform: translate(-0.8%, -0.5%); }
}

/* "Kijk nog eens": appears once the story has played */
.scene-replay {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 7;
  width: 44px;
  height: 44px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  animation: popin 0.3s ease both;
}

.scene-replay[hidden] { display: none; }
.scene-replay svg { width: 20px; height: 20px; }
.scene-replay:active { transform: scale(0.92); }

/* The round arrow and the blurred backdrop are for the full-screen layout only */
.scene-next,
.scene-ambient { display: none; }

/* ---------- the line under the picture ---------- */
.scene-say {
  margin-top: 12px;
  min-height: 58px;
}

.scene-line {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  animation: slideup 0.3s ease both;
}

.scene-line.is-right {
  flex-direction: row-reverse;
  margin-left: 24px;
}

.scene-line:not(.is-right) { margin-right: 24px; }

.scene-av {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid var(--white);
  background: var(--white) center / cover no-repeat;
  box-shadow: var(--shadow-sm);
}

.scene-av-crasher {
  background: none;
  border: 0;
  box-shadow: none;
  width: 52px;
  height: auto;
}

.scene-av-crasher svg { display: block; width: 100%; height: auto; }
.scene-av.is-talking { animation: talkbob 0.5s ease-in-out infinite; }

.scene-bubble {
  flex: 1;
  margin: 0;
  background: var(--white);
  color: var(--ink);
  border-radius: var(--r-lg);
  border-bottom-left-radius: 6px;
  padding: 12px 16px 13px;
  box-shadow: var(--shadow-sm);
  font-size: var(--fs-lg);
  line-height: 1.4;
  font-weight: 600;
  text-wrap: pretty;
}

.scene-line.is-right .scene-bubble {
  background: var(--ink);
  color: var(--white);
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: 6px;
}

.scene-who {
  display: block;
  margin-bottom: 2px;
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--purple);
}

.scene-line.is-right .scene-who { color: var(--comp-purple); }

/* A reply to the kid's choice: same bubble, a purple edge so it reads as
   "that's what your answer did", not as the next part of the story. */
.scene-line.is-reply .scene-bubble { box-shadow: 0 0 0 2px var(--comp-purple), var(--shadow-sm); }

/* A line with nobody speaking: a sound or a moment ("Klik!") */
.scene-narr {
  margin: 6px 0 0;
  text-align: center;
  font-size: var(--fs-md);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  animation: popin 0.3s ease both;
}

/* ---------- while the story plays, the question waits ----------
   Off-screen, not display:none: Bella's animated face (Rive) sizes its
   canvas when it loads, and a canvas inside display:none loads at 0x0 and
   stays blank for the whole mission. Laid out but out of sight, she is
   ready the moment the question slides in.
   Pinned to the top and clipped (#467): left where it was, the hidden
   question (sticky notes and all) hung below the screen on wide windows,
   so the page scrolled on into the navy background behind the game. */
.mission-stage.scene-playing .round-ask,
.mission-stage.scene-playing .round-area {
  position: absolute;
  top: 0;
  left: -200vw;
  width: calc(100% - 32px);
  max-height: 100%;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

/* A round that fills its bottom bar right away (the compose round's
   "Stuur naar Botto") showed that button under the story, next to the
   story's own Verder, before there was anything to choose. It waits
   until the question is on screen. The story's Verder bar is its own
   element on the stage, so it stays. */
.mission-stage.scene-playing .round-feedback {
  display: none;
}

/* Card: a bigger picture while the story plays (phones have the room
   then); the usual 16:9 once the question needs the space below it. */
.mission-stage.scene-playing .scene.is-card .scene-canvas {
  aspect-ratio: 4 / 3;
}

.mission-stage.scene-asked .round-ask,
.mission-stage.scene-asked .round-area {
  animation: slideup 0.35s ease both;
}

/* the sticky "Verder" bar reuses .mission-actions; it sits after the
   (hidden) round area, so it needs the push to the bottom itself */
.scene-actions { margin-top: auto; }

/* ============================================================
   Full screen (cinema)
   ============================================================ */
.mission-stage.scene-cinema {
  /* the sharp picture: as wide as the screen, about half its height on a
     phone (twice the card), never blown up past what the art can carry */
  --band-h: min(62vh, 112.5vw);
  --band-h: min(62svh, 112.5vw);
  /* where the question sheet starts once the story pauses: just under
     the picture, so the frozen moment stays in view */
  --sheet-top: min(50vh, 108vw);
  --sheet-top: min(50svh, 108vw);
  --cine-bg: #05031F;
}

.scene.is-cinema {
  position: fixed;
  inset: 0;
  z-index: 30;
  margin: 0;
  background: var(--cine-bg, #05031F);
  animation: scene-fade 0.35s ease both;
}

@keyframes scene-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.scene.is-cinema .scene-stage {
  position: absolute;
  inset: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: var(--cine-bg, #05031F);
}

/* the rest of the screen: the whole picture, blurred and dark */
.scene.is-cinema .scene-ambient {
  display: block;
  position: absolute;
  inset: -48px;
  background: var(--cine-bg, #05031F) center / 100% 100% no-repeat;
  filter: blur(30px) brightness(0.42) saturate(1.3);
  transition: background-image 0.45s ease;
}

.scene.is-cinema .scene-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(5, 3, 31, 0.2), rgba(5, 3, 31, 0.55));
}

/* While the story plays the picture sits in the middle, the blurred scene
   above and below it; at the pause it moves up for the question sheet. */
.scene.is-cinema .scene-canvas {
  position: absolute;
  z-index: 2;
  top: calc((100vh - var(--band-h, 62vh)) / 2);
  top: calc((100svh - var(--band-h, 62svh)) / 2);
  left: 0;
  right: 0;
  height: var(--band-h, 62vh);
  aspect-ratio: auto;
  transition: top 0.55s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.mission-stage.scene-cinema.scene-asked .scene.is-cinema .scene-canvas { top: 0; }

/* a soft edge into the backdrop, and dark under the game's top bar once
   the picture has moved up to it */
.scene.is-cinema .scene-canvas::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(to bottom,
    rgba(5, 3, 31, 0.35) 0%, rgba(5, 3, 31, 0) 16%,
    rgba(5, 3, 31, 0) 80%, rgba(5, 3, 31, 0.5) 100%);
  transition: opacity 0.4s ease;
}

.scene.is-cinema .scene-world { transition: transform 1.2s cubic-bezier(0.45, 0, 0.2, 1), filter 0.5s ease; }
.scene.is-cinema .scene-plate.is-on { animation-duration: 12s; }

/* progress along the bottom edge of the picture, like a video player */
.scene.is-cinema .scene-bars {
  top: auto;
  bottom: 12px;
  left: 16px;
  right: 16px;
}

.scene.is-cinema .scene-bars span { height: 3px; }

.scene.is-cinema .scene-tap { width: 64px; }

.scene.is-cinema .scene-crasher { width: 30%; max-width: 170px; }
.scene.is-cinema .scene-crasher.pos-peek { right: 5%; top: 19%; }
.scene.is-cinema .scene-crasher.pos-corner { right: 4%; top: 15%; width: 26%; }
.scene.is-cinema .scene-crasher.pos-laugh { right: 6%; top: 17%; }
.scene.is-cinema .scene-crasher.pos-sulk { right: 5%; top: 18%; bottom: auto; width: 22%; }
.scene.is-cinema .scene-crasher.pos-left { right: auto; left: 5%; top: 17%; width: 26%; }

/* the line: big, like subtitles, low on the screen */
.scene.is-cinema .scene-say {
  position: absolute;
  z-index: 8;
  left: 0;
  right: 0;
  max-width: var(--appw, 520px);
  margin: 0 auto;
  min-height: 0;
  padding: 0 76px 0 16px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transition: bottom 0.5s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.scene.is-cinema .scene-line { margin: 0; }

.scene.is-cinema .scene-bubble {
  background: rgba(13, 6, 91, 0.8);
  color: var(--white);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  border-bottom-left-radius: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  font-size: clamp(18px, 4.9vw, 22px);
  line-height: 1.35;
  font-weight: 700;
  padding: 12px 16px 14px;
}

.scene.is-cinema .scene-line.is-right .scene-bubble {
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 6px;
}

.scene.is-cinema .scene-who { color: #C9B8FF; }
.scene.is-cinema .scene-line.is-right .scene-who { color: var(--yellow); }
.scene.is-cinema .scene-line.is-reply .scene-bubble { box-shadow: 0 0 0 2px var(--yellow), 0 12px 30px rgba(0, 0, 0, 0.35); }
.scene.is-cinema .scene-av { width: 54px; height: 54px; border-color: rgba(255, 255, 255, 0.9); }
.scene.is-cinema .scene-av-crasher { width: 58px; height: auto; }

.scene.is-cinema .scene-narr {
  color: var(--white);
  font-size: clamp(26px, 8vw, 36px);
  letter-spacing: 0.1em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

/* a big round arrow beside the line: tap it, or anywhere, to go on */
.scene.is-cinema.is-playing .scene-next {
  position: absolute;
  z-index: 9;
  right: max(16px, calc(50% - var(--appw, 520px) / 2 + 16px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.scene.is-cinema .scene-next svg { width: 26px; height: 26px; }
.scene.is-cinema .scene-next:active { transform: scale(0.92); }

/* the game's own top bar, over the picture */
.mission-stage.scene-cinema .mission-top::before {
  background: linear-gradient(to bottom, rgba(5, 3, 31, 0.55) 40%, rgba(5, 3, 31, 0) 100%);
}
.mission-stage.scene-cinema .mission-top::after { background: var(--cine-bg, #05031F); }
.mission-stage.scene-cinema .rdot { background: rgba(255, 255, 255, 0.3); }
.mission-stage.scene-cinema .rdot.now { background: var(--yellow); }
.mission-stage.scene-cinema .rdot.done { background: var(--good); }

/* ---------- the pause: the picture freezes, the question slides up ---------- */
.mission-stage.scene-cinema.scene-asked .scene.is-cinema .scene-world { filter: brightness(0.82) saturate(0.85); }

.mission-stage.scene-cinema.scene-asked .scene.is-cinema .scene-say {
  bottom: calc(100vh - var(--sheet-top) + 12px);
  bottom: calc(100svh - var(--sheet-top) + 12px);
  padding-right: 72px;
}

.scene.is-cinema .scene-replay {
  right: max(16px, calc(50% - var(--appw, 520px) / 2 + 16px));
  bottom: calc(100vh - var(--sheet-top) + 14px);
  bottom: calc(100svh - var(--sheet-top) + 14px);
}

/* the question screen itself is the sheet: same Bella, same answers */
.mission-stage.scene-cinema.scene-asked .round-ask,
.mission-stage.scene-cinema.scene-asked .round-area {
  position: relative;
  z-index: 31;
  margin-left: -16px;
  margin-right: -16px;
  padding-left: 16px;
  padding-right: 16px;
  background: #F7F6FE;
  background: color-mix(in srgb, var(--top-fade, #EFEAFC) 40%, #FFFFFF);
  animation: scene-sheet 0.5s 0.12s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.mission-stage.scene-cinema.scene-asked .round-ask {
  margin-top: calc(var(--sheet-top) - 64px - env(safe-area-inset-top, 0px));
  margin-bottom: 0;
  padding-top: 24px;
  padding-bottom: 22px;
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -18px 40px rgba(5, 3, 31, 0.45);
}

@keyframes scene-sheet {
  from { transform: translateY(40vh); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .scene,
  .scene-line,
  .scene-narr,
  .scene-plate.is-on,
  .scene-crasher.pos-peek,
  .scene-crasher.pos-corner,
  .scene-crasher.pos-laugh,
  .scene-crasher.pos-left,
  .scene-crasher.is-talking svg,
  .scene-av.is-talking,
  .scene-stage.fx-alarm .scene-canvas,
  .mission-stage.scene-cinema.scene-asked .round-ask,
  .mission-stage.scene-cinema.scene-asked .round-area {
    animation: none;
  }
  .scene-world,
  .scene.is-cinema .scene-world { transition: none; }
  .scene-stage.fx-alarm .scene-tint {
    animation: none;
    background: rgba(255, 92, 122, 0.2);
  }
  .scene-tap.is-on {
    animation: none;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Full-screen story (marketing only, ?story=cinema): one Crasher, the one
   next to his speech bubble. The extra floating Crasher on the picture
   made two of him (Laura, 18 nov). The normal card view is unchanged. */
.scene.is-cinema .scene-crasher {
  display: none;
}

/* Movie mode (#504, ?story=cinema): a film, not the game. No arrow, no
   replay, no progress bars; the story fills the screen. */
.scene.is-cinema .scene-next,
.scene.is-cinema.is-playing .scene-next,
.scene.is-cinema .scene-replay,
.scene.is-cinema .scene-bars {
  display: none !important;
}

.movie {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #0D065B;
}

.movie-stage {
  position: absolute;
  inset: 0;
}

.movie-stage .scene {
  height: 100%;
}

.movie-start {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(13, 6, 91, 0.55);
  cursor: pointer;
}

.movie-play {
  display: block;
  width: 96px;
  height: 96px;
  margin: auto;
  border-radius: 50%;
  background: #FAFF05;
  clip-path: circle(50%);
  position: relative;
}

.movie-play::after {
  content: "";
  position: absolute;
  left: 38px;
  top: 28px;
  border-style: solid;
  border-width: 20px 0 20px 32px;
  border-color: transparent transparent transparent #0D065B;
}

.movie-end {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: linear-gradient(135deg, #4D21CC, #5F29FF);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  animation: movie-fade 0.8s ease both;
}

.movie-end img {
  width: min(70%, 320px);
  height: auto;
}

@keyframes movie-fade {
  from { opacity: 0; }
}

/* Without the arrow the speech bubble uses the whole width (Laura). */
.scene.is-cinema .scene-say {
  padding-left: 16px;
  padding-right: 16px;
}
