/* ────────────────────────────────────────────────
   Base
──────────────────────────────────────────────── */

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

:root {
  --bg:        #1a1a2e;
  --surface:   #16213e;
  --surface2:  #0f3460;
  --accent:    #e94560;
  --text:      #eaeaea;
  --text-muted:#a0a0b0;
  --fret-line: #3a3a5c;
  --string-line: #8a8a9a;
  --inlay:     #4a4a7a;
  --inlay-col: rgba(255,255,255,0.03);
  --cell-w:    54px;
  --cell-h:    56px;
  --dot-w:     44px;
  --dot-h:     40px;
  --dot-size:  40px;
  --radius:    8px;
  --font:      'Segoe UI', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  padding: 1.5rem 1rem 3rem;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text);
  margin-bottom: 0.2rem;
}

h1 span {
  color: var(--accent);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* ────────────────────────────────────────────────
   App header (title + lang toggle)
──────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.lang-toggle {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  border: 1px solid var(--fret-line);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 4px;
}

.lang-btn {
  background: var(--surface);
  color: var(--text-muted);
  border: none;
  padding: 0.35rem 0.75rem;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lang-btn:first-child {
  border-right: 1px solid var(--fret-line);
}

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

.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ────────────────────────────────────────────────
   Controls panel
──────────────────────────────────────────────── */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--fret-line);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 130px;
}

.control-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

select, input[type="number"] {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--fret-line);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  font-family: var(--font);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23a0a0b0' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 1.8rem;
}

input[type="number"] {
  background-image: none;
  padding-right: 0.6rem;
  width: 70px;
}

select:focus, input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.control-group.checkboxes {
  justify-content: flex-end;
  gap: 0.5rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ────────────────────────────────────────────────
   Scale info + legend
──────────────────────────────────────────────── */

.info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.2rem;
  align-items: flex-start;
}

#scale-info {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  border: 1px solid var(--fret-line);
  flex: 1 1 auto;
}

#scale-info h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.scale-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.scale-note-badge {
  background: var(--surface2);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}

#legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface);
  border: 1px solid var(--fret-line);
  border-radius: 20px;
  padding: 0.15rem 0.55rem 0.15rem 0.2rem;
}

.legend-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.legend-label {
  display: flex;
  gap: 0.3rem;
  align-items: baseline;
}

.legend-fi {
  font-size: 0.72rem;
  color: var(--text);
  white-space: nowrap;
}

.legend-en {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ────────────────────────────────────────────────
   Diatonic chord table
──────────────────────────────────────────────── */

#diatonic-chords {
  margin-bottom: 1.2rem;
  overflow-x: auto;
}

.diatonic-chord-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  width: 100%;
  max-width: 600px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--fret-line);
  overflow: hidden;
}

.diatonic-chord-table thead th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.45rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--fret-line);
}

.diatonic-chord-table tbody tr:hover {
  background: var(--surface2);
}

.diatonic-chord-table tbody td {
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid var(--fret-line);
}

.diatonic-chord-table tbody tr:last-child td {
  border-bottom: none;
}

.diatonic-roman {
  font-weight: 700;
  font-family: Georgia, serif;
  color: var(--accent);
  white-space: nowrap;
  width: 3rem;
}

.diatonic-symbol {
  font-weight: 600;
  white-space: nowrap;
  width: 6rem;
}

.diatonic-seventh {
  color: #a0d4ff;
}

.diatonic-notes {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Degrees where no scale triad fits are dimmed */
.diatonic-no-triad td {
  opacity: 0.45;
}

/* ────────────────────────────────────────────────
   Chord progressions
──────────────────────────────────────────────── */

#progressions {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

#progressions .section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.75rem 0;
}

.progression-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--fret-line);
  flex-wrap: wrap;
}

.progression-item:last-child {
  border-bottom: none;
}

.progression-item--blues12bar {
  flex-direction: column;
  align-items: flex-start;
}

.progression-name {
  min-width: 11rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.progression-chords {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-wrap: wrap;
}

.prog-pill {
  background: var(--surface2);
  border: 1px solid var(--fret-line);
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
  text-align: center;
  min-width: 2.4rem;
}

.prog-pill-roman {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.3;
  font-family: Georgia, serif;
}

.prog-pill-triad {
  font-size: 0.9rem;
  color: #fff;
  font-weight: 700;
  line-height: 1.2;
}

.prog-pill-sep {
  border-top: 1px solid var(--fret-line);
  margin: 0.18rem 0;
}

.prog-pill-seventh {
  font-size: 0.9rem;
  color: #a0d4ff;
  font-weight: 700;
  line-height: 1.2;
}

.prog-pill-seventh--none {
  color: var(--fret-line);
  font-weight: 400;
  font-size: 0.75rem;
}

.prog-separator {
  color: var(--fret-line);
  font-size: 1rem;
  padding: 0 0.1rem;
  user-select: none;
}

/* 12-bar blues grid */
.blues12bar-grid {
  display: grid;
  grid-template-columns: auto repeat(4, 1fr);
  gap: 0.3rem;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin-top: 0.35rem;
}

.blues12bar-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  padding-right: 0.4rem;
  white-space: nowrap;
}

.blues12bar-cell {
  background: var(--surface2);
  border: 1px solid var(--fret-line);
  border-radius: 5px;
  text-align: center;
  padding: 0.3rem 0.2rem;
  font-weight: 700;
  color: #fff;
  font-size: 0.85rem;
}

/* ────────────────────────────────────────────────
   Fretboard container
──────────────────────────────────────────────── */

#fretboard-wrapper {
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

/* ────────────────────────────────────────────────
   Fretboard grid
──────────────────────────────────────────────── */

.fretboard {
  display: table;
  border-collapse: collapse;
  /* On desktop: fixed cell sizes, wrapper scrolls if needed */
  min-width: max-content;
}

/* On mobile the cell-w is viewport-driven (see Responsive section),
   so we let the table shrink naturally to fit */
@media (max-width: 600px) {
  .fretboard {
    width: max-content;
  }
}

.fret-row {
  display: table-row;
}

.fret-cell {
  display: table-cell;
  width: var(--cell-w);
  height: var(--cell-h);
  text-align: center;
  vertical-align: middle;
  position: relative;
}

/* Fret number header */
.fret-header .fret-cell {
  height: 24px;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding-bottom: 4px;
}

.fret-number.fret-marker {
  color: var(--text);
  font-weight: 600;
}

/* String label column */
.string-label-cell {
  width: 40px;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-right: 6px;
  text-align: right;
  white-space: nowrap;
}

.fret-header .string-label-cell {
  /* empty top-left corner */
}

/* Note cells */
.note-cell {
  border-left: 2px solid var(--fret-line);
  position: relative;
}

/* Open string — no fret, just a nut line */
.note-cell.open-string {
  border-left: none;
  border-right: 4px solid var(--text-muted);
}

/* String line (horizontal) through all cells */
.note-cell::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--string-line);
  transform: translateY(-50%);
  z-index: 0;
}

.note-cell.open-string::before {
  left: 0;
}

/* Subtle column tint for inlay frets */
.fret-col-marker {
  background: var(--inlay-col);
}
.fret-col-double {
  background: rgba(255,255,255,0.055);
}

/* Inlay row */
.inlay-row .fret-cell {
  height: 18px;
  border-left: 2px solid var(--fret-line);
}
.inlay-row .string-label-cell {
  border-left: none;
}
.inlay-cell {
  display: table-cell;
  text-align: center;
  vertical-align: middle;
  position: relative;
}
.inlay-cell.inlay-double {
  display: table-cell;
}
/* single dot */
.inlay-cell .inlay-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--inlay);
  margin: 0 1px;
}
/* double dot: side by side */
.inlay-double .inlay-dot {
  width: 7px;
  height: 7px;
}

/* Note dot — circle with two lines */
.note-dot {
  position: relative;
  z-index: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: var(--dot-w);
  height: var(--dot-h);
  border-radius: 50%;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  cursor: default;
  transition: transform 0.1s;
  padding: 2px 3px;
}

.note-dot:hover {
  transform: scale(1.1);
}

.note-dot-degree {
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.note-dot-name {
  font-size: 0.6rem;
  font-weight: 500;
  line-height: 1;
  opacity: 0.88;
}

/* Root note — highlighted ring */
.note-root .note-dot {
  width: calc(var(--dot-w) + 4px);
  height: calc(var(--dot-h) + 4px);
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff, 0 2px 8px rgba(0,0,0,0.5);
}

.note-root .note-dot-degree {
  font-size: 0.72rem;
}

.note-root .note-dot-name {
  font-size: 0.64rem;
}

/* Ghost note (all notes shown, not in scale) */
.note-ghost {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2a2a2a;
  border: 1px solid var(--fret-line);
  color: #ffffff;
  box-shadow: none;
  font-weight: 400;
  width: 30px;
  height: 26px;
  border-radius: 5px;
  font-size: 0.62rem;
  cursor: default;
}

/* ────────────────────────────────────────────────
   Error
──────────────────────────────────────────────── */
.error {
  color: var(--accent);
  background: var(--surface);
  padding: 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

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

/* ────────────────────────────────────────────────
   View tabs (Intervallit / Asemat)
──────────────────────────────────────────────── */
.view-tabs {
  display: flex;
  gap: 0;
  margin: 0.75rem 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  width: fit-content;
  border: 1px solid var(--fret-line);
}

.view-tab {
  background: var(--surface);
  color: var(--text-muted);
  border: none;
  padding: 0.45rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.02em;
}

.view-tab + .view-tab {
  border-left: 1px solid var(--fret-line);
}

.view-tab:hover {
  background: var(--surface2);
  color: var(--text);
}

.view-tab.active {
  background: var(--accent);
  color: #fff;
}

/* ────────────────────────────────────────────────
   Voicing row (selector + chord diagram)
──────────────────────────────────────────────── */
.voicing-row {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  margin: 0 1rem 0.75rem;
  flex-wrap: wrap;
}

.voicing-controls {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.voicing-controls label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ────────────────────────────────────────────────
   Chord diagram (SVG box)
──────────────────────────────────────────────── */
#chord-diagram {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 120px;
}

#chord-diagram svg {
  overflow: visible;
}

/* ────────────────────────────────────────────────
   Responsive
──────────────────────────────────────────────── */

/* ── Mobile (≤ 600px) ──
   cell-w is derived from viewport so exactly 13 columns fit
   (string-label + fret 0…12). Frets 13-15 are accessible by scrolling.

   Formula:
     available = 100vw - 2rem (body padding)
     label     = 28px
     13 fret columns: (available - 28px) / 13
*/
/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  margin-top: 2.5rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid #333;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  justify-content: center;
  font-size: 0.75rem;
  color: #666;
}

@media (max-width: 600px) {
  :root {
    --cell-w:  calc((100vw - 2rem - 28px) / 13);
    --cell-h:  calc((100vw - 2rem - 28px) / 13 * 1.15);
    --dot-w:   calc((100vw - 2rem - 28px) / 13 - 6px);
    --dot-h:   calc((100vw - 2rem - 28px) / 13 - 8px);
  }

  h1 { font-size: 1.3rem; }

  .string-label-cell {
    width: 28px;
    font-size: 0.65rem;
    padding-right: 3px;
  }

  .note-dot-degree { font-size: 0.58rem; }
  .note-dot-name   { font-size: 0.52rem; }
  .fret-header .fret-cell { font-size: 0.6rem; }
}
