/* =========================================================================
   NULLFRAME — HUD & VFX LIBRARY
   Linear-inspired dark theme · Inter typography · purple accent
   ------------------------------------------------------------------------- */


/* -------------------------------------------------------------------------
   1. DESIGN TOKENS
   Mirrors Linear's tri-token approach (base, accent, contrast) plus
   semantic surface tokens. Values are tuned for OLED-friendly contrast
   and a desaturated, slightly cool gray base.
   ----------------------------------------------------------------------- */
:root {
  /* Base surfaces — layered backgrounds */
  --bg-0:   #06040A;            /* deepest — page */
  --bg-1:   #06040A;            /* panels */
  --bg-2:   #06040A;            /* cards / hover */
  --bg-3:   #06040A;            /* elevated */

  /* Foregrounds */
  --fg-0:   #F7F8F8;            /* primary text */
  --fg-1:   #B4BCD0;            /* secondary text */
  --fg-2:   #8A8F98;            /* tertiary / meta */
  --fg-3:   #4C525C;            /* disabled / hairlines */

  /* Lines */
  --line:        rgba(255,255,255,0.06);
  --line-strong: rgba(255,255,255,0.12);

  /* Accent — Linear purple */
  --accent:      #F7F8F8;
  --accent-soft: rgba(94,106,210,0.16);
  --accent-glow: rgba(94,106,210,0.45);

  /* Secondary signals */
  --warn: #F2C94C;
  --ok:   #4CC38A;
  --hot:  #FF5C5C;

  /* Type */
  --font-display: "Inter", "Inter Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Scale — refined, not chunky */
  --t-xs:   11px;
  --t-sm:   12px;
  --t-md:   14px;
  --t-lg:   16px;
  --t-xl:   20px;
  --t-2xl:  28px;
  --t-3xl:  40px;
  --t-4xl:  64px;
  --t-5xl:  88px;

  /* Spacing */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  24px;
  --s-6:  32px;
  --s-7:  48px;
  --s-8:  72px;
  --s-9:  120px;

  /* Layout */
  --gutter: clamp(20px, 4vw, 56px);
  --row-height: 156px;

  /* Motion */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --d-fast:   180ms;
  --d-med:    420ms;
  --d-slow:   720ms;
}

/* -------------------------------------------------------------------------
   2. RESET / BASE
   ----------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; scroll-behavior: smooth; }
img, svg, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }

body {
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-body);
  font-size: var(--t-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;

  /* Subtle radial wash — the only "color" on the page apart from accent. */
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(94,106,210,0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(94,106,210,0.06), transparent 60%);
  background-attachment: fixed;
}

::selection { background: var(--accent-soft); color: var(--fg-0); }

/* -------------------------------------------------------------------------
   3. VFX LAYERS — site-wide overlays
   These produce the "HUD" feel: film grain, scanlines, vignette.
   Driven by the body[data-hud="on"|"off"] attribute.
   ----------------------------------------------------------------------- */
.vfx-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9000;
  transition: opacity var(--d-med) var(--ease-out);
}
body[data-hud="off"] .vfx-layer { opacity: 0 !important; }

/* Procedural grain via inline SVG turbulence — no asset needed. */
.vfx-grain {
  opacity: 0.10;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.6' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 200px 200px;
  animation: grainShift 4s steps(8) infinite;
}
@keyframes grainShift {
  0%   { transform: translate(0, 0); }
  10%  { transform: translate(-5%, -3%); }
  25%  { transform: translate(3%, 7%); }
  40%  { transform: translate(-7%, 4%); }
  55%  { transform: translate(6%, -6%); }
  70%  { transform: translate(-3%, 5%); }
  85%  { transform: translate(4%, 1%); }
  100% { transform: translate(0, 0); }
}

/* Horizontal scanlines, very low contrast. */
.vfx-scan {
  opacity: 0.18;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    rgba(255,255,255,0.025) 3px,
    transparent 4px
  );
}

/* Edge vignette to focus attention. */
.vfx-vignette {
  opacity: 0.55;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.6) 100%);
}

/* -------------------------------------------------------------------------
   4. DIAGNOSTIC HUD CORNERS
   Live read-outs in the four corners of the viewport.
   ----------------------------------------------------------------------- */
.hud-diagnostics {
  position: fixed; inset: 0;
  z-index: 9100;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  color: var(--fg-2);
  transition: opacity var(--d-med) var(--ease-out);
}
body[data-hud="off"] .hud-diagnostics { opacity: 0; }

.hud-corner {
  position: absolute;
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 18px;
}
.hud-corner--tl { top: 64px;  left: 0; }
.hud-corner--tr { top: 64px;  right: 0; align-items: flex-end; text-align: right; }
.hud-corner--bl { bottom: 0;  left: 0; }
.hud-corner--br { bottom: 0;  right: 0; align-items: flex-end; text-align: right; }

.hud-ticker {
  position: relative;
  padding-left: 10px;
  white-space: nowrap;
}
.hud-corner--tr .hud-ticker,
.hud-corner--br .hud-ticker {
  padding-left: 0;
  padding-right: 10px;
}
.hud-ticker::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 4px; height: 4px;
  background: var(--accent);
  transform: translateY(-50%);
  box-shadow: 0 0 6px var(--accent-glow);
}
.hud-corner--tr .hud-ticker::before,
.hud-corner--br .hud-ticker::before {
  left: auto; right: 0;
}

/* Cursor-tracking crosshair */
.hud-crosshair {
  position: fixed;
  top: 0; left: 0;
  width: 0; height: 0;
  z-index: 9200;
  pointer-events: none;
  transition: opacity var(--d-med) var(--ease-out);
}
body[data-hud="off"] .hud-crosshair { opacity: 0; }
.hud-crosshair__h, .hud-crosshair__v {
  position: absolute;
  background: var(--accent);
  opacity: 0.25;
}
.hud-crosshair__h { left: -50vw; top: 0; width: 100vw; height: 1px; }
.hud-crosshair__v { left: 0; top: -50vh; width: 1px; height: 100vh; }
.hud-crosshair__tag {
  position: absolute;
  left: 12px; top: 12px;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--accent);
  letter-spacing: 0.06em;
  padding: 2px 6px;
  background: rgba(94,106,210,0.10);
  border: 1px solid rgba(94,106,210,0.3);
  white-space: nowrap;
}

/* -------------------------------------------------------------------------
   5. TOP BAR
   Brand-left · category-center · actions-right.
   ----------------------------------------------------------------------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(8,9,10,0.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-4) var(--gutter);
  min-height: 64px;
}

/* Scroll progress bar — purple, hairline */
.topbar__progress {
  position: absolute;
  bottom: -1px; left: 0;
  height: 1px;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, transparent, var(--accent));
  box-shadow: 0 0 6px var(--accent-glow);
  transition: width 60ms linear;
}

/* Brand */
.brand {
  display: flex; align-items: center; gap: var(--s-3);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.brand__mark {
  width: 24px; height: 24px;
  color: var(--accent);
  display: inline-flex;
}
.brand__name {
  font-family: var(--font-display);
  font-size: var(--t-md);
  letter-spacing: 0.18em;
}
.brand__suffix {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--fg-2);
  letter-spacing: 0.08em;
}

/* "indexed" connector text — narrative bridge from the reference */
.topbar__connector {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  color: var(--fg-1);
  letter-spacing: 0.02em;
}

/* Category selector */
.topbar__category {
  position: relative;
  justify-self: center;
}
.category-btn {
  display: inline-flex; align-items: baseline; gap: var(--s-2);
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  background: var(--bg-1);
  font-family: var(--font-display);
  transition: background var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out);
}
.category-btn:hover { background: var(--bg-2); border-color: var(--accent); }
.category-btn__index {
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  color: var(--fg-2);
}
.category-btn__label {
  font-size: var(--t-md);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.category-btn__chev {
  color: var(--accent);
  font-size: 10px;
  transition: transform var(--d-fast) var(--ease-out);
}
.category-btn[aria-expanded="true"] .category-btn__chev { transform: rotate(180deg); }

.category-menu {
  position: absolute;
  top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%) translateY(-4px);
  min-width: 220px;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  opacity: 0; pointer-events: none;
  transition: opacity var(--d-fast) var(--ease-out), transform var(--d-fast) var(--ease-out);
}
.category-menu[data-open="true"] {
  opacity: 1; pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.category-menu li {
  padding: 10px 14px;
  font-family: var(--font-display);
  font-size: var(--t-md);
  color: var(--fg-1);
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out);
}
.category-menu li:hover { background: var(--accent-soft); color: var(--fg-0); }

/* Actions */
.topbar__actions {
  display: flex; align-items: center; gap: var(--s-3);
  justify-self: end;
}

.hud-toggle, .menu-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--fg-1);
  border: 1px solid var(--line-strong);
  background: var(--bg-1);
  transition: all var(--d-fast) var(--ease-out);
}
.hud-toggle:hover, .menu-btn:hover {
  border-color: var(--accent);
  color: var(--fg-0);
}
.hud-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.hud-toggle__icon { width: 16px; height: 16px; }

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line-strong);
}
.view-toggle button {
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--fg-2);
  background: transparent;
  transition: all var(--d-fast) var(--ease-out);
}
.view-toggle button + button { border-left: 1px solid var(--line-strong); }
.view-toggle button[aria-selected="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.menu-btn__bars { display: inline-flex; flex-direction: column; gap: 2px; }
.menu-btn__bars i {
  width: 14px; height: 1px;
  background: currentColor;
}

/* -------------------------------------------------------------------------
   6. INDEX HERO
   Clean editorial intro — replaces a noisy hero image.
   ----------------------------------------------------------------------- */
.index-hero {
  padding: calc(var(--s-9) + 64px) var(--gutter) var(--s-8);
  display: grid;
  grid-template-columns: 3fr 3fr;
  gap: var(--s-7);
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.18em;
  color: var(--fg-2);
  text-transform: uppercase;
}
.index-hero__title {
  margin: var(--s-5) 0 0;
  font-family: var(--font-display);
  font-size: clamp(36px, 6.5vw, 88px);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.035em;
  color: var(--fg-0);
}
.index-hero__title em {
  font-style: normal;
  font-weight: 500;
  color: var(--accent);
  font-feature-settings: "ss01";
}
.index-hero__meta { align-self: end; }
.index-hero__meta dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5) var(--s-4);
  margin: 0;
}
.index-hero__meta dt {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.16em;
  color: var(--fg-2);
  margin-bottom: 4px;
}
.index-hero__meta dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--t-xl);
  font-weight: 200;
  color: var(--fg-0);
  letter-spacing: -0.01em;
}

/* -------------------------------------------------------------------------
   7. LIBRARY — ROW LIST
   The signature interaction. Long horizontal divider rows.
   Each row carries a small preview swatch on its own, and
   expands on click into a fuller preview + detail panel.
   ----------------------------------------------------------------------- */
.library {
  padding: 0 var(--gutter) var(--s-9);
}

.library__header {
  display: grid;
  grid-template-columns: 80px 1fr 200px 80px;
  gap: var(--s-5);
  align-items: center;
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.16em;
  color: var(--fg-2);
}

.row {
  position: relative;
  display: block;
  border-bottom: 1px solid var(--line);

  /* Reveal-on-scroll initial state — JS adds .row--in to animate. */
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity var(--d-slow) var(--ease-out),
    transform var(--d-slow) var(--ease-out);
}
.row--in { opacity: 1; transform: translateY(0); }

.row__main {
  display: grid;
  grid-template-columns: 80px 1fr 200px 80px;
  gap: var(--s-5);
  align-items: center;
  min-height: var(--row-height);
  padding: var(--s-5) 0;
  cursor: pointer;
  position: relative;
  transition: padding var(--d-med) var(--ease-out);
}

/* ID column — generated from data-id */
.row__main::before {
  content: attr(data-id, "");
  display: block;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--fg-2);
  grid-column: 1;
}
.row[data-id]::before { content: ""; }
.row .row__main::before { content: attr(data-id-display); }
/* fallback for browsers that don't render attr() in content cleanly */
.row[data-id]::before { content: ""; }

/* Use JS to inject the data-id into a span instead to avoid attr() quirks */
.row__id {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--fg-2);
  grid-column: 1;
}

.row__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 2.6vw, 34px);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--fg-0);
  grid-column: 2;
  transition: color var(--d-med) var(--ease-out);
}

/* Per-row preview swatch — small, sits in row, becomes the source
   for the bottom-right "follower" thumbnail. */
.row__preview {
  position: absolute;
  width: 250px; height: 250px;
  top: 50%; right: 320px;
  transform: translateY(-50%);
  border: 1px solid var(--line-strong);
  background: var(--bg-1);
  color: var(--fg-1);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;                /* hidden in list — the follower shows it instead */
  pointer-events: none;
}
.row__preview svg { width: 100%; height: 100%; }

/* Meta cluster */
.row__meta {
  display: contents;
}
.row__kind {
  grid-column: 3;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-size: var(--t-sm);
  color: var(--fg-1);
}
.row__kind .dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 0;
  box-shadow: 0 0 6px var(--accent-glow);
}
.row__dur {
  grid-column: 4;
  font-family: var(--font-mono);
  font-size: var(--t-sm);
  color: var(--fg-2);
  text-align: right;
}

/* Hover state — single-source-of-color: title goes white, accent dot pulses */
.row:hover .row__title {
  color: #fff;
  letter-spacing: -0.027em;
}
.row__main::after {
  content: "";
  position: absolute;
  left: -16px; right: -16px; top: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, var(--accent-soft), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--d-med) var(--ease-out);
  z-index: -1;
}
.row:hover .row__main::after { opacity: 1; }

/* Active row marker — sliver on the left */
.row.is-active .row__title { color: var(--accent); }
.row.is-active .row__main::before {
  content: "";
  position: absolute;
  left: -8px; top: 50%; height: 24px; width: 2px;
  background: var(--accent);
  transform: translateY(-50%);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Expanded state — slides open. The reference video showed a
   side-by-side image + body when a row was opened. */
.row__expand {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--s-7);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    max-height var(--d-slow) var(--ease-in-out),
    opacity var(--d-med) var(--ease-out),
    padding var(--d-slow) var(--ease-in-out);
}
.row.is-open .row__expand {
  max-height: 720px;
  opacity: 1;
  padding: var(--s-6) 0 var(--s-7);
}
.row__expand-vis {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  overflow: hidden;
}
.placeholder {
  position: absolute; inset: 0;
}
.placeholder__tag {
  position: absolute;
  left: 12px; bottom: 12px;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--fg-2);
  padding: 4px 8px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--line);
}
.row__expand-doc p {
  margin: 0 0 var(--s-4);
  font-size: var(--t-lg);
  color: var(--fg-1);
  line-height: 1.6;
  max-width: 56ch;
}
.row__expand-doc code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 2px 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--accent);
}
/* --- CTA: download spec link ---
   The CTA is now a real download. Three visual parts:
   .cta__label (main verb) / .cta__meta (file info) / .cta__icon (download glyph).
   On click, JS adds .is-downloading for a brief flash to confirm the action. */
.cta {
  display: inline-grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: var(--s-4);
  row-gap: 2px;
  padding: 12px 16px;
  margin-top: var(--s-3);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-display);
  text-decoration: none;
  transition: all var(--d-fast) var(--ease-out);
  position: relative;
  overflow: hidden;
}
.cta__label {
  grid-column: 1;
  grid-row: 1;
  font-size: var(--t-md);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.cta__meta {
  grid-column: 1;
  grid-row: 2;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--fg-2);
  transition: color var(--d-fast) var(--ease-out);
}
.cta__icon {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-family: var(--font-mono);
  font-size: 22px;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  /* The icon block telegraphs "click to receive a file" — distinct from a → */
  transition: transform var(--d-med) var(--ease-out), background var(--d-fast) var(--ease-out);
}
.cta:hover {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 24px var(--accent-glow);
}
.cta:hover .cta__meta { color: rgba(255,255,255,0.7); }
.cta:hover .cta__icon { transform: translateY(2px); background: rgba(255,255,255,0.12); }

/* Active/downloading flash — JS sets .is-downloading for ~900ms after click.
   The icon slides off, a "STREAMING…" caption fills in, then we revert. */
.cta.is-downloading {
  background: var(--accent);
  color: #fff;
  animation: ctaPulse 900ms var(--ease-out);
}
.cta.is-downloading .cta__icon {
  transform: translateY(20px);
  opacity: 0;
}
.cta.is-downloading .cta__label::after {
  content: " ↳ streaming…";
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  margin-left: 6px;
  color: rgba(255,255,255,0.85);
}
@keyframes ctaPulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  100% { box-shadow: 0 0 0 24px transparent; }
}


/* ------ Placeholder visualizations (no external assets) -------------- */
.placeholder--reticle  { background: radial-gradient(circle, var(--bg-3), var(--bg-1)); }
.placeholder--telemetry{ background: linear-gradient(180deg, var(--bg-2), var(--bg-1));}
.placeholder--brackets { background:
  repeating-linear-gradient(45deg, var(--bg-2), var(--bg-2) 6px, var(--bg-1) 6px, var(--bg-1) 12px);}
.placeholder--gauge    { background: radial-gradient(circle at 50% 60%, var(--bg-3), var(--bg-1)); }
.placeholder--glitch   { background:
  linear-gradient(90deg, var(--bg-1), var(--bg-2), var(--bg-1)); }
.placeholder--boot     { background: var(--bg-1); }
.placeholder--compass  { background: radial-gradient(circle, var(--bg-3), var(--bg-1)); }
.placeholder--spectro  { background: linear-gradient(0deg, var(--bg-2), var(--bg-1)); }

/* Each placeholder gets a label injected via data-spec */
.placeholder::after {
  content: attr(data-spec);
  position: absolute;
  top: 12px; left: 12px;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--accent);
  padding: 2px 6px;
  background: rgba(94,106,210,0.10);
  border: 1px solid rgba(94,106,210,0.3);
}

/* Decorative animated diagnostic inside each open preview */
.placeholder::before {
  content: "";
  position: absolute;
  left: 8%; right: 8%;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: sweep 3.4s linear infinite;
  opacity: 0.5;
}
@keyframes sweep {
  0%   { transform: translateY(-160%); }
  100% { transform: translateY(160%); }
}

/* -------------------------------------------------------------------------
   8. GRID VIEW — alternate "asset index" layout
   ----------------------------------------------------------------------- */
.grid-view {
  padding: 0 var(--gutter) var(--s-9);
}
.grid-view__head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: var(--s-6) 0 var(--s-4);
  border-bottom: 1px solid var(--line);
}
.grid-view__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--t-2xl);
  letter-spacing: -0.02em;
}
.grid-view__count {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--fg-2);
  letter-spacing: 0.16em;
}
.grid-view__cells {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1px;
  background: var(--line);                /* gaps reveal as hairlines */
  margin-top: 1px;
  border: 1px solid var(--line);
}
.cell {
  position: relative;
  background: var(--bg-0);
  padding: var(--s-5);
  aspect-ratio: 1;
  display: flex; flex-direction: column; justify-content: space-between;
  cursor: pointer;
  overflow: hidden;
  transition: background var(--d-med) var(--ease-out);
}
.cell:hover { background: var(--bg-1); }
.cell:hover .cell__preview { transform: scale(1.04); color: var(--accent); }
.cell__id {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--fg-2);
}
.cell__preview {
  position: absolute;
  inset: 30% 20% 22% 20%;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-1);
  transition: transform var(--d-med) var(--ease-out), color var(--d-med) var(--ease-out);
}
.cell__preview svg { width: 100%; height: 100%; }
.cell__title {
  position: relative;
  z-index: 2;
  font-family: var(--font-display);
  font-size: var(--t-md);
  color: var(--fg-0);
  letter-spacing: -0.01em;
  line-height: 1.25;
  max-width: 90%;
}
.cell__kind {
  position: relative;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--fg-2);
  letter-spacing: 0.12em;
}

/* -------------------------------------------------------------------------
   9. FOLLOWER — scrolling thumbnail
   Moved from CENTER (in reference) to BOTTOM-RIGHT per the brief,
   and made a touch larger. Snaps to the row near viewport center.
   ----------------------------------------------------------------------- */
.follower {
  position: fixed;
  right: clamp(20px, 4vw, 56px);
  bottom: clamp(50px, 4vw, 56px);
  width: clamp(220px, 22vw, 300px);   /* slightly larger than the reference's center thumb */
  z-index: 50;
  pointer-events: none;
  transition: opacity var(--d-med) var(--ease-out), transform var(--d-med) var(--ease-out);
}
/* Hide follower when in grid mode or when no row is active */
.follower[data-hidden="true"] {
  opacity: 0;
  transform: translateY(20px) scale(0.96);
}

.follower__frame {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  overflow: hidden;
}


.follower__corner--tl { top: -1px; left: -1px;  border-right: 0; border-bottom: 0; }
.follower__corner--tr { top: -1px; right: -1px; border-left: 0;  border-bottom: 0; }
.follower__corner--bl { bottom: -1px; left: -1px;  border-right: 0; border-top: 0; }
.follower__corner--br { bottom: -1px; right: -1px; border-left: 0;  border-top: 0; }

/* Stack of preview SVGs — only the active one is visible. */
.follower__stack {
  position: absolute; inset: 16px;
  display: grid;
  place-items: center;
  color: var(--fg-1);
}
.follower__stack > * {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transform: scale(0.94);
  transition:
    opacity var(--d-med) var(--ease-out),
    transform var(--d-med) var(--ease-out);
}
.follower__stack > .is-shown {
  opacity: 1;
  transform: scale(1);
}
.follower__stack svg { width: 100%; height: 100%; }

/* Read-out bar under the frame */
.follower__readout {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--fg-1);
  pointer-events: none;
}
.follower__id    { color: var(--accent); }
.follower__kind  { color: var(--fg-1); }

/* HUD off → strip the brackets */
body[data-hud="off"] .follower__corner { border-color: var(--line-strong); }
body[data-hud="off"] .follower__readout { background: rgba(0,0,0,0.4); }

/* -------------------------------------------------------------------------
   10. FOOTER
   ----------------------------------------------------------------------- */
.footer {
  padding: var(--s-9) var(--gutter) var(--s-6);
  border-top: 1px solid var(--line);
}
.footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--s-7);
}
.footer__grid ul li {
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-family: var(--font-display);
  color: var(--fg-1);
  transition: color var(--d-fast) var(--ease-out);
}
.footer__grid ul li:first-child { border-top: 0; }
.footer__grid ul li:hover { color: var(--accent); cursor: pointer; }
.footer__statement {
  margin: var(--s-4) 0 0;
  font-family: var(--font-display);
  font-size: var(--t-xl);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--fg-0);
  max-width: 24ch;
  line-height: 1.2;
}
.footer__time {
  margin: var(--s-4) 0 0;
  font-family: var(--font-mono);
  font-size: var(--t-2xl);
  color: var(--accent);
}
.footer__build {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--fg-2);
  letter-spacing: 0.16em;
}
.footer__rule {
  height: 1px;
  background: var(--line);
  margin: var(--s-7) 0 var(--s-4);
}
.footer__base {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.16em;
  color: var(--fg-2);
}

/* -------------------------------------------------------------------------
   11. RESPONSIVE
   Mobile-first overrides. We collapse the grid topbar, hide some
   diagnostic chrome, and reflow rows to a single column.
   ----------------------------------------------------------------------- */

/* MOBILE NOTE: Below ~860px the topbar drops the central category
   selector into a row below the brand. The bottom-right follower
   thumbnail shrinks but stays anchored. */
@media (max-width: 1100px) {
  .topbar__connector { display: none; }
  .index-hero {
    grid-template-columns: 1fr;
    gap: var(--s-6);
  }
  .row__preview { display: none; }
  .footer__grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .topbar__inner {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    row-gap: var(--s-3);
    padding-bottom: var(--s-3);
  }
  .topbar__connector { display: none; }
  .topbar__category {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
  }
  .topbar__actions { grid-column: 2; grid-row: 1; }

  /* Hide some chrome on mobile to reduce noise */
  .hud-corner--tl, .hud-corner--bl { display: none; }
  /* MOBILE NOTE: bottom-right diagnostic moves up out of the follower's path. */
  .hud-corner--br { bottom: auto; top: 110px; padding: 8px 12px; }
  .view-toggle { display: none; }
  .brand__suffix { display: none; }

  .library__header { grid-template-columns: 48px 1fr 48px; }
  .library__header span:nth-child(3) { display: none; }

  .row__main {
    grid-template-columns: 48px 1fr 48px;
    min-height: 96px;
    padding: var(--s-4) 0;
    gap: var(--s-3);
  }
  .row__title { font-size: clamp(18px, 5.2vw, 24px); }
  .row__id { font-size: 10px; }
  .row__dur { font-size: 10px; }
  .row__kind { display: none; }
  .row__expand { grid-template-columns: 1fr; gap: var(--s-4); }
  .row__expand-doc p { font-size: var(--t-md); }

  .index-hero { padding-top: 160px; }
  .index-hero__title { font-size: clamp(32px, 9vw, 56px); }

  .follower {
    width: 128px;
    right: 12px;
    bottom: 12px;
  }
  .follower__readout { padding: 6px 8px; font-size: 9px; }

  .footer__grid { grid-template-columns: 1fr; gap: var(--s-5); }
  .footer__base { flex-direction: column; gap: 6px; }
}

/* MOBILE NOTE: The crosshair is cursor-driven, which doesn't translate
   to touch — we hide it on coarse pointers to avoid a "stuck" overlay. */
@media (hover: none) and (pointer: coarse) {
  .hud-crosshair { display: none; }
  .row:hover .row__main::after { opacity: 0; }
}

/* Reduced motion — disable our heavier animations. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .vfx-grain { animation: none; }
}

/* --- ASSET VIDEO with HUD-styled sound toggle ---------------------------
   Sits inside .row__expand-vis (which is already aspect-ratio 16/9 + clipped).
   The video covers the frame; the toggle floats top-right, the existing
   placeholder__tag stays bottom-left. */
.asset-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg-1);
  /* Sit underneath the placeholder::after REF tag + scan line. */
  z-index: 0;
}

/* Hide the moving sweep line from .placeholder::before — it competes
   with the video. Comment out if you'd rather keep it for HUD vibe. */
.placeholder--spectro::before { display: none; }

/* Sound toggle button */
.asset-video__sound {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  color: var(--fg-1);
  background: rgba(8, 9, 10, 0.7);
  border: 1px solid var(--line-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition:
    color var(--d-fast) var(--ease-out),
    border-color var(--d-fast) var(--ease-out),
    background var(--d-fast) var(--ease-out);
}
.asset-video__sound:hover {
  color: var(--fg-0);
  border-color: var(--accent);
}
/* When sound is ON (aria-pressed="true") the button takes the accent
   treatment — mirrors the HUD toggle in the top bar. */
.asset-video__sound[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 12px var(--accent-glow);
}

.asset-video__icon {
  width: 14px;
  height: 14px;
}
/* Show one icon at a time based on aria-pressed. */
.asset-video__icon--on  { display: none; }
.asset-video__icon--off { display: block; }
.asset-video__sound[aria-pressed="true"] .asset-video__icon--off { display: none; }
.asset-video__sound[aria-pressed="true"] .asset-video__icon--on  { display: block; }

/* The label flips ON / OFF via the <em> data-attrs. */
.asset-video__label em {
  font-style: normal;
  color: inherit;
}
.asset-video__sound[aria-pressed="false"] .asset-video__label em::before {
  content: attr(data-off);
}
.asset-video__sound[aria-pressed="true"] .asset-video__label em::before {
  content: attr(data-on);
}
.asset-video__label em { font-size: 0; }      /* hide the literal text */
.asset-video__label em::before { font-size: var(--t-xs); }

/* Keep the REF tag and the tag chip readable on top of moving video. */
.placeholder--spectro .placeholder__tag,
.placeholder--spectro::after {
  z-index: 2;
}
