/* ═══════════════════════════════════════════════════════════════════════
   GuitarApp – style.css
   Dark theme with amber accent
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:          #0f172a;
  --surface:     #1e293b;
  --surface2:    #263548;
  --border:      #334155;
  --accent:      #f59e0b;
  --accent-dim:  #b45309;
  --accent-glow: rgba(245,158,11,0.35);
  --green:       #22c55e;
  --green-dim:   #166534;
  --red:         #ef4444;
  --yellow:      #eab308;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --text-dim:    #64748b;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,0.5);
}

/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100dvh;
  line-height: 1.5;
}

button { cursor: pointer; font: inherit; border: none; background: none; }
canvas { display: block; }
.hidden { display: none !important; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 60px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.logo-svg { width: 28px; height: 28px; flex-shrink: 0; }

/* ── Navigation ─────────────────────────────────────────────────────────── */
.app-nav {
  display: flex;
  gap: 0.25rem;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.nav-btn {
  padding: 0.4rem 1rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.18s, color 0.18s;
}

.nav-btn:hover { color: var(--text); background: var(--surface2); }

.nav-btn.active {
  background: var(--accent);
  color: #000;
  font-weight: 700;
}

/* ── Views ──────────────────────────────────────────────────────────────── */
.view { display: none; flex: 1; padding: 1.5rem 1.25rem 3rem; }
.view.active { display: block; }

.app-main { flex: 1; }

/* ══════════════════════════════════════════════════════════════════════════
   TUNER
   ══════════════════════════════════════════════════════════════════════════ */

#view-tuner {
  max-width: 540px;
  margin: 0 auto;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

/* Note display card */
.tuner-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.tuner-note-wrap {
  margin-bottom: 0.5rem;
}

#tuner-note {
  font-size: clamp(3.5rem, 14vw, 5rem);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.04em;
}

#tuner-freq {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Cents bar */
.tuner-bar-wrap {
  position: relative;
  margin: 1.75rem 0 0.5rem;
}

.tuner-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
  padding: 0 2px;
}

.tuner-bar {
  position: relative;
  height: 14px;
  border-radius: 7px;
  overflow: visible;
  background: linear-gradient(
    to right,
    var(--red)    0%,
    var(--yellow) 30%,
    var(--green)  45%,
    var(--green)  55%,
    var(--yellow) 70%,
    var(--red)    100%
  );
  box-shadow: 0 0 12px rgba(0,0,0,0.5);
}

/* Center tick mark */
.tuner-bar::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -4px;
  width: 2px;
  height: calc(100% + 8px);
  background: rgba(255,255,255,0.25);
  transform: translateX(-50%);
}

#tuner-needle {
  position: absolute;
  top: -8px;
  left: 50%;
  width: 4px;
  height: 30px;
  background: #fff;
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.14s ease-out;
  box-shadow: 0 0 8px rgba(255,255,255,0.7);
  z-index: 2;
}

#tuner-cents {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
}

/* Status badge */
.tuner-status {
  display: inline-block;
  margin-top: 1rem;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.3rem 1rem;
  border-radius: 20px;
  background: transparent;
  min-height: 2rem;
  transition: background 0.2s, color 0.2s;
}

.status-in-tune {
  background: var(--green-dim);
  color: var(--green);
  box-shadow: 0 0 16px rgba(34,197,94,0.3);
}
.status-flat  { background: rgba(239,68,68,0.15); color: var(--red); }
.status-sharp { background: rgba(239,68,68,0.15); color: var(--red); }

/* Matched string info */
#tuner-string {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  min-height: 1.2em;
}

/* Start/stop button */
.btn-start-stop {
  display: block;
  width: 100%;
  margin: 1.25rem 0;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  background: var(--accent);
  color: #000;
  transition: background 0.18s, transform 0.1s;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-start-stop:hover  { background: #fbbf24; }
.btn-start-stop:active { transform: scale(0.98); }

.btn-start-stop.btn-stop {
  background: var(--surface2);
  color: var(--red);
  border: 1px solid var(--red);
  box-shadow: none;
}
.btn-start-stop.btn-stop:hover { background: rgba(239,68,68,0.1); }

/* Mic error message */
.mic-error {
  background: rgba(239,68,68,0.15);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin-top: 0.75rem;
  animation: fadeIn 0.3s ease;
}

/* String selector */
.string-selector {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.string-selector h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}

.strings-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem;
}

/* String indicator – purely visual, not interactive */
.string-btn {
  padding: 0.5rem 0.25rem;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);          /* dimmer than before – passive state */
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  cursor: default;                 /* no pointer – not clickable */
  user-select: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.3s, transform 0.15s;
}

/* Detected / active string – prominent highlight */
.string-btn.string-active {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
  box-shadow: 0 0 14px var(--accent-glow), inset 0 0 6px rgba(245,158,11,0.15);
  transform: scale(1.06);          /* slight pop to draw attention */
}

/* ══════════════════════════════════════════════════════════════════════════
   CHORDS
   ══════════════════════════════════════════════════════════════════════════ */

#view-chords { max-width: 860px; margin: 0 auto; }

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.filter-btn {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter-btn:hover { color: var(--text); border-color: var(--text-dim); }

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
}

/* Chord grid */
.chords-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.9rem;
}

/* Chord card */
.chord-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.chord-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.chord-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.chord-card canvas {
  border-radius: 4px;
}

.chord-card-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.2rem;
}

.chord-card-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Category badges */
.chord-badge {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
}

.chord-badge-beginner     { background: rgba(34,197,94,0.15);  color: var(--green); }
.chord-badge-intermediate { background: rgba(245,158,11,0.15); color: var(--accent); }
.chord-badge-7th          { background: rgba(99,102,241,0.15); color: #818cf8; }

/* ══════════════════════════════════════════════════════════════════════════
   CHORD MODAL
   ══════════════════════════════════════════════════════════════════════════ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 380px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow);
  animation: slideUp 0.22s ease;
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.modal-close-btn:hover { background: var(--border); color: var(--text); }

.modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.4rem;
  letter-spacing: -0.02em;
}

.modal-badge { margin-bottom: 1rem; display: inline-block; }

.modal-canvas {
  display: block;
  margin: 0 auto 1rem;
  border-radius: 8px;
}

.modal-notes {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.modal-notes strong { color: var(--text); }

/* Finger color legend */
.finger-color-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.75rem;
  margin-bottom: 1rem;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
}

.fcl-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.fcl-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.fcl-label { line-height: 1.2; }

/* Fingering legend */
.fingering-legend { margin-bottom: 1rem; }

.legend-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.legend-table { display: flex; flex-direction: column; gap: 0.3rem; }

.legend-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.875rem;
}

/* Colored swatch in legend rows */
.leg-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.leg-swatch-muted { background: var(--text-dim); }

.leg-string {
  min-width: 70px;
  color: var(--text-muted);
  font-weight: 500;
}

.leg-fret { color: var(--text); }
.leg-x    { color: var(--text-dim); }

/* Tip box */
.modal-tip {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.tip-icon { flex-shrink: 0; }

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ══════════════════════════════════════════════════════════════════════════
   CHORD MODAL – NAVIGATION
   ══════════════════════════════════════════════════════════════════════════ */

.modal-topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.modal-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.modal-nav-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.modal-counter {
  flex: 1;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* push close button to right */
.modal-close-btn { margin-left: auto; }

/* ══════════════════════════════════════════════════════════════════════════
   SONGS VIEW
   ══════════════════════════════════════════════════════════════════════════ */

#view-songs { max-width: 860px; margin: 0 auto; }

.song-filter-btn {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  cursor: pointer;
}

.song-filter-btn:hover { color: var(--text); border-color: var(--text-dim); }
.song-filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
}

/* Song grid */
.songs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

/* Song card */
.song-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.song-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.song-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.song-card-meta { display: flex; align-items: center; justify-content: flex-end; }

.song-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.song-card-artist { font-size: 0.8rem; color: var(--text-dim); }

.song-chord-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.song-chord-tag {
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.songs-disclaimer {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  line-height: 1.5;
}

/* ── Song detail view ─────────────────────────────────────────────────── */

.song-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.song-back-btn:hover { color: var(--text); border-color: var(--text-dim); }

.song-detail-header { margin-bottom: 1rem; }

.song-detail-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.song-detail-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Mini chord diagrams strip */
.song-chord-diagrams {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.song-diagram-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.song-diagram-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Song section */
.song-section {
  margin-bottom: 1.5rem;
}

.song-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

/* Chord / lyric line */
.chord-lyric-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  margin-bottom: 0.9rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
}

.clp {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 80px;
}

.clp-chord {
  display: inline-block;
  background: var(--accent);
  color: #000;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
  width: fit-content;
}

.clp-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .strings-grid { grid-template-columns: repeat(3, 1fr); }
  .chords-grid  { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .songs-grid   { grid-template-columns: 1fr 1fr; }
  .app-header   { padding: 0 0.75rem; }
  .view         { padding: 1rem 0.75rem 3rem; }
  .clp-text     { font-size: 0.85rem; }
}

@media (max-width: 360px) {
  .strings-grid { grid-template-columns: repeat(2, 1fr); }
  .songs-grid   { grid-template-columns: 1fr; }
  #tuner-note   { font-size: 3rem; }
}
