/* ═══ Imahe — Story Player (immersive fullscreen stage) ═══ */

.player-stage {
  position: fixed; inset: 0; z-index: 70;
  background: var(--ink);
  overflow: hidden;
  --seg: 6s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  cursor: pointer;
}

/* ─── frames: crossfade + Ken Burns ─── */
.player-frames { position: absolute; inset: 0; }
.pframe {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}
.pframe.is-active { opacity: 1; }
.pframe img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
}
.pframe.kb-a img { animation: kb-a calc(var(--seg) * 1.25) ease-in-out both; }
.pframe.kb-b img { animation: kb-b calc(var(--seg) * 1.25) ease-in-out both; }
.player-stage.is-paused .pframe img,
.player-stage.is-ended .pframe img { animation-play-state: paused; }
@keyframes kb-a {
  from { transform: scale(1.02) translate(-0.8%, 0.5%); }
  to { transform: scale(1.08) translate(1.2%, -0.8%); }
}
@keyframes kb-b {
  from { transform: scale(1.02) translate(0.8%, -0.5%); }
  to { transform: scale(1.08) translate(-1.2%, 0.8%); }
}

/* ─── rendered MP4 mode ─── */
.player-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: var(--ink);
}
.v-actions {
  position: absolute; z-index: 6;
  left: 14px; bottom: calc(var(--safe-b) + 44px);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.player-progress { cursor: pointer; }

/* ─── caption speech bubble (typewriter) ─── */
.player-cap {
  position: absolute; left: 14px;
  bottom: calc(var(--safe-b) + 64px);
  max-width: min(78vw, 420px);
  z-index: 4; pointer-events: none;
}
.player-cap .speech { font-size: 14px; }
.cap-text {
  border-right: 2px solid var(--ink);
  padding-right: 2px;
  animation: typewriter-caret 0.8s step-end infinite;
}

/* ─── film-strip progress + segment ticks ─── */
.player-progress {
  position: absolute;
  left: 14px; right: 14px;
  bottom: calc(var(--safe-b) + 16px);
  z-index: 4;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35);
}
.player-progress .fp-fill { transition: width 0.3s linear; }
.fp-tick {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--riso-yellow);
  opacity: 0.85; z-index: 2;
}

/* ─── top chrome ─── */
.p-topbar {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  display: flex; gap: 10px; z-index: 6;
}
.p-btn {
  width: 44px; height: 44px;
  border: 2.5px solid var(--ink-line); border-radius: 14px;
  background: var(--paper-2); color: var(--ink);
  font-family: var(--f-display); font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.p-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.p-title {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 18px);
  left: 16px; z-index: 5;
  color: var(--paper); font-size: 20px; letter-spacing: 0.04em;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
  transform: rotate(-1.5deg);
  max-width: 55vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}

/* ─── play/pause big bubble ─── */
.play-badge {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  background: var(--paper-2); color: var(--ink);
  border: 3px solid var(--ink-line); border-radius: 22px;
  padding: 14px 30px;
  font-size: 54px; line-height: 1;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  opacity: 0; pointer-events: none;
}
.play-badge .play-hint { display: none; font-family: var(--f-head); font-size: 12px; color: var(--newsprint-mute); }
.player-stage.is-paused .play-badge { opacity: 1; animation: badge-pop 0.3s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.player-stage.is-paused .play-badge .play-hint { display: block; }
.play-badge.flash { animation: badge-flash 0.7s ease-out both; }
.player-stage.is-ended .play-badge { display: none; }
@keyframes badge-pop {
  0% { transform: translate(-50%, -50%) scale(0.5) rotate(-8deg); }
  70% { transform: translate(-50%, -50%) scale(1.1) rotate(2deg); }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0); }
}
@keyframes badge-flash {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.7); }
  55% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* ─── lyrics panel ─── */
.lyrics-panel {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 66px);
  right: 12px;
  width: min(320px, 82vw);
  max-height: 55%;
  overflow-y: auto;
  z-index: 6;
  background: var(--paper-2);
  border: var(--border-ink); border-radius: 16px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5);
  padding: 12px 14px;
  cursor: auto;
}
.lyrics-panel .lp-title { font-size: 20px; margin-bottom: 6px; }
.lyrics-panel .lp-body {
  font-family: var(--f-body); font-size: 14px; line-height: 1.55;
  white-space: pre-wrap;
}

/* ─── end overlay ─── */
.end-overlay {
  position: absolute; inset: 0; z-index: 8;
  background: var(--overlay-scrim);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  cursor: auto;
}
.end-card {
  background: var(--paper-2);
  border: var(--border-ink); border-radius: var(--radius-lg);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5);
  padding: 26px 22px;
  width: 100%; max-width: 400px;
}
.end-burst {
  font-size: 44px; color: var(--riso-pink);
  text-shadow: 2px 2px 0 var(--ink);
  animation: pow 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.end-actions { flex-wrap: wrap; justify-content: center; }

/* ─── fallback / loading panels on the dark stage ─── */
.p-fallback {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  cursor: auto;
}
.p-fallback-card { width: 100%; max-width: 340px; }

/* ═══ desktop ≥1024px: letterboxed with ink curtains ═══ */
@media (min-width: 1024px) {
  .player-stage::before, .player-stage::after {
    content: ''; position: absolute; top: 0; bottom: 0; width: 7vw; z-index: 2;
    background:
      repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0 3px, transparent 3px 26px),
      #120F0B;
  }
  .player-stage::before { left: 0; border-right: 3px solid rgba(247, 241, 225, 0.2); }
  .player-stage::after { right: 0; border-left: 3px solid rgba(247, 241, 225, 0.2); }

  .player-frames { inset: 0 7vw; }
  /* <video> is a replaced element: with top/bottom set and height:auto it takes
     its INTRINSIC height instead of stretching, which overflows the stage and
     defeats object-fit. Size it explicitly. */
  .player-video { left: 7vw; right: 7vw; width: 86vw; height: 100%; }
  .v-actions { left: calc(7vw + 20px); bottom: 56px; }
  .player-cap { left: calc(7vw + 24px); bottom: 74px; max-width: 480px; }
  .player-cap .speech { font-size: 17px; padding: 12px 16px; }
  .player-progress { left: calc(7vw + 20px); right: calc(7vw + 20px); bottom: 22px; }
  .p-topbar { right: calc(7vw + 16px); }
  .p-title { left: calc(7vw + 20px); font-size: 24px; }
  .lyrics-panel { right: calc(7vw + 16px); }
}
