/* Throughlines — dark precision gallery. See DESIGN.md. */
:root {
  --bg: oklch(0.16 0.006 280);
  --surface: oklch(0.20 0.008 280);
  --surface-2: oklch(0.25 0.008 280);
  --line: oklch(0.34 0.006 280);
  --ink: oklch(0.94 0.005 90);
  --ink-dim: oklch(0.72 0.006 280);
  --accent: oklch(0.66 0.20 25);
  --accent-ink: oklch(0.20 0.02 25);
  --accent-dim: oklch(0.66 0.20 25 / 0.16);

  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --maxw: 1200px;
  --pad: clamp(1.25rem, 4vw, 4rem);
  --radius: 4px;

  --z-nav: 100;
  --z-backdrop: 200;
  --z-modal: 300;
  --z-toast: 400;
}

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  position: relative; /* containing block for the page-spanning throughline */
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.66;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; letter-spacing: -0.01em; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.02; letter-spacing: -0.03em; text-wrap: balance; }
h1 { font-size: clamp(2.6rem, 1.8rem + 4vw, 5.5rem); font-weight: 800; }
h2 { font-size: clamp(1.9rem, 1.4rem + 2vw, 3rem); }
p { text-wrap: pretty; }
a { color: inherit; text-decoration: none; }

.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .6rem 1rem; z-index: var(--z-toast); }
.skip:focus { left: 1rem; top: 1rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* ---------- throughline (the continuous scroll-drawn line, weaving behind sections) ---------- */
.throughline {
  position: absolute;
  inset: 100vh 0 0 0;
  width: 100%; height: calc(100% - 100vh);
  z-index: 0; opacity: 0.55; pointer-events: none;
}
.throughline path { stroke-dasharray: 1; stroke-dashoffset: 1; }
@media (max-width: 820px) { .throughline { display: none; } }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.9rem var(--pad);
  background: color-mix(in oklch, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in oklch, var(--line) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: .6rem; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.nav-links { display: flex; gap: 1.4rem; margin-left: auto; }
.nav-links a { color: var(--ink-dim); font-size: 0.94rem; transition: color .25s; }
.nav-links a:hover { color: var(--ink); }
@media (max-width: 720px) { .nav-links { display: none; } }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body); font-weight: 500; font-size: 0.95rem;
  padding: 0.7rem 1.25rem; border-radius: var(--radius); border: 1px solid transparent;
  cursor: pointer; transition: transform .25s cubic-bezier(.2,.7,.2,1), background .25s, border-color .25s, color .25s;
  display: inline-flex; align-items: center; gap: .5rem; line-height: 1; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-accent { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-accent:hover { background: oklch(0.72 0.2 25); }
.btn-accent:disabled { background: var(--surface-2); color: var(--ink-dim); cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink-dim); background: color-mix(in oklch, var(--surface) 50%, transparent); }
.btn-block { width: 100%; justify-content: center; padding-block: 0.9rem; }

/* ---------- layout primitives ---------- */
main { position: relative; z-index: 1; }
.section { max-width: var(--maxw); margin: 0 auto; padding: clamp(4rem, 8vw, 8rem) var(--pad); }
.section-head { max-width: 60ch; margin-bottom: clamp(2rem, 4vw, 3.5rem); }
.section-head p { color: var(--ink-dim); margin-top: 1rem; font-size: 1.075rem; }
.panel { background: linear-gradient(180deg, color-mix(in oklch, var(--surface) 50%, transparent), transparent); border-top: 1px solid color-mix(in oklch, var(--line) 50%, transparent); border-bottom: 1px solid color-mix(in oklch, var(--line) 50%, transparent); max-width: none; }
.panel > * { max-width: var(--maxw); margin-inline: auto; }
.eyebrow { font-family: var(--font-mono); font-size: 0.8rem; color: var(--accent); letter-spacing: 0.02em; margin-bottom: 1.5rem; }

/* ---------- frame (the gallery unit) ---------- */
.frame {
  position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: #08080a;
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--bg) 50%, transparent), 0 20px 50px -30px rgba(0,0,0,.9);
}
.frame img { width: 100%; height: 100%; display: block; }
.frame svg { width: 100%; height: 100%; display: block; }
.frame [data-art] { width: 100%; height: 100%; }
.frame-glow::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); box-shadow: 0 0 80px -20px var(--accent-dim); pointer-events: none; }

/* ---------- living hero (a line continuously drawn on canvas) ---------- */
#live-hero { width: 100%; height: 100%; display: block; background: #0b2545; }

/* ---------- hero ---------- */
.hero {
  max-width: var(--maxw); margin: 0 auto;
  padding: clamp(3rem, 7vw, 6rem) var(--pad) clamp(4rem, 8vw, 7rem);
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: clamp(2rem, 5vw, 5rem); align-items: center;
}
.hero-copy h1 { margin-bottom: 1.5rem; }
.lede { color: var(--ink-dim); font-size: 1.15rem; max-width: 46ch; }
.hero-actions { display: flex; gap: 0.75rem; margin: 2rem 0 2.5rem; flex-wrap: wrap; }
.readout { display: flex; gap: clamp(1.5rem, 4vw, 3rem); flex-wrap: wrap; padding-top: 1.75rem; border-top: 1px solid color-mix(in oklch, var(--line) 60%, transparent); }
.readout dt { font-size: 0.78rem; color: var(--ink-dim); margin-bottom: 0.35rem; text-transform: lowercase; letter-spacing: 0.01em; }
.readout dd { font-size: 1.35rem; font-weight: 500; }
.hero-piece figcaption { margin-top: 0.9rem; font-size: 0.8rem; color: var(--ink-dim); text-align: center; }
@media (max-width: 880px) { .hero { grid-template-columns: 1fr; } .hero-piece { max-width: 420px; order: -1; } }

/* ---------- lore ---------- */
.lore { max-width: 900px; margin: 0 auto; padding: clamp(3rem, 7vw, 6rem) var(--pad); text-align: center; }
.lore-lead { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.5rem, 1.1rem + 2vw, 2.4rem); line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
.lore-body { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; max-width: 720px; margin: 2.5rem auto 0; text-align: left; }
.lore-body p { color: var(--ink-dim); }
@media (max-width: 640px) { .lore-body { grid-template-columns: 1fr; } }

/* ---------- gallery ---------- */
.wall-status { display: inline-flex; align-items: center; gap: 0.5em; margin-top: 1rem; font-size: 0.78rem; color: var(--accent); border: 1px solid color-mix(in oklch, var(--accent) 35%, transparent); border-radius: 99px; padding: 0.3em 0.9em; }
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse-dot 2.2s ease-in-out infinite; flex: none; }
@keyframes pulse-dot { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: clamp(1rem, 2vw, 1.75rem); }
/* mobile: two columns so the wall stays a wall, not a 6,000px column of voids */
@media (max-width: 640px) { .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; } .tile-cap { font-size: 0.68rem; margin-top: 0.45rem; } }
.tile { background: none; border: 0; padding: 0; text-align: left; }
.tile .frame { transition: transform .4s cubic-bezier(.2,.7,.2,1), border-color .3s, box-shadow .4s; }
.tile:hover .frame { transform: translateY(-6px); border-color: var(--ink-dim); box-shadow: 0 30px 60px -30px rgba(0,0,0,.95), 0 0 70px -30px var(--accent-dim); }
.tile-cap { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.7rem; font-size: 0.78rem; color: var(--ink-dim); }
.tile-cap .gen { color: var(--accent); }

/* museum placard under each piece */
.placard { margin-top: 0.8rem; padding: 0.55rem 0.75rem; border-left: 2px solid var(--accent); background: color-mix(in oklch, var(--surface-2) 55%, transparent); }
.placard b { display: block; font-family: var(--font-mono); font-size: 0.78rem; font-weight: 500; color: var(--ink); }
.placard span { font-size: 0.7rem; color: var(--ink-dim); font-family: var(--font-mono); }

/* generation dividers — the wall reads as an evolution, gen 0 to max */
.gen-divider { grid-column: 1 / -1; display: flex; align-items: center; gap: 0.8rem; font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent); margin-top: 0.6rem; }
.gen-divider::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, color-mix(in oklch, var(--accent) 40%, transparent), transparent); }

/* draw-on-view: the primary line draws itself, then the on-chain pulse takes over */
.tile svg use:first-of-type { stroke-dasharray: 1000; stroke-dashoffset: 1000; }
.tile.drawn svg use:first-of-type { animation: drawline 2.4s cubic-bezier(.4, 0, .2, 1) forwards; }
.tile svg use:nth-of-type(2) { opacity: 0; transition: opacity 0.8s ease 2.1s; }
.tile.drawn svg use:nth-of-type(2) { opacity: 0.95; }
@keyframes drawline { to { stroke-dashoffset: 0; } }

/* ---------- cast ---------- */
.cast-grid { max-width: 640px; }
.cast-instrument { display: flex; flex-direction: column; gap: 1.5rem; }
.cast-minted { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 0.25rem; border-bottom: 1px solid color-mix(in oklch, var(--line) 60%, transparent); }
.cast-minted .mono { font-size: 1.1rem; }
.meter-head { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--ink-dim); margin-bottom: 0.6rem; }
.meter-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter-fill { height: 100%; width: 100%; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, var(--accent), oklch(0.74 0.18 35)); border-radius: 99px; transition: transform 1s cubic-bezier(.2,.7,.2,1); will-change: transform; }
.meter-note { font-size: 0.86rem; color: var(--ink-dim); margin-top: 0.8rem; max-width: 48ch; }
.chance { padding: 1.1rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in oklch, var(--surface) 40%, transparent); }
.chance-copy { color: var(--ink-dim); font-size: 0.95rem; margin: 0; }
.chance-copy strong { color: var(--ink); font-weight: 600; }
.field-label { font-size: 0.85rem; color: var(--ink-dim); }

/* ---------- the long line gate (one line, never lifted) ---------- */
.trace-gate { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem 0.9rem; background: color-mix(in oklch, var(--surface) 40%, transparent); }
.trace-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 0.75rem; }
.trace-sub { font-size: 0.7rem; color: var(--ink-dim); }
.line-stage { position: relative; height: clamp(220px, 32vh, 320px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
#line-canvas { display: block; width: 100%; height: 100%; }
.line-hud { position: absolute; top: 0.6rem; left: 0.75rem; right: 0.75rem; display: flex; justify-content: space-between; gap: 1rem; font-size: 0.7rem; color: var(--ink-dim); pointer-events: none; }
.line-hud b { color: var(--ink); font-weight: 600; }
.line-hud-earned b { color: var(--accent); }
.line-hint { position: absolute; inset: auto 0 0.7rem 0; text-align: center; font-size: 0.7rem; color: var(--ink-dim); pointer-events: none; }
.line-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.trace-status { font-size: 0.74rem; color: var(--ink-dim); margin-top: 0.6rem; min-height: 1.2em; }
.trace-gate.traced { border-color: color-mix(in oklch, var(--accent) 45%, transparent); }
.trace-gate.traced .trace-status { color: var(--accent); }
.trace-gate.traced .line-stage { cursor: default; }
.trace-skip { background: none; border: 0; color: var(--ink-dim); font-size: 0.68rem; text-decoration: underline dotted; cursor: pointer; padding: 0.35rem 0; margin-top: 0.1rem; }
.trace-skip:hover { color: var(--ink); }

/* ---------- quantity selector (1..earned per cast) ---------- */
.qty-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.85rem 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in oklch, var(--surface) 40%, transparent); }
.qty-ctl { display: inline-flex; align-items: center; gap: 0.7rem; }
.qty-btn { width: 30px; height: 30px; display: inline-grid; place-items: center; background: transparent; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); font-size: 1rem; line-height: 1; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.qty-btn:hover:not(:disabled) { border-color: var(--ink-dim); background: color-mix(in oklch, var(--surface) 60%, transparent); }
.qty-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.qty-val { min-width: 2ch; text-align: center; font-size: 1rem; }
.cast-summary { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in oklch, var(--surface) 40%, transparent); }
.cast-summary > div { display: flex; justify-content: space-between; font-size: 0.92rem; }
.cast-summary span:first-child { color: var(--ink-dim); }
.fineprint { font-size: 0.74rem; color: var(--ink-dim); text-align: center; }

/* ---------- weave ---------- */
.weave-proof { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: clamp(1rem, 3vw, 2.5rem); max-width: 760px; margin: 0 auto clamp(2.5rem, 5vw, 4rem); }
.weave-proof figcaption { text-align: center; margin-top: 0.8rem; font-size: 0.8rem; color: var(--ink-dim); }
.weave-op { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; color: var(--accent); }
.weave-op svg { width: 60px; }
.weave-op span { font-size: 0.72rem; }
.weave-instrument { max-width: 760px; margin: 0 auto; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.25rem, 3vw, 2rem); background: color-mix(in oklch, var(--surface) 40%, transparent); }
.weave-gate { color: var(--ink-dim); text-align: center; }
.weave-pick { display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: end; gap: 1rem; }
.weave-plus { color: var(--ink-dim); padding-bottom: 0.7rem; font-size: 1.2rem; }
.field { display: flex; flex-direction: column; gap: 0.45rem; }
.input { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); padding: 0.7rem 0.85rem; font-size: 1rem; }
.input:focus { border-color: var(--accent); outline: none; }
.weave-status, [data-weave-status] { margin-top: 1rem; text-align: center; min-height: 1.2em; }
@media (max-width: 640px) { .weave-proof { grid-template-columns: 1fr; } .weave-op { flex-direction: row; } .weave-op svg { transform: rotate(90deg); } .weave-pick { grid-template-columns: 1fr; } .weave-plus { display: none; } }

/* ---------- owned ---------- */
.owned .empty { color: var(--ink-dim); padding: 2rem 0; }

/* ---------- faq ---------- */
.faq { max-width: 760px; }
.faq details { border-top: 1px solid var(--line); padding: 1.25rem 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-weight: 400; font-size: 1.4rem; transition: transform .3s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { color: var(--ink-dim); margin-top: 0.9rem; max-width: 65ch; }
.faq code { background: var(--surface-2); padding: 0.1em 0.4em; border-radius: 3px; font-size: 0.85em; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); padding: clamp(3rem, 6vw, 5rem) var(--pad); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.footer-mark { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-display); font-weight: 700; }
.footer-mark svg { width: 26px; height: 26px; color: var(--accent); }
.footer-meta { font-size: 0.8rem; color: var(--ink-dim); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.35em; }
.prelaunch-pill { display: inline-flex; align-items: center; gap: 0.5em; color: var(--accent); border: 1px solid color-mix(in oklch, var(--accent) 35%, transparent); border-radius: 99px; padding: 0.25em 0.85em; }
.footer-fine { font-size: 0.78rem; color: var(--ink-dim); opacity: 0.7; }
.footer-os { color: var(--accent); font-size: 0.85rem; border: 1px solid color-mix(in oklch, var(--accent) 40%, transparent); padding: 0.5rem 1.1rem; border-radius: 99px; transition: background .25s, border-color .25s; }
.footer-os:hover { background: var(--accent-dim); border-color: var(--accent); }

/* ---------- modal ---------- */
.modal { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); padding: 0; max-width: min(880px, 92vw); width: 100%; }
.modal::backdrop { background: color-mix(in oklch, var(--bg) 75%, transparent); backdrop-filter: blur(6px); }
.modal-close { position: absolute; top: 0.75rem; right: 0.75rem; background: var(--surface-2); border: 0; color: var(--ink); width: 2.2rem; height: 2.2rem; border-radius: 99px; cursor: pointer; z-index: 1; }
.modal-body { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1.5rem; padding: 1.5rem; }
.modal-meta h3 { font-family: var(--font-mono); font-weight: 500; font-size: 1.1rem; margin-bottom: 1.25rem; }
.trait-list { display: grid; grid-template-columns: 1fr; gap: 0; }
.trait-list div { display: flex; justify-content: space-between; padding: 0.6rem 0; border-bottom: 1px solid color-mix(in oklch, var(--line) 60%, transparent); font-size: 0.9rem; }
.trait-list dt { color: var(--ink-dim); }
.trait-list dd { font-family: var(--font-mono); }
@media (max-width: 620px) { .modal-body { grid-template-columns: 1fr; } }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); z-index: var(--z-toast); background: var(--surface); border: 1px solid var(--line); color: var(--ink); padding: 0.85rem 1.3rem; border-radius: 99px; font-size: 0.9rem; box-shadow: 0 20px 50px -20px rgba(0,0,0,.8); max-width: 90vw; }
.toast[data-kind="error"] { border-color: var(--accent); }

/* ---------- motion defaults ---------- */
/* reveals only hide when JS is present (so no-JS / failed-load still shows everything) */
.js [data-reveal] { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); transition-delay: calc(min(var(--i, 0) * 0.04s, 0.32s)); }
[data-reveal].is-revealed { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1 !important; transform: none !important; transition: none; }
  .throughline path { stroke-dashoffset: 0 !important; }
  .meter-fill { transition: none; }
  .pulse-dot { animation: none; }
  .tile svg use:first-of-type { stroke-dasharray: none; stroke-dashoffset: 0; animation: none; }
  .tile svg use:nth-of-type(2) { opacity: 0.95; transition: none; }
}
