/* Abyssal: the ocean world, and the agents that built it.
   Two frame-aligned encodes of the same 64.5 s timeline, one clean and one with Vortex on
   screen. "Show Vortex" wipes from one to the other on the same frame. Reads page tokens
   (--wd-*) with fallbacks so it also stands alone. */

@property --oc-wipe {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 0%;
}

.oc {
  --oc-ink: var(--wd-ink, #eef4fb);
  --oc-muted: var(--wd-muted, rgba(214, 228, 245, 0.62));
  --oc-line: var(--wd-line, rgba(170, 205, 245, 0.16));
  --oc-accent: var(--wd-accent, #7cc8ff);
  --oc-sans: var(--wd-sans, "Inter", system-ui, -apple-system, "Segoe UI", sans-serif);
  --oc-mono: var(--wd-mono, "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace);
  --oc-gutter: clamp(1rem, 4vw, 3.5rem);
  --oc-ease: cubic-bezier(0.65, 0, 0.35, 1);

  position: relative;
  isolation: isolate;
  color: var(--oc-ink);
  font-family: var(--oc-sans);
  padding: clamp(5rem, 11vw, 9.5rem) 0 clamp(4.5rem, 9vw, 8rem);
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(30, 110, 190, 0.28), transparent 60%),
    radial-gradient(90% 60% at 50% 100%, rgba(10, 60, 120, 0.35), transparent 70%),
    linear-gradient(180deg, #020a17 0%, #03132a 45%, #020914 100%);
  overflow: clip;
}

.oc-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- head ---------- */
.oc-head {
  max-width: 44rem;
  margin: 0 auto clamp(2.25rem, 5vw, 3.75rem);
  padding: 0 var(--oc-gutter);
  text-align: center;
}
.oc-kicker {
  margin: 0;
  font: 500 0.66rem/1 var(--oc-mono);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--oc-accent);
}
.oc-head h2 {
  margin: 1rem 0 0;
  font-weight: 500;
  font-size: clamp(2.6rem, 7vw, 5.4rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}
.oc-lede {
  margin: 1.25rem auto 0;
  max-width: 34rem;
  font-size: clamp(1.02rem, 1.5vw, 1.2rem);
  line-height: 1.55;
  color: var(--oc-muted);
  text-wrap: pretty;
}

/* ---------- stage ---------- */
.oc-stage {
  width: min(100% - 2 * var(--oc-gutter), 168vh, 1720px);
  margin: 0 auto;
}
.oc-screen { position: relative; }
.oc-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: clamp(10px, 1.4vw, 20px);
  overflow: hidden;
  background: #01060e;
  box-shadow:
    0 0 0 1px rgba(150, 200, 255, 0.10),
    0 40px 120px -30px rgba(0, 40, 90, 0.75),
    0 0 140px -40px rgba(60, 150, 255, 0.35);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.oc-v {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform-origin: 0 0;
  transition: transform 900ms var(--oc-ease);
}

/* The world layer sits on top; Vortex is revealed by wiping it away left to right. */
.oc-v-world {
  --oc-wipe: 0%;
  /* Soft 12% edge that ends exactly at the wipe line: fully opaque at 0%, fully gone at 112%. */
  -webkit-mask-image: linear-gradient(90deg, transparent calc(var(--oc-wipe) - 12%), #000 var(--oc-wipe));
  mask-image: linear-gradient(90deg, transparent calc(var(--oc-wipe) - 12%), #000 var(--oc-wipe));
  transition: --oc-wipe 1100ms var(--oc-ease), transform 900ms var(--oc-ease);
}
.oc-stage[data-mode="vortex"] .oc-v-world { --oc-wipe: 112%; }

/* The light seam that travels with the wipe. */
.oc-frame::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: 0;
  width: 2px;
  margin-left: -1px;
  background: linear-gradient(180deg, transparent, rgba(160, 225, 255, 0.95) 20%, rgba(160, 225, 255, 0.95) 80%, transparent);
  box-shadow: 0 0 24px 6px rgba(110, 200, 255, 0.45);
  opacity: 0;
  pointer-events: none;
  translate: var(--oc-seam, -10px) 0;
}
.oc-frame.is-wiping::after { animation: oc-seam 1100ms var(--oc-ease) forwards; }
.oc-stage[data-mode="world"] .oc-frame.is-wiping::after { animation-direction: reverse; }
@keyframes oc-seam {
  0% { left: -2%; opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { left: 102%; opacity: 0; }
}

/* Browsers without @property (checked in JS) fade instead of wiping. */
.oc--fade .oc-v-world {
  -webkit-mask-image: none;
  mask-image: none;
  transition: opacity 700ms var(--oc-ease), transform 900ms var(--oc-ease);
}
.oc--fade .oc-stage[data-mode="vortex"] .oc-v-world { opacity: 0; }
.oc--fade .oc-frame::after { display: none; }

/* Zoom into the Vortex panel (top-right of the frame). */
/* Zoom onto the chapter's panel rectangle; JS writes the fitted scale and offsets. */
.oc-stage[data-zoom="on"][data-mode="vortex"] .oc-v {
  transform: translate(var(--oc-zx, 0%), var(--oc-zy, 0%)) scale(var(--oc-zs, 1));
}
.oc-zoom {
  flex: none;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem 0.55rem 0.7rem;
  border: 1px solid rgba(190, 225, 255, 0.28);
  border-radius: 999px;
  background: rgba(8, 26, 52, 0.55);
  color: var(--oc-ink);
  font: 500 0.82rem/1 var(--oc-sans);
  cursor: pointer;
  opacity: 0;
  translate: 0 6px;
  pointer-events: none;
  transition: opacity 400ms var(--oc-ease) 300ms, translate 400ms var(--oc-ease) 300ms, background 200ms;
}
.oc-zoom svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.oc-zoom:hover { background: rgba(10, 32, 62, 0.8); }
.oc-zoom-out, .oc-zs-in, .oc-zs-out { display: none; }
.oc-zoom[aria-pressed="true"] .oc-zoom-in { display: none; }
.oc-zoom[aria-pressed="true"] .oc-zoom-out { display: inline; }
.oc-stage[data-mode="vortex"][data-panel="yes"] .oc-zoom { opacity: 1; translate: 0 0; pointer-events: auto; }
.oc-zoom:disabled { cursor: default; }

/* ---------- under the frame: what you are looking at ---------- */
/* Captions live off the picture: the footage carries its own game HUD and Vortex banner. */
.oc-under {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: clamp(1.1rem, 2vw, 1.6rem);
}
.oc-caption {
  flex: 1;
  max-width: 46rem;
  min-height: 3.4rem;
  display: grid;
}
.oc-caption p {
  grid-area: 1 / 1;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: opacity 500ms var(--oc-ease), translate 500ms var(--oc-ease);
}
.oc-caption b {
  font-weight: 500;
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
  letter-spacing: -0.015em;
}
.oc-caption span {
  font-size: clamp(0.88rem, 1.05vw, 1rem);
  line-height: 1.5;
  color: var(--oc-muted);
  text-wrap: pretty;
}
.oc-cap-vortex b { font-family: var(--oc-mono); font-size: clamp(0.92rem, 1.3vw, 1.15rem); letter-spacing: 0; color: var(--oc-accent); }
.oc-stage[data-mode="world"] .oc-cap-vortex,
.oc-stage[data-mode="vortex"] .oc-cap-world { opacity: 0; translate: 0 8px; }
.oc-caption.is-swap p { opacity: 0 !important; translate: 0 6px; transition-duration: 180ms; }

/* ---------- control bar ---------- */
.oc-bar {
  display: flex;
  align-items: flex-start;
  gap: clamp(1rem, 2.5vw, 2.25rem);
  margin-top: clamp(1.1rem, 2vw, 1.5rem);
  padding-top: clamp(1rem, 1.8vw, 1.3rem);
  border-top: 1px solid var(--oc-line);
}

.oc-switch {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.9rem 0.5rem 0.55rem;
  border: 1px solid var(--oc-line);
  border-radius: 999px;
  background: rgba(8, 26, 52, 0.55);
  color: var(--oc-ink);
  font: 500 0.92rem/1 var(--oc-sans);
  cursor: pointer;
  transition: border-color 250ms, background 250ms, box-shadow 400ms;
}
.oc-switch:hover { border-color: rgba(170, 215, 255, 0.4); }
.oc-switch-track {
  position: relative;
  width: 2.5rem;
  height: 1.45rem;
  border-radius: 999px;
  background: rgba(150, 190, 235, 0.22);
  transition: background 350ms var(--oc-ease);
}
.oc-switch-thumb {
  position: absolute;
  top: 0.18rem;
  left: 0.18rem;
  width: 1.09rem;
  height: 1.09rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transition: translate 350ms var(--oc-ease);
}
.oc-switch[aria-checked="true"] { border-color: rgba(124, 200, 255, 0.55); box-shadow: 0 0 30px -6px rgba(110, 195, 255, 0.55); }
.oc-switch[aria-checked="true"] .oc-switch-track { background: var(--oc-accent); }
.oc-switch[aria-checked="true"] .oc-switch-thumb { translate: 1.05rem 0; }
.oc-kbd {
  font: 500 0.66rem/1 var(--oc-mono);
  padding: 0.22rem 0.38rem;
  border: 1px solid var(--oc-line);
  border-radius: 5px;
  color: var(--oc-muted);
}

.oc-chapters {
  flex: 1;
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
}
.oc-chapters li { flex: var(--w, 1) 1 0; min-width: 0; position: relative; }
.oc-chapters button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.95rem 0 0.4rem;
  border: 0;
  background: none;
  color: var(--oc-muted);
  text-align: left;
  cursor: pointer;
  font: 500 0.66rem/1.2 var(--oc-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 250ms;
}
.oc-chapters button::before {
  content: "";
  position: absolute;
  top: 0.35rem;
  left: 0; right: 0;
  height: 3px;
  border-radius: 3px;
  background: rgba(160, 200, 245, 0.2);
  transition: background 250ms;
}
.oc-ch-fill {
  position: absolute;
  top: 0.35rem;
  left: 0; right: 0;
  height: 3px;
  border-radius: 3px;
  background: var(--oc-ink);
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
}
.oc-stage[data-mode="vortex"] .oc-ch-fill { background: var(--oc-accent); }
.oc-ch-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Vortex mode: the rail also names what the panel is showing, matching the caption. */
.oc-ch-agent {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
  padding-right: 0.4rem;
  max-height: 0;
  opacity: 0;
  color: var(--oc-accent);
  font-size: 0.74rem;
  letter-spacing: 0.01em;
  text-transform: none;
  transition: max-height 400ms var(--oc-ease), opacity 400ms var(--oc-ease), margin 400ms var(--oc-ease);
}
.oc-stage[data-mode="vortex"] .oc-ch-agent { max-height: 1.3em; opacity: 1; margin-top: 0.4rem; }
.oc-chapters button:not([aria-current]) .oc-ch-agent { color: rgba(214, 228, 245, 0.72); }

.oc-chapters button:hover { color: var(--oc-ink); }
.oc-chapters button:hover::before { background: rgba(170, 210, 250, 0.36); }
.oc-chapters button[aria-current="true"] { color: var(--oc-ink); }

/* Chapter thumbnail on hover (pointer devices). */
.oc-thumb {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  width: 168px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(170, 210, 255, 0.25), 0 18px 40px -12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  translate: 0 6px;
  pointer-events: none;
  transition: opacity 220ms var(--oc-ease), translate 220ms var(--oc-ease);
  z-index: 2;
}
.oc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
/* A small tick anchors the preview to its segment. */
.oc-thumb::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 18px;
  border: 6px solid transparent;
  border-top-color: rgba(170, 210, 255, 0.45);
}
.oc-chapters li:last-child .oc-thumb { left: auto; right: 0; }
.oc-chapters li:last-child .oc-thumb::after { left: auto; right: 18px; }
@media (hover: hover) {
  .oc-chapters li:hover:not(.is-picked) .oc-thumb { opacity: 1; translate: 0 0; }
}

.oc-play {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 0.6rem 0 0.75rem;
  border: 1px solid var(--oc-line);
  border-radius: 999px;
  background: rgba(8, 26, 52, 0.55);
  color: var(--oc-ink);
  cursor: pointer;
  transition: border-color 250ms;
}
.oc-play:hover { border-color: rgba(170, 215, 255, 0.4); }
.oc-play svg { width: 14px; height: 14px; fill: currentColor; }
.oc-play .oc-i-play { display: none; }
.oc-play.is-paused .oc-i-play { display: inline; }
.oc-play.is-paused .oc-i-pause { display: none; }

/* Rounded focus, in the same pill language as the controls. */
.oc button:focus-visible,
.oc-frame:focus-visible {
  outline: 2px solid rgba(124, 200, 255, 0.7);
  outline-offset: 4px;
  border-radius: 999px;
}
.oc-chapters button:focus-visible { border-radius: 8px; outline-offset: 2px; }
.oc-frame:focus-visible { border-radius: clamp(10px, 1.4vw, 20px); }

/* ---------- facts ---------- */
.oc-facts {
  /* Same column as the stage, so the facts line up with the video and caption. */
  width: min(100% - 2 * var(--oc-gutter), 168vh, 1720px);
  margin: clamp(3.5rem, 7vw, 5.5rem) auto 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(1.5rem, 3vw, 3rem);
}
.oc-facts div { border-top: 1px solid var(--oc-line); padding-top: 1.1rem; }
.oc-facts dt { font-weight: 500; font-size: 1.02rem; letter-spacing: -0.01em; }
.oc-facts dd { margin: 0.55rem 0 0; color: var(--oc-muted); font-size: 0.95rem; line-height: 1.6; text-wrap: pretty; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  /* The stage is a size container so the switch can sit on the film's bottom edge. */
  .oc-stage { width: 100%; position: relative; container-type: inline-size; }
  .oc-frame { border-radius: 0; box-shadow: none; }
  .oc-under { padding: 0 var(--oc-gutter); gap: 0.75rem; margin-top: 1rem; }
  .oc-caption { min-height: 5.6rem; }
  .oc .oc-zoom { padding: 0.5rem 0.8rem 0.5rem 0.65rem; font-size: 0.8rem; }
  .oc-zoom-in, .oc-zoom-out, .oc-zoom .oc-kbd { display: none !important; }
  .oc-zoom .oc-zs-in { display: inline; }
  .oc-zoom[aria-pressed="true"] .oc-zs-in { display: none; }
  .oc-zoom[aria-pressed="true"] .oc-zs-out { display: inline; }
  .oc-ch-agent { display: none; }
  .oc { padding-bottom: 3.5rem; }
  .oc-bar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.9rem 0.75rem;
    padding: 0 var(--oc-gutter);
    margin-top: 0.75rem;
  }
  /* Phones: the switch rides on the film, so tapping it and the change are in one view. */
  .oc .oc-switch {
    position: absolute;
    z-index: 3;
    left: 0.75rem;
    top: calc(100cqw * 9 / 16 - 0.75rem);
    translate: 0 -100%;
    min-height: 44px;
    padding: 0.4rem 0.95rem 0.4rem 0.5rem;
    background: rgba(3, 13, 30, 0.66);
    border-color: rgba(190, 225, 255, 0.3);
    -webkit-backdrop-filter: blur(12px) saturate(1.3);
    backdrop-filter: blur(12px) saturate(1.3);
    box-shadow: 0 6px 24px -8px rgba(0, 0, 0, 0.6);
  }
  .oc-switch[aria-checked="true"] { background: rgba(6, 26, 52, 0.72); }
  .oc .oc-play { order: 2; margin-left: auto; padding: 0; width: 2.75rem; height: 2.75rem; }
  /* Phones: one proportional segmented scrubber; the caption above names the chapter. */
  .oc-chapters { order: 1; flex: 1 1 auto; gap: 4px; }
  .oc-chapters button { padding: 0.35rem 0 0.9rem; }
  .oc-chapters button::before, .oc-ch-fill { top: 0.85rem; height: 4px; }
  .oc-ch-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .oc-kbd { display: none; }
  .oc-facts { grid-template-columns: 1fr; gap: 1.5rem; margin-top: 1.25rem; padding: 0 var(--oc-gutter); width: auto; }
  .oc-chapters button { padding-bottom: 0.4rem; }
  .oc-under .oc-caption { min-height: 4.6rem; }
}


@media (prefers-reduced-motion: reduce) {
  .oc-v, .oc-v-world, .oc-caption p, .oc-switch-thumb, .oc-switch-track, .oc-zoom, .oc-thumb { transition-duration: 1ms !important; transition-delay: 0ms !important; }
  .oc-frame.is-wiping::after { animation: none; }
}
