/* The Tuner's own panel (Task 293 A, Task 309 Needle | Strobe). Scoped to html[data-gn-tuner-panel], which
   gn-tuner-panel.js sets once it has moved Tuning out of Keys. Dark readout wells match the metronome glass
   (gn-metronome.css); controls stay the ivory gn-k kit. */

/* ---------- shared: the readout well ---------- */
html[data-gn-tuner-panel] #gnTunerBig {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 0;
  margin: 8px 0 10px; padding: 10px 12px 12px; min-height: 176px; box-sizing: border-box; overflow: hidden;
  background: var(--gnw-mt-glass, #3A2820); border: 2px solid #000; border-radius: 10px;
  box-shadow: inset 0 3px 8px rgba(0,0,0,.8);
  color: var(--gnw-mt-lit, #FFF3B8); font-variant-numeric: tabular-nums;
}
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-noteline {
  display: grid; grid-template-columns: 44px auto 44px; align-items: center; justify-content: center; gap: 14px;
}
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-note { display: inline-flex; align-items: baseline; line-height: 1; min-width: 2.2ch; justify-content: center; }
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-letter { font-size: 76px; font-weight: 800; letter-spacing: 0; }
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-octave { font-size: 52px; font-weight: 700; margin-left: 2px; }
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-cents { font-size: 40px; font-weight: 800; line-height: 1.05; min-height: 42px; }
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-message { font-size: 15px; font-weight: 650; text-align: center; color: rgba(255,243,184,.85); }
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-message:empty { display: none; }
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-arrow { width: 44px; height: 44px; display: grid; place-items: center; }
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-arrow svg { width: 34px; height: 34px; fill: rgba(255,243,184,.14); transition: fill .12s; }
html[data-gn-tuner-panel] #gnTunerBig[data-lean="flat"] .gn-tp-flat svg,
html[data-gn-tuner-panel] #gnTunerBig[data-lean="sharp"] .gn-tp-sharp svg { fill: var(--gnw-mt-lit, #FFF3B8); filter: drop-shadow(0 0 6px rgba(213,168,63,.8)); }
/* Mic off: dim, so it still reads as a tuner waiting to listen. */
html[data-gn-tuner-panel] #gnTunerBig[data-state="none"] .gn-tp-letter,
html[data-gn-tuner-panel] #gnTunerBig[data-state="listening"] .gn-tp-letter { color: rgba(255,243,184,.28); }
html[data-gn-tuner-panel] #gnTunerBig[data-state="in-tune"] { color: var(--gnw-mt-green, #7BE39A); }
html[data-gn-tuner-panel] #gnTunerBig[data-state="in-tune"] .gn-tp-letter { text-shadow: 0 0 14px rgba(47,158,87,.75); }
html[data-gn-tuner-panel] #gnTunerBig[data-state="in-tune"] .gn-tp-arrow svg { fill: rgba(123,227,154,.55); filter: none; }
/* The big well carries the reading; the small ladder and line stay in the page for the shipped contract. */
html[data-gn-tuner-panel] #gnwTunerNeedle,
html[data-gn-tuner-panel] #gnwTunerReadout {
  position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important;
  clip-path: inset(50%) !important; white-space: nowrap !important; padding: 0 !important; border: 0 !important; margin: -1px !important;
}

/* Needle face: cents arc */
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-arc { width: 100%; max-width: 280px; height: auto; display: block; margin-bottom: -2px; }
html[data-gn-tuner-panel] .gn-tp-arc-track { fill: none; stroke: rgba(255,243,184,.16); stroke-width: 3; }
html[data-gn-tuner-panel] .gn-tp-tick { stroke: rgba(255,243,184,.4); stroke-width: 2; stroke-linecap: round; }
html[data-gn-tuner-panel] .gn-tp-tick-mid { stroke: var(--gnw-mt-green, #7BE39A); stroke-width: 3; }
html[data-gn-tuner-panel] .gn-tp-needle {
  stroke: var(--gnw-mt-lit, #FFF3B8); stroke-width: 3.5; stroke-linecap: round; visibility: hidden;
  transform-box: view-box; transform-origin: 100px 110px; transform: rotate(var(--gn-tp-angle, 0deg));
  transition: transform .09s linear; filter: drop-shadow(0 0 3px rgba(213,168,63,.8));
}
html[data-gn-tuner-panel] #gnTunerBig:is([data-state="reading"], [data-state="in-tune"]) .gn-tp-needle { visibility: visible; }
html[data-gn-tuner-panel] #gnTunerBig[data-state="in-tune"] .gn-tp-needle { stroke: var(--gnw-mt-green, #7BE39A); filter: drop-shadow(0 0 4px rgba(47,158,87,.9)); }

/* Strobe face: the band. Stripes drift with the cents (gn-tuner-panel.js); in tune they stand still and turn green. */
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-strobe {
  width: 100%; height: 34px; margin-bottom: 8px; overflow: hidden; border-radius: 5px;
  background: rgba(0,0,0,.35); box-shadow: inset 0 0 0 1px rgba(255,243,184,.12);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-strobe-band {
  display: block; height: 100%; margin-left: -48px; width: calc(100% + 96px);
  background: repeating-linear-gradient(90deg, rgba(255,243,184,.16) 0 12px, transparent 12px 24px);
}
html[data-gn-tuner-panel] #gnTunerBig:is([data-state="reading"]) .gn-tp-strobe-band {
  background: repeating-linear-gradient(90deg, var(--gnw-mt-lit, #FFF3B8) 0 12px, transparent 12px 24px);
  filter: drop-shadow(0 0 4px rgba(213,168,63,.7));
}
html[data-gn-tuner-panel] #gnTunerBig[data-state="in-tune"] .gn-tp-strobe-band {
  background: repeating-linear-gradient(90deg, var(--gnw-mt-green, #7BE39A) 0 12px, transparent 12px 24px);
  filter: drop-shadow(0 0 4px rgba(47,158,87,.8));
}

/* ---------- the two faces share one box, so the note line never moves when the face changes ---------- */
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-face {
  width: 100%; height: 74px; display: grid; place-items: end center; margin-bottom: 2px;
}
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-face > * { grid-area: 1 / 1; }
html[data-gn-tuner-panel] #gnTunerBig .gn-tp-strobe { align-self: center; margin-bottom: 0; }
html[data-gn-tuner-panel] #gnTunerBig[data-face="needle"] .gn-tp-strobe,
html[data-gn-tuner-panel] #gnTunerBig[data-face="strobe"] .gn-tp-arc { display: none; }

/* ---------- Needle | Strobe in the header, between the title and the close button ---------- */
html[data-gn-tuner-panel] #gnTunerPanel .gn-tp-header { gap: 8px; }
html[data-gn-tuner-panel] #gnTunerFace { flex: 0 1 auto; margin-left: auto; }
html[data-gn-tuner-panel] #gnTunerFace > button { min-height: 44px; min-width: 64px; font-size: 14px; padding: 2px 8px; }

/* ---------- shared: Listen is one big switch, A= and transposition are small chips ---------- */
html[data-gn-tuner-panel] .gnw-tuner-row { display: block; margin-top: 0; }
html[data-gn-tuner-panel] #gnwTunerListen {
  width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 19px; font-weight: 800;
}
html[data-gn-tuner-panel] #gnwTunerListen svg { width: 24px; height: 24px; }
html[data-gn-tuner-panel] .gn-tp-listen-word { order: -1; }
html[data-gn-tuner-panel] #gnwTunerListen[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--gnw-mt-green, #7BE39A), 0 0 10px rgba(47,158,87,.45); }
html[data-gn-tuner-panel] #gnwTuningBay .gnw-choice-row { gap: 4px; margin-top: 8px; }
html[data-gn-tuner-panel] #gnwTuningBay .gnw-choice-row > button { min-height: 44px; min-width: 44px; font-size: 14px; padding: 2px 4px; }
html[data-gn-tuner-panel] .gn-tp-chip-label { display: block; margin: 10px 0 -4px 2px; font-size: 12px; }

/* ---------- the Tuner's own panel ---------- */
html[data-gn-tuner-panel] #gnTunerPanel {
  /* Keys' dock is display: contents in the Glow look, so the panel floats on its own: bottom left, above the bar. */
  position: fixed; left: 16px; bottom: 88px; z-index: 100; /* above the page-turn zones (3), under the Toolkit fan (109) */
  width: min(340px, calc(100vw - 32px)); max-height: calc(100vh - 120px); overflow-y: auto;
  box-sizing: border-box; padding: 10px 12px 12px; pointer-events: auto;
}
html[data-gn-tuner-panel] #gnTunerPanel[hidden] { display: none !important; }
html[data-gn-tuner-panel] #gnTunerPanel .gn-tp-header { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
html[data-gn-tuner-panel] #gnTunerPanel .gn-tp-close { min-width: 44px; min-height: 44px; }
html[data-gn-tuner-panel] #gnTunerPanel #gnwTuningBay { display: block; margin: 0; padding: 0; border: 0; background: none; }
html[data-gn-tuner-panel] #gnTunerPanel #gnwTuningBay[hidden] { display: none; }
html[data-gn-tuner-panel] #gnTunerPanel .gnw-tuning-head { order: 2; }
/* "Tuning" repeats the panel title here; it stays as the region's name for screen readers. */
html[data-gn-tuner-panel] #gnTunerPanel #gnwTuningTitle {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
html[data-gn-tuner-panel] #gnTunerPanel .gnw-tuning-head { justify-content: flex-end; margin-top: 8px; }
html[data-gn-tuner-panel] #gnTunerPanel #gnwTuningBay { display: flex; flex-direction: column; }
html[data-gn-tuner-panel] #gnTunerPanel #gnwTuningBay[hidden] { display: none; }
html[data-gn-tuner-panel] #gnTunerPanel #gnTunerBig { order: 0; margin-top: 2px; }
html[data-gn-tuner-panel] #gnTunerPanel .gnw-tuner-row { order: 1; }
html[data-gn-tuner-panel] #gnTunerPanel .gn-tp-chip-label { order: 3; }
html[data-gn-tuner-panel] #gnTunerPanel .gnw-choice-row { order: 3; }
html[data-gn-tuner-panel] #gnTunerPanel .gnw-tuning-head { order: 4; }
html[data-gn-tuner-panel] #gnTunerPanel .gnw-reference-key { min-height: 44px; min-width: 112px; }

@media (prefers-reduced-motion: reduce) {
  html[data-gn-tuner-panel] .gn-tp-needle,
  html[data-gn-tuner-panel] #gnTunerBig .gn-tp-arrow svg { transition: none; }
}

/* The panel hides with the reader chrome, as Keys does (it stays laid out, so the tuner keeps listening, as the
   shipped Keys tuner does). */
body.reader-focus.reader-chrome-hidden:not(.annotation-mode) #gnTunerPanel { opacity: 0 !important; visibility: hidden !important; pointer-events: none !important; }
