/* ============================================================
   DOLMEN SOUNDS — FUNCTIONAL TERMINAL
   Design tokens + 1px industrial border system.
   Rules: 1px borders, no rounded edges, no gradients in chrome,
   #00FF41 accents only. See CLAUDE.md before changing tokens.
   ============================================================ */

:root {
  --bg:      #000000;
  --bg-deep: #020503;            /* near-black w/ green undertone (Nuada bridge) */
  --ink:     #ffffff;
  --term:    #00ff41;            /* terminal green — ACCENTS ONLY */
  --forest:  #0e2a20;            /* Nuada forest green — imagery/previews only, never chrome */
  --dim:     rgba(255,255,255,.55);
  --ghost:   rgba(255,255,255,.16);
  --line:    1px solid var(--ink);
  --line-dim:1px solid rgba(255,255,255,.35);

  /* Type roles. Display type is the SVG wordmark; these are functional stacks.
     No webfont requests in v0.x (weight + privacy). Upgrade path in CLAUDE.md. */
  --font-tech: "Arial Narrow", "Helvetica Neue", Haettenschweiler, "Franklin Gothic Medium", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Courier New", monospace;

  --track: 0.18em;               /* functional small-cap tracking */
}

* { margin: 0; padding: 0; box-sizing: border-box; border-radius: 0 !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-tech);
  overflow: hidden;               /* stages are fixed viewports; internal panes may scroll */
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

/* ---- stage roots ------------------------------------------------ */
.stage { position: absolute; inset: 0; background: var(--bg); }
.stage[data-leaving] { pointer-events: none; }

/* ---- functional text -------------------------------------------- */
.t-tech  { font-family: var(--font-tech); text-transform: uppercase; letter-spacing: var(--track); }
.t-mono  { font-family: var(--font-mono); }
.t-dim   { color: var(--dim); }
.t-ghost { color: var(--ghost); }
.t-term  { color: var(--term); }
.t-xs    { font-size: 10px; }
.t-sm    { font-size: 12px; }

/* ---- 1px furniture ---------------------------------------------- */
.box       { border: var(--line); background: var(--bg); }
.box-dim   { border: var(--line-dim); }

.btn {
  display: inline-block;
  border: var(--line);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-tech);
  text-transform: uppercase;
  letter-spacing: var(--track);
  font-size: 12px;
  padding: 10px 22px;
  cursor: pointer;
  user-select: none;
}
.btn:hover, .btn:focus-visible { background: var(--ink); color: var(--bg); outline: none; }
.btn:focus-visible { box-shadow: 0 0 0 1px var(--term); }
.btn--solid { background: var(--ink); color: var(--bg); }
.btn--solid:hover { background: var(--term); border-color: var(--term); color: var(--bg); }
.btn[disabled] { opacity: .3; pointer-events: none; }

input.field {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: var(--line);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 8px 2px;
}
input.field:focus { outline: none; border-bottom-color: var(--term); }
input.field::placeholder { color: var(--ghost); text-transform: uppercase; }

/* ---- scanline / grain overlays (imagery only) -------------------- */
.scanlines::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.22) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.flicker { animation: flick 7s steps(1) infinite; }
@keyframes flick {
  0%,93%,100% { opacity: 1; }
  94%        { opacity: .86; }
  95%        { opacity: 1; }
  97.5%      { opacity: .92; }
}

/* ---- INIT / BOOT -------------------------------------------------- */
.boot-center { position: absolute; inset: 0; display: grid; place-items: center; }
.boot-mark   { width: min(72vw, 620px); position: relative; }
.boot-foot   { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; transition: opacity .42s linear; }
.boot-canvas { position: absolute; pointer-events: none; }

/* Display fonts for the boot sign — the five faces in the SIGN_FONTS rotation.
   Self-hosted WOFF2 subsets (rule 5: no CDN); each is whitelisted in the predeploy
   font guard (scripts/predeploy-font-guard.mjs → ALLOW). The two Deadwax cuts stay
   in /fonts-source/ only (dropped from the rotation as illegible). LICENSING: these
   are interim non-commercial/demo faces, shipped by explicit decision — replace with
   cleared licensed subsets before wider distribution. boot.js stacks lead with these
   Dolmen* names and fall back to Copperplate → serif if a face fails to load. */
@font-face { font-family: 'DolmenSolipsistic'; src: url('../fonts/solipsistic.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'DolmenHeavytal';    src: url('../fonts/heavytal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'DolmenPickyside';   src: url('../fonts/pickyside.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'DolmenHostgard';    src: url('../fonts/hostgard.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'DolmenLodeh';       src: url('../fonts/lodeh.woff2') format('woff2'); font-display: swap; }

/* faint fracturing-light "DOLMEN" sign — JS cycles gothic/blackletter scripts.
   White only — the headphone qubit keeps the green budget. Flickering per rule 4. */
.boot-sign   {
  position: absolute; top: 23%; left: 0; right: 0; text-align: center;
  line-height: 1; white-space: nowrap;
  font-size: clamp(64px, 10.8vw, 136px); text-transform: uppercase; color: var(--ink);
  opacity: .1; user-select: none; pointer-events: none;
  text-shadow: 0 0 12px rgba(255,255,255,.5), 0 0 36px rgba(255,255,255,.14);
  filter: blur(1.6px);            /* out of focus — a sign far in the distance */
  animation: sign-haze 9s ease-in-out infinite;
}
.boot-sign::before, .boot-sign::after {
  content: attr(data-text); position: absolute; left: 0; top: 0; width: 100%;
  color: var(--ink); pointer-events: none;
}
.boot-sign::before { animation: sign-frac-a 1.6s steps(1) infinite; }
.boot-sign::after  { animation: sign-frac-b 2.0s steps(1) infinite; }
@keyframes sign-haze { 0%,100% { filter: blur(1.6px); } 50% { filter: blur(2.8px); } }
/* hard horizontal slice-tearing — several shears per cycle */
@keyframes sign-frac-a {
  0%,20%,28%,52%,58%,100% { opacity: 0; clip-path: inset(0 0 64% 0); transform: translate(0,0); }
  22% { opacity: .7;  clip-path: inset(0 0 70% 0);   transform: translate(-30px, -3px); }
  25% { opacity: .4;  clip-path: inset(10% 0 56% 0); transform: translate(22px, 2px); }
  54% { opacity: .6;  clip-path: inset(0 0 76% 0);   transform: translate(-16px, 0); }
  56% { opacity: .35; clip-path: inset(6% 0 62% 0);  transform: translate(34px, -2px); }
}
@keyframes sign-frac-b {
  0%,38%,48%,80%,88%,100% { opacity: 0; clip-path: inset(60% 0 0 0); transform: translate(0,0); }
  40% { opacity: .62; clip-path: inset(64% 0 0 0);   transform: translate(26px, 3px); }
  43% { opacity: .38; clip-path: inset(52% 0 10% 0); transform: translate(-24px, 0); }
  82% { opacity: .58; clip-path: inset(72% 0 0 0);   transform: translate(-32px, 2px); }
  85% { opacity: .32; clip-path: inset(66% 0 4% 0);  transform: translate(18px, 0); }
}

/* ---- GATE --------------------------------------------------------- */
.gate-bg     { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.gate-mark   { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -58%); width: min(78vw, 760px); }
.gate-cta    { position: absolute; bottom: 7vh; left: 50%; transform: translateX(-50%); }
.flash       { position: absolute; inset: 0; background: var(--ink); opacity: 0; pointer-events: none; }

/* ---- AUTH --------------------------------------------------------- */
.auth-dim  { position: absolute; inset: 0; background: rgba(0,0,0,.62); }
.auth-box  {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(86vw, 380px); border: var(--line); background: rgba(0,0,0,.85);
  padding: 22px 22px 26px;
}
.auth-head { display: flex; justify-content: space-between; border-bottom: var(--line); padding-bottom: 10px; margin-bottom: 22px; }
.auth-row  { margin-bottom: 20px; }
.auth-msg  { min-height: 14px; margin: 2px 0 14px; font-size: 10px; letter-spacing: .14em; }
.auth-box.deny { animation: deny .18s steps(2) 2; }
@keyframes deny { 50% { transform: translate(calc(-50% + 5px), -50%); } }

/* ---- DASHBOARD ----------------------------------------------------- */
.dash        { display: flex; flex-direction: column; height: 100%; background: var(--bg-deep); }
.dash-head   {
  position: relative; flex: 0 0 33vh; min-height: 180px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  border-bottom: var(--line);
  padding: clamp(20px, 4vh, 56px) clamp(24px, 6vw, 88px);
}
.dash-mark   { width: min(58vw, 560px, 96vh); }
.dash-sub    { width: min(24vw, 230px, 42vh); margin-top: clamp(8px, 1.4vh, 18px); }
.dash-meta   { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; }
.dash-grid   {
  flex: 1; display: grid; gap: clamp(16px, 2.4vw, 28px);
  padding: clamp(24px, 4vh, 56px) clamp(24px, 6vw, 88px);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-content: stretch; overflow-y: auto;
}
.card {
  position: relative; border: var(--line); background: var(--bg);
  display: flex; flex-direction: column; min-height: 220px; cursor: pointer;
}
.card:hover .card-label, .card:focus-visible .card-label { color: var(--term); }
.card:focus-visible { outline: 1px solid var(--term); outline-offset: -3px; }
.card-preview { flex: 1; position: relative; overflow: hidden; border-bottom: var(--line); background: var(--bg-deep); }
.card-preview canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.card-meta   { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px; }
.card-label  { font-size: 13px; letter-spacing: var(--track); }
.card-glyph  { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; opacity: .9; }
.card-idx    { font-size: 10px; color: var(--ghost); }


/* ---- OBSERVER TERMINAL --------------------------------------------- */
.term        { display: flex; flex-direction: column; height: 100%; background: var(--bg); }
.term-head   { display: flex; align-items: center; justify-content: space-between; border-bottom: var(--line); padding: 10px 88px 10px 16px; }
.term-grid   { flex: 1; display: grid; grid-template-columns: 1fr 1.35fr 1fr; min-height: 0; }
.term-col    { border-right: var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.term-col:last-child { border-right: 0; }
.term-col-head { border-bottom: var(--line); padding: 8px 12px; font-size: 11px; letter-spacing: var(--track); display: flex; justify-content: space-between; }
.term-col-body { flex: 1; position: relative; min-height: 0; padding: 14px; overflow-y: auto; }

.dropzone {
  border: var(--line); height: 42%; min-height: 150px; display: grid; place-items: center;
  text-align: center; font-size: 11px; letter-spacing: var(--track); color: var(--dim);
  cursor: pointer;
}
.dropzone.armed { border-color: var(--term); color: var(--term); }
.readout { margin-top: 14px; font-family: var(--font-mono); font-size: 10px; line-height: 1.9; color: var(--dim); word-break: break-all; }
.readout b { color: var(--ink); font-weight: normal; }

.obs-wrap  { position: absolute; inset: 0; }
.obs-wrap canvas { width: 100%; height: 100%; display: block; }
.hud { position: absolute; font-family: var(--font-mono); font-size: 9px; color: var(--ink); opacity: .34; pointer-events: none; white-space: pre; }
.hud.tl { top: 8px; left: 10px; } .hud.tr { top: 8px; right: 10px; text-align: right; }
.hud.bl { bottom: 8px; left: 10px; } .hud.br { bottom: 8px; right: 10px; text-align: right; }

.param      { margin-bottom: 26px; }
.param-head { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: var(--track); margin-bottom: 8px; }
.param-val  { font-family: var(--font-mono); color: var(--dim); }
.slider     { position: relative; height: 18px; border: var(--line); cursor: ew-resize; touch-action: none; }
.slider-fill{ position: absolute; top: 0; bottom: 0; left: 0; background: rgba(255,255,255,.14); }
.slider-needle { position: absolute; top: -4px; bottom: -4px; width: 1px; background: var(--ink); }
.slider:focus-visible { outline: 1px solid var(--term); outline-offset: 2px; }

.term-action { margin-top: 8px; width: 100%; padding: 14px 0; font-size: 13px; }
.term-note   { margin-top: 12px; font-family: var(--font-mono); font-size: 9px; color: var(--ghost); line-height: 1.8; }

/* ---- fixed chrome ---------------------------------------------------- */
.snd-toggle { position: fixed; top: 10px; right: 10px; z-index: 60; font-size: 9px; padding: 5px 9px; letter-spacing: .14em; }
.back-link  { background: none; border: 0; color: var(--dim); font-family: var(--font-tech); font-size: 10px; letter-spacing: var(--track); text-transform: uppercase; cursor: pointer; }
.back-link:hover { color: var(--term); }

/* ---- responsive: stack the 3-block grid, keep 1px logic --------------- */
@media (max-width: 860px) {
  html, body { overflow: auto; }
  .term-grid { grid-template-columns: 1fr; overflow-y: auto; }
  .term-col  { border-right: 0; border-bottom: var(--line); min-height: 340px; }
  .term-col:last-child { border-bottom: 0; }
  .dash-grid { grid-template-columns: 1fr; }
  }

@media (prefers-reduced-motion: reduce) {
  .flicker { animation: none; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* auth as a node gate — return path stays inside the box (rule 2) */
.auth-back { display: block; width: 100%; margin-top: 16px; text-align: center; }

/* THE CALL v2 — wider panel for brief/terms/entry */
.auth-box--wide { width: min(92vw, 560px); max-height: 84vh; overflow-y: auto; }

/* PROCESSOR — total silence: the SND toggle is hidden while mounted */
.stage-processor .snd-toggle { display: none; }

/* PROCESSOR — mode tiers (SUBJECT / OBSERVER / CREATOR). Active tier inverts
   (white on black) rather than using green — the green budget is spent on the
   live indicators, not chrome (rule 1). */
.mode-controls { margin-bottom: 22px; }
.mode-seg { display: flex; border: var(--line); margin-bottom: 18px; }
.seg-btn {
  flex: 1; background: transparent; color: var(--dim);
  border: 0; border-right: var(--line); padding: 9px 0;
  font-family: var(--font-tech); font-size: 10px; letter-spacing: var(--track);
  text-transform: uppercase; cursor: pointer;
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--ink); color: var(--bg); }
.mode-field { margin-bottom: 16px; }
.mode-field label { display: block; margin-bottom: 6px; }
.mode-controls select.mode-select {
  width: 100%; background: transparent; border: 0; border-bottom: var(--line);
  color: var(--ink); font-family: var(--font-mono); font-size: 12px;
  text-transform: uppercase; letter-spacing: .1em; padding: 7px 2px;
  appearance: none; cursor: pointer;
}
.mode-controls select.mode-select option { background: var(--bg); color: var(--ink); }
.locked-readout {
  border: var(--line-dim); padding: 10px 12px; margin-bottom: 8px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; color: var(--dim);
}
/* locked (not-selectable) CREATOR tab — visible, padlocked, in 1px language */
.seg-btn.locked { color: var(--ghost); cursor: not-allowed;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg-btn.locked:hover { color: var(--ghost); background: transparent; }
.seg-btn .lock { width: 9px; height: 9px; opacity: .8; flex: 0 0 auto; }
/* EXPORT FORMAT segment — same 1px segmented language as MODE, and its note
   carries the headphones-only warning + the Warp instruction inline (rule 4:
   tiny, translucent, no explanation beyond the fact). */
.fmt-seg { margin-bottom: 0; }
.fmt-note {
  margin-top: 8px; font-size: 9px; line-height: 1.9;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ghost);
}
/* DOLM3N FREQUENCY — a 1px checkbox (no native control) + a 1px mix slider.
   The real input is visually hidden but focusable, so keyboard + screen readers
   get a genuine checkbox and the box we draw follows its :checked state. */
.check-row { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.check-row input[type="checkbox"] {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.check-box {
  flex: 0 0 auto; width: 12px; height: 12px; border: var(--line);
  display: inline-block; position: relative;
}
/* Filled white, not green: the green budget in this view is spent on the
   visualiser's live indicator (constitution rule 1). Green appears only on the
   transient focus ring. */
.check-row input:checked + .check-box::after {
  content: ''; position: absolute; inset: 2px; background: var(--ink);
}
.check-row input:focus-visible + .check-box { outline: 1px solid var(--term); outline-offset: 2px; }
.check-label { font-size: 10px; letter-spacing: var(--track); text-transform: uppercase; color: var(--dim); }
.check-row input:checked ~ .check-label { color: var(--ink); }
.check-row:hover .check-label { color: var(--ink); }

.smithy-mix { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.smithy-mix label { margin: 0; flex: 0 0 auto; }
.smithy-mix .mix-slider { flex: 1; }
.smithy-mix span { flex: 0 0 34px; text-align: right; color: var(--dim); }
input[type="range"].mix-slider {
  appearance: none; -webkit-appearance: none; background: transparent;
  height: 12px; margin: 0; cursor: pointer;
}
input[type="range"].mix-slider::-webkit-slider-runnable-track {
  height: 1px; background: var(--ghost);
}
input[type="range"].mix-slider::-moz-range-track { height: 1px; background: var(--ghost); }
input[type="range"].mix-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 1px; height: 11px;
  background: var(--ink); margin-top: -5px; border: 0;
}
input[type="range"].mix-slider::-moz-range-thumb {
  width: 1px; height: 11px; background: var(--ink); border: 0;
}
input[type="range"].mix-slider:disabled { cursor: default; }
input[type="range"].mix-slider:focus-visible { outline: 1px solid var(--term); outline-offset: 3px; }
/* MONITOR on/off switch — ON is the inverted (solid) state */
.mon-switch.on { background: var(--ink); color: var(--bg); }
/* TEMPO source tag + the TAP / ÷2 / ×2 row */
/* compact BPM row: labelled input + TAP inline, ÷2/×2 small & secondary, source suffix */
.bpm-row { display: flex; align-items: center; gap: 8px; }
.bpm-row label { margin: 0; flex: 0 0 auto; }
input.field.bpm-input { width: 4ch; flex: 0 0 auto; text-align: center; padding: 6px 2px; -moz-appearance: textfield; }
input.field.bpm-input::-webkit-outer-spin-button,
input.field.bpm-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bpm-tap { flex: 0 0 auto; padding: 6px 12px; font-size: 10px; }
.bpm-oct { flex: 0 0 auto; padding: 6px 7px; font-size: 10px; color: var(--dim); }
.tempo-src { margin-left: auto; color: var(--dim); font-size: 10px; letter-spacing: .1em; }
/* WHIRL — a switch ON the visualiser panel (display only): the slow camera orbit.
   The canvas gets its own flex stage above it so the switch reads as a footer bar. */
.obs-body { display: flex; flex-direction: column; }
.obs-stage { position: relative; flex: 1 1 auto; min-height: 0; }
.view-switch { width: 100%; margin: 0; border: 0; border-top: var(--line);
  padding: 11px 0; font-size: 12px; flex: 0 0 auto; }
.view-switch.on { background: var(--ink); color: var(--bg); }
/* HALT SOUND / SOUND PARKED — audible on/off switch; ON is the inverted state */
.halt-switch.on { background: var(--ink); color: var(--bg); }
/* held-coordinates readout shown while HALT STATE is engaged */
.halt-readout { margin-top: 8px; }

/* THE DOLMEN — NODE 03 */
.tomb-wrap { position: absolute; inset: 0; display: grid; place-items: center; background: #000; }
.tomb-wrap canvas { image-rendering: pixelated; }
.tomb-head { position: absolute; top: 0; left: 0; right: 0; z-index: 3; }
.tomb-hud { position: absolute; z-index: 2; font-size: 10px; letter-spacing: .12em; color: rgba(255,255,255,.5); white-space: pre; pointer-events: none; }
.tomb-hud.tl { top: 56px; left: 14px; }
.tomb-hud.tr { top: 56px; right: 14px; text-align: right; }
.tomb-hud.bc { bottom: 9vh; left: 50%; transform: translateX(-50%); color: var(--term); font-size: 12px; letter-spacing: .18em; opacity: 0; transition: opacity .15s linear; text-align: center; }
/* The format line under a pickup prompt — subordinate to the gesture above it,
   but never so faint it can be missed: it is the headphones-only warning. */
.tomb-fmt { font-size: 10px; letter-spacing: .14em; opacity: .66; }
.tomb-hud.bl { bottom: 4vh; left: 14px; right: 14px; color: rgba(255,255,255,.55); opacity: 0; transition: opacity .6s linear; }
.tomb-intro { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(0,0,0,.55); }
