/* =============================================================================
   guitar.css — guitar fretboard (#guitar-fretboard), drawn by www/js/guitar.js
   ========================================================================== */

:root {
  /* frame + controls (same family as the piano frame) */
  --gf-frame: #2b2b2e;
  --gf-fg: #f2f2f2;
  --gf-muted: #bdbdc2;
  --gf-control-bg: #3a3a3e;
  --gf-control-border: #66666d;
  --gf-focus: #3d7be8;
  /* sound toggle — SYNC: --pk-mute-* in piano.css (same button) */
  --gf-mute-bg: #3a3a3e;
  --gf-mute-fg: #f2f2f2;
  --gf-muted-bg: #c62828;        /* Material Red 800 — sound is off */
  --gf-muted-fg: #ffffff;

  /* chord badges — SYNC: .cp-seq-badge in circle-o-5ths.css (same dark pill) */
  --gf-badge-bg: #2b2b2e;
  --gf-badge-border: #66666d;
  --gf-badge-fg: #f2f2f2;
  --gf-badge-active: #3d7be8;

  /* fingerboard: rosewood, cream binding, nickel frets, bone nut, pearl inlays */
  --gf-wood: #4a2a1a;
  --gf-wood-edge: #2a170d;
  --gf-binding: #efe6d2;
  --gf-fret-light: #f7f7f8;
  --gf-fret-dark: #8b8e94;
  --gf-nut: #f6eedc;
  --gf-nut-shade: #c9bb98;
  --gf-pearl: #ffffff;
  --gf-pearl-mid: #ede8dc;
  --gf-pearl-shade: #c9c1ad;

  /* strings */
  --gf-string-plain: #dcdde0;
  --gf-string-wound: #c4ab7f;
  --gf-winding: rgba(60, 42, 20, 0.55);
  --gf-string-hi: rgba(255, 255, 255, 0.75);
  --gf-string-shadow: rgba(0, 0, 0, 0.5);

  /* open-string labels + fret numbers */
  --gf-open-bg: #3a3a3e;
  --gf-open-fg: #f2f2f2;
  --gf-num: #8f8f96;
  --gf-num-strong: #f2f2f2;

  /* progression overlay FALLBACK only (no piano / colors.js): dots normally take the piano's octave
     colours from guitar.js — scale degree 1 (tonic, darkest) -> 7 (lightest) */
  --gf-deg-1: #004d40;
  --gf-deg-2: #00695c;
  --gf-deg-3: #00796b;
  --gf-deg-4: #00897b;
  --gf-deg-5: #26a69a;
  --gf-deg-6: #4db6ac;
  --gf-deg-7: #80cbc4;
  --gf-deg-fg-dark: #ffffff;      /* text on degrees 1–5 */
  --gf-deg-fg-light: #0b2e2a;     /* text on degrees 6–7 */
  --gf-root-ring: #ffffff;        /* root chord's root note */

  /* SYNC: CSS_VERSION in www/js/guitar.js — guitar.js warns in the console if they differ */
  --gf-css-version: 7;

  /* geometry read by guitar.js */
  --gf-string-gap: 30px;          /* string spacing (board height = 6 × gap) */
  --gf-open-col: 40px;            /* open-string column left of the nut */
}

.gf {
  touch-action: manipulation;   /* no double-tap zoom on fast taps (pinch zoom still works): a zoomed page
                                  pushes the pinned keyboard / fretboard out of view while scrolling down */
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 10px 10px 6px;
  border-radius: 10px;
  background: var(--gf-frame);
  color: var(--gf-fg);
  box-sizing: border-box;
  text-align: left;               /* ignore page-level centring */
}

/* --- top row: status · chord badges · progression and tuning dropdowns (upper right) --- */
.gf-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.gf-status {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--gf-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gf-badges {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.gf-badges[hidden] { display: none; }

.gf-badge {
  appearance: none;
  -webkit-appearance: none;
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border: 1px solid var(--gf-badge-border);
  border-radius: 22px;
  background: var(--gf-badge-bg);
  color: var(--gf-badge-fg);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gf-badge:hover { border-color: var(--gf-badge-fg); }
.gf-badge:focus-visible { outline: 3px solid var(--gf-focus); outline-offset: 2px; }
.gf-badge.is-active { box-shadow: 0 0 0 3px var(--gf-badge-active); }
.gf-badge--all { font-size: 14px; letter-spacing: 0.02em; }

.gf-selects {
  display: flex;
  flex: 0 1 auto;
  gap: 8px;
  min-width: 0;
  margin-left: auto;              /* dropdowns stay at the upper right */
}

.gf-select,
.gf-tuning {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 0 40px 0 12px;
  border: 1px solid var(--gf-control-border);
  border-radius: 8px;
  background-color: var(--gf-control-bg);
  /* chevron: inline SVG data URI (no external request) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23f2f2f2' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  color: var(--gf-fg);
  font: inherit;
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.gf-select:hover,
.gf-tuning:hover { border-color: var(--gf-fg); }
.gf-select:focus-visible,
.gf-tuning:focus-visible { outline: 3px solid var(--gf-focus); outline-offset: 2px; }
.gf-select option,
.gf-tuning option { background: var(--gf-control-bg); color: var(--gf-fg); }

/* --- sound toggle (upper right, same as the piano's .pk-mute) ---------------------- */
.gf-mute {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #555;
  border-radius: 22px;
  background: var(--gf-mute-bg);
  color: var(--gf-mute-fg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 80ms linear;
}
.gf-mute:hover { border-color: var(--gf-mute-fg); }
.gf-mute:focus-visible { outline: 3px solid var(--gf-focus); outline-offset: 2px; }
.gf-mute.is-muted { background: var(--gf-muted-bg); border-color: var(--gf-muted-bg); color: var(--gf-muted-fg); }

/* --- fret window controls (narrow screens only) ------------------------------- */
.gf-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.gf-controls[hidden] { display: none; }

.gf-shift {
  appearance: none;
  -webkit-appearance: none;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--gf-control-border);
  border-radius: 8px;
  background: var(--gf-control-bg);
  color: var(--gf-fg);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gf-shift:disabled { opacity: 0.35; cursor: default; }
.gf-shift:focus-visible { outline: 3px solid var(--gf-focus); outline-offset: 2px; }

.gf-range {
  color: #ddd;
  font-size: 14px;
  letter-spacing: 0.04em;
}

/* --- the drawing --------------------------------------------------------------- */
.gf-stage { width: 100%; min-width: 0; overflow: hidden; }
.gf-svg { display: block; }

/* --- sticky fretboard (class added by guitar.js) — takes over from the pinned piano ---------- */
.gf-sticky {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 1021;                  /* just above the pinned piano (1020); below Bootstrap modals (1050) */
  background: var(--gf-sticky-bg, #ffffff);
}
.gf.gf-sticky { background: var(--gf-frame); }

.gf-c-wood { stop-color: var(--gf-wood); }
.gf-c-wood-edge { stop-color: var(--gf-wood-edge); }
.gf-c-fret-light { stop-color: var(--gf-fret-light); }
.gf-c-fret-dark { stop-color: var(--gf-fret-dark); }
.gf-c-nut { stop-color: var(--gf-nut); }
.gf-c-nut-shade { stop-color: var(--gf-nut-shade); }
.gf-c-pearl { stop-color: var(--gf-pearl); }
.gf-c-pearl-mid { stop-color: var(--gf-pearl-mid); }
.gf-c-pearl-shade { stop-color: var(--gf-pearl-shade); }

.gf-grain { opacity: 0.55; mix-blend-mode: multiply; pointer-events: none; }
.gf-binding { stroke: var(--gf-binding); stroke-width: 2.5; }
.gf-inlay { stroke: rgba(0, 0, 0, 0.35); stroke-width: 0.75; }
.gf-has-overlay .gf-inlay { opacity: 0.3; }      /* inlays recede behind progression dots */
.gf-fret-shadow { fill: rgba(0, 0, 0, 0.28); }
.gf-nut { stroke: rgba(0, 0, 0, 0.25); stroke-width: 0.75; }

.gf-string { stroke: var(--gf-string-plain); stroke-linecap: round; }
.gf-string--wound { stroke: var(--gf-string-wound); }
.gf-winding { stroke: var(--gf-winding); }
.gf-string-hi { stroke: var(--gf-string-hi); }
.gf-string-shadow { stroke: var(--gf-string-shadow); }

.gf-open-dot { fill: var(--gf-open-bg); stroke: rgba(255, 255, 255, 0.25); stroke-width: 1; }
.gf-open-text { fill: var(--gf-open-fg); font-size: 12px; font-weight: 700; }

.gf-num { fill: var(--gf-num); font-size: 11px; font-weight: 600; }
.gf-num--inlay { fill: var(--gf-num-strong); font-weight: 700; }

/* --- progression overlay dots ---------------------------------------------------- */
.gf-dot { --gf-dot-bg: var(--gf-deg-1); --gf-dot-fg: var(--gf-deg-fg-dark); }
.gf-deg-2 { --gf-dot-bg: var(--gf-deg-2); }
.gf-deg-3 { --gf-dot-bg: var(--gf-deg-3); }
.gf-deg-4 { --gf-dot-bg: var(--gf-deg-4); }
.gf-deg-5 { --gf-dot-bg: var(--gf-deg-5); }
.gf-deg-6 { --gf-dot-bg: var(--gf-deg-6); --gf-dot-fg: var(--gf-deg-fg-light); }
.gf-deg-7 { --gf-dot-bg: var(--gf-deg-7); --gf-dot-fg: var(--gf-deg-fg-light); }

.gf-dot-c { fill: var(--gf-dot-bg); stroke: rgba(255, 255, 255, 0.55); stroke-width: 1.25; }
.gf-dot-t { fill: var(--gf-dot-fg); font-weight: 700; pointer-events: none; }
/* root chord's root: thick white ring with a dark outline so it reads on light and dark dots */
.gf-dot.is-root .gf-dot-c { stroke: var(--gf-root-ring); stroke-width: 3; filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.9)); }

/* --- playable circles (fretted dots and open strings): click / Enter / Space plays the note ---------- */
.gf-press { cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }
.gf-hit { fill: transparent; pointer-events: all; }   /* the whole fret cell is the touch target */
.gf-press .gf-dot-c,
.gf-press .gf-open-dot {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 90ms ease-out;
}
.gf-press:hover .gf-dot-c,
.gf-press:hover .gf-open-dot { transform: scale(1.1); }
.gf-press.is-pressed .gf-dot-c,
.gf-press.is-pressed .gf-open-dot { transform: scale(1.25); }
.gf-press:focus-visible .gf-dot-c,
.gf-press:focus-visible .gf-open-dot { stroke: var(--gf-focus); stroke-width: 3; }

/* =============================================================================
   BREAKPOINTS — keep at end of file
   ========================================================================== */

/* SYNC POINT: must match opts.mobileQuery in www/js/guitar.js */
@media (max-width: 768px) {
  :root { --gf-string-gap: 34px; --gf-open-col: 36px; }
  .gf { padding: 8px 6px 4px; border-radius: 8px; }
  .gf-top { flex-wrap: wrap; }
  .gf-status { flex: 1 1 0; }                       /* first line: status + sound toggle (as on the piano) */
  .gf-mute { order: -1; margin-left: auto; }
  .gf-status { order: -2; }
  .gf-badges { flex: 1 1 100%; }
  .gf-selects { flex: 1 1 100%; margin-left: 0; }
  .gf-select,
  .gf-tuning { flex: 1 1 0; }
}

@media (max-width: 430px) {
  .gf-status { font-size: 13px; }
  .gf-badge { padding: 0 12px; font-size: 15px; }
  .gf-selects { flex-direction: column; }            /* stack: both dropdowns full width */
  .gf-select,
  .gf-tuning { width: 100%; font-size: 14px; }
}

/* Touch screens: dropdown text at least 16px — phones zoom the page in when a smaller dropdown is tapped,
   and a zoomed page pushes the pinned keyboard / fretboard out of view while scrolling down.
   Kept last so it wins over the width breakpoints above. */
@media (hover: none) and (pointer: coarse) {
  .gf-select,
  .gf-tuning { font-size: 16px; }
}
