/* pitch-detector/pitch-detector.css: the Pitch Detector's layout. Page parts
 * (header, buttons, windows, footer) come from shared/ui/page.css. No panels:
 * the note and its cents on one line at the top, the graph (a canvas) filling
 * the middle, Start/Stop and Pause at the bottom. */

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tool-title { white-space: nowrap; overflow: hidden; }
.tool-title.two-lines { white-space: normal; line-height: 1.2; }

.detector { min-height: 0; display: grid; grid-template-rows: auto minmax(160px, 1fr) auto; gap: 8px; }
/* Computers: the buttons above the graph, never at the window's bottom edge (phones keep them under the thumb). */
@media (min-width: 700px) and (hover: hover) and (pointer: fine) {
  .detector { grid-template-rows: auto auto minmax(160px, 1fr); }
  .detector > .controls { grid-row: 2; }
  .detector > .graph { grid-row: 3; }
}

/* The note you sing and a plain number: La4 · −12 cents. Nothing changes colour. */
.readout {
  margin: 0; height: clamp(46px, 8dvh, 64px); display: flex; align-items: center; justify-content: center; gap: 0.5em;
  white-space: nowrap; color: var(--color-text);
}
.note { display: flex; align-items: flex-start; font-family: var(--font-display); font-weight: 800; font-size: clamp(34px, 6.5dvh, 52px); line-height: 1; }
.note .acc { width: 0.36em; height: 0.58em; margin: 0.06em 0 0 0.05em; }
.note .oct { font-size: 0.34em; margin: 0.1em 0 0 0.1em; opacity: 0.6; }
.cents { font-size: 16px; opacity: 0.85; font-variant-numeric: tabular-nums; }
.cents:not(:empty)::before { content: '·'; margin-right: 0.5em; opacity: 0.6; }
.prompt { font-size: 17px; line-height: 1.25; text-align: center; white-space: normal; }
.readout [hidden] { display: none; }
.mic-msg { font-size: 15px; max-width: 30em; }
/* A microphone message may take a few lines: the top grows, the graph gives way. */
.readout.msg { height: auto; min-height: clamp(46px, 8dvh, 64px); padding: 4px 8px; }

/* The graph fills the middle; the canvas draws the keys, lanes and the line. */
.graph { position: relative; min-height: 0; border-top: 1px solid color-mix(in srgb, var(--color-text) 15%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--color-text) 15%, transparent); }
.graph canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }
.detector.looking .graph canvas { cursor: grab; }

/* Start/Stop, a slim button, and the round Pause beside it while listening. */
.controls { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 6px 0 4px; }
.listen-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: min(240px, 62vw); min-height: 48px; border-radius: var(--radius-control); font-size: 16px;
}
/* The main action is filled; while it runs it turns into an outline. */
.listen-btn.on { background: transparent; color: var(--color-text); border-color: color-mix(in srgb, var(--color-text) 55%, transparent); }
@media (hover: hover) { .listen-btn.on:hover { background: var(--color-hover); color: var(--color-hover-text); } }
.pause-btn {
  width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--color-text); border-color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
.pause-btn[hidden] { display: none; }
.listen-btn svg, .pause-btn svg { width: 20px; height: 20px; flex: none; }
.listen-btn .stop-icon, .listen-btn.on .mic-icon, .pause-btn .play-icon, .pause-btn[aria-pressed="true"] .pause-icon { display: none; }
.listen-btn.on .stop-icon, .pause-btn[aria-pressed="true"] .play-icon { display: block; }

/* Settings: the microphone's level now, and the mark where the sensitivity starts (-70..-10 dBFS). */
.level { position: relative; height: 8px; margin-top: 10px; border-radius: 4px; background: color-mix(in srgb, var(--color-text) 15%, transparent); overflow: hidden; }
.level-fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--level, 0%); background: var(--color-tune); border-radius: 4px; }
.level-mark { position: absolute; top: -2px; bottom: -2px; left: var(--mark, 0%); width: 2px; margin-left: -1px; background: var(--color-text); }
.sens-hint { margin: 8px 0 0; font-size: 12px; line-height: 1.35; opacity: 0.8; }

/* Settings: segmented choices. */
.group-label { font-size: 15px; font-weight: 600; }
.seg { display: flex; border: var(--border-width) solid var(--border-panel); border-radius: var(--radius-control); overflow: hidden; }
.seg button {
  flex: 1 1 0; min-width: 0; min-height: 44px; padding: 4px 8px; border: 0; background: var(--color-panel); color: var(--color-btn-text); cursor: pointer;
  font: 600 14px/1.15 var(--font-main); touch-action: manipulation; transition: background 0.15s ease-out, color 0.15s ease-out;
}
.seg button + button { border-left: 1px solid var(--border-panel); }
.seg button[aria-pressed="true"] { background: var(--color-left); color: var(--color-text-pinched); }
.seg button:focus-visible { outline: 2px solid var(--color-right); outline-offset: -3px; }
@media (hover: hover) and (pointer: fine) {
  .seg button:hover:not([aria-pressed="true"]) { background: var(--color-hover); color: var(--color-hover-text); }
  .listen-btn:hover, .pause-btn:hover { background: color-mix(in srgb, var(--color-text) 12%, transparent); color: var(--color-text); }
}

/* Themes */
body[data-theme="retro"] .note { text-shadow: 0 0 var(--shadow-blur) color-mix(in srgb, currentColor 55%, transparent); }
body[data-theme="y2k"] .note { text-shadow: 0 0 14px color-mix(in srgb, currentColor 55%, transparent); }
body[data-theme="bw"] :is(.seg, .listen-btn) { border-radius: 0; }

/* Phones: everything on one screen; line heights pinned (theme fonts differ a lot in height). */
@media (max-width: 600px) {
  .detector { gap: 6px; }
  .prompt { font-size: 15px; }
  .cents { font-size: 15px; }
  .listen-btn { min-height: 46px; }
  #about-modal .about-text { font-size: 14px; line-height: 1.4; }
  /* Soft Pink's tall font: Settings still fits one screen. */
  body[data-theme="pink"] #settings-modal .seg button { min-height: 40px; }
  body[data-theme="pink"] .sens-hint { line-height: 1.12; }
  .level { margin-top: 8px; }
}
