/* vocal-tuner/vocal-tuner.css: the Vocal Tuner's layout. Page parts (header,
 * buttons, windows, footer) come from shared/ui/page.css. No panels: the wave
 * ball (a canvas) fills the middle, the note sits in it. */

.tool-title { white-space: nowrap; overflow: hidden; }
.tool-title.two-lines { white-space: normal; line-height: 1.2; }

.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; }

.tuner {
  position: relative; min-height: 0;
  display: grid; grid-template-rows: minmax(0, 1fr) auto auto auto; justify-items: center; align-items: center;
}
/* Computers: the tuner is centred in the window with a capped height, so Listen
   is never at the window's bottom edge (phones keep it under the thumb). */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .page > main.tuner { flex: 0 1 auto; height: min(580px, calc(100dvh - 180px)); margin-block: auto; }
}

.ball { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage, .readout, .listen-btn, .say { position: relative; }
.stage { align-self: stretch; justify-self: stretch; display: flex; align-items: center; justify-content: center; min-height: 0; }

/* The note: its name big, the octave small beside it. Colour eases into the accent in tune. */
.note {
  margin: 0; display: flex; align-items: flex-start; line-height: 1; white-space: nowrap;
  font-family: var(--font-display); font-weight: 800; font-size: var(--note-size, clamp(64px, min(26vw, 15dvh), 150px));
  color: var(--color-text); transition: color 0.25s;
  text-shadow: 0 0 18px var(--bg-page), 0 0 6px var(--bg-page);
}
.note .acc { width: 0.36em; height: 0.58em; margin: 0.06em 0 0 0.05em; }
.note .oct { font-size: 0.26em; margin: 0.12em 0 0 0.12em; opacity: 0.6; }
.tuner.in-tune .note, .tuner.in-tune .say { color: var(--color-tune); }
/* Monochrome has no accent colour: off the note is grey, in tune it lights up white (with the ring). */
body[data-theme="bw"] .tuner.has-note:not(.in-tune) :is(.note, .say) { color: var(--color-tune-line); }

/* No note: a prompt inside the resting ball. Before listening, the ball starts it. */
.prompt {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0;
  width: var(--prompt-w, 60%); text-align: center; font-size: 18px; line-height: 1.3;
  color: var(--color-text); text-shadow: 0 0 12px var(--bg-page), 0 0 4px var(--bg-page); pointer-events: none;
}
.tuner.idle .stage { cursor: pointer; }

.readout { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 6px 0 18px; }
.say { margin: 0; min-height: 1.3em; font-size: 16px; line-height: 1.3; text-align: center; transition: color 0.25s; }

/* The thin line: a notch in the middle, the dot slides ±50 cents. */
.line { position: relative; width: min(260px, 70vw); height: 1px; background: color-mix(in srgb, var(--color-text) 35%, transparent); }
.notch { position: absolute; left: 50%; top: -7px; width: 1px; height: 15px; background: var(--color-text); }
/* The in-tune zone (±10 cents, or ±5 in Hard mode: --tol is set in JS). */
.zone {
  position: absolute; left: calc(50% - var(--tol, 10%)); width: calc(2 * var(--tol, 10%)); top: -1px; height: 3px; border-radius: 2px;
  background: color-mix(in srgb, var(--color-text) 45%, transparent); transition: background 0.25s, left 0.25s, width 0.25s;
}
.tuner.in-tune .zone { background: var(--color-tune); }
.dot {
  position: absolute; left: var(--at, 50%); top: -6px; width: 13px; height: 13px; margin-left: -6.5px; border-radius: 50%;
  background: var(--color-tune-line); opacity: 0; transition: opacity 0.2s, background 0.25s;
}
.tuner.has-note .dot { opacity: 1; }
.tuner.in-tune .dot { background: var(--color-tune); box-shadow: 0 0 12px var(--color-tune); }

/* The main button, at the bottom. */
.listen-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: min(260px, 70vw); 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); } }
.listen-btn svg { width: 20px; height: 20px; flex: none; }
.listen-btn .stop-icon, .listen-btn.on .mic-icon { display: none; }
.listen-btn.on .stop-icon { display: block; }
.mic-msg { max-width: 30em; text-align: center; }

/* 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 { 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, .zone) { border-radius: 0; }

/* Phones: everything on one screen; line heights pinned (theme fonts differ a lot in height). */
@media (max-width: 600px) {
  .readout { gap: 16px; padding-bottom: 14px; }
  .say { font-size: 15px; line-height: 1.25; }
  .prompt { font-size: 16px; line-height: 1.25; }
  .listen-btn { min-height: 46px; margin-bottom: 4px; }
}
