/* ────────────────────────────────────────────────────────────────────────────
   NEREU · la veu
   Prémer, parlar i deixar anar. El micròfon del xat, la pestanya Neso (mòbil)
   i «Pregunta a la Neso» a la capçalera (escriptori). Pensat per a un polze,
   amb guants o mans molles, i per llegir-se d'una ullada en una cuina amb
   soroll. Només tokens: es veu igual de bé en clar i en fosc.
   ────────────────────────────────────────────────────────────────────────── */

:root {
  --veu-on: var(--c-danger);
  --veu-ring: color-mix(in srgb, var(--c-danger) 22%, transparent);
}

/* Res de menú contextual, selecció ni lupa en mantenir premut. */
.veu-mic {
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* ── el micròfon del xat ─────────────────────────────────────────────────── */
.neso-composer .veu-mic {
  position: relative;
  background: var(--c-brand); color: var(--c-on-brand); border: 1px solid transparent;
  transition: transform var(--dur-1) var(--ease), background var(--dur-1), color var(--dur-1), border-color var(--dur-1);
}
.neso-composer .veu-mic:hover:not(:disabled) { background: var(--c-brand-hover); }
.neso-composer .veu-mic .ico, .neso-composer .veu-mic svg { position: relative; z-index: 1; }
.neso-composer .veu-mic::after {
  content: ""; position: absolute; inset: -2px; border-radius: var(--r-full); pointer-events: none;
  box-shadow: 0 0 0 calc(4px + var(--nivell, 0) * 16px) var(--veu-ring); opacity: 0; transition: opacity .15s, box-shadow .08s linear;
}
.neso-composer .veu-mic.veu-mic--on, .neso-composer .veu-mic.veu-mic--on:hover:not(:disabled) { background: var(--veu-on); color: var(--c-text-inverse); border-color: transparent; transform: scale(1.12); }
.neso-composer .veu-mic.veu-mic--on::after { opacity: 1; }
.neso-composer .veu-mic.veu-mic--fora, .neso-composer .veu-mic.veu-mic--fora:hover:not(:disabled) { background: var(--c-text-3); transform: scale(1); }
.neso-composer .veu-mic.veu-mic--fora::after { opacity: 0; }
.neso-composer .veu-mic.veu-mic--bloc { background: var(--c-surface); color: var(--c-text-3); border: 1px dashed var(--c-border-strong); }
.neso-composer .veu-mic:disabled { opacity: .4; }

/* La tira de gravació ocupa el lloc de la caixa de text. */
.veu-tira {
  flex: 1; min-width: 0; min-height: 48px; display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-3) 0 var(--sp-5); border-radius: var(--r-full); background: var(--c-danger-bg);
  border: 1px solid var(--c-danger-border); color: var(--c-danger); font-weight: var(--fw-bold);
}
.veu-tira__punt { width: 10px; height: 10px; border-radius: var(--r-full); background: currentColor; flex: none; animation: veu-batec 1s ease-in-out infinite; }
.veu-tira__temps { flex: none; font-variant-numeric: tabular-nums; }
.veu-tira__nivell { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: var(--sp-2); height: 28px; overflow: hidden; }
.veu-tira__nivell i { --k: .6; flex: none; width: 4px; border-radius: 2px; background: currentColor; opacity: .85;
  height: calc(4px + var(--nivell, 0) * 24px * var(--k)); transition: height .08s linear; }
.veu-tira__nivell i:nth-child(2n) { --k: .9; }
.veu-tira__nivell i:nth-child(3n) { --k: .45; }
.veu-tira__nivell i:nth-child(5n) { --k: 1.05; }
.veu-tira__nivell i:nth-child(7n) { --k: .75; }
.veu-tira__x {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; padding: 0; border: 0; border-radius: var(--r-full);
  background: transparent; color: var(--c-danger); cursor: pointer;
}
.veu-tira__x:hover { background: color-mix(in srgb, var(--c-danger) 12%, transparent); }
.veu-tira--fora { background: var(--c-surface-subtle); border-color: var(--c-border); color: var(--c-text-3); }
.veu-tira--fora .veu-tira__punt { animation: none; }

/* L'avís sobre el compositor: privacitat la primera vegada, errors i ajudes. */
.veu-avis {
  max-width: 760px; margin: 0 auto var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  font-size: var(--fs-sm); line-height: var(--lh-sm); background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text-2);
  animation: veu-entra var(--dur-2) var(--ease);
}
.veu-avis a { color: var(--c-accent); font-weight: var(--fw-bold); }
.veu-avis small { display: block; margin-top: var(--sp-1); font-weight: var(--fw-regular); color: var(--c-text-2); }
.veu-avis--grava { color: var(--c-text); font-weight: var(--fw-bold); }
.veu-avis--fora { color: var(--c-text-2); font-weight: var(--fw-bold); background: var(--c-surface-subtle); }
.veu-avis--error { background: var(--c-danger-bg); border-color: var(--c-danger-border); color: var(--c-danger); font-weight: var(--fw-bold); }

/* La bombolla dictada porta la seva marca; la provisional, els tres punts. */
.bombolla__veu { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); font-size: var(--fs-xs); font-weight: var(--fw-bold); opacity: .8; white-space: normal; }
.bombolla__veu svg { width: 12px; height: 12px; }
.bombolla--dictant { display: flex; align-items: center; gap: var(--sp-3); font-size: var(--fs-sm); }
.bombolla--dictant .pensant i { background: currentColor; }

/* El context que acompanya el pròxim missatge («Sobre: …»). */
.neso-sobre {
  margin: 0 auto var(--sp-3); display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-4); border-radius: var(--r-full); width: fit-content; max-width: min(760px, 100%);
  background: var(--c-accent-subtle); border: 1px solid var(--c-neso-border); color: var(--c-accent); font-size: var(--fs-sm); font-weight: var(--fw-bold);
}
.neso-sobre__t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.neso-sobre button { display: grid; place-items: center; width: 30px; height: 30px; flex: none; padding: 0; border: 0; border-radius: var(--r-full); background: transparent; color: var(--c-accent); cursor: pointer; }
.neso-sobre button:hover { background: color-mix(in srgb, var(--c-accent) 12%, transparent); }
.neso:has(.neso-sobre:not([hidden])) .neso-xat, .neso:has(.veu-avis:not([hidden])) .neso-xat { padding-bottom: 170px; }
.neso--calaix:has(.neso-sobre:not([hidden])) .neso-xat, .neso--calaix:has(.veu-avis:not([hidden])) .neso-xat { padding-bottom: var(--sp-4); }

/* ── la pestanya Neso: tocar obre, mantenir premut grava ─────────────────── */
.tab.tab--veu { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none; }
.tab__veu {
  position: absolute; left: 50%; top: -26px; width: 52px; height: 52px; margin-left: -26px; border-radius: var(--r-full);
  display: grid; place-items: center; background: var(--veu-on); color: var(--c-text-inverse); pointer-events: none;
  box-shadow: var(--e-2), 0 0 0 4px var(--c-bg), 0 0 0 calc(6px + var(--nivell, 0) * 18px) var(--veu-ring);
  opacity: 0; transform: translateY(10px) scale(.7); transition: opacity .16s, transform .16s var(--ease), box-shadow .08s linear;
}
.tab__veu svg { width: 24px; height: 24px; }
.tab--veu-on .tab__veu { opacity: 1; transform: none; }
.tab--veu-on.veu-fora .tab__veu { background: var(--c-text-3); box-shadow: 0 0 0 4px var(--c-bg); }
.tab--veu-on { color: var(--c-danger); }

/* ── escriptori: «Pregunta a la Neso» a la capçalera ─────────────────────── */
.hd__veu {
  position: relative; cursor: pointer; flex: none;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: background var(--dur-1), color var(--dur-1), border-color var(--dur-1);
}
.hd__veu .ico, .hd__veu svg { color: var(--c-accent); }
.hd__veu:hover { border-color: var(--c-accent); }
.hd__veu::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; opacity: 0;
  box-shadow: 0 0 0 calc(3px + var(--nivell, 0) * 12px) var(--veu-ring); transition: opacity .15s, box-shadow .08s linear; }
.hd__veu.hd__veu--on { background: var(--veu-on); border-color: transparent; color: var(--c-text-inverse); }
.hd__veu.hd__veu--on svg { color: inherit; }
.hd__veu.hd__veu--on::after { opacity: 1; }
.hd__veu.hd__veu--on.veu-fora { background: var(--c-text-3); }
@media (max-width: 899px) { .hd__veu { display: none; } }

/* La bafarada d'estat de les entrades globals: al costat de qui grava. */
.veu-bafarada {
  position: fixed; z-index: var(--z-toast); max-width: min(320px, calc(100vw - 24px)); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg);
  background: var(--c-surface); color: var(--c-danger); border: 1px solid var(--c-danger-border); box-shadow: var(--e-2);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); line-height: var(--lh-sm); animation: veu-entra var(--dur-2) var(--ease);
}
.veu-bafarada small { display: block; margin-top: var(--sp-1); font-weight: var(--fw-regular); color: var(--c-text-2); }
.veu-bafarada--info { background: var(--c-tooltip); color: var(--c-on-tooltip); border-color: transparent; }
.veu-bafarada--info small { color: inherit; opacity: .8; }
.veu-bafarada--fora { color: var(--c-text); background: var(--c-surface-subtle); border-color: var(--c-border); }
.veu-bafarada--error { background: var(--c-danger-bg); }

@keyframes veu-batec { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes veu-entra { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .veu-tira__punt, .veu-avis, .veu-bafarada { animation: none; }
  .tab__veu, .hd__veu, .neso-composer .veu-mic { transition: none; }
}
