/* ─── FretVision — Main CSS ─────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
  --color-bg:         #0f172a;   /* slate-900 */
  --color-surface:    #1e293b;   /* slate-800 */
  --color-border:     #334155;   /* slate-700 */
  --color-text:       #e2e8f0;   /* slate-200 */
  --color-muted:      #94a3b8;   /* slate-400 */
  --color-accent:     #06b6d4;   /* cyan-500  */
  --color-accent-dim: #0e7490;   /* cyan-700  */
  --font-sans:        'Inter', system-ui, sans-serif;
  --radius:           6px;
  --header-h:         60px;
  --footer-h:         52px;
}

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

html, body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-wrap: wrap;
}

.app-header .logo {
  font-weight: 700;
  font-size: 20px;
  color: var(--color-accent);
  letter-spacing: -0.5px;
  white-space: nowrap;
  margin-right: 4px;
}

/* ── Scale banner ───────────────────────────────────────────────────── */
.scale-banner {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
}

.scale-banner-label {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: -0.5px;
}

/* ── Play button ─────────────────────────────────────────────────────── */
.play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--color-accent);
  color: var(--color-accent);
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.play-btn:hover {
  background: var(--color-accent);
  color: var(--color-bg);
}

.play-btn.playing {
  background: var(--color-accent);
  color: var(--color-bg);
  animation: playPulse 1.2s ease-in-out infinite;
}

@keyframes playPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.5); }
  50%       { box-shadow: 0 0 0 7px rgba(6, 182, 212, 0); }
}

/* ── Main fretboard area ─────────────────────────────────────────────── */
.fretboard-area {
  /* Fixed height so the fretboard fills the viewport on load;
     the theory section below is revealed by scrolling */
  flex: none;
  height: calc(100dvh - var(--header-h) - 60px - var(--footer-h));
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px 0 8px;
  display: flex;
  align-items: center;
  /* iOS momentum scroll */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.fretboard-area::-webkit-scrollbar { height: 4px; }
.fretboard-area::-webkit-scrollbar-track { background: transparent; }
.fretboard-area::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

#fretboard-container {
  width: 100%;
  min-width: 700px;
  padding: 0 16px;
}

.fretboard-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Theory panel ─────────────────────────────────────────────────────── */
.theory-section {
  border-top: 1px solid var(--color-border);
  padding: 48px 24px 56px;
  background: var(--color-bg);
}

.theory-section-header {
  text-align: center;
  margin-bottom: 36px;
}

.theory-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 6px;
}

.theory-section-subtitle {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.4px;
}

/* ── Single-column vertical stack ─── */
.theory-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.theory-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 28px 32px;
}

.theory-card-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 16px;
}

.theory-card-character {
  font-size: 17px;
  color: var(--color-text);
  line-height: 1.6;
  margin-bottom: 16px;
}

.theory-card-note {
  font-size: 14px;
  color: var(--color-muted);
  line-height: 1.6;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.theory-brightness {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}

.theory-brightness-label {
  font-size: 12px;
  color: var(--color-muted);
  white-space: nowrap;
}

.theory-brightness-bar {
  flex: 1;
  height: 5px;
  background: var(--color-border);
  border-radius: 3px;
  overflow: hidden;
}

.theory-brightness-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--color-accent);
  transition: width 0.3s ease;
}

.theory-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.theory-tag {
  font-size: 12px;
  padding: 4px 10px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: 4px;
  color: var(--color-accent);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.theory-tag:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--color-accent);
}

.theory-diatonic {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.theory-diatonic-chord {
  font-size: 14px;
  font-weight: 500;
  padding: 4px 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text);
  font-family: 'Georgia', serif;
}

.theory-diatonic-chord.is-tonic {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.theory-cofa {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding: 14px 20px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 13px;
}

.theory-cofa-neighbor {
  color: var(--color-muted);
  font-size: 13px;
  text-align: center;
}

.theory-cofa-neighbor strong {
  display: block;
  font-size: 18px;
  color: var(--color-text);
  font-weight: 600;
}

.theory-cofa-current {
  font-size: 26px;
  font-weight: 700;
  color: var(--color-accent);
  text-align: center;
}

/* ── Exercise card: 3-column row ─── */
.theory-exercises-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 4px;
}

.theory-exercise-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  font-family: var(--font-sans);
}

.theory-exercise-btn:hover {
  background: rgba(6, 182, 212, 0.06);
  border-color: rgba(6, 182, 212, 0.4);
}

.theory-exercise-btn-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

.theory-exercise-btn-desc {
  font-size: 14px;
  color: var(--color-muted);
  line-height: 1.5;
}

.theory-exercise-link {
  font-size: 12px;
  color: var(--color-accent);
  margin-top: 6px;
  display: block;
}

.theory-section-cta {
  text-align: center;
  margin-top: 40px;
}

.theory-section-cta a {
  display: inline-block;
  padding: 10px 24px;
  background: transparent;
  border: 1px solid var(--color-accent);
  border-radius: 6px;
  color: var(--color-accent);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s;
}

.theory-section-cta a:hover {
  background: rgba(6, 182, 212, 0.1);
}

details.theory-advanced summary {
  font-size: 12px;
  color: var(--color-muted);
  cursor: pointer;
  padding-top: 12px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

details.theory-advanced[open] summary::before { content: '▲ '; font-size: 9px; }
details.theory-advanced:not([open]) summary::before { content: '▼ '; font-size: 9px; }

details.theory-advanced .theory-advanced-content {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

/* scroll-down hint between fretboard and theory panel */
.theory-scroll-hint {
  text-align: center;
  padding: 12px 0 4px;
  font-size: 11px;
  color: var(--color-muted);
  opacity: 0.6;
  letter-spacing: 0.05em;
}

@media (max-width: 860px) {
  .theory-section {
    padding: 32px 16px 44px;
  }
  .theory-card {
    padding: 20px;
  }
  .theory-exercises-grid {
    grid-template-columns: 1fr;
  }
  .theory-exercise-btn-title { font-size: 15px; }
  .theory-exercise-btn-desc  { font-size: 13px; }
}

@media (max-width: 599px) {
  .theory-card-character { font-size: 15px; }
  .theory-cofa-current   { font-size: 22px; }
}

/* ── Footer ────────────────────────────────────────────────────────────── */
.app-footer {
  position: sticky;
  bottom: 0;
  z-index: 50;
  min-height: var(--footer-h);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 16px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-link {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--color-accent);
}

.footer-dot {
  color: var(--color-border);
  font-size: 14px;
  user-select: none;
}

.footer-copy {
  font-size: 10px;
  color: var(--color-muted);
  text-align: center;
  opacity: 0.65;
}

/* ── Scroll hint (desktop horizontal scroll) ─────────────────────────── */
.scroll-hint {
  display: none;
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(to left, var(--color-bg) 40%, transparent);
  width: 48px;
  height: 100%;
  pointer-events: none;
}

/* ── Controls toggle (mobile only, hidden on desktop) ────────────────── */
.controls-toggle-btn { display: none; }
.header-scale-label  { display: none !important; }

/* ── Controls panel: inline on desktop ──────────────────────────────── */
#controls-panel {
  display: contents; /* children participate in header flex flow */
}

/* ── Mobile breakpoint ───────────────────────────────────────────────── */
@media (max-width: 599px) {

  /* Header: single tight row */
  .app-header {
    position: relative;
    height: var(--header-h);
    padding: 0 12px;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
  }

  /* Show mobile-only elements */
  .controls-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    color: var(--color-muted);
    cursor: pointer;
    min-height: 36px;
    white-space: nowrap;
    transition: border-color 0.2s, color 0.2s;
  }
  .controls-toggle-btn:hover,
  .controls-toggle-btn.active {
    border-color: var(--color-accent);
    color: var(--color-accent);
  }
  .controls-toggle-arrow { font-size: 10px; }

  /* Scale banner: shown on mobile, compact size */
  .scale-banner { padding: 8px 12px; }
  .scale-banner-label { font-size: 18px; }

  /* Controls panel: hidden dropdown */
  #controls-panel {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 12px;
    flex-wrap: wrap;
    gap: 10px;
    z-index: 48;
    align-items: center;
  }
  #controls-panel.open {
    display: flex;
  }

  /* Hide dividers inside panel on mobile */
  #controls-panel .ctrl-divider { display: none; }


  /* Fretboard: vertical mode */
  #fretboard-container {
    min-width: unset;
    width: 100%;
    padding: 0 8px;
  }
  .fretboard-area {
    height: calc(100dvh - var(--header-h) - 38px - var(--footer-h));
    overflow-x: hidden;
    overflow-y: auto;
    align-items: flex-start;
    padding: 8px 0;
  }
  .fretboard-svg--vertical {
    width: 100%;
    height: auto;
    display: block;
  }
}

/* ── Very small screens ──────────────────────────────────────────────── */
@media (max-width: 380px) {
  .random-label { display: none; }
  .scale-banner-label { font-size: 15px; }
}

/* ── Footer responsive ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  .footer-dot { display: none; }
}
