/* ============================================================
   ChordCast — additive-display "Aurora Glass" design system
   Black remains transparent. Essential surfaces use luminous color rather
   than grayscale so they remain visible on the glasses.
   ============================================================ */
:root {
  /* page black stays transparent on the additive display */
  --bg: #000000;                /* page = transparent on the display */
  --surface: linear-gradient(135deg, rgba(34,159,194,0.34), rgba(105,75,204,0.30));
  --surface-2: linear-gradient(135deg, rgba(52,211,235,0.48), rgba(126,91,232,0.42));
  --surface-primary: linear-gradient(135deg, rgba(24,190,225,0.62), rgba(112,82,224,0.56));
  --line: rgba(138,229,255,0.52);
  --line-soft: rgba(167,139,250,0.34);
  --glass-highlight: rgba(235,252,255,0.52);
  --glass-shadow: rgba(53,205,238,0.22);

  /* colored light survives where grayscale would disappear */
  --ink: #F5F3EF;               /* primary text + marks */
  --ink-dim: #C9DCFF;           /* secondary */
  --ink-mute: #88BDD8;          /* muted / idle */

  /* warm amber identifies focus, the active chord, and the NOW marker */
  --accent: #FFD166;
  --accent-soft: rgba(255,209,102,0.24);
  --accent-glow: rgba(255,209,102,0.48);
  --cyan-glow: rgba(88,224,255,0.38);

  --danger: #FF8F7A;

  --r-sm: 8px; --r-md: 12px; --r-lg: 18px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  width: 600px; height: 600px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { width: 100%; height: 100%; position: relative; }

/* --- Screens --- */
.screen {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  position: absolute; top: 0; left: 0;
}
.screen.hidden { display: none; }

/* --- Header: quiet, no filled bar --- */
.header {
  display: flex; align-items: center;
  padding: 22px 26px 14px;
  gap: 14px; flex-shrink: 0;
}
.header h1 {
  font-size: 15px; font-weight: 600; flex: 1;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-dim); text-shadow: 0 0 12px rgba(122,207,255,0.2);
}
.header-meta { font-size: 12px; color: var(--ink-mute); letter-spacing: 0.06em; }
.back-btn {
  background: var(--surface); color: var(--ink);
  font-size: 20px; line-height: 1; padding: 8px 12px;
  border-radius: 13px; border: 1.5px solid var(--line);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 16px var(--glass-shadow);
  backdrop-filter: blur(12px) saturate(140%);
}

/* --- Content --- */
.content {
  flex: 1; padding: 8px 26px 20px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}

/* --- Focus (D-pad): a single amber ring, no fill flooding --- */
.focusable {
  transition: border-color 0.15s ease, box-shadow 0.2s ease,
              background 0.15s ease, color 0.15s ease;
  cursor: pointer;
}
.focusable:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55),
              0 0 0 3px var(--accent-soft), 0 0 22px var(--accent-glow);
}

/* --- Bottom nav: text actions, not filled buttons --- */
.nav-bar {
  display: flex; gap: 12px; padding: 16px 26px 24px;
  flex-shrink: 0;
}
.nav-item {
  flex: 1; padding: 15px 16px;
  background: var(--surface); border-radius: var(--r-md);
  color: var(--ink); font-size: 15px; font-weight: 600;
  text-align: center; letter-spacing: 0.02em;
  border-color: var(--line); backdrop-filter: blur(14px) saturate(145%);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 18px var(--glass-shadow);
}
.nav-item:focus { background: var(--surface-2); }
.nav-item.primary { color: #FFF7D6; background: var(--surface-primary); }

/* ==================== HOME (landing) ==================== */
.landing {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 36px; gap: 18px;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 22px; }
/* brand mark = six "strings" (vertical hairlines) with one lit amber — the
   subject's own vernacular (a fretboard), not a generic logo */
.brand-mark {
  width: 102px; height: 72px; position: relative;
  background:
    repeating-linear-gradient(to right,
      var(--ink) 0, var(--ink) 1.5px,
      transparent 1.5px, transparent 19.5px);
  opacity: 0.78;
  -webkit-mask-image: linear-gradient(to bottom, #000, #000);
}
.brand-mark::after {   /* one string lit amber */
  content: ''; position: absolute; top: 0; bottom: 0; left: 58.5px;
  width: 2px; background: var(--accent); box-shadow: 0 0 12px var(--accent-glow);
}
.brand-name {
  font-size: 46px; font-weight: 800; letter-spacing: -0.025em; color: var(--ink);
  line-height: 1;
}
.brand-accent { color: var(--accent); }
.landing-sub {
  font-size: 17px; color: var(--ink-dim); line-height: 1.5; max-width: 34ch;
  margin-top: 2px; text-shadow: 0 0 12px rgba(108,199,255,0.18);
}
.landing-actions {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 14px; margin-top: 22px; max-width: 520px;
}
.cta {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 17px 30px; border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  font-size: 17px; font-weight: 650; border: 1.5px solid var(--line);
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 18px var(--glass-shadow);
  backdrop-filter: blur(14px) saturate(145%);
}
/* Standard inline-SVG icon — one size everywhere so icons stay legible on the
   glasses display. Stroke follows the button's text color. */
.icon {
  width: 22px; height: 22px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.cta.primary .icon { stroke: var(--accent); }
.cta:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface-2); }
.cta.primary { color: #FFF7D6; background: var(--surface-primary); }

/* ==================== SEARCH ==================== */
.search-body { flex: 1; display: flex; flex-direction: column; padding: 4px 26px 20px; gap: 16px; overflow: hidden; }

/* query = a LABEL readout, not a text box: baseline underline + caret */
.query {
  display: flex; align-items: baseline; gap: 1px;
  font-size: 30px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--ink); min-height: 40px;
  border-bottom: 2px solid var(--line); padding: 4px 8px 10px;
  background: linear-gradient(90deg, rgba(42,184,218,0.16), rgba(115,82,211,0.08), transparent);
  white-space: nowrap; overflow: hidden;
}
/* white-space: pre keeps a trailing space visible (the space key would
   otherwise appear to do nothing until the next letter arrives) */
.query-text { overflow: hidden; text-overflow: ellipsis; white-space: pre; }
/* empty query = empty space (no placeholder text) */
.caret {
  display: inline-block; width: 2px; height: 0.9em;
  background: var(--accent); margin-left: 2px;
  animation: blink 1.1s step-start infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* rail label ("Recent songs") shown above the rail when the query is empty */
.rail-label {
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-mute); margin: -4px 0 -6px 2px;
}

/* results — HORIZONTAL row of landscape cards, scroll left/right */
.results-rail {
  display: flex; gap: 14px; overflow-x: auto; overflow-y: hidden;
  padding: 2px 2px 8px; min-height: 210px; flex-shrink: 0;
  scroll-snap-type: x mandatory;
  -webkit-mask-image: linear-gradient(to right, #000 92%, transparent 100%);
          mask-image: linear-gradient(to right, #000 92%, transparent 100%);
}
.results-rail::-webkit-scrollbar { display: none; }
.result-card {
  flex: 0 0 220px; scroll-snap-align: start;
  display: flex; flex-direction: column; gap: 0;
  padding: 0; overflow: hidden; background: var(--surface); border-radius: var(--r-lg);
  border: 1.5px solid var(--line); text-align: left;
  color: var(--ink); font: inherit; appearance: none;
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 20px var(--glass-shadow);
  backdrop-filter: blur(14px) saturate(145%);
}
.result-card:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface-2); }
.result-thumb {
  width: 100%; height: 132px; border-radius: 0; flex-shrink: 0;
  background-image: var(--thumb-image),
    linear-gradient(135deg, rgba(48,214,238,0.82), rgba(126,86,224,0.78));
  background-position: center; background-size: cover; background-repeat: no-repeat;
  background-blend-mode: screen, normal;
  border: 0;
  box-shadow: inset 0 -1px 0 rgba(181,239,255,0.52);
}
.result-title { color: var(--ink); font-size: 16px; font-weight: 600; line-height: 1.3;
  padding: 14px 18px 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result-channel { font-size: 13px; color: var(--ink-mute); padding: 8px 18px 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results-empty { color: var(--ink-mute); font-size: 14px; padding: 70px 2px; align-self: center; }

/* keyboard — phone-style QWERTY, subtle boxes, focus lights amber */
.keyboard { display: flex; flex-direction: column; gap: 7px; margin-top: auto; flex-shrink: 0; }
.kb-row { display: flex; gap: 6px; justify-content: center; }
.kb-spacer { min-width: 0; }          /* invisible half-key filler for the stagger */
.kb-key {
  flex: 1; min-width: 0; height: 46px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border-radius: 9px;
  color: var(--ink); font-size: 18px; font-weight: 600;
  border: 1.5px solid var(--line-soft);
  box-shadow: inset 0 1px 0 rgba(235,252,255,0.28), 0 0 10px rgba(72,204,239,0.12);
  backdrop-filter: blur(10px) saturate(140%);
}
.kb-key:focus {
  outline: none; color: var(--ink);
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface-2);
}
/* action row: delete · space (wide) · clear · search — icon keys equal width */
.kb-actions { gap: 8px; margin-top: 2px; }
.kb-actions .kb-key { font-size: 13px; letter-spacing: 0.06em; color: var(--ink-dim); }
.kb-key.space { flex: 4; }
.kb-key.action { color: var(--accent); }

/* --- Loading --- */
.loading-container { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 32px; flex: 1; margin: 18px 8px 28px; border: 1.5px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 26px var(--glass-shadow); backdrop-filter: blur(16px) saturate(145%); }
.loading-spinner {
  width: 42px; height: 42px; border: 3px solid rgba(103,216,245,0.28);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 17px; color: var(--ink); font-weight: 600; text-align: center; max-width: 34ch; }
.progress-bar { width: 200px; height: 5px; background: rgba(83,191,224,0.28); border: 1px solid rgba(149,229,255,0.45); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
.hint { color: var(--ink-dim); font-size: 13px; letter-spacing: 0.03em; }

/* --- Error --- */
.error-container { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 32px; text-align: center; flex: 1; margin: 18px 8px 28px; border: 1.5px solid rgba(255,143,122,0.62); border-radius: 24px; background: linear-gradient(135deg, rgba(225,91,119,0.28), rgba(106,76,207,0.32)); box-shadow: inset 0 1px 0 rgba(255,231,226,0.48), 0 0 26px rgba(255,112,126,0.18); backdrop-filter: blur(16px) saturate(145%); }
.error-icon { font-size: 34px; color: var(--danger); }
.error-message { font-size: 15px; color: var(--ink-dim); max-width: 40ch; line-height: 1.5; }
.error-container .nav-item { flex: none; min-width: 250px; padding: 15px 24px; }

/* ==================== TUNER (real fretboard) ==================== */
.tuner-content { padding: 4px 26px 14px; gap: 12px; overflow: hidden; align-items: center; }
.tuner-hint {
  font-size: 14px; color: var(--ink-dim); line-height: 1.4;
  text-align: center; max-width: 46ch;
  text-shadow: 0 0 12px rgba(108,199,255,0.18);
}

/* the guitar = headstock (left) joined to a fretboard (the 6 strings). Laid out
   horizontally so strings run left→right like a guitar on your lap. */
.guitar {
  flex: 1; width: 100%; display: flex; align-items: stretch;
  min-height: 0;
}
/* headstock: the wood block the tuning pegs sit in */
.headstock {
  width: 46px; flex-shrink: 0; border-radius: 16px 6px 6px 16px;
  background: linear-gradient(135deg, rgba(52,211,235,0.34), rgba(126,91,232,0.30));
  border: 1.5px solid var(--line); border-right: none;
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 18px var(--glass-shadow);
  backdrop-filter: blur(12px) saturate(140%);
}
/* fretboard: dark neck with faint fret lines, holds the string rows */
.fretboard {
  flex: 1; display: flex; flex-direction: column;
  border-radius: 6px 14px 14px 6px;
  border: 1.5px solid var(--line); border-left: none;
  background:
    repeating-linear-gradient(to right,
      transparent 0, transparent 78px,
      rgba(143,234,255,0.12) 78px, rgba(143,234,255,0.12) 79px),
    linear-gradient(135deg, rgba(34,159,194,0.22), rgba(105,75,204,0.20));
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 18px var(--glass-shadow);
  backdrop-filter: blur(12px) saturate(140%);
  overflow: hidden;
}

/* a single string row: peg (over the headstock) + the wire (the vibrating line)
   + the note letter at the far end. --gauge (1..6) thickens the low strings. */
.gstring {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; gap: 0;
  background: transparent; border: none; border-radius: 0;
  color: var(--ink); text-align: left; width: 100%; padding: 0;
  border-bottom: 1px solid rgba(143,234,255,0.14);
}
.gstring:last-child { border-bottom: none; }
.gstring:focus { outline: none; background: rgba(255,209,102,0.10); }
.gstring:focus .wire-line { background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }

/* tuning peg — a knob sitting on the headstock, aligned to this string */
.peg {
  position: absolute; left: -35px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(235,252,255,0.9), rgba(120,200,235,0.5));
  border: 1.5px solid var(--line);
  box-shadow: 0 0 8px rgba(72,204,239,0.3);
}

/* the wire = the actual string. A horizontal line, thickness scales with gauge. */
.wire {
  flex: 1; height: 100%; position: relative; display: flex; align-items: center;
  padding-left: 6px;
}
.wire-line {
  display: block; width: 100%;
  height: calc(1px + (6 - var(--gauge)) * 0.5px);   /* low E thickest → high E thinnest */
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(214,244,255,0.9), rgba(143,234,255,0.6));
  box-shadow: 0 0 4px rgba(143,234,255,0.35);
  transform-origin: center;
}
/* the note letter cap at the sound-hole end */
.gstring-note {
  width: 40px; flex-shrink: 0; text-align: center;
  font-size: 22px; font-weight: 800; color: var(--ink-dim); line-height: 1;
}

/* the currently-held string: amber wire + lit note + steady shimmer */
.gstring.playing { background: rgba(255,209,102,0.12); }
.gstring.playing .gstring-note { color: var(--accent); text-shadow: 0 0 16px var(--accent-glow); }
.gstring.playing .peg { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }
.gstring.playing .wire-line {
  background: linear-gradient(90deg, #FFF3CE, var(--accent));
  box-shadow: 0 0 12px var(--accent-glow);
}
/* one-shot pluck vibration on each strike (class toggled from JS) */
.wire-line.struck { animation: pluck 0.6s ease-out; }
@keyframes pluck {
  0%   { transform: scaleY(4.5); }
  18%  { transform: scaleY(3.2); }
  40%  { transform: scaleY(2.0); }
  70%  { transform: scaleY(1.3); }
  100% { transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
  .wire-line.struck { animation: none; }
}

/* --- Toast --- */
.toast {
  position: fixed; top: 18px; left: 50%;
  transform: translateX(-50%) translateY(-140px);
  background: var(--surface-2); color: var(--ink);
  padding: 11px 22px; border-radius: 22px; font-size: 13px;
  border: 1px solid var(--line); transition: transform 0.3s ease;
  box-shadow: inset 0 1px 0 var(--glass-highlight), 0 0 22px var(--cyan-glow);
  backdrop-filter: blur(16px) saturate(150%);
  z-index: 100; pointer-events: none; max-width: 536px;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--accent); }

/* ==================== PLAYER ==================== */
.player-content { padding: 0; gap: 8px; overflow: hidden; align-items: center; }
.player-hero {
  width: 100%; min-height: 238px; padding: 0 38px;
  display: flex; align-items: center; justify-content: center; gap: 44px;
  flex-shrink: 0;
}

/* now-playing: spinning vinyl record + hairline progress */
.nowplaying { display: flex; flex-direction: column; align-items: center; gap: 12px; flex-shrink: 0; }
.vinyl { width: 152px; height: 152px; }
.vinyl-disc {
  width: 100%; height: 100%; border-radius: 50%; position: relative;
  /* luminous grooves: dark-only records disappear on additive displays */
  background:
    repeating-radial-gradient(circle at 50% 50%,
      rgba(132,231,255,0.72) 0, rgba(132,231,255,0.72) 1px,
      rgba(115,79,205,0.30) 1px, rgba(115,79,205,0.30) 4px),
    radial-gradient(circle, rgba(35,184,215,0.34), rgba(101,72,190,0.38));
  box-shadow: inset 0 0 18px rgba(118,235,255,0.22), 0 0 24px var(--cyan-glow);
  display: flex; align-items: center; justify-content: center;
}
/* the record label = the song thumbnail, as a circle in the disc center */
.vinyl-label {
  width: 84px; height: 84px; border-radius: 50%;
  background-image: var(--cover-image),
    linear-gradient(135deg, rgba(48,214,238,0.88), rgba(126,86,224,0.84));
  background-position: center; background-size: cover; background-repeat: no-repeat;
  background-blend-mode: screen, normal;
  box-shadow: 0 0 0 4px rgba(255,209,102,0.78), 0 0 18px var(--accent-glow);
}
.vinyl-hole {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px rgba(255,248,220,0.72);
}
/* spin only while playing (stops when paused) */
.vinyl.spinning .vinyl-disc { animation: spin 3.2s linear infinite; }
@media (prefers-reduced-motion: reduce) { .vinyl.spinning .vinyl-disc { animation: none; } }

.np-progress { width: 174px; height: 5px; background: rgba(83,191,224,0.28); border: 1px solid rgba(149,229,255,0.45); border-radius: 3px; overflow: hidden; }
.np-fill { height: 100%; width: 0; background: var(--accent); }

/* chord fingering diagram */
.chord-current { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
#chord-diagram { width: 205px; height: 233px; }

/* ---- horizontal chord timeline ---- */
.timeline {
  position: relative; width: 100%; height: 112px; flex-shrink: 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 12%, #000 88%, transparent 100%);
}
.timeline-lane { position: absolute; top: 0; left: 0; height: 100%; will-change: transform; }

.now-marker {
  position: absolute; top: 5px; height: 72px; left: 50%;
  width: 2px; margin-left: -1px;
  background: var(--accent); box-shadow: 0 0 14px var(--accent-glow);
  border-radius: 2px; z-index: 5;
}
.now-label {
  position: absolute; top: 86px; left: 50%; transform: translateX(-50%);
  font-size: 9px; letter-spacing: 0.28em; font-weight: 700;
  color: var(--accent); z-index: 5;
}

.tl-chip {
  position: absolute; top: 5px; height: 72px;
  display: flex; align-items: center; justify-content: center; padding: 0 8px;
  background: linear-gradient(180deg, rgba(47,224,197,0.20), rgba(40,145,207,0.08));
  border: 0; border-top: 2px solid rgba(108,244,224,0.72);
  border-bottom: 2px solid rgba(108,244,224,0.48); border-radius: 0;
  box-sizing: border-box; color: var(--ink-dim); overflow: hidden;
  box-shadow: inset 3px 0 0 rgba(108,244,224,0.62), 0 0 12px rgba(61,226,205,0.12);
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease,
              box-shadow 0.12s ease, opacity 0.12s ease;
}
.tl-chip::after {
  content: ''; position: absolute; right: 0; top: 14px; bottom: 14px; width: 1px;
  background: rgba(137,255,237,0.48);
}
.tl-chip-label {
  color: #D9FFF8; font-size: 20px; font-weight: 800; white-space: nowrap; line-height: 1;
  text-shadow: 0 0 10px rgba(103,245,226,0.40);
}
.tl-chip.active {
  background: linear-gradient(180deg, rgba(255,209,102,0.52), rgba(255,126,105,0.30));
  border-top-color: rgba(255,248,221,0.96); border-bottom-color: rgba(255,209,102,0.82);
  box-shadow: inset 4px 0 0 #FFF5D2, inset -1px 0 0 rgba(255,245,210,0.58),
              0 0 20px rgba(255,209,102,0.32);
}
.tl-chip.active::after { background: rgba(255,249,232,0.72); }
.tl-chip.active .tl-chip-label {
  color: #FFFFFF; font-size: 25px;
  text-shadow: 0 1px 2px rgba(87,43,139,0.9), 0 0 12px rgba(255,255,255,0.45);
}
.tl-chip.past {
  background: linear-gradient(180deg, rgba(111,96,207,0.24), rgba(55,134,194,0.10));
  border-top-color: rgba(142,170,239,0.42); border-bottom-color: rgba(142,170,239,0.24);
  box-shadow: inset 3px 0 0 rgba(142,170,239,0.34); opacity: 0.62;
}
.tl-chip.nochord .tl-chip-label { font-size: 14px; color: var(--ink-mute); }

/* --- Utility --- */
.hidden { display: none !important; }
