/* MetroNota — styles
   The current/next note colors are pastel shades set from JS as
   --note-color / --upcoming-color; the page background stays white. */

:root {
  --note-color: #e9ecf2;     /* pastel circle behind the current letter */
  --upcoming-color: #e9ecf2; /* pastel circle for the upcoming note */
  --accent: #5b6cf0;         /* fixed indigo UI accent */
  --accent-soft: #8b97ff;
  --panel: rgba(18, 20, 28, 0.88);
  --panel-solid: #14161e;
  --line: rgba(255, 255, 255, 0.16);
  --text: #f4f6fb;
  --muted: rgba(255, 255, 255, 0.6);
  --ink: #2a2d3a;            /* dark text on the white page */
  --ink-soft: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: #ffffff;
  overflow-x: hidden;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.1rem;
  background: var(--panel);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}
.brand span { color: var(--accent-soft); }

.stats {
  display: flex;
  gap: 1.25rem;
  margin-left: auto;
}
.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.stat-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat-val { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.ghost-btn {
  margin-left: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.ghost-btn:hover, .ghost-btn.active { background: rgba(255, 255, 255, 0.22); }

/* ---------- Stage ---------- */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 1rem;
  position: relative;
  overflow: hidden;
}

/* The vine grows behind the note; the stage's content is lifted above it. */
#vine {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
#vine.hidden { display: none; }
.beat-dots, .note-area, .mic-status { position: relative; z-index: 1; }

/* Intro prompt shown until the player enables the mic or starts a session. */
.intro-msg {
  position: absolute;
  top: 7%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  font-size: clamp(1rem, 2.6vmin, 1.45rem);
  font-weight: 600;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.35s ease;
}
.intro-msg strong { color: var(--accent); }
.intro-msg.hidden { opacity: 0; }

.vine-svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* Each vine segment "draws" itself in via stroke-dashoffset. */
.vine-seg {
  stroke: #3f7d34;
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: vineDraw 0.6s ease forwards;
}
@keyframes vineDraw { to { stroke-dashoffset: 0; } }

/* Leaves and flowers pop in (and flowers re-pop on each bloom stage). */
.leaf-grow, .flower-stage { transform-box: fill-box; }
.leaf-grow {
  transform: scale(0);
  transform-origin: 50% 100%;
  animation: vineScaleIn 0.5s ease forwards;
}
@keyframes vineScaleIn { to { transform: scale(1); } }
.flower-stage {
  transform-origin: 50% 72%;
  animation: bloomPop 0.5s ease;
}
@keyframes bloomPop {
  0%   { transform: scale(0.5); }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.vine-flower, .vine-leaf { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.12)); }

.beat-dots { display: flex; gap: 0.7rem; }
.beat-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.18);
  transition: transform 0.08s, background 0.08s, box-shadow 0.08s;
}
.beat-dot.on {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.35);
  box-shadow: 0 0 14px rgba(91, 108, 240, 0.55);
}

/* Current note + upcoming preview, stacked */
/* Now + Next sit side by side, each the same size. */
.note-area {
  --circle: clamp(150px, 30vmin, 320px);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(1rem, 5vw, 3.5rem);
}
.note-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}
.block-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--ink-soft);
}

/* The colored circle behind the letter — this is what changes color */
.note-circle {
  position: relative;
  width: var(--circle);
  height: var(--circle);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--note-color);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.14), inset 0 -10px 26px rgba(0, 0, 0, 0.06);
  transition: background 0.24s ease;
}
.next-circle { background: var(--upcoming-color); }

/* The note — white fill, thick black outline so it reads on any pastel */
.note-text {
  font-size: clamp(3.6rem, 16vmin, 10rem);
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  -webkit-text-stroke: 6px #000;
  paint-order: stroke fill;
  letter-spacing: 0.02em;
  user-select: none;
  transition: color 0.12s ease, -webkit-text-stroke-color 0.12s ease;
}
.note-text.correct { color: #38ff85; -webkit-text-stroke-color: #04361b; }
.note-text.wrong   { color: #ff5a5a; -webkit-text-stroke-color: #3a0606; }

/* ±ms timing readout, sitting below the Next circle. Its space is always
   reserved (fixed height) so showing/hiding it never shifts the layout. */
.timing {
  box-sizing: border-box;
  height: clamp(1.9rem, 5.2vmin, 2.5rem);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.7rem;
  white-space: nowrap;
  font-size: clamp(1rem, 3.4vmin, 1.6rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.timing.show { opacity: 1; transform: scale(1); }
.timing.tight { color: #1c8f4e; border-color: rgba(28, 143, 78, 0.4); }

.mic-status {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--panel);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
}

/* ---------- Fretboard ---------- */
.fretboard-wrap {
  padding: 0.6rem 1rem 0.2rem;
  overflow-x: auto;
}
.fb-bar {
  display: flex;
  justify-content: flex-end;
  max-width: 1100px;
  margin: 0 auto 0.45rem;
}
.fb-toggle {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.fb-toggle:hover { background: rgba(0, 0, 0, 0.12); }
.fretboard-wrap.fb-hidden #fretboard { display: none; }
.fb {
  min-width: 640px;
  max-width: 1100px;
  margin: 0 auto;
  background: linear-gradient(#3a2417, #271810);
  border: 2px solid #1a0f08;
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}
.fb-row { display: flex; align-items: center; height: 34px; }
.fb-row.fb-disabled { opacity: 0.28; }

.fb-label {
  width: 54px;
  flex: 0 0 54px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #e8d8c4;
}
.fb-sub { display: block; font-size: 0.55rem; color: #a98e72; letter-spacing: 0.05em; }

.fb-fret {
  position: relative;
  flex: 1 1 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 2px solid rgba(180, 180, 190, 0.45); /* fret wire */
}
.fb-fret::before { /* the string */
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  background: rgba(220, 220, 230, 0.55);
}
.fb-open {
  flex: 0 0 30px;
  border-right: 5px solid #d9c9b3; /* the nut */
}
.fb-open::before { left: 50%; }

.fb-dot {
  position: relative;
  z-index: 2;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 800; color: #1b1b1b;
  transform: scale(0);
  transition: transform 0.12s ease;
}
.fb-fret.active .fb-dot {
  transform: scale(1);
  background: var(--note-color);
  border: 2px solid rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.35);
}

.fb-numbers { display: flex; margin-top: 4px; }
.fb-num {
  flex: 1 1 0;
  text-align: center;
  font-size: 0.7rem;
  color: #b59a7d;
}
.fb-num-open { flex: 0 0 30px; } /* under the nut/open column, like .fb-open */
.fb-num.fb-inlay { color: #f0e2cf; font-weight: 700; }
.fb-num.fb-inlay::after {
  content: "•";
  display: block;
  color: #d9c9b3;
  margin-top: -2px;
}
.fb-num.fb-inlay-double::after { content: "••"; letter-spacing: 2px; }

/* Fretless fingerboard (violin / cello / double bass / oud) — ebony board,
   no fret wires; faint dashed lines just hint at semitone positions. */
.fb-fretless { background: linear-gradient(#2b2622, #14110d); }
.fb-fretless .fb-fret { border-right: 1px dashed rgba(210, 210, 225, 0.14); }
.fb-fretless .fb-open { border-right: 4px solid #cabfae; }
.fb-fretless .fb-num { color: #a9a2b0; }
.fb-fretless .fb-num.fb-inlay { color: #e7e2ef; }
.fb-fretless .fb-num.fb-inlay::after { color: #b9b2c4; }

/* Sitar — warm long neck with curved brass frets. */
.fb-sitar { background: linear-gradient(#7a5326, #4f3416); }
.fb-sitar .fb-fret { border-right: 3px solid #d8b15a; }
.fb-sitar .fb-open { border-right: 5px solid #e7d4a6; }
.fb-sitar .fb-fret::before { background: rgba(245, 235, 210, 0.6); }
.fb-sitar .fb-num { color: #e8cf9c; }

/* Double-course instruments (mandolin / bouzouki / oud): two parallel string
   lines per course, but a single note dot is shown across both. */
.fb-doubled .fb-fret::before { top: calc(50% - 2.5px); }
.fb-doubled .fb-fret::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: calc(50% + 2.5px);
  height: 2px;
  background: rgba(220, 220, 230, 0.55);
}
.fb-doubled .fb-open::before,
.fb-doubled .fb-open::after { left: 50%; }

/* ---------- Transport ---------- */
.transport {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  padding: 0.8rem 1rem 1.1rem;
}
.primary-btn {
  min-width: 150px;
  padding: 0.85rem 1.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
  transition: transform 0.1s, background 0.15s, color 0.15s;
}
.primary-btn:hover { transform: translateY(-1px); }
.primary-btn:active { transform: translateY(1px); }
.primary-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Settings drawer ---------- */
.panel {
  position: fixed;
  top: 0; right: 0;
  height: 100%;
  width: min(360px, 88vw);
  background: var(--panel-solid);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  padding: 1.2rem 1.3rem;
  overflow-y: auto;
  transform: translateX(105%);
  transition: transform 0.25s ease;
  z-index: 20;
}
.panel.open { transform: translateX(0); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.panel-head h2 { margin: 0; font-size: 1.3rem; }
.close-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s;
}
.close-btn:hover { background: rgba(255, 255, 255, 0.22); }

.field { margin-bottom: 1.3rem; }
.field > label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field strong { color: var(--text); }
.sub-note { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; }

input[type="range"] { width: 100%; accent-color: var(--accent); }

/* Per-string tuning: compact note dropdowns, one per string */
.tuning-grid { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tuning-string {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.tuning-string span {
  font-size: 0.62rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tuning-string select {
  width: 56px;
  padding: 0.3rem 0.2rem;
  text-align: center;
  font-weight: 700;
}
select {
  width: 100%;
  padding: 0.6rem;
  border-radius: 8px;
  background: #1f2230;
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 0.95rem;
}

.chip-grid { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 0.45rem 0.6rem;
  border-radius: 9px;
  background: #1f2230;
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent-soft);
  color: #fff;
}

/* Sharp/Flat switch */
.toggle-field { display: flex; align-items: center; gap: 0.7rem; }
.toggle-end { font-size: 0.95rem; color: var(--muted); }
.switch { position: relative; display: inline-block; width: 52px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: #3a3f52;
  border-radius: 999px;
  transition: 0.2s;
}
.slider::before {
  content: "";
  position: absolute;
  height: 22px; width: 22px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(24px); }

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

@media (max-width: 560px) {
  .stats { gap: 0.8rem; }
  .brand { font-size: 1rem; }
  .ghost-btn { padding: 0.45rem 0.6rem; font-size: 0.8rem; }
}
