/* ============================================================
   Cadence — time on the dial, sound underneath.
   Sweep's analog clockface (live time + focus-block wedge)
   over Murmur's synthesized soundscape. Warm, calm, analog.
   ============================================================ */

:root {
  --bg:        #17130f;
  --bg-vignette:#0d0a07;
  --face-hi:   #221c16;
  --face-lo:   #18130e;
  --bezel:     #2c241b;
  --tick:      #6b5d4c;
  --tick-major:#b9a585;
  --numeral:   #cdbb9c;
  --hand:      #e9dcc4;
  --hand-hour: #d8c6a6;
  --second:    #e0913a;
  --cap:       #e9dcc4;
  --cap-dot:   #17130f;

  --sand:      #d8a84a;
  --amber:     #e0913a;
  --text:      #e9dcc4;
  --muted:     #9c8b72;
  --faint:     #6b5d4c;
  --btn:       #261e16;
  --btn-hi:    #33291d;
  --line:      #463a2a;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: radial-gradient(120% 120% at 50% 32%, var(--bg) 0%, var(--bg-vignette) 100%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Inter, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

main {
  min-height: 100%;
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.6vh, 14px);
  padding: calc(12px + env(safe-area-inset-top, 0px))
           calc(20px + env(safe-area-inset-right, 0px))
           calc(16px + env(safe-area-inset-bottom, 0px))
           calc(20px + env(safe-area-inset-left, 0px));
}

button {
  font: inherit;
  color: var(--text);
  background: var(--btn);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s ease, border-color .2s ease, color .2s ease, transform .08s ease;
}
button:hover  { background: var(--btn-hi); }
button:active { transform: translateY(1px); }

header { line-height: 1; }
h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: .14em; color: var(--muted); }

/* ---------------- the dial ---------------- */

#dial-wrap {
  cursor: pointer;
  border-radius: 50%;
  outline-offset: 6px;
  transition: filter .8s ease;
}
.dial { width: min(86vw, 46vh); max-width: 390px; height: auto; display: block; }

.bezel { fill: var(--bezel); }
.face  { stroke: rgba(0,0,0,.25); stroke-width: 1; }

.tick       { stroke: var(--tick); stroke-width: 2; stroke-linecap: round; }
.tick.major { stroke: var(--tick-major); stroke-width: 4; }

.numeral {
  fill: var(--numeral);
  font-size: 26px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: central;
  font-variant-numeric: tabular-nums;
}

.hand rect { fill: var(--hand); }
.hand.hour rect { fill: var(--hand-hour); }
.hand.second rect, .hand.second .tail { fill: var(--second); }
.cap     { fill: var(--cap); }
.cap-dot { fill: var(--cap-dot); transition: fill .5s ease; }
.hand { transform-box: view-box; transform-origin: 200px 200px; }

body[data-playing="on"] .cap-dot { fill: var(--amber); }
body[data-playing="on"] #dial-wrap {
  animation: dialbreathe 4.5s ease-in-out infinite;
}
@keyframes dialbreathe {
  0%, 100% { filter: drop-shadow(0 0 14px rgba(224, 145, 58, .10)); }
  50%      { filter: drop-shadow(0 0 30px rgba(224, 145, 58, .26)); }
}

/* focus-block arc on the minute dial — visible only while a block runs */
#arc-layer { display: none; }
body[data-block="running"] #arc-layer { display: inline; }
.arc       { fill: var(--sand); fill-opacity: .30; }
.arc-ghost { fill: none; stroke: var(--tick-major); stroke-width: 11; stroke-linecap: round; opacity: .26; }
.arc-rim   { fill: none; stroke: var(--sand); stroke-width: 11; stroke-linecap: round; opacity: .95; }
.mark { stroke-linecap: round; }
.mark.start { stroke: var(--tick-major); stroke-width: 5; opacity: .9; }
.mark.end   { stroke: var(--sand); stroke-width: 6; }

/* ---------------- under-dial readout ---------------- */

#under-dial {
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#readout {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--sand);
  font-variant-numeric: tabular-nums;
}
#readout[hidden] { display: none; }
#readout.ending { color: var(--amber); }
#hint { color: var(--muted); font-size: 13px; transition: opacity .4s ease; }
body[data-playing="on"] #hint { opacity: 0; }

/* ---------------- rows ---------------- */

.row-label { color: var(--faint); font-size: 12.5px; letter-spacing: .08em; }

#block-row, #presets, #chtoggles, #level-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.b-chip {
  min-width: 44px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.b-chip.is-active {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 55%, var(--line));
  background: var(--btn-hi);
}

.p-chip { padding: 7px 13px; border-radius: 999px; font-size: 13.5px; color: var(--muted); }
.p-chip.is-active {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 55%, var(--line));
  background: var(--btn-hi);
}

.ch-toggle {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--faint);
}
.ch-toggle[aria-pressed="true"] {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 45%, var(--line));
}
.ch-toggle svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------- master level ---------------- */

#level-row { max-width: 340px; gap: 12px; flex-wrap: nowrap; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 24px;
  margin: 0;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right,
    var(--amber) 0 calc(var(--val, 0) * 1%),
    var(--line)  calc(var(--val, 0) * 1%) 100%);
}
input[type="range"]::-moz-range-track    { height: 4px; border-radius: 2px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--amber); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text);
  border: 1px solid #0d0a07;
  margin-top: -8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text);
  border: 1px solid #0d0a07;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}

footer {
  color: var(--faint);
  font-size: 11.5px;
  letter-spacing: .06em;
  margin-top: auto;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  body[data-playing="on"] #dial-wrap {
    animation: none;
    filter: drop-shadow(0 0 18px rgba(224, 145, 58, .18));
  }
}
