/* Hush components. Read only role tokens: bg, surface, ink, muted, accent, on-accent, track.
   Mood swatches are the one exception (--swatch). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
svg { display: block; }
[hidden] { display: none !important; }

.hush-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.hush-screen, .hush-screen * {
  transition: background-color var(--fade-colors), color var(--fade-colors), border-color var(--fade-colors);
}

.hush-content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-7) var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* Header */
.hush-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.hush-brand { display: flex; flex-direction: column; gap: var(--space-1); }
.hush-wordmark { margin: 0; font-size: 24px; line-height: 28px; font-weight: 500; letter-spacing: -0.02em; }
.hush-mood { font-size: 13px; line-height: 18px; color: var(--muted); }
.hush-actions { display: flex; gap: var(--space-2); }
.hush-chip {
  appearance: none; border: 0;
  height: var(--hit-target); padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: 15px; line-height: 20px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.hush-chip svg { width: 24px; height: 24px; flex: none; }

/* Type */
.hush-heading, .hush-panel-title { margin: 0; font-size: 18px; line-height: 24px; font-weight: 500; }
.hush-body { margin: 0; font-size: 16px; line-height: 24px; color: var(--muted); }
.hush-caption { margin: 0; font-size: 13px; line-height: 18px; color: var(--muted); min-height: 18px; }
.hush-center { text-align: center; }
.hush-error { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink); }

/* Panels */
.hush-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-4);
}
.hush-intro { gap: var(--space-1); }
.hush-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin: -10px 0; }
.hush-text-btn {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  height: var(--hit-target); padding: 0 var(--space-2); margin-right: calc(var(--space-2) * -1);
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: 15px; line-height: 20px; font-weight: 500;
}
.hush-text-btn svg { width: 24px; height: 24px; }

/* Sound groups and tiles */
.hush-groups { display: flex; flex-direction: column; gap: var(--space-6); }
.hush-group { display: flex; flex-direction: column; gap: var(--space-3); }
.hush-tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.hush-tile {
  appearance: none; border: 0; text-align: left;
  min-height: var(--button-height); padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface); color: var(--ink);
  display: flex; align-items: center; gap: var(--space-2);
  font-size: 15px; line-height: 20px; font-weight: 500;
  min-width: 0; overflow-wrap: anywhere;
}
.hush-tile[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.hush-swatch {
  width: 12px; height: 12px; flex: none; box-sizing: content-box;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background: var(--swatch, var(--accent));
}
.hush-tile[aria-pressed="true"] .hush-swatch { border-color: var(--on-accent); }

/* Sliders: a native range over a drawn track, so the fill works in every engine. */
.hush-sliders { display: flex; flex-direction: column; gap: var(--space-4); }
.hush-slider { display: flex; flex-direction: column; }
.hush-slider-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.hush-slider-name { font-size: 15px; line-height: 20px; font-weight: 500; }
.hush-slider-value { font-size: 13px; line-height: 18px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hush-slider-ends { display: flex; justify-content: space-between; margin-top: -6px; font-size: 13px; line-height: 18px; color: var(--muted); }
.hush-range-wrap { position: relative; height: var(--hit-target); color: var(--ink); }
.hush-range-track, .hush-range-fill {
  position: absolute; left: 0; top: 20px; height: var(--track-height);
  border-radius: var(--radius-full);
}
.hush-range-track { right: 0; background: var(--track); }
.hush-range-fill {
  --fill: 0.5;
  width: calc(var(--thumb-size) / 2 + (100% - var(--thumb-size)) * var(--fill));
  background: var(--accent);
}
.hush-range {
  -webkit-appearance: none; appearance: none;
  position: absolute; inset: 0;
  width: 100%; height: var(--hit-target); margin: 0; padding: 0;
  background: transparent; cursor: pointer; touch-action: pan-y;
}
.hush-range::-webkit-slider-runnable-track { height: var(--hit-target); background: transparent; border: 0; }
.hush-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--thumb-size); height: var(--thumb-size); margin-top: 11px;
  border-radius: var(--radius-full); background: currentColor; border: 0;
}
.hush-range::-moz-range-track { height: var(--hit-target); background: transparent; border: 0; }
.hush-range::-moz-range-thumb {
  width: var(--thumb-size); height: var(--thumb-size);
  border-radius: var(--radius-full); background: currentColor; border: 0;
}
.hush-range:focus { outline: none; }
.hush-range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
.hush-range:focus-visible::-moz-range-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Bottom bar: Start in thumb reach */
.hush-bottom-bar {
  position: sticky; bottom: 0;
  border-top: 1px solid var(--track);
  background: var(--bg);
}
.hush-bottom-inner {
  max-width: var(--content-max); margin: 0 auto;
  padding: var(--space-4) var(--space-5) max(var(--space-5), env(safe-area-inset-bottom));
}
.hush-start {
  appearance: none; border: 0;
  width: 100%; height: var(--button-height);
  border-radius: var(--radius-md);
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-size: 15px; line-height: 20px; font-weight: 500;
  transition: transform 120ms ease, background-color var(--fade-colors), color var(--fade-colors);
}
.hush-start svg { width: 24px; height: 24px; }
.hush-start .hush-icon-pause { display: none; }
.hush-start[aria-pressed="true"] .hush-icon-pause { display: block; }
.hush-start[aria-pressed="true"] .hush-icon-play { display: none; }
.hush-start:active:not(:disabled) { transform: scale(0.98); }
.hush-start:disabled { background: var(--surface); color: var(--muted); }

/* Sheets: native dialogs that rise from the bottom */
.hush-sheet {
  width: 100%; max-width: var(--content-max);
  max-height: min(88dvh, 760px);
  margin: auto auto 0; padding: 0; border: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--surface); color: var(--ink);
  overflow: hidden;
}
.hush-sheet[open] { display: flex; animation: hush-rise 280ms ease-out; }
.hush-sheet::backdrop { background: rgba(0, 0, 0, 0.4); animation: hush-dim 280ms ease-out; }
.hush-sheet-body {
  flex: 1; min-height: 0; width: 100%;
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-2) var(--space-5) max(var(--space-5), env(safe-area-inset-bottom));
}
.hush-sheet-grabber { flex: none; width: 36px; height: 5px; border-radius: var(--radius-full); background: var(--track); align-self: center; }
.hush-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-right: calc(var(--space-2) * -1); }
.hush-sheet-title { margin: 0; font-size: 28px; line-height: 34px; font-weight: 500; letter-spacing: -0.01em; }
.hush-sheet-intro { display: flex; flex-direction: column; gap: var(--space-1); }
.hush-sheet-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: var(--space-5);
  padding: var(--space-2) 0 var(--space-2);
  scrollbar-width: none;
}
.hush-sheet-scroll::-webkit-scrollbar { display: none; }
.hush-close {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  width: var(--hit-target); height: var(--hit-target); border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
}
.hush-close svg { width: 24px; height: 24px; }

/* Presets */
.hush-preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.hush-preset {
  appearance: none; text-align: left;
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--radius-md);
  background: var(--bg); color: var(--ink);
  border: 2px solid var(--bg);
  min-width: 0;
}
.hush-preset[aria-pressed="true"] { border-color: var(--accent); }
.hush-bars { display: flex; gap: var(--space-1); }
.hush-bars span { width: 28px; height: 8px; border-radius: var(--radius-sm); background: var(--swatch); }
.hush-preset-text { display: flex; flex-direction: column; gap: var(--space-1); }
.hush-preset-name { font-size: 15px; line-height: 20px; font-weight: 500; }
.hush-preset-sounds { font-size: 13px; line-height: 18px; color: var(--muted); }

/* Timer options */
.hush-options { margin: 0; padding: 0; border: 0; border-top: 1px solid var(--track); display: flex; flex-direction: column; }
.hush-option {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  height: var(--button-height); border-bottom: 1px solid var(--track); cursor: pointer;
  font-size: 15px; line-height: 20px; font-weight: 500;
}
.hush-option input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.hush-radio {
  width: 22px; height: 22px; flex: none; border-radius: var(--radius-full);
  border: 2px solid var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.hush-option input:checked + .hush-radio { border-color: var(--ink); }
.hush-option input:checked + .hush-radio::after { content: ""; width: 10px; height: 10px; border-radius: var(--radius-full); background: var(--ink); }
.hush-option input:focus-visible + .hush-radio { outline: 2px solid var(--accent); outline-offset: 2px; }
.hush-outline-btn {
  appearance: none; background: transparent; color: var(--ink);
  height: var(--button-height); border-radius: var(--radius-md);
  border: 1px solid var(--track);
  font-size: 15px; line-height: 20px; font-weight: 500;
}

.hush-visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Focus: accent ring, ink on accent fills */
.hush-screen button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hush-screen .hush-start:focus-visible,
.hush-screen .hush-tile[aria-pressed="true"]:focus-visible { outline-color: var(--ink); }

@keyframes hush-rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes hush-dim { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .hush-screen, .hush-screen * { transition: none !important; }
  .hush-sheet[open], .hush-sheet::backdrop { animation: none; }
  .hush-start:active:not(:disabled) { transform: none; }
}

/* Mood swatches: the one place a mood color is painted directly. */
[data-mood="meadow"] { --swatch: var(--meadow-accent); }
[data-mood="concrete"] { --swatch: var(--concrete-accent); }
[data-mood="porch"] { --swatch: var(--porch-accent); }
[data-mood="shore"] { --swatch: var(--shore-accent); }
[data-mood="static"] { --swatch: var(--static-accent); }
[data-mood="dusk"] { --swatch: var(--dusk-accent); }
[data-mood="ember"] { --swatch: var(--ember-accent); }
[data-mood="slate"] { --swatch: var(--slate-accent); }
[data-mood="tide"] { --swatch: var(--tide-accent); }
[data-mood="moss"] { --swatch: var(--moss-accent); }

/* Keep the page still behind an open sheet. */
body:has(dialog[open]) { overflow: hidden; }

/* Narrow phones: Presets goes icon-only, like the iPhone app, so the header stays on one line. */
@media (max-width: 420px) {
  .hush-chip:has(.hush-chip-text) { width: var(--hit-target); padding: 0; justify-content: center; }
  .hush-chip-text {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .hush-header { flex-wrap: nowrap; }
  .hush-brand { min-width: 0; }
}
