/* ============================================================================
 * Base layout — resets, stage, canvas/video layers, scene name, beat
 * indicator, idle hint. Everything that paints the underlying "screen" before
 * any UI chrome (controls, panel) is drawn on top.
 *
 * The :root block below is the single source of truth for the Vizzy visual
 * system. Every other CSS file references these tokens — change a hue or a
 * radius here and it propagates everywhere. Do not redefine these in other
 * files; extend the system by adding new tokens to this block.
 * ========================================================================== */

:root {
  /* Surface palette — neutral charcoal stack used for chrome, panels, controls.
     Kept in raw hex so backdrop-filter blurs render predictably across browsers. */
  --surface-0:  #000;
  --surface-1:  rgba(8, 8, 10, 0.65);    /* fixed header */
  --surface-2:  rgba(12, 12, 14, 0.92);  /* settings drawer */
  --surface-3:  rgba(255, 255, 255, 0.04);
  --surface-4:  rgba(255, 255, 255, 0.08);
  --surface-5:  rgba(255, 255, 255, 0.14);

  /* Foreground — keep ink mostly white; muted tiers are the only way text
     should ever fade. No bespoke "rgba(255,255,255,0.5)" sprinkles. */
  --ink:        #fff;
  --ink-2:      rgba(255, 255, 255, 0.85);
  --ink-3:      rgba(255, 255, 255, 0.62);
  --ink-4:      rgba(255, 255, 255, 0.42);
  --ink-5:      rgba(255, 255, 255, 0.22);

  --hairline:   rgba(255, 255, 255, 0.08);
  --hairline-2: rgba(255, 255, 255, 0.14);

  /* Accent — the Vizzy magenta. Used sparingly: progress fill, beat moments,
     active states, primary CTAs. Promoted from the legacy #ff3c78 literal so
     every "alive" signal across the app reads as one brand. */
  --accent:        #ff3c78;
  --accent-soft:   rgba(255, 60, 120, 0.18);
  --accent-glow:   rgba(255, 60, 120, 0.45);
  --accent-ink:    #fff;  /* text color on top of solid --accent */

  /* Status colors — only used for record / error / success states. */
  --record:        #ff3050;
  --record-glow:   rgba(255, 48, 80, 0.55);
  --ok:            #7affb6;
  --err:           #ff7a9c;

  /* Type stack. Body uses the Apple system stack (already installed everywhere);
     mono is used for tabular numerics and small uppercase eyebrows. */
  --font-body:    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  --font-mono:    ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  /* Spacing scale — keep multiples of 4 for grid rhythm. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  /* Radii — small for inline chips, medium for buttons/inputs, large for cards. */
  --radius-1: 4px;
  --radius-2: 6px;
  --radius-3: 8px;
  --radius-4: 10px;
  --radius-5: 12px;
  --radius-pill: 999px;

  /* Motion — shared easing so chrome transitions feel uniform. */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html, body {
  width: 100%; height: 100%;
  /* Phones: no double-tap zoom, no rubber-band page scroll; the page stays put. */
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--surface-0);
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  /* Crisper rendering for white-on-black UI chrome. */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

#stage    { position: fixed; inset: 0; }
#canvas   { position: absolute; inset: 0; width: 100%; height: 100%; }
#glCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; pointer-events: none; }
#video    { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }

/* Scene name — a quiet uppercase eyebrow under the header that fires on every
   scene / filter change, so it stays small, dim and brief (1.2s, see
   showSceneName in core/helpers.js). Mono so it reads as metadata. Never
   part of exports. */
#sceneName {
  position: absolute;
  top: calc(var(--vizzy-header-height, 52px) + var(--space-3));
  left: var(--space-6);
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-4); opacity: 0;
  transition: opacity 0.35s ease;
  z-index: 10; pointer-events: none;
  font-weight: 600;
}
#sceneName.show { opacity: 0.8; }

/* Beat indicator — picks up the Vizzy accent so the pulse reads as the
   brand color rather than generic white. */
#beatIndicator {
  position: absolute;
  top: calc(var(--vizzy-header-height, 52px) + var(--space-5));
  right: var(--space-6);
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); opacity: 0.35;
  transition: opacity 0.05s, transform 0.05s, box-shadow 0.05s;
  z-index: 10;
}
#beatIndicator.beat {
  opacity: 1; transform: scale(1.7);
  box-shadow: 0 0 22px var(--accent-glow);
}

/* Stage status line (vizzyToast) — top-center under the header, above the
   stage but below the header + drawer, so status and errors are readable
   with or without the drawer open (on phones the sheet covers the bottom).
   Kinds: info (neutral), ok (green), err (red). */
#stageToast {
  position: absolute;
  top: calc(var(--vizzy-header-height, 52px) + var(--space-3));
  left: 50%;
  transform: translate(-50%, -6px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--hairline-2);
  color: var(--ink-2);
  font-size: 12px; font-weight: 600; line-height: 1.35;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  z-index: 35;
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}
#stageToast.show { opacity: 1; transform: translate(-50%, 0); }
#stageToast[data-kind="ok"]  { color: var(--ok); }
#stageToast[data-kind="err"] { color: var(--err); border-color: rgba(255, 122, 156, 0.4); }

/* Visually hidden but still clickable programmatically (file inputs). */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

#idleHint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  text-align: center; flex-direction: column; gap: var(--space-6);
  z-index: 4;
  pointer-events: none;
  /* A faint radial vignette behind the cover keeps the idle screen from
     looking like flat black — gives the wordmark something to sit on. */
  background: radial-gradient(ellipse at 50% 38%,
    rgba(255, 60, 120, 0.06) 0%,
    rgba(255, 60, 120, 0.02) 28%,
    transparent 60%);
}
#idleHint h1 {
  font-family: var(--font-display);
  font-size: clamp(48px, 10vw, 128px); font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.95;
  /* Pure-white wordmark with a soft accent shadow — feels intentional,
     not like a default gradient text trick. */
  color: var(--ink);
  text-shadow: 0 6px 40px rgba(255, 60, 120, 0.22);
}
#idleHint p { font-size: 15px; color: var(--ink-4); }

/* In-place audio loader on the idle screen.
   Parent #idleHint has pointer-events:none so it doesn't eat clicks on the
   visualizer once a track is playing — restore them on this element. */
#idleHint .idle-load {
  pointer-events: auto;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-5) var(--space-7);
  border: 1px dashed var(--ink-5);
  border-radius: var(--radius-5);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.2s var(--ease-out),
              background 0.2s var(--ease-out),
              transform 0.15s var(--ease-out),
              box-shadow 0.2s var(--ease-out);
}
#idleHint .idle-load:hover,
#idleHint .idle-load.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
  box-shadow: 0 8px 32px rgba(255, 60, 120, 0.2);
}
#idleHint .idle-load-main {
  font-size: 15px; font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0;
}
#idleHint .idle-load-sub {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--ink-4);
  letter-spacing: 0.18em; text-transform: uppercase;
}

/* Phone tuning — make the idle screen feel like a native app onboard
   rather than a desktop hero. Tighter drop target with safe-area padding
   so it doesn't slide under the unified header. */
@media (max-width: 767px) {
  /* The beat dot is desktop-only garnish; on a phone it's just clutter. */
  #beatIndicator { display: none; }
  #idleHint {
    padding: calc(var(--vizzy-header-height, 52px) + 16px) 20px
             calc(96px + env(safe-area-inset-bottom)) 20px;
    gap: 20px;
    justify-content: center;
  }
  #idleHint h1 {
    font-size: clamp(36px, 12vw, 64px);
  }
  #idleHint .idle-load {
    width: 100%;
    max-width: 320px;
    padding: 20px;
  }
  #idleHint .idle-load-main {
    font-size: 15px;
  }
}
#idleHint .idle-load input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Phones: iOS zooms into any text box under 16px when it's tapped. */
@media (pointer: coarse) {
  input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
  select,
  textarea { font-size: max(16px, 1em) !important; }
}
