/* Escalas: one position large, practice bar, and the neck map with its positions. */

.scl {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-5);
  padding: var(--s-4) var(--gutter) var(--s-7);
  background: var(--bg);
}

.scl:focus {
  outline: none;
}

/* ---------- Config ---------- */

.scl-config {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3) var(--s-5);
}

.scl-pick {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

.scl-pick-title {
  color: var(--ink-2);
  font-size: var(--t-small);
  font-weight: 600;
}

.segmented button:disabled {
  color: var(--ink-2);
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- Stage ---------- */

.scl-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: var(--s-5) var(--s-6);
  align-items: start;
}

.scl-info {
  grid-column: 1;
  grid-row: 1;
}

.scl-legend {
  grid-column: 1;
  grid-row: 2;
}

.scl-visual {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: relative;
  order: 0;
}

.scl-info h1 {
  font: 800 clamp(2.75rem, 1.5rem + 2.4vw, 4rem) / 0.95 var(--font-display);
  letter-spacing: -0.03em;
}

.scl-sub {
  margin-top: var(--s-2);
  font: 600 var(--t-title) / 1.15 var(--font-display);
}

.scl-frets {
  margin-top: var(--s-1);
  color: var(--ink-2);
  font-weight: 600;
}

.scl-now {
  display: grid;
  justify-items: start;
  gap: 2px;
  margin-top: var(--s-5);
}

.scl-now:empty {
  display: none;
}

.scl-now b {
  font: 800 4rem / 1 var(--font-display);
  letter-spacing: -0.02em;
}

.scl-now b.is-done {
  font-size: 2.5rem;
}

.scl-now span {
  color: var(--ink-2);
  font-weight: 600;
}

.scl-status {
  margin-top: var(--s-3);
  color: var(--ink-2);
  font-size: var(--t-small);
  font-weight: 600;
}



.scl-key .key-wide {
  grid-column: 1 / -1;
}

.key-root,
.key-note {
  flex: none;
  width: 28px;
  height: 28px;
}

.key-root {
  border-radius: 7px;
  background: var(--ink);
}

.key-note {
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-2);
}

.scl-key-hint {
  margin-top: var(--s-3);
  color: var(--ink-2);
  font-size: var(--t-small);
}

.scl-key-hint:empty {
  display: none;
}

.scl-visual {
  width: 100%;
  padding: var(--s-4) var(--s-5) var(--s-3) var(--s-3);
}

.scl-visual .fretboard {
  display: block;
  width: 100%;
  height: auto;
  max-height: 440px;
}

.scl-count {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  display: none;
  place-items: center;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font: 800 5.5rem / 1 var(--font-display);
  outline: 8px solid var(--bg);
  pointer-events: none;
}

.is-counting .scl-count {
  display: grid;
}

/* ---------- Fretboard ---------- */

.fb-fret {
  stroke: var(--line-strong);
  stroke-width: 2;
}

.fretboard--map .fb-fret {
  stroke-width: 1;
}

.fb-nut {
  fill: var(--ink);
}

.fb-string {
  stroke: var(--ink);
  stroke-opacity: 0.55;
}

.fb-inlays circle {
  fill: var(--surface-2);
}

.fretboard--map .fb-inlays circle {
  fill: var(--line-strong);
}

.fb-string-names text,
.fb-fret-numbers text {
  fill: var(--ink-2);
  font: 700 20px var(--font-ui);
}

.fretboard--map .fb-fret-numbers text {
  font-size: 11px;
  font-weight: 800;
}

.fb-dot {
  fill: var(--surface-2);
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.fb-label {
  fill: var(--ink);
  font: 800 21px var(--font-display);
  pointer-events: none;
}

.fretboard--wide .fb-label {
  font-size: 16px;
}

.fb-finger--1 .fb-dot { fill: var(--finger-1); stroke: none; }
.fb-finger--2 .fb-dot { fill: var(--finger-2); stroke: none; }
.fb-finger--3 .fb-dot { fill: var(--finger-3); stroke: none; }
.fb-finger--4 .fb-dot { fill: var(--finger-4); stroke: none; }

.fb-note[class*="fb-finger--"] .fb-label {
  fill: var(--on-finger);
}

.fb-note--open .fb-dot {
  fill: var(--surface);
  stroke: var(--ink);
  stroke-width: 3;
}

/* Root notes: a filled ink square, readable without colour. */
.fb-note--root .fb-dot {
  fill: var(--ink);
  stroke: none;
}

.fb-note--root .fb-label,
.fb-note--root[class*="fb-finger--"] .fb-label {
  fill: var(--bg);
}

.fretboard--map .fb-dot {
  fill: var(--ink-2);
  stroke: none;
}

.fretboard--map .fb-note--root .fb-dot {
  fill: var(--ink);
}

.fretboard--map .fb-note.is-dim {
  opacity: var(--dim);
}

.fb-note .fb-dot,
.fb-note .fb-label {
  transform-box: fill-box;
  transform-origin: center;
}

.fb-note .fb-dot {
  transition: fill 80ms var(--ease-out), transform 80ms var(--ease-out);
}

/* Play-along: the note to play now is the lamp; every other note steps back equally. */
.fb-note.is-current .fb-dot {
  fill: var(--accent);
  stroke: none;
  transform: scale(1.14);
}

.fb-note.is-current .fb-label {
  fill: var(--accent-ink);
}

.is-playing .scl-visual .fb-note:not(.is-current),
.is-paused .scl-visual .fb-note:not(.is-current),
.is-playing .sol-board .fb-note:not(.is-current),
.is-paused .sol-board .fb-note:not(.is-current) {
  opacity: 0.35;
}

.fb-note {
  transition: opacity 120ms var(--ease-out);
}

/* ---------- Practice bar ---------- */

.scl-practice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3) var(--s-5);
}

.scl-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.scl-controls .btn {
  min-height: 50px;
  padding: 0 var(--s-4);
}

.scl-controls [data-action="toggle"] {
  min-width: 150px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:disabled:active {
  transform: none;
}

.scl-tempo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}

.scl-all-hint {
  flex-basis: 100%;
  color: var(--ink-2);
  font-size: var(--t-small);
  font-weight: 600;
}

.is-finished .scl-now {
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-lg);
  background: var(--surface);
  outline: 2px solid var(--accent-edge);
}

/* ---------- Neck map ---------- */

.scl-map {
  display: grid;
  gap: var(--s-3);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}

.scl-map-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-2) var(--s-4);
}

.scl-map-head h2 {
  font: 800 var(--t-title) / 1.1 var(--font-display);
  letter-spacing: -0.01em;
}

.scl-map-head p {
  color: var(--ink-2);
}

.scl-map-head .chip {
  margin-left: auto;
  align-self: center;
}

.scl-map-board {
  --map-pad: 60px;
  position: relative;
  padding-bottom: var(--map-pad);
}

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

/* Signature: the highlight slides along the neck to the chosen position. */
.scl-map-span {
  position: absolute;
  border: 2px solid var(--ink);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: left var(--dur) var(--ease-out), width var(--dur) var(--ease-out);
}

.scl-map-svg {
  position: relative;
}

.scl-map-positions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
}

.scl-pos {
  position: absolute;
  top: 0;
  translate: -50% 0;
  width: 46px;
  height: 46px;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  font: 800 1.25rem / 1 var(--font-display);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.scl-pos:hover {
  border-color: var(--ink);
}

.scl-pos:active {
  transform: scale(0.94);
}

.scl-pos[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

/* ---------- Full screen class view ---------- */

.scl.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 20;
  align-content: center;
  padding: var(--s-6) clamp(24px, 4vw, 64px);
  overflow: auto;
}

.scl.is-fullscreen .scl-config,
.scl.is-fullscreen .scl-map,
.scl.is-fullscreen .scl-legend,
.scl.is-fullscreen .scl-tempo,
.scl.is-fullscreen .scl-all-hint,
.scl.is-fullscreen .scl-status,
.scl.is-fullscreen [data-action="restart"],
.scl.is-fullscreen [data-action="mute"],
.scl.is-fullscreen [data-action="notes"] {
  display: none;
}

.scl.is-fullscreen .scl-stage {
  grid-template-columns: minmax(240px, 0.32fr) minmax(0, 1fr);
}

.scl.is-fullscreen .scl-visual .fretboard {
  max-height: calc(100dvh - 220px);
}

.scl.is-fullscreen .scl-now b {
  font-size: clamp(5rem, 9vw, 9rem);
}

/* ---------- Responsive ---------- */

@media (max-width: 1040px) {
  .scl-stage {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
    gap: var(--s-5);
  }

  .scl-now b {
    font-size: 3rem;
  }
}

@media (max-width: 860px) {
  .scl-stage,
  .scl.is-fullscreen .scl-stage {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-4);
  }

  .scl-info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--s-4);
    align-items: end;
  }

  .scl-info > * {
    grid-column: 1;
  }

  .scl-now {
    grid-column: 2;
    grid-row: 1 / span 3;
    justify-items: end;
    margin-top: 0;
    text-align: right;
  }

  .scl-info,
  .scl-legend,
  .scl-visual {
    grid-column: 1;
    grid-row: auto;
  }

  .scl-key {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .scl-visual.is-all {
    overflow-x: auto;
  }

  .scl-visual.is-all .fretboard {
    width: 860px;
    max-width: none;
  }
}

/* Phone: the play controls live in a bar fixed to the bottom, like Progresiones. */
@media (max-width: 520px) {
  .scl {
    gap: var(--s-4);
    padding-bottom: 120px;
  }

  .scl-config {
    gap: var(--s-3);
  }

  .scl-count {
    width: 110px;
    height: 110px;
    font-size: 3.75rem;
  }

  .scl-info h1 {
    font-size: 2.75rem;
  }

  .scl-sub {
    font-size: 1.25rem;
  }

  .scl-info {
    display: block;
  }

  .scl-now {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--s-1) var(--s-3);
    margin-top: var(--s-3);
    text-align: left;
  }

  .is-finished .scl-now {
    padding: var(--s-3) var(--s-4);
  }

  .scl-now .btn--small {
    margin-top: 0;
  }

  .scl-now b {
    font-size: 2.5rem;
  }

  .scl-visual {
    padding: var(--s-3) var(--s-3) var(--s-2) var(--s-1);
  }

  .scl-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    display: grid;
    grid-template-columns: 1fr repeat(4, 52px);
    gap: var(--s-2);
    padding: var(--s-3) var(--gutter) calc(var(--s-3) + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(10px);
  }

  .scl-controls .btn {
    min-height: 52px;
    padding: 0;
  }

  .scl-controls [data-action="toggle"] {
    min-width: 0;
    padding: 0 var(--s-4);
  }

  .scl-controls .btn:not([data-action="toggle"]) span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .is-playing .scl-config,
  .is-paused .scl-config {
    display: none;
  }

  /* The map keeps a readable scale and scrolls sideways instead of shrinking. */
  .scl-map-scroll {
    overflow-x: auto;
    margin: 0 calc(var(--gutter) * -1);
    padding: 0 var(--gutter);
    scrollbar-width: none;
  }

  .scl-map-board {
    min-width: 720px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scl-map-span,
  .fb-note .fb-dot {
    transition: none;
  }
}

.scl-key li:first-child {
  grid-column: 1 / -1;
}

/* The finished card already says it; keep the status for screen readers only. */
.is-finished .scl-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Phone: scale and key share one row (their names stay for screen readers),
   so the whole position fits above the play bar. */
@media (max-width: 520px) {
  .scl-config > .scl-pick:first-child .scl-pick-title,
  .scl-config > .field > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .scl-config {
    column-gap: var(--s-2);
  }

  .scl-info h1 {
    font-size: 2.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fb-note {
    transition: none;
  }
}
