/* Tharvik - voice.css (2026-11-03): the voice conversation screen (pairs with js/voice.js).
   The Tharvik emblem sits in the centre and shows what is happening: listening (rings drawn in), thinking (a turning arc), speaking (it moves with the
   real sound). Scoped to #voicePanel / .vp-*; uses the app's tokens so dark and light both work. */

#voicePanel{
  position:fixed; inset:0; z-index:140; display:flex; flex-direction:column;
  background:var(--bg); color:var(--text);
  padding-top:env(safe-area-inset-top);
}
#voicePanel[hidden]{ display:none; }
body.voice-open{ overflow:hidden; }

.vp-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 20px; }
.vp-head h2{ margin:0; font-family:var(--font-display); font-weight:700; font-size:22px; letter-spacing:-0.01em; }
.vp-end{
  padding:8px 16px; border-radius:999px; border:1px solid var(--line-strong); background:transparent;
  color:var(--text); font:600 14px var(--font-ui); cursor:pointer;
}

/* ---- the centre ------------------------------------------------------------- */
.vp-stage{ flex:1; min-height:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:16px; padding:8px 24px 0; text-align:center; }
.vp-ares{
  position:relative; width:240px; height:240px; display:grid; place-items:center; flex-shrink:0;
  border:0; border-radius:50%; background:transparent; padding:0; cursor:pointer; color:inherit;
  -webkit-tap-highlight-color:transparent;
}
.vp-emblem{
  position:relative; z-index:2; width:116px; height:116px;
  filter:drop-shadow(0 0 0 rgba(244,176,74,0));
  transition:transform .35s ease, filter .35s ease, opacity .35s ease;
}
.vp-ring{ position:absolute; inset:62px; border-radius:50%; border:1px solid var(--accent-line); opacity:0; pointer-events:none; }
.vp-arc{ position:absolute; inset:52px; border-radius:50%; border:2px solid transparent; border-top-color:var(--gold); opacity:0; pointer-events:none; }

/* idle: quietly breathing */
#voicePanel[data-state="idle"] .vp-emblem{ animation:vpBreathe 5s ease-in-out infinite; }

/* listening: rings gently drawn in towards Tharvik, a little brighter whenever words are heard */
#voicePanel[data-state="listening"] .vp-emblem{ transform:scale(1.04); filter:drop-shadow(0 0 18px rgba(244,176,74,.35)); }
#voicePanel[data-state="listening"].vp-hear .vp-emblem{ transform:scale(1.09); filter:drop-shadow(0 0 26px rgba(244,176,74,.55)); }
#voicePanel[data-state="listening"] .vp-ring{ animation:vpListen 2.4s cubic-bezier(.3,.1,.3,1) infinite; }
#voicePanel[data-state="listening"] .r2{ animation-delay:.8s; }
#voicePanel[data-state="listening"] .r3{ animation-delay:1.6s; }

/* thinking / getting the voice ready: one thin arc turning around the emblem */
#voicePanel[data-state="thinking"] .vp-emblem, #voicePanel[data-state="loading"] .vp-emblem{ opacity:.8; transform:scale(.97); }
#voicePanel[data-state="thinking"] .vp-arc, #voicePanel[data-state="loading"] .vp-arc{ opacity:1; animation:vpSpin 1.15s linear infinite; }

/* speaking: it follows the actual sound (--vp-lvl is set from the audio, 0..1) */
#voicePanel[data-state="speaking"] .vp-emblem{ transform:scale(calc(1.02 + var(--vp-lvl, 0) * .2)); filter:drop-shadow(0 0 22px rgba(244,176,74,.45)); transition:transform .08s linear, filter .35s ease; }
#voicePanel[data-state="speaking"] .r1{ opacity:calc(.25 + var(--vp-lvl, 0) * .6); inset:calc(58px - var(--vp-lvl, 0) * 26px); }
#voicePanel[data-state="speaking"] .r2{ opacity:calc(.15 + var(--vp-lvl, 0) * .4); inset:calc(50px - var(--vp-lvl, 0) * 34px); }

@keyframes vpBreathe{ 0%,100%{ transform:scale(1); } 50%{ transform:scale(1.025); } }
@keyframes vpListen{ 0%{ inset:0; opacity:0; } 35%{ opacity:.55; } 100%{ inset:62px; opacity:0; } }
@keyframes vpSpin{ to{ transform:rotate(360deg); } }

.vp-status{ margin:0; min-height:1.4em; font-size:15px; font-weight:600; color:var(--text-dim); }
#voicePanel[data-state="listening"] .vp-status, #voicePanel[data-state="speaking"] .vp-status{ color:var(--gold); }
/* just the latest words, small: this is a conversation, not a transcript */
.vp-caption{
  margin:0; max-width:460px; min-height:3em; font-size:14px; line-height:1.5; color:var(--text-dim);
  display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden;
}
.vp-note{ margin:0; min-height:1.2em; font-size:12.5px; color:var(--text-dim); font-style:italic; }

/* ---- first use: the voice download ---------------------------------------- */
.vp-card{ display:none; width:100%; max-width:420px; flex-direction:column; align-items:center; gap:12px; text-align:center; }
.vp-card h3{ margin:0; font-family:var(--font-display); font-weight:700; font-size:20px; }
.vp-card p{ margin:0; font-size:14.5px; line-height:1.5; color:var(--text-dim); }
#voicePanel[data-state="download"] .vp-download, #voicePanel[data-state="error"] .vp-error{ display:flex; }
#voicePanel[data-state="download"] .vp-ares, #voicePanel[data-state="error"] .vp-ares{ width:150px; height:150px; pointer-events:none; opacity:.9; }
#voicePanel[data-state="download"] .vp-status, #voicePanel[data-state="download"] .vp-caption, #voicePanel[data-state="download"] .vp-note,
#voicePanel[data-state="error"] .vp-status, #voicePanel[data-state="error"] .vp-caption, #voicePanel[data-state="error"] .vp-note{ display:none; }
.vp-btn{
  padding:12px 22px; border-radius:999px; border:1px solid var(--gold); background:var(--gold); color:var(--bg);
  font:600 15px var(--font-ui); cursor:pointer;
}
.vp-btn[hidden], .vp-bar[hidden]{ display:none; }
.vp-bar{ width:100%; display:flex; flex-direction:column; gap:8px; }
.vp-bar-track{ height:6px; border-radius:99px; background:var(--line); overflow:hidden; }
.vp-bar-track i{ display:block; height:100%; width:0; border-radius:99px; background:var(--gold); transition:width .25s linear; }
.vp-bar p{ font-variant-numeric:tabular-nums; }
#voicePanel .vp-fail{ color:var(--text); min-height:1em; }

/* ---- the foot ------------------------------------------------------------------ */
.vp-foot{ display:flex; flex-direction:column; align-items:center; gap:8px; padding:12px 22px calc(18px + env(safe-area-inset-bottom)); }
/* which language the microphone listens in (device recognition: one at a time) */
.vp-lang{ display:flex; align-items:center; gap:4px; font-size:12px; color:var(--text-dim); }
.vp-lang span{ margin-right:4px; }
.vp-lang-opt{
  padding:4px 10px; border-radius:999px; border:1px solid var(--line); background:transparent;
  color:var(--text-dim); font:700 11.5px var(--font-ui); letter-spacing:.06em; cursor:pointer;
}
.vp-lang-opt.on{ border-color:var(--gold); color:var(--gold); }
.vp-diag{ margin:0; min-height:1.2em; font:11.5px var(--font-ui); color:var(--text-dim); opacity:.75; font-variant-numeric:tabular-nums; }
.vp-ares:focus-visible, .vp-end:focus-visible, .vp-lang-opt:focus-visible, .vp-btn:focus-visible{ outline:2px solid var(--gold); outline-offset:4px; }

@media (max-height:640px){
  .vp-ares{ width:190px; height:190px; }
  .vp-emblem{ width:96px; height:96px; }
}
@media (prefers-reduced-motion: reduce){
  #voicePanel .vp-emblem, #voicePanel .vp-ring, #voicePanel .vp-arc{ animation:none !important; }
  #voicePanel[data-state="listening"] .r1{ opacity:.6; inset:40px; }
  #voicePanel[data-state="thinking"] .vp-arc, #voicePanel[data-state="loading"] .vp-arc{ opacity:.8; }
}
