/* aura. — embedded visualizer control surface.
   Ported from the attune source: the full-viewport takeover is scoped to the
   .aura container, attune's :root vars are namespaced --au-* (so --text etc.
   don't shadow the site tokens), and whites become brand coral. The stage
   itself stays near-black — the additive WebGL is content, like a video.

   Signal colors still encode frequency region everywhere they appear:
   amber = lows, rose = mids, cyan = highs. These are functional (mirrored as
   JS constants in ui/scope.js), not brand, so they are kept as raw values. */

.aura {
  /* namespaced so attune's props can't shadow the site tokens inside here */
  --au-panel: rgba(12, 13, 16, 0.84);
  --au-line: rgba(255, 255, 255, 0.09);
  --au-text: #cac5bc;
  --au-dim: #6f6b64;
  --au-faint: #3d3b37;
  --au-low: #ffb454;
  --au-mid: #ff5c8a;
  --au-high: #6ee7ff;
  --au-white: #f2efe9;

  position: relative;
  /* The site navbar is position:fixed and its real (logo-driven) height is
     taller than the --navbar-h token, so main.js measures it live into
     --au-nav-h; the token is only the pre-JS fallback. */
  height: calc(100vh - var(--au-nav-h, var(--navbar-h)));
  margin-top: var(--au-nav-h, var(--navbar-h));
  overflow: hidden;
  background: #060708;                 /* the stage is content: stays black */
  color: var(--au-text);
  font-family: var(--font-mono);       /* IBM Plex Mono, self-hosted */
}
.aura:fullscreen { height: 100vh; margin-top: 0; }
.aura * { margin: 0; padding: 0; box-sizing: border-box; }  /* reset, scoped */

.aura #stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- idle hint ---------- */

.aura #hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.6s ease;
  text-align: center;
}
.aura #hint.gone { opacity: 0; }
/* a dark, blurred scrim behind the hint content so the light text stays
   legible over the palette field; it fades out with the hint once audio
   starts. The alpha is sized against the *brightest* stage we ship, not an
   average one: ink is the default scene and its water is near-white, which
   at the original 0.62 composited to a mid grey and left the dim line at
   ~1.3:1 — invisible. Any new scene brighter than ink's water needs this
   re-checked. */
.aura .hint-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 40px;
  border-radius: var(--radius-lg);
  background: rgba(6, 7, 8, 0.85);
  border: 1px solid var(--au-line);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.aura .hint-mark {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: normal;
  text-transform: lowercase;
  color: var(--au-white);
  margin-bottom: 18px;
}
.aura .hint-mark span { color: var(--accent); }
.aura .hint-line { font-size: 12px; letter-spacing: 0.08em; color: var(--au-text); }
/* subordinate to the line above, but still readable: --au-dim is a rack
   colour, tuned for the opaque panel, and it does not survive out here on
   the stage even with the scrim above */
.aura .hint-line.dim { color: color-mix(in srgb, var(--au-text) 75%, var(--au-dim)); }

.aura kbd {
  border: 1px solid var(--au-line);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--au-white);
  background: rgba(255, 255, 255, 0.1);
}

/* ---------- rack ---------- */

.aura #rack {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: 304px;
  display: flex;
  flex-direction: column;
  background: var(--au-panel);
  border: 1px solid var(--au-line);
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;   /* the active .rack-panel scrolls; head/tabs/foot pin */
  transition: transform 0.35s var(--ease-dreamy), opacity 0.35s ease;
}
.aura #rack.hidden {
  transform: translateX(calc(100% + 20px));
  opacity: 0;
  pointer-events: none;
}

.aura #rack-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--au-line);
}

/* ---------- rack tabs ---------- */
/* engine (audio) vs generator (scene): pinned below the head, they switch the
   panel below without scrolling the head away. .rack-tab inherits the base
   .aura button look; only the active + spacing deltas live here. */
.aura .rack-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--au-line);
}
.aura .rack-tab { letter-spacing: 0.2em; padding: 8px 4px; }
.aura .rack-tab.is-active {
  color: var(--au-white);
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--coral-300);
}

/* only the active panel is in the DOM flow; it takes the remaining height and
   scrolls on its own (min-height:0 lets a flex child shrink below content) */
/* No scroll fade (#201): aura's rack is its own surface, on its own
   background, and the panel's edge is already drawn. */
.aura .rack-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--au-faint) transparent;
}
.aura .rack-panel[hidden] { display: none; }

/* input + global controls live outside the tab panels — pinned below the head,
   always visible whichever tab is active (the panels take the rest + scroll) */
.aura #sec-input, .aura #sec-global { flex: 0 0 auto; }
/* bpm readout + fullscreen toggle share the right end of the rack head */
.aura .rack-head-right { display: flex; align-items: center; gap: 10px; }
.aura .wordmark {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: normal;
  text-transform: lowercase;
  color: var(--au-white);
}
.aura .wordmark span { color: var(--accent); }
.aura .bpm {
  font-size: 12px;
  color: var(--au-text);
  font-variant-numeric: tabular-nums;
}
.aura .bpm em { font-style: normal; font-size: 9px; color: var(--au-dim); letter-spacing: 0.15em; }
.aura .bpm.locked { color: var(--au-white); }

.aura .sec { padding: 12px 16px; border-bottom: 1px solid var(--au-line); }
.aura .sec-label {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--au-dim);
  margin-bottom: 9px;
}

/* ---------- buttons ---------- */

.aura .btn-row { display: flex; gap: 6px; }
.aura .btn-row + .btn-row { margin-top: 8px; }
/* scene tabs wrap as the generator wave grows the lineup — flex-basis auto
   (the base button flex:1 is basis 0%) so rows break instead of crushing */
.aura #scene-tabs { flex-wrap: wrap; }
.aura #scene-tabs button { flex: 1 1 auto; }

.aura button {
  flex: 1;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--au-text);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--au-line);
  border-radius: 5px;
  padding: 7px 4px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.aura button:hover { background: rgba(255, 255, 255, 0.09); color: var(--au-white); }
.aura button:focus-visible { outline: 1px solid var(--coral-300); outline-offset: 1px; }
.aura button.active {
  color: #0b0c0e;
  background: var(--coral-300);
  border-color: var(--coral-300);
}
.aura button:disabled { opacity: 0.35; cursor: default; }

/* fullscreen toggle (added to the rack head in the A2 template) — a compact
   icon button, so it opts out of the buttons' flex:1 stretch */
.aura #btn-fs {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
}
.aura #btn-fs svg { display: block; }
.aura #btn-fs:hover { color: var(--coral-300); border-color: var(--coral-300); }

.aura .transport { align-items: center; }
.aura .transport #btn-play { flex: 0 0 72px; }
.aura .track-name {
  flex: 1;
  font-size: 10px;
  color: var(--au-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.04em;
}

.aura .vol-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--au-dim);
}
.aura .vol-row input { flex: 1; }
.aura .vol-row output {
  flex: 0 0 34px;
  text-align: right;
  font-size: 9px;
  color: var(--au-text);
  font-variant-numeric: tabular-nums;
}

/* reactivity + motion sit in the generator panel as macro rows (they are
   per-scene), with the same spacing as the macros they precede */
.aura #scene-globals { margin-top: 10px; }

/* ---------- scope ---------- */

.aura #scope {
  display: block;
  width: 100%;
  height: 132px;
  border: 1px solid var(--au-line);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.35);
}

/* ---------- signal rows ---------- */

.aura .sig-row { margin-bottom: 10px; }
.aura .sig-row:last-child { margin-bottom: 0; }

.aura .sig-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}
.aura .led {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--au-faint);
  transition: none;
}
.aura .sig-name {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--au-text);
}
.aura .sig-spacer { flex: 1; }
.aura .sig-val {
  font-size: 9px;
  color: var(--au-dim);
  font-variant-numeric: tabular-nums;
}

/* the signature control: the live meter lives inside the control block,
   directly under the sliders that shape it */
.aura .meter {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-top: 5px;
}
.aura .meter-fill {
  height: 100%;
  width: 100%;
  transform-origin: left;
  transform: scaleX(0);
}

.aura .slider-pair { display: flex; gap: 8px; }
.aura .slider-pair label {
  flex: 1;
  min-width: 0; /* flex items refuse to shrink below content otherwise */
  display: flex;
  flex-direction: column; /* name/value line above, full-width slider below */
  gap: 2px;
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--au-dim);
}
.aura .slider-pair input {
  min-width: 0;
  width: 100%; /* kill the ~129px intrinsic width of range inputs */
}

.aura .param-head {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.aura .param-head span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aura .param-val {
  margin-left: auto;
  font-size: 8px;
  letter-spacing: 0;
  color: var(--au-text);
  font-variant-numeric: tabular-nums;
}

/* ---------- range inputs ---------- */

.aura input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 14px;
  background: transparent;
  cursor: pointer;
}
.aura input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 1px;
}
.aura input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 9px;
  height: 9px;
  margin-top: -3.5px;
  border-radius: 2px;
  background: var(--au-text);
  border: none;
}
.aura input[type="range"]:hover::-webkit-slider-thumb { background: var(--coral-300); }
.aura input[type="range"]::-moz-range-track {
  height: 2px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 1px;
}
.aura input[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--au-text);
  border: none;
}
.aura input[type="range"]:hover::-moz-range-thumb { background: var(--coral-300); }
.aura input[type="range"]:focus-visible { outline: 1px solid var(--coral-300); outline-offset: 2px; }

/* ---------- scene macros ---------- */

/* 7px, matching the gap between macro rows: reactivity/motion and the scene's
   own macros are one group now, so the seam between the two hosts shouldn't
   show. (It can't be 0 — .macro-row:last-child drops its bottom margin, so
   this margin is the whole gap.) */
.aura #scene-macros { margin-top: 7px; }
.aura .macro-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}
.aura .macro-row:last-child { margin-bottom: 0; }
.aura .macro-row span {
  flex: 0 0 72px;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--au-dim);
}
/* min-width:0 is load-bearing: a range input has an intrinsic minimum width,
   and flex:1 alone will not shrink past it (min-width defaults to auto), so
   long-labelled rows silently overflowed the rack and clipped their readout */
.aura .macro-row input { flex: 1; min-width: 0; }
.aura .macro-val {
  flex: 0 0 30px;
  text-align: right;
  font-size: 9px;
  color: var(--au-text);
  font-variant-numeric: tabular-nums;
}

/* ---------- info dots + shared tooltip ---------- */

.aura .info-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  padding: 0;
  font-size: 8px;
  font-style: italic;
  line-height: 1;
  text-transform: none;
  letter-spacing: 0;
  color: var(--au-dim);
  background: transparent;
  border: 1px solid var(--au-faint);
  border-radius: 50%;
  cursor: help;
}
.aura .info-dot:hover { color: var(--au-white); border-color: var(--au-dim); background: transparent; }

/* The shared tooltip is appended to #aura-root (see ui/tooltip.js), so it
   stays scoped under .aura while still floating over the rack. */
.aura #tip {
  position: fixed;
  z-index: 40;
  max-width: 240px;
  padding: 7px 9px;
  background: rgba(18, 19, 23, 0.97);
  border: 1px solid var(--au-line);
  border-radius: 6px;
  color: var(--au-text);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.aura #tip.on { opacity: 1; }

/* ---------- backdrop picker ---------- */

.aura .bg-row { margin-top: 10px; }
.aura .bg-row input[type="color"] {
  flex: 1;
  height: 20px;
  padding: 0;
  border: 1px solid var(--au-line);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}
.aura .bg-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.aura .bg-row input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}
.aura .bg-row input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 2px;
}
.aura .bg-reset {
  flex: 0 0 24px;
  padding: 2px 0;
  font-size: 11px;
  line-height: 1;
}

/* ---------- palette swatches ---------- */

.aura .pal-row { margin-top: 10px; }
.aura .pal-btn {
  height: 20px;
  padding: 0;
  opacity: 0.45;
  border: 1px solid var(--au-line);
  border-radius: 4px;
}
.aura .pal-btn:hover { opacity: 0.8; }
.aura .pal-btn.active {
  opacity: 1;
  border-color: var(--coral-300);
}

/* auto-cycle rows: a toggle + interval. Two of them — the palette one below
   the swatches, the generator one directly under the scene tabs. */
.aura .cycle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.aura .cycle-toggle {
  flex: 0 0 auto;
  font-size: 9px;
  letter-spacing: 0.16em;
  padding: 5px 10px;
}
.aura .cycle-row input { flex: 1; min-width: 0; }  /* see .macro-row input */

/* ---------- generator panel grouping ---------- */

/* The panel reads as three groups, separated by air rather than rules:
     1. the lineup      — scene tabs + auto-switch
     2. the parameters  — reactivity, motion, the macros, any transport
     3. the colours     — backdrop, swatches, auto-cycle
   #scene-cycle closes the first (:not(:empty) so a single-generator build,
   where no auto-switch row is rendered, doesn't leave a floating gap), and
   .group-start opens the third on whichever colour row comes first. Declared
   after .bg-row / .pal-row so it wins the equal-specificity tie. */
.aura #scene-cycle:not(:empty) { margin-bottom: 40px; }
.aura .group-start { margin-top: 40px; }

/* ---------- transport (scene.player) ---------- */

/* ‹ readout › walk — a stepper for scenes with a discrete list to walk
   (cymatics' Chladni figures). Sits in the macro stack, so it inherits the
   72px label column and only styles what follows it. */
.aura .player-btn {
  flex: 0 0 22px;
  padding: 3px 0;
  font-size: 12px;
  line-height: 1;
}
.aura .player-val {
  flex: 0 0 30px;
  text-align: center;
  font-size: 9px;
  color: var(--au-text);
  font-variant-numeric: tabular-nums;
}
/* the walk button names its own state (hold · loop · morph), so it is sized
   for the longest of them — cycling it must not resize the row */
.aura .player-loop {
  flex: 0 0 auto;
  min-width: 62px;
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.16em;
  padding: 4px 9px;
}

/* ---------- footer ---------- */

.aura #rack-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--au-dim);
}

/* ---------- drop veil / errors ---------- */

.aura #drop-veil {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(6, 7, 8, 0.72);
  border: 1px dashed var(--coral-300);
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--au-white);
  pointer-events: none;
  z-index: 20;
}
.aura #drop-veil.on { display: flex; }

/* No scroll fade (#201): an error dump is read to the end, not skimmed. */
.aura #err {
  position: absolute;
  left: 14px;
  bottom: 14px;
  max-width: min(560px, calc(100vw - 28px));
  max-height: 40vh;
  overflow: auto;
  background: rgba(40, 8, 10, 0.92);
  border: 1px solid rgba(255, 90, 90, 0.4);
  border-radius: 8px;
  color: #ffb3b3;
  font-size: 11px;
  line-height: 1.5;
  padding: 10px 12px;
  white-space: pre-wrap;
  z-index: 30;
}

/* ---------- small screens ---------- */

@media (max-width: 720px) {
  .aura #rack {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 52vh;
  }
  .aura #rack.hidden { transform: translateY(calc(100% + 16px)); }
}

@media (prefers-reduced-motion: reduce) {
  .aura #rack, .aura #hint { transition: none; }
}
