/* — voice mode. A mic in the top bar, before "All todos", is the way in and the way out (on a phone, a button at the foot of the screen). Turn it
     on and the typing boxes give way: your words and Miller's answer appear in a soft ring of light that grows with
     them, standing at the foot of the screen. Everything above stays as it was (scrolls, opens, drags) and fades out toward the
     bottom. Ink, never a colour; the only movement is the light rising with your voice. — */
:root { --voice-glow-rgb: 38, 37, 30; --dock-zone: 32px; }   /* the room under the words: the stop sits just above it */   /* the light's colour: Miller's ink. A warm tint to try instead: 196, 128, 84 */

body.voice-on .todo-form,
body.voice-on .comment-form,
body.voice-on .thread__empty-sub { display: none; }
body.voice-on .page { padding-bottom: calc(var(--voice-h, 220px) + 8px); }   /* --voice-h: the bar's height as it is now (voice.js) */
html:has(body.voice-on) { scroll-padding-bottom: calc(var(--voice-h, 220px) + 24px); }  /* anything scrolled into view lands above the bar, not under it */
body.voice-on .notice { bottom: calc(var(--voice-h, 220px) + 8px); }

/* ——— the mic, in the top bar ——— */
/* It never rests with the rest of the bar (main.css). It starts voice mode; while on, it is only tinted, to show it is on:
   stopping is done from the arch itself. */
.topbar__voice[aria-pressed="true"] { color: var(--text); background: rgba(38, 37, 30, 0.07); }
@media (max-width: 760px) { .topbar__voice { display: none; } }   /* a phone has the button at the foot instead */

/* ——— the mic at the foot of the screen: phones only ——— */
@media (min-width: 761px) { body .voice-dock { display: none; } }   /* (body: so it outranks the button's own rules below) */
body.voice-on .voice-dock { display: none; }   /* on, the stop is in the arch */


/* At the foot of the screen, in the middle: over the gap between the two columns, level with the update box. */
.voice-dock { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 52px; height: 52px; padding: 0; border: none; border-radius: 26px; cursor: pointer;
  background: var(--bg); color: var(--text-2); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(38, 37, 30, 0.2), 0 4px 14px rgba(38, 37, 30, 0.05); -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease; }
.voice-dock:hover { color: var(--text); background: rgba(38, 37, 30, 0.035); box-shadow: inset 0 0 0 1px rgba(38, 37, 30, 0.45), 0 6px 18px rgba(38, 37, 30, 0.07); }
.voice-dock:active { transform: translateX(-50%) scale(0.96); }
.voice-dock:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.voice-dock__label, .voice-dock__stop { display: none; }
/* A modal open over a quiet page: the mic steps aside until it's closed. */
body:has(#overlay > .overlay):not(.voice-on) .voice-dock { opacity: 0; pointer-events: none; }

/* ——— the bar: as tall as what is in it ——— */
/* A long transcript or reply makes it grow upward, never out of its own backdrop. The top 72px is the fade (paint
   only: clicks and scrolling pass through to the list underneath); below that the page colour is solid, so words
   never land on the list. The foot is left clear for the mic. */
.voice { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; pointer-events: none; max-height: 70vh;
  display: flex; flex-direction: column; align-items: center; padding: 72px 24px calc(var(--dock-zone) + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(247, 247, 244, 0) 0, rgba(247, 247, 244, 0.92) 56px, var(--bg) 84px);
  animation: voice-in 0.3s ease; }
.voice[hidden] { display: none; }
@keyframes voice-in { from { opacity: 0; } to { opacity: 1; } }

.voice__stage { position: relative; flex: 0 1 auto; min-height: 44px; min-width: 0; width: min(560px, 100%); overflow: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.voice__heard, .voice__reply { margin: 0; max-width: 100%; overflow-wrap: anywhere; }
/* What you said: small, in mono, in quotes, quiet. What Miller says: a size up and a shade softer than the page's own text, balanced across its lines so none is left
   hanging, one change to a line. Long words wrap and stop at a few lines, ending in an ellipsis. */
.voice__heard { font-family: var(--font-mono); font-size: 11.5px; line-height: 17px; letter-spacing: 0.01em; color: var(--text-4);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; text-wrap: balance; }
.voice__reply { font-size: 15px; line-height: 23px; font-weight: 400; letter-spacing: -0.01em; color: var(--text-2); white-space: pre-line; text-wrap: balance;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; line-clamp: 5; overflow: hidden; }
.voice__heard:empty, .voice__reply:empty { display: none; }
.voice__reply.is-tip { color: var(--text-4); }   /* a suggestion, not an answer: quieter */
.voice__heard.is-new, .voice__reply.is-new { animation: voice-text 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes voice-text { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* The one quiet line under the words, only when there is something to say: Undo, what's left of the budget, a state
   that needs a word (Tap anywhere to start, Microphone blocked). Otherwise it isn't there. */
.voice__meta { margin: 4px 0 0; display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 16px;
  font-family: var(--font-mono); font-size: 11px; line-height: 16px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-4); }
.voice__meta[hidden] { display: none; }
.voice__hint:empty { display: none; }
.voice__undo { pointer-events: auto; padding: 0; background: none; border: none; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--text-3); text-decoration: underline dotted; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.voice__undo:hover { color: var(--text); }
.voice__undo[hidden] { display: none; }

/* ——— stop: a small ring at the foot of the arch, with a square in it ——— */
.voice__stop { pointer-events: auto; flex: none; width: 34px; height: 34px; margin-top: 10px; padding: 0; border: none; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; background: var(--bg); color: var(--text-2); -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(38, 37, 30, 0.35), 0 0 0 calc(2px + var(--voice-level, 0) * 10px) rgba(var(--voice-glow-rgb), 0.08);
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease; }
.voice__stop span { width: 10px; height: 10px; border-radius: 2.5px; background: currentColor; }
.voice__stop:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--text), 0 0 0 calc(2px + var(--voice-level, 0) * 10px) rgba(var(--voice-glow-rgb), 0.08); }
.voice__stop:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
/* While it works on what you said, the ring breathes: no words needed. */
.voice[data-state="thinking"] .voice__stop { animation: voice-dock-wait 1.6s ease-in-out infinite; }
@keyframes voice-dock-wait {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(38, 37, 30, 0.35), 0 0 0 2px rgba(var(--voice-glow-rgb), 0.06); }
  50%      { box-shadow: inset 0 0 0 1px rgba(38, 37, 30, 0.5), 0 0 0 9px rgba(var(--voice-glow-rgb), 0.10); }
}

/* ——— the ring of light ——— */
/* An arch standing on the mic, around the words: clear in the middle where the words are, a ring of light just
   outside them, nothing beyond. voice.js sizes it to the words, so a longer answer makes a bigger arch (it eases
   there), and its light rises a little with your voice (--voice-level). */
.voice__arc { position: absolute; left: 50%; bottom: calc(var(--dock-zone) - 34px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: var(--arc-w, 560px); height: var(--arc-h, 240px); pointer-events: none;
  background: radial-gradient(ellipse 50% 100% at 50% 100%,
    rgba(var(--voice-glow-rgb), 0) 0%, rgba(var(--voice-glow-rgb), 0) 66%,
    rgba(var(--voice-glow-rgb), calc(0.08 + var(--voice-level, 0) * 0.08)) 85%,
    rgba(var(--voice-glow-rgb), 0) 100%);
  -webkit-mask-image: linear-gradient(to top, transparent 0, #000 38%); mask-image: linear-gradient(to top, transparent 0, #000 38%);   /* its feet fade out, not end */
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  animation: voice-breathe 7s ease-in-out infinite; }
.voice[data-state="thinking"] .voice__arc { animation: voice-wait 1.8s ease-in-out infinite; }
.voice.is-done .voice__arc { animation: voice-lift 1s ease-out; }
@keyframes voice-breathe { 0%, 100% { opacity: 0.85; } 50% { opacity: 1; } }
@keyframes voice-wait { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes voice-lift { 0% { opacity: 1; } 35% { opacity: 1.8; } 100% { opacity: 1; } }

/* A hairline round the window: the page is under voice control. */
.voice__edge { position: fixed; inset: 0; pointer-events: none; border: 1px solid rgba(var(--voice-glow-rgb), 0.12); transition: border-color 0.4s ease; }
.voice[data-state="listening"] .voice__edge { border-color: rgba(var(--voice-glow-rgb), calc(0.10 + var(--voice-level, 0) * 0.12)); }

@media (prefers-reduced-motion: reduce) {
  .voice, .voice__heard.is-new, .voice__reply.is-new, .voice__arc, .voice.is-done .voice__arc, .voice[data-state="thinking"] .voice__arc { animation: none; }
  .voice__arc, .voice-dock, .voice__stop { transition: none; }
  .voice[data-state="thinking"] .voice__stop { animation: none; }
}

/* — usage: what voice has cost against its limit (Settings). A hairline bar, the way the rest of Settings draws things. — */
.usage { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.usage__bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.usage__bar i { display: block; height: 100%; min-width: 2px; background: var(--text); border-radius: 2px; transition: width 0.4s ease; }
.usage--full .usage__bar i { background: var(--st-blocked); }
.usage__text { margin: 0; display: flex; justify-content: space-between; gap: 12px; font-family: var(--font-mono); font-size: 11px; color: var(--text-2); }
.usage__text--quiet { color: var(--text-4); }

/* — phones: the mic is a labelled pill until voice mode is on, targets a thumb can hit, the reply a size down — */
@media (max-width: 760px) {
  .voice-dock { width: auto; padding: 0 24px 0 20px; bottom: calc(18px + env(safe-area-inset-bottom)); }
  .voice-dock__label { display: inline; }
  body.voice-on .voice-dock { width: 52px; padding: 0; }
  body.voice-on .voice-dock__label { display: none; }
  .voice { padding-left: 16px; padding-right: 16px; }
  .voice__undo { padding: 10px 6px; }
}
@media (max-width: 480px) {
  .voice__reply { font-size: 14.5px; line-height: 22px; }
  .voice__heard { font-size: 11px; }
}

/* A short screen (a phone on its side): less text, so the mic and the words always fit. */
@media (max-height: 520px) {
  .voice { padding-top: 48px; }
  .voice__reply { -webkit-line-clamp: 2; line-clamp: 2; }
  .voice__heard { -webkit-line-clamp: 1; line-clamp: 1; }
}
