/* ==========================================================================
   OpenVids landing — story slice: #problem (pb-) and #graph (gr-).
   Consumes core tokens only. Motion state is written by openvids-landing-story.js.
   ========================================================================== */

/* ==========================================================================
   c2 · The problem
   ========================================================================== */
.pb-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.pb-frame { position: relative; height: 100%; }

.pb-top {
  position: absolute; left: 0; right: 0; top: calc(var(--nav-h) + clamp(14px, 3vh, 30px)); z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
}
.pb-src { display: inline-flex; align-items: center; gap: 10px; margin: 0; font: 500 11.5px/1 var(--font-mono); color: var(--muted); white-space: nowrap; }
.pb-src-k { letter-spacing: .14em; text-transform: uppercase; }
.pb-src-f { color: var(--fg-2); }
.pb-src .tc { padding: 5px 7px; border: 1px solid var(--border); border-radius: var(--r-xs); color: var(--fg); background: var(--glass); }

.pb-lines { position: absolute; left: 0; right: 0; top: calc(var(--nav-h) + clamp(64px, 11vh, 118px)); z-index: 2; display: grid; pointer-events: none; }
.pb-line {
  grid-area: 1 / 1; margin: 0; max-width: 14em;
  font: 400 clamp(36px, 5.8vw, 88px)/1.02 var(--font-display); letter-spacing: -0.04em; color: var(--fg);
  text-wrap: balance; will-change: transform, opacity;
}
.pb-line em { font-style: italic; letter-spacing: -0.03em; }
.pb-line .c { display: inline-block; }

.pb-count {
  position: absolute; left: 0; top: calc(50% - 38px); z-index: 2; margin: 0; opacity: 0;
  display: flex; align-items: baseline; gap: 10px;
  font: 500 11px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.pb-count b { font: 500 22px/1 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--fg); }

/* the thread: six chapters as one track bar (also the first frame of #graph) */
.pb-thread, .gr-thread { position: absolute; left: 0; right: 0; top: 64%; z-index: 2; pointer-events: none; }
.pb-segs { display: flex; gap: 3px; margin: 0; padding: 0; list-style: none; }
.pb-seg { position: relative; flex: var(--w) 1 0; min-width: 0; }
.pb-bar { display: block; height: 2px; border-radius: 1px; background: color-mix(in oklab, var(--fg) 64%, transparent); transform-origin: 0 50%; }
.pb-lbl { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px 6px 0 1px; font: 500 11px/1 var(--font-mono); color: var(--muted); white-space: nowrap; }
.pb-lbl::before { content: ''; position: absolute; left: 0; top: -8px; width: 1px; height: 14px; background: var(--fg); }
.pb-lbl b { display: block; overflow: hidden; text-overflow: ellipsis; font: 500 12.5px/1.15 var(--font-body); color: var(--fg-2); }
.pb-ph { position: absolute; left: 0; top: -15px; width: 2px; height: 32px; margin-left: -1px; border-radius: 1px; background: var(--accent); opacity: calc(var(--ph-o, 0) * var(--ph-x, 1)); }
.pb-ph::before { content: ''; position: absolute; top: -8px; left: 50%; width: 12px; height: 9px; transform: translateX(-50%); background: var(--accent); clip-path: polygon(0 0, 100% 0, 50% 100%); }

/* ==========================================================================
   c3 · Meet OpenVids
   ========================================================================== */
.gr-frame { position: relative; height: 100%; }
.gr-top {
  position: absolute; left: 0; right: 0; top: calc(var(--nav-h) + clamp(12px, 2.4vh, 24px)); z-index: 4;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
}
.gr-modes {
  display: inline-flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.gr-mode { display: inline-flex; align-items: center; height: 26px; padding: 0 11px; border-radius: 5px; font: 600 12px/1 var(--font-body); color: var(--fg-2); transition: background-color .45s var(--ease-out), color .45s var(--ease-out); }
.gr-mode.is-on { background: var(--fg); color: var(--bg); }
.gr-status { margin-left: 4px; padding: 0 9px 0 11px; border-left: 1px solid var(--border); font: 500 11.5px/26px var(--font-mono); font-style: normal; color: var(--fg-2); white-space: nowrap; }

.gr-head { position: absolute; left: 0; top: calc(var(--nav-h) + 76px); z-index: 3; display: grid; gap: 22px; max-width: min(780px, 60%); will-change: transform, opacity; }
.gr-head .h2 { font-size: clamp(40px, 5.4vw, 84px); }

.gr-space, .gr-build { position: absolute; left: 0; right: 0; top: calc(var(--nav-h) + 76px); bottom: calc(var(--hud-h) + 44px); }
.gr-space { z-index: 1; perspective: 1300px; perspective-origin: 50% 32%; }
.gr-world { position: absolute; inset: 0; transform-style: preserve-3d; transform-origin: 50% 70%; }
.gr-edges { position: absolute; left: 0; top: 0; overflow: visible; }
.gr-nodes { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-style: preserve-3d; }
.gr-n { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform, opacity; }
.gr-m.t-video { --tl: var(--k-video-l); }
.gr-m.t-image { --tl: var(--k-image-l); }
.gr-m.t-audio { --tl: var(--k-audio-l); }
.gr-m.t-motion { --tl: var(--k-motion-l); }
.gr-m.t-missing { --tl: var(--border-strong); }

/* edges: drawn with stroke-dashoffset on normalised paths */
.gr-e, .gr-spine { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.gr-spine { stroke: color-mix(in oklab, var(--fg) 34%, transparent); stroke-width: 2; }
.gr-e { stroke: var(--border-strong); stroke-width: 1.5; }
.gr-e.t-motion { stroke: var(--k-motion-l); }
.gr-e.t-missing { stroke: var(--muted); stroke-dasharray: .012 .01; }
.gr-e.is-x { stroke: color-mix(in oklab, var(--k-audio-l) 80%, transparent); }

/* chapter node */
.gr-ch-in {
  position: absolute; left: 0; top: 0; width: var(--chw, 196px); height: 106px; margin: -53px 0 0 calc(var(--chw, 196px) / -2); overflow: hidden;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2);
  box-shadow: 0 14px 34px oklch(0% 0 0 / .45), inset 0 1px 0 color-mix(in oklab, var(--fg) 6%, transparent);
}
.gr-ch.is-lg .gr-ch-in { height: 146px; margin-top: -73px; }
.gr-ch-fr { position: relative; height: 64px; margin: 3px 3px 0; overflow: hidden; border-radius: 7px; background: var(--surface-3); }
.gr-ch-fr img { width: 100%; height: 100%; object-fit: cover; }
.gr-ch-num, .gr-ch-flag {
  position: absolute; top: 6px; display: inline-flex; align-items: center; justify-content: center; height: 18px; padding: 0 6px; border-radius: 4px;
  background: oklch(0% 0 0 / .55); color: var(--fg); font: 600 10.5px/1 var(--font-mono);
}
.gr-ch-num { left: 6px; }
.gr-ch-flag { right: 6px; font-size: 11px; }
.gr-ch-body { padding: 8px 10px 0; }
.gr-ch-row { display: flex; align-items: baseline; gap: 8px; }
.gr-ch-row b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 13px/1.25 var(--font-body); color: var(--fg); }
.gr-ch-row .tc { flex: none; font-size: 11.5px; color: var(--fg-2); }
.gr-ch-body p { margin: 5px 0 0; font-size: 11.5px; line-height: 1.3; color: var(--fg-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* media node — A: floating card, B: compact chip (crossfaded mid-flight) */
.gr-card {
  position: absolute; left: 0; top: 0; width: 164px; height: 130px; margin: -65px 0 0 -82px; padding: 6px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2);
  box-shadow: 0 20px 44px oklch(0% 0 0 / .5); backface-visibility: hidden;
}
.gr-card-th { position: relative; height: 86px; overflow: hidden; border-radius: 6px; background: var(--surface-3); }
.gr-card-th img { width: 100%; height: 100%; object-fit: cover; }
.gr-card-th::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--tl); }
.gr-card-meta { display: grid; gap: 5px; padding: 8px 2px 0; }
.gr-card-meta b, .gr-chip-tx b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 11.5px/1.2 var(--font-body); color: var(--fg); }
.gr-card-meta span, .gr-chip-tx span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 10.5px/1 var(--font-mono); color: var(--muted); }
.gr-m.t-missing .gr-card { border-style: dashed; background: var(--surface); }
.gr-m.t-missing .gr-card-th { background: none; }
.gr-miss {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 8px 10px;
  border: 1px dashed var(--border-strong); border-radius: 6px; font: 500 11.5px/1.3 var(--font-body); color: var(--fg-2);
}
.gr-miss em { font: 600 10px/1 var(--font-mono); font-style: normal; letter-spacing: .12em; text-transform: uppercase; color: var(--warn); }
.gr-miss small { font: 500 10px/1.2 var(--font-mono); color: var(--muted); }

.gr-chip {
  position: absolute; left: 0; top: 0; width: var(--cw, 184px); height: 38px; margin: -19px 0 0 calc(var(--cw, 184px) / -2); overflow: hidden;
  display: flex; align-items: center; gap: 8px; padding: 0 8px 0 7px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); box-shadow: 0 8px 22px oklch(0% 0 0 / .4);
  opacity: 0; visibility: hidden;
}
.gr-chip::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--tl); }
.gr-chip-th { flex: none; width: 48px; height: 27px; overflow: hidden; border-radius: 4px; background: var(--surface-3); }
.gr-chip-th img { width: 100%; height: 100%; object-fit: cover; }
.gr-chip-tx { display: grid; gap: 4px; min-width: 0; }
.gr-m.t-missing .gr-chip { border-style: dashed; background: var(--surface); }
.gr-m.t-missing .gr-chip-th { background: none; }
.gr-miss-s { display: grid; place-items: center; width: 100%; height: 100%; border: 1px dashed var(--border-strong); border-radius: 4px; color: var(--muted); font-size: 13px; }

/* build: steps, timeline, result */
.gr-build { z-index: 2; display: flex; flex-direction: column; justify-content: center; gap: 16px; visibility: hidden; opacity: 0; transform-origin: 50% 100%; will-change: transform, opacity; }
.gr-steps { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; padding: 0; list-style: none; }
.gr-step { display: inline-flex; align-items: center; gap: 8px; font: 500 12.5px/1 var(--font-body); color: var(--muted); transition: color .3s; }
.gr-step-ic { display: grid; place-items: center; width: 16px; height: 16px; border: 1.5px solid var(--border-strong); border-radius: 50%; color: transparent; font-size: 10px; }
.gr-step-ic .ic { stroke-width: 2.6; }
.gr-step.is-on { color: var(--fg); }
.gr-step.is-on .gr-step-ic { border-color: var(--fg); border-right-color: transparent; animation: gr-spin .8s linear infinite; }
.gr-step.is-done { color: var(--fg-2); }
.gr-step.is-done .gr-step-ic { border-color: var(--ok); background: color-mix(in oklab, var(--ok) 18%, transparent); color: var(--ok); }
@keyframes gr-spin { to { transform: rotate(360deg); } }

.gr-tl { --hw: 96px; --tk: 1; flex: none; }
.gr-tl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-tl-tc { font: 500 12px/1 var(--font-mono); color: var(--fg); }
.gr-tl-body { position: relative; }
.gr-row { display: grid; grid-template-columns: var(--hw) minmax(0, 1fr); height: calc(var(--h) * var(--tk) * 1px + 4px); border-bottom: 1px solid var(--hair); }
.gr-row:last-child { border-bottom: 0; }
.gr-row-ruler { height: 24px; }
.gr-th { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 10px; border-right: 1px solid var(--border); background: var(--surface-2); font: 600 11px/1 var(--font-mono); color: var(--fg); }
.gr-th span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 11px/1 var(--font-body); color: var(--muted); }
.gr-ruler { display: flex; gap: 2px; padding-top: 5px; }
.gr-ruler span { flex: var(--w) 1 0; min-width: 0; padding-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 1px solid var(--border-strong); font: 500 10.5px/14px var(--font-mono); color: var(--muted); }
.gr-lane { position: relative; overflow: hidden; }
.gr-clip {
  position: absolute; top: 2px; bottom: 2px; display: flex; align-items: center; overflow: hidden;
  border: 1px solid var(--kl); border-radius: 4px; background: var(--kh);
  font: 500 10.5px/1 var(--font-mono); color: var(--fg-2); white-space: nowrap;
  clip-path: inset(-1px 100% -1px 0);
}
.gr-clip.t-video { --kh: var(--k-video-h); --kl: var(--k-video-l); }
.gr-clip.t-image { --kh: var(--k-image-h); --kl: var(--k-image-l); }
.gr-clip.t-audio { --kh: var(--k-audio-b); --kl: var(--k-audio-l); }
.gr-clip.t-motion { --kh: var(--k-motion-h); --kl: var(--k-motion-l); }
.gr-clip.t-caption { --kh: var(--k-caption-h); --kl: var(--k-caption-l); }
.gr-clip span { position: relative; min-width: 0; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.gr-clip-th { flex: none; width: auto; height: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.gr-wave { position: absolute; left: 0; top: 4px; width: 100%; height: calc(100% - 8px); opacity: .7; }
.gr-wave path { fill: none; stroke: var(--wave); stroke-width: 1; vector-effect: non-scaling-stroke; }
.gr-wr { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.gr-wr::before { content: ''; position: absolute; left: -1px; top: 0; bottom: 0; width: 2px; background: var(--fg); box-shadow: 0 0 12px color-mix(in oklab, var(--fg) 55%, transparent); }
.gr-tl-ph { position: absolute; top: 0; bottom: 0; left: var(--hw); right: 0; pointer-events: none; }
.gr-tl-ph::before { content: ''; position: absolute; left: -1px; top: 0; bottom: 0; width: 2px; background: var(--accent); }
.gr-tl-ph::after { content: ''; position: absolute; left: -6px; top: 0; width: 12px; height: 9px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 50% 100%); }

.gr-result { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.gr-res-i { opacity: 0; }
.gr-result .chip .ic { stroke-width: 2.4; }
.gr-kept { margin-left: 6px; font: 500 11px/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.gr-edit { display: inline-flex; align-items: center; gap: 7px; font: 500 13px/1.3 var(--font-body); color: var(--fg); }
.gr-edit .ic { color: var(--ok); stroke-width: 2.4; }

/* graph summary: screen-reader copy of the graph; the visible summary in reduced motion */
.gr-sum { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; list-style: none; }

/* ---- ≤920px: vertical graph, compact timeline ---- */
.gr-mob .gr-chip { height: 30px; margin-top: -15px; gap: 7px; }
.gr-mob .gr-chip-th { width: 34px; height: 19px; }
.gr-mob .gr-chip-tx span { display: none; }
.gr-mob .gr-ch-in, .gr-mob .gr-ch.is-lg .gr-ch-in { height: 50px; margin-top: -25px; }
.gr-mob .gr-ch-fr, .gr-mob .gr-ch-body p { display: none; }
.gr-mob .gr-ch-body { padding: 15px 10px 0 12px; }

@media (max-height: 760px) {
  .gr-tl { --tk: .78; }
  .gr-head .h2 { font-size: clamp(38px, 4.6vw, 68px); }
}
@media (max-width: 920px) {
  .pb-lines { top: calc(var(--nav-h) + 104px); }
  .gr-head { top: calc(var(--nav-h) + 92px); max-width: 100%; gap: 16px; }
  .gr-space, .gr-build { top: calc(var(--nav-h) + 92px); bottom: calc(var(--hud-h) + 36px); }
  .gr-tl { --hw: 46px; --tk: .72; }
  .gr-th span, .gr-clip span, .gr-ruler span { font-size: 0; }
  .gr-th { padding: 0 8px; }
  .gr-clip-th { display: none; }
  .gr-step:not(.is-cur) { display: none; }
  .gr-result { gap: 8px 10px; }
  .gr-kept { flex-basis: 100%; margin-left: 0; }
  .gr-edit { font-size: 12.5px; }
}
@media (max-width: 600px) {
  .gr-status { display: none; }
  .pb-lbl b { display: none; }
  .pb-lbl { font-size: 10px; padding-right: 2px; }
  .pb-src-k { display: none; }
}

/* ==========================================================================
   Reduced motion: static compositions (JS adds .pb-static / .gr-static)
   ========================================================================== */
.problem.pb-static, .graph.gr-static { height: auto; }
.pb-static .pb-stage, .gr-static .gr-stage { position: relative; height: auto; overflow: visible; padding: calc(var(--nav-h) + 48px) 0 clamp(96px, 14vh, 160px); }
.pb-static .pb-frame, .gr-static .gr-frame { height: auto; display: grid; gap: 40px; }
.pb-static .pb-canvas, .pb-static .pb-count { display: none; }
.pb-static .pb-top, .pb-static .pb-lines { position: static; }
.pb-static .pb-lines { gap: 30px; }
.pb-static .pb-line { grid-area: auto; font-size: clamp(30px, 4.4vw, 64px); }
.pb-static .pb-line::before { content: attr(data-tc); display: block; margin-bottom: 12px; font: 500 11.5px/1 var(--font-mono); letter-spacing: .04em; color: var(--muted); }
.pb-static .pb-src .tc { display: none; }
.pb-static .pb-thread { position: relative; top: auto; margin-top: 24px; }
.pb-static .pb-ph { opacity: 1; }

.gr-static .gr-top, .gr-static .gr-head, .gr-static .gr-build { position: static; max-width: none; }
.gr-static .gr-head { max-width: 1000px; }
.gr-static .gr-space, .gr-static .gr-thread { display: none; }
.gr-static .gr-build { order: 2; visibility: visible; opacity: 1; transform: none; }
.gr-static .gr-res-i { opacity: 1; }
.gr-static .gr-sum {
  order: 1; position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px;
}
.gr-sum-i { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 6px 10px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); }
.gr-sum-i b { font: 600 14px/1.25 var(--font-body); color: var(--fg); }
.gr-sum-i .tc { font-size: 12px; color: var(--fg-2); }
.gr-sum-n { color: var(--muted); }
.gr-sum-p, .gr-sum-m { grid-column: 1 / -1; font-size: 13px; line-height: 1.4; color: var(--fg-2); }
.gr-sum-m { font: 500 11.5px/1.4 var(--font-mono); color: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .gr-step.is-on .gr-step-ic { animation: none; }
}
