/* metronome/metronome.css: the Metronome's layout. Page parts (header, panels,
 * buttons, sliders, windows, footer) come from shared/ui/page.css. */

.met { display: grid; gap: 16px; align-content: center; }
@media (min-width: 820px) {
  .met { grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); align-items: start; }
}

.met-main { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }

/* Beat dots: one button per beat; two rows above 6 beats (--cols set in JS). */
.beat-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; width: 100%; max-width: calc(var(--cols, 4) * 56px - 4px); min-height: 44px; }
/* Up to 52px, smaller on narrow phones so a row of 6 always fits. */
.beat-dot { position: relative; flex: 0 0 calc((100% - (var(--cols, 4) - 1) * 4px) / var(--cols, 4)); max-width: 52px; aspect-ratio: 1; padding: 0; background: none; border: none; border-radius: 50%; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.beat-dot::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 24px; height: 24px; box-sizing: border-box;
  transform: translate(-50%, -50%); border-radius: 50%; border: 3px solid var(--color-left); background: transparent;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, width 0.12s, height 0.12s;
}
.beat-dot[data-level="strong"]::before { width: 34px; height: 34px; background: var(--color-left); }
/* The strong beat sounding: a ring around it, so the bar's start is seen at a glance. */
.beat-dot[data-level="strong"].lit::before { box-shadow: 0 0 0 5px color-mix(in srgb, var(--color-right) 45%, transparent), 0 0 16px color-mix(in srgb, var(--color-right) 70%, transparent); }
.beat-dot[data-level="silent"]::before { border: 2px dashed var(--color-text-inactive); }
.beat-dot.lit::before { background: var(--color-right); border-color: var(--color-right); box-shadow: 0 0 14px color-mix(in srgb, var(--color-right) 70%, transparent); animation: beat-pop 0.16s ease-out; }
.beat-dot[data-level="silent"].lit::before { background: transparent; border: 2px dashed var(--color-right); box-shadow: none; }
@keyframes beat-pop { from { transform: translate(-50%, -50%) scale(1.45); } to { transform: translate(-50%, -50%) scale(1); } }
.beat-dot:focus-visible { outline: 2px solid var(--color-right); outline-offset: -2px; }
.hint { margin: -6px 0 0; font-size: 13px; color: var(--color-text-inactive); }

/* The tempo number is an input you can type into (its width follows the digits, set in JS). */
.tempo { display: flex; flex-direction: column; align-items: center; }
.tempo-number { display: flex; flex-direction: column; align-items: center; }
.bpm-input {
  width: 3.3ch; padding: 0; margin: 0; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; color: var(--color-text); font-family: var(--font-num); font-weight: 800; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; font-size: clamp(76px, 24vw, 128px); line-height: 1; text-align: center;
  -moz-appearance: textfield; appearance: textfield;
}
.bpm-input::-webkit-outer-spin-button, .bpm-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.bpm-input:focus { outline: none; border-bottom-color: var(--color-right); }
.bpm-unit { font-size: 14px; font-weight: 700; letter-spacing: 0.12em; color: var(--color-text-inactive); }
.tempo-name { margin: 8px 0 0; font-size: 16px; min-height: 1.4em; }
.tempo-word { color: var(--color-right); font-weight: 700; }

.tempo-row { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 460px; }
.big-row { display: flex; gap: 12px; width: 100%; max-width: 460px; }
.big-btn { flex: 1; min-height: 68px; font-size: 20px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.big-btn svg { width: 22px; height: 22px; }
#start-btn .stop-icon, #start-btn.playing .play-icon { display: none; }
#start-btn.playing .stop-icon { display: block; }
#start-btn.playing { box-shadow: 0 8px 22px -8px color-mix(in srgb, var(--color-primary) 80%, transparent); }
#tap-btn.tapped { animation: tap-flash 0.18s ease-out; }
@keyframes tap-flash { from { background: var(--color-left); color: var(--color-text-pinched); } }

.met-settings { padding-top: 6px; padding-bottom: 14px; }
/* Dropdowns sit under their label; on phones the two share one row. */
.select-pair { border-top: 1px solid color-mix(in srgb, var(--border-panel) 50%, transparent); }
.setting-row.stacked { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 0; }
.setting-row.stacked .custom-select { min-width: 0; }
.stepper { display: flex; align-items: center; gap: 10px; }
.round-btn.small { width: 44px; height: 44px; font-size: 22px; }
.stepper output { min-width: 2ch; text-align: center; font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 700; }

/* Volume: 0–200%. Above 100% the track, thumb, number and note go from
   --color-warn-start to --color-warn-end (set in JS). */
.volume { padding-top: 12px; border-top: 1px solid color-mix(in srgb, var(--border-panel) 50%, transparent); }
.volume-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.volume-head > label { margin-right: auto; }
#volume-out { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 19px; font-weight: 700; color: var(--vol-color, var(--color-text)); }
.volume-track { position: relative; padding-bottom: 18px; }
.volume-track .range { display: block; position: relative; z-index: 1; }
.volume-mark { position: absolute; left: 50%; top: -6px; width: 2px; height: 20px; margin-left: -1px; background: var(--color-text-inactive); }
.volume-mark-label { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); font-size: 12px; color: var(--color-text-inactive); }
.volume-note { font-size: 13px; font-weight: 700; color: var(--vol-color); }

/* Phones: the whole Metronome fits on one screen (about 375 × 667 and up).
   The number and the big buttons grow with the screen's height. */
@media (max-width: 600px) {
  .met { gap: 6px; }
  .met-main { gap: clamp(5px, 1dvh, 12px); }
  /* Line heights are pinned: theme fonts differ a lot in height (Literata, Nunito). */
  .hint { margin: -2px 0 0; font-size: 13px; line-height: 1.25; }
  .tempo-number { flex-direction: row; align-items: baseline; gap: 6px; }
  .bpm-input { font-size: clamp(50px, 9.5dvh, 112px); height: 1.05em; }
  .bpm-unit { font-size: 13px; letter-spacing: 2px; }
  .tempo-name { margin-top: 2px; font-size: 14px; line-height: 1.3; }
  .round-btn { width: 44px; height: 44px; }
  .big-btn { min-height: clamp(46px, 7dvh, 68px); font-size: 18px; }
  /* Retro CRT's monospace is wide: "Batti il tempo" stays on one line. */
  body[data-theme="retro"] .big-btn { font-size: 15px; letter-spacing: -0.02em; padding-inline: 8px; }
  .beat-dots.two-rows { max-width: calc(var(--cols) * 42px - 4px); }
  .beat-dots.two-rows .beat-dot { max-width: 38px; }
  .met-settings { padding-top: 2px; padding-bottom: 6px; }
  .select-pair { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); column-gap: 10px; }
  .select-pair > .setting-row + .setting-row { border-top: none; }
  .setting-row.stacked { padding: 8px 0; gap: 5px; }
  .setting-row.stacked > label { font-size: 13px; line-height: 1.2; }
  .setting-label, .stepper output, #volume-out { line-height: 1.2; }
  .select-pair .select-selected { padding: 10px 30px 10px 12px; font-size: 14px; line-height: 1.2; }
  .select-pair .select-selected:after { right: 12px; }
  .volume { padding-top: 6px; }
  .volume-head { margin-bottom: 8px; }
  .volume-track { padding-bottom: 14px; }
  .volume-mark-label { top: 14px; font-size: 12px; line-height: 1; }
}

body[data-theme="pink"] .beat-dot[data-level="strong"]:not(.lit)::before { box-shadow: 0 2px 8px color-mix(in srgb, var(--color-left) 50%, transparent); }

/* Reduce motion: the beat still lights up, without the pop. */
@media (prefers-reduced-motion: reduce) {
  .beat-dot.lit::before { animation: none; }
}
