/* Tuner screen: pitch (reading + gauge + player feel) and lugs. */

.tuner { padding-bottom: var(--s4); }

/* ------------------------------------------------------------ setup rows */
.tuner-modes { flex: none; width: 172px; }

.drum-chips > .tuner-editkit {
  flex: none;
  display: inline-flex; flex-direction: row; align-items: center; gap: 6px;
  min-height: var(--hit);
  padding: 0 var(--s4);
  background: var(--white);
  font: 700 var(--t-control)/1 var(--label-font);
  letter-spacing: .05em;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px;
  white-space: nowrap;
  scroll-snap-align: start;
}
.drum-chips > .tuner-editkit .icon { width: 12px; height: 12px; }
/* scrolled: a chip cut at the left edge fades out like the right edge does,
   instead of leaving a sliver with one stray glyph */
.drum-chips.is-scrolled {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}
.drum-chips.is-scrolled.is-end {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 24px);
  mask-image: linear-gradient(to right, transparent, #000 24px);
}

.tuner-headrow { position: relative; }

/* --------------------------------------------------------------- reading
   Nothing above the gauge changes height between idle and a reading: the
   caption and the Hz line hold their place unseen (.is-off), and the status
   slot is as tall as the tallest line it can show. */
.tuner-read { display: flex; flex-direction: column; }
.tuner-cap.is-off, #gauge-note.is-off { visibility: hidden; }
.tuner-mon {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s2);
  min-height: 104px;
}
.tuner-mon .monitor { min-width: 0; }
.tuner-mon .monitor.is-idle .unit { visibility: hidden; }
.tuner-mon .monitor.is-idle b { color: var(--ink60); }
.tuner-dir {
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
  padding-bottom: 8px;
  text-align: right;
}
.tuner-dir .dir { white-space: nowrap; }
/* The Hz line wraps the target under the reading on narrow phones. The note
   box is always as wide as the longest reading ("388.7 Hz · C#4", 14 glyphs),
   so whether it wraps depends on the width and the target, never on the
   reading: a C4 to C#4 flip can't move the gauge. */
.tuner-hzline {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  column-gap: var(--s1); row-gap: 4px;
  margin-top: 10px;
}
.tuner-hzline:not(:has(> :not(.hidden))) { display: none; }
#gauge-note {
  min-width: calc(14ch - 14 * .02em);
  font: 700 22px/1.15 var(--mono-font);
  letter-spacing: -.02em;
  white-space: nowrap;
}
#gauge-note .tuner-note { font-weight: 400; color: var(--ink60); }
.tuner-hzline #gauge-target {
  margin-left: auto;
  font: 600 var(--t-control)/1.2 var(--label-font);
  letter-spacing: .04em;
  color: var(--ink60);
  white-space: nowrap;
}
.tuner-status { margin-top: var(--s2); }
.tuner-status, .tuner-slot__size { font: 400 var(--t-body)/1.4 var(--mono-font); text-wrap: pretty; }
/* the sizers and the live line share one grid cell: the cell keeps the
   tallest sizer's height whatever the live line says */
.tuner-slot { display: grid; margin-top: var(--s2); }
.tuner-slot > * { grid-area: 1 / 1; }
.tuner-slot > .tuner-status { margin-top: 0; }
.tuner-slot__size { visibility: hidden; }
.tuner-pair { font: 400 var(--t-label)/1.4 var(--mono-font); color: var(--ink60); text-wrap: pretty; }

/* a reading older than --d-stale steps back to secondary ink (never opacity on text) */
.tuner-read.is-stale :is(#gauge-cents, .unit, #gauge-state, #gauge-note) { color: var(--ink60); transition: color 200ms linear; }

.tuner-notarget { display: flex; align-items: center; min-height: 64px; }
.tuner-notarget p { font: 400 var(--t-body)/1.4 var(--mono-font); }

/* ----------------------------------------------------------------- gauge */
.gauge-card { position: relative; height: var(--h-gauge); padding: 11px 12px; }
.gauge-stage { height: 150px; }
.gauge-stage svg { display: block; width: 100%; height: 100%; overflow: visible; }
.gauge-legend {
  position: absolute; top: 10px; left: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  font: 400 var(--t-caption)/1 var(--mono-font);
  color: var(--green-ink);
}
.gauge-legend i { width: 14px; height: 10px; background: var(--green); }
.gauge-end {
  position: absolute; bottom: 10px;
  font: 700 var(--t-label)/1 var(--label-font);
  letter-spacing: .08em;
}
.gauge-end--flat { left: 12px; }
.gauge-end--sharp { right: 12px; }

.g-track { fill: none; stroke: var(--tint); stroke-width: 12; }
.g-zone { fill: none; stroke: var(--green); stroke-width: 12; }
.g-cap { fill: none; stroke: var(--ink); stroke-width: 3; }
.g-tick { stroke: var(--ink); stroke-width: 1; }
.g-tick--major { stroke-width: 2; }
/* 13 user units = 11.5 CSS px at the 150 px stage (scale 150/170) */
.g-label { font: 400 13px var(--mono-font); fill: var(--ink60); }
.g-hand line { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.g-pin { fill: var(--ink); }
.g-pivot { fill: var(--ink); }
.g-hand.is-stale { opacity: .4; }
.g-hand.is-idle { opacity: .25; }

/* ---------------------------------------------------------- player feel */
.tuner-feel { display: flex; flex-direction: column; gap: var(--s2); }
.tuner-feel .sec-head { justify-content: space-between; }
.tuner-feel .sec-head__aside { font: 600 var(--t-label)/1.2 var(--label-font); letter-spacing: .06em; }
.tuner-feel__seg > button { gap: 4px; padding: 6px 2px; }
/* four feels share the width; NONE closes the row at tap-target width */
.tuner-feel__seg { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)) var(--hit); }
.fr-name { font: 400 18px/1 var(--display-font); letter-spacing: .02em; white-space: nowrap; }
.tuner-feel__seg > .feel-none { padding: 6px 0; font: 700 var(--t-label)/1 var(--label-font); letter-spacing: .06em; }
/* JORDISON needs a 69 px cell at 18 px: below 390 px the names step down */
@media (max-width: 389px) {
  .fr-name { font-size: 16px; }
}
/* narrowest phones: NONE takes its own row under the four feels */
@media (max-width: 359px) {
  .tuner-feel__seg { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tuner-feel__seg > .feel-none { grid-column: 1 / -1; min-height: var(--hit); border-left: 0; border-top: var(--border); }
}

/* ------------------------------------------------------------------ lugs */
/* card padding 12/14 (spec 3) and 8 px between blocks: at 390 x 763 the
   outcome line under the cells clears the START OVER bar at rest */
.lug-panel { display: flex; flex-direction: column; gap: var(--s2); padding: 12px 14px; }

/* top row: label, pass progress, then the lug count stepper (− N +,
   remembered per drum). The progress chip lives here, not over the verdict,
   so the verdict column is no taller than the ring. */
.lug-count { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.lug-count__label {
  flex: 1 1 0; min-width: 0;
  font: 600 var(--t-label)/1.15 var(--label-font);
  letter-spacing: .08em;
  color: var(--ink60);
  text-wrap: balance;
}
.lug-count .lug-progress { flex: none; }
/* narrowest phones: the label takes its own line over the chip + stepper */
@media (max-width: 359px) {
  .lug-count { flex-wrap: wrap; row-gap: var(--s2); }
  .lug-count__label { flex-basis: 100%; }
}
.lug-count__ctl {
  flex: none;
  display: grid; grid-template-columns: var(--hit) 48px var(--hit);
  border: var(--border);
  background: var(--white);
  box-shadow: var(--sh-ctl);
}
.lug-count__btn {
  display: grid; place-items: center;
  min-width: var(--hit); min-height: var(--hit);
  background: var(--white); color: var(--ink);
}
.lug-count__btn .icon { width: 18px; height: 18px; }
.lug-count__btn:active { background: var(--tint); }
.lug-count__btn[aria-disabled="true"] { background: var(--cream3); color: var(--ink60); cursor: default; }
.lug-count__n {
  display: grid; place-items: center;
  border-inline: var(--border);
  font: 700 20px/1 var(--mono-font);
}

.lug-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); align-items: center; }
/* ring geometry mirrors lugGeom() in tuner.js: 132 box, slots 26 (<= 10 lugs),
   22 (11-12), and a 148 box with 20 px slots (13-16) */
.lug-ring { position: relative; width: 132px; height: 132px; }
.lug-ring::before, .lug-ring::after {
  content: ''; position: absolute; border-radius: 50%;
}
.lug-ring::before { inset: 14px; border: var(--border); }
.lug-ring::after { inset: 32px; border: 1px solid var(--rule); }
.lug-ring--m::before { inset: 12px; }
.lug-ring--m .lug-dot { width: 22px; height: 22px; font-size: 12px; }
.lug-ring--s { width: 148px; height: 148px; }
.lug-ring--s::before { inset: 11px; }
.lug-ring--s::after { inset: 36px; }
.lug-ring--s .lug-dot { width: 20px; height: 20px; font-size: var(--t-axis); letter-spacing: -.04em; }
.lug-ring__head {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font: 600 var(--t-label)/1 var(--label-font);
  letter-spacing: .08em;
  color: var(--ink60);
}
.lug-dot {
  position: absolute; z-index: 1;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border: var(--border); border-radius: 50%;
  background: var(--white);
  font: 700 13px/1 var(--mono-font);
}
.lug-dot.is-empty { color: var(--ink60); }
.lug-dot.is-out { background: var(--ink); color: var(--paper); }
.lug-dot.is-next { background: var(--amber); border-style: dashed; }

.lug-verdict {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); min-width: 0;
  container-type: inline-size;
}
.lug-progress { font-family: var(--mono-font); font-weight: 700; letter-spacing: 0; white-space: nowrap; }
.lug-hero { max-width: 100%; }
.lug-hero .hero__cap { margin-bottom: 4px; }
/* the number fits its column: Space Mono glyphs are .6 em, the ¢ and its
   gap take ~20 px; --glyphs (sign + digits) comes from tuner.js */
.lug-hero b {
  display: block;
  font-size: min(var(--t-hero), calc((100cqi - 20px) / (var(--glyphs, 3) * .6)));
}
/* "median 261.4 Hz" (15 glyphs at .612 em) stays on one line in its column:
   14 px where it fits, smaller on the narrowest phones, never under 11 px
   (a 16-lug ring at 320 px leaves too little room: the value then wraps
   under the word) */
.lug-median {
  margin-top: 6px;
  font: 400 var(--t-body)/1.3 var(--mono-font);
  font-size: max(var(--t-axis), min(var(--t-body), calc(100cqi / 9.2)));
}

.lug-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.lug-cell {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0; min-height: 70px;
  padding: 7px 8px;
  border: var(--border);
  background: var(--white);
}
.lug-cell__lab {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 4px; /* "LUG 10 SHARP" wraps at 320 px */
  font: 600 var(--t-caption)/1 var(--label-font);
  letter-spacing: .08em;
  color: var(--ink60);
  white-space: nowrap;
}
/* values sit at the bottom: a cell whose "LUG 6 SHARP" wraps keeps its Hz
   and ¢ level with the rest of the row */
.lug-cell b { margin-top: auto; font: 700 20px/1.1 var(--mono-font); letter-spacing: -.02em; white-space: nowrap; }
.lug-cell i { font: 700 var(--t-control)/1 var(--mono-font); font-style: normal; white-space: nowrap; }
.lug-cell.is-empty b { font: 700 var(--t-control)/1.45 var(--label-font); letter-spacing: .05em; }
.lug-cell.is-empty i { color: var(--ink60); }
.lug-cell.is-next { border-style: dashed; }
.lug-cell.is-out { background: var(--ink); color: var(--paper); }
.lug-cell.is-out .lug-cell__lab { color: var(--paper); }
.lug-cell__word { color: var(--amber); }
.lug-line { font: 400 var(--t-body)/1.4 var(--mono-font); text-wrap: pretty; }
