* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: #05070a;
  color: #f6f4ef;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
  width: 100%;
}

.page {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.masthead {
  padding: 28px 20px 16px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(246, 244, 239, 0.5);
  margin: 0 0 8px;
}

.title {
  font-size: clamp(22px, 4vw, 36px);
  font-weight: 600;
  margin: 0;
  color: #f8f6f0;
}

.playerShell {
  width: 100%;
  padding: 0 12px;
}

.player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 82vh;
  overflow: hidden;
  background: #05070a;
  border-radius: 10px;
  isolation: isolate;
}

.frameWrap {
  position: absolute;
  inset: 0;
}

.frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity 900ms ease;
  filter: brightness(0.93) contrast(1.05) saturate(0.98);
}

.frameActive {
  opacity: 1;
  z-index: 1;
}

.frameMoving {
  animation: pushIn 6500ms ease-out both;
}

@keyframes pushIn {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.035);
  }
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(to top, rgba(4, 6, 10, 0.72) 0%, rgba(4, 6, 10, 0.06) 36%, rgba(4, 6, 10, 0) 60%),
    linear-gradient(to bottom, rgba(4, 6, 10, 0.42) 0%, rgba(4, 6, 10, 0) 28%);
}

.storyMeta {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 5;
}

.storyMetaTitle {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
  color: rgba(248, 246, 240, 0.92);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
}

.storyMetaCount {
  font-size: 11px;
  margin: 2px 0 0;
  color: rgba(246, 244, 239, 0.55);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
}

.captionRow {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 15%;
  display: flex;
  justify-content: center;
  padding: 0 6vw;
  z-index: 4;
  pointer-events: none;
}

.caption {
  font-size: clamp(18px, 3vw, 32px);
  line-height: 1.3;
  font-weight: 500;
  text-align: center;
  max-width: 20ch;
  margin: 0;
  color: #f8f6f0;
  /* Layered shadow gives consistent perceptual legibility on both bright and
     dark frames without a heavy black box: a tight crisp edge shadow plus two
     softer haloes that lift the text off the image. Keeps the cinematic feel. */
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.72),
    0 2px 10px rgba(0, 0, 0, 0.55),
    0 4px 30px rgba(0, 0, 0, 0.42);
  opacity: 0;
  transform: translateY(70px);
}

.captionEnter {
  transition: transform var(--caption-enter-ms, 2300ms) cubic-bezier(0.16, 1, 0.3, 1),
    opacity var(--caption-enter-ms, 2300ms) cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateY(0);
  opacity: 1;
}

.captionExit {
  transition: transform var(--caption-exit-ms, 800ms) ease-in,
    opacity var(--caption-exit-ms, 800ms) ease-in;
  transform: translateY(16px);
  opacity: 0;
}

.brandBlock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 30%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 900ms ease, transform 900ms ease;
}

.brandBlock.brandVisible {
  opacity: 1;
  transform: translateY(0);
}

.brandBlock[hidden] {
  display: none !important;
}

.brandName {
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0;
  color: rgba(248, 246, 240, 0.9);
  font-weight: 600;
}

.ctaButton {
  display: inline-block;
  padding: 11px 24px;
  border-radius: 999px;
  border: 1px solid rgba(248, 246, 240, 0.7);
  color: #f8f6f0;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.progressTrack {
  position: absolute;
  top: 60px;
  left: 20px;
  right: 20px;
  display: flex;
  gap: 5px;
  z-index: 5;
}

.progressSegment {
  flex: 1;
  height: 2.5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  overflow: hidden;
}

.progressFill {
  height: 100%;
  width: 0%;
  background: #f8f6f0;
}

.controls {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 12px;
}

.controlButton {
  background: rgba(10, 12, 16, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #f6f4ef;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
}

.controlButton:hover {
  background: rgba(20, 24, 30, 0.75);
}

/* CSS-only "full view" fallback for browsers/contexts where the real
   Fullscreen API isn't available (notably iframed content on some mobile
   browsers). Fills the viewport without cropping the video/frame — the
   opposite of `.frame`'s normal `object-fit: cover`, which is fine for the
   inline 16:9 player but would cut off content once it fills the screen. */
.player.fallbackFullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  width: 100vw;
  height: 100vh;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
  background: #000;
}

.player.fallbackFullscreen .frame {
  object-fit: contain;
}

.debugIndicator {
  position: absolute;
  bottom: 6px;
  right: 6px;
  z-index: 20;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 4px 6px;
}

.library {
  padding: 32px 20px 60px;
}

.libraryHeading {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(246, 244, 239, 0.75);
  margin: 0 0 16px;
}

.cardRow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  color: inherit;
  font: inherit;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
}

.cardActive {
  border-color: rgba(248, 246, 240, 0.45);
  background: rgba(255, 255, 255, 0.07);
}

.cardThumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #05070a;
  display: block;
}

.cardThumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cardBody {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cardTitle {
  font-size: 18px;
  font-weight: 600;
  color: #f8f6f0;
}

.cardDesc {
  font-size: 13px;
  color: rgba(246, 244, 239, 0.6);
  line-height: 1.4;
}

@media (max-width: 640px) {
  .cardRow {
    grid-template-columns: 1fr;
  }

  .playerShell {
    padding: 0;
  }

  .player {
    border-radius: 0;
  }
}

/* ---- Public presentational mode (?mode=public / ?embed=1) ----
   Used by the public /historie/[slug] pages. Strips every technical/working
   affordance so the iframe reads as a clean, cinematic film — no gallery,
   no counters, no progress bar, no debug output. Story navigation belongs
   to the Next.js page, not to the film itself. Full mode (used by
   /commercials and /commercials-basic) is completely unaffected. */

body.mode-public .masthead,
body.mode-public .storyMeta,
body.mode-public .progressTrack,
body.mode-public .library,
body.mode-public .debugIndicator {
  display: none !important;
}

body.mode-public .page {
  max-width: none;
}

body.mode-public .playerShell {
  padding: 0;
}

body.mode-public .player {
  border-radius: 0;
  max-height: 100vh;
}

body.mode-public #btnPrev,
body.mode-public #btnNext {
  display: none;
}

/* Minimal, subtle, bottom-edge controls: hidden by default, revealed on
   hover/focus (desktop) or tap (touch, via .controlsVisible toggled in JS).
   Real <button> elements stay in the tab order regardless of opacity, so
   keyboard users reach them via Tab and :focus-within reveals them. */
body.mode-public .controls {
  opacity: 0;
  transition: opacity 220ms ease;
  bottom: 0;
  padding: 22px 16px 16px;
  background: linear-gradient(to top, rgba(4, 6, 10, 0.55) 0%, rgba(4, 6, 10, 0) 100%);
  justify-content: flex-end;
}

body.mode-public .player:hover .controls,
body.mode-public .player:focus-within .controls,
body.mode-public .player.controlsVisible .controls {
  opacity: 1;
}

body.mode-public .controlButton {
  font-size: 13px;
  background: rgba(10, 12, 16, 0.45);
}

/* Replay only makes sense once the film has ended; Pause/Resume only makes
   sense while it hasn't. */
body.mode-public #btnReplay {
  display: none;
}

body.mode-public .player.isEnded #btnReplay {
  display: inline-flex;
}

body.mode-public .player.isEnded #btnPlay {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  body.mode-public .controls {
    transition: none;
  }
}
