/* La PWA di Trevor (ADR-0005). Scura come lo sfondo dell'avatar del PC; il colore d'accento è quello della maglia. */

:root {
  --bg: #1c1e26;
  --panel: #252833;
  --line: #343846;
  --text: #e6edf3;
  --muted: #9aa4b2;
  --accent: #7fe3f0;
  --accent-ink: #0c2a30;
  --warn: #f2c66d;
  --bad: #f08a7f;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px 0;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 4px;
}

.name { font-weight: 600; letter-spacing: 0.02em; }

.status {
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.status[data-state="ready"]::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status[data-state="pairing"]::before,
.status[data-state="pairingClosed"]::before,
.status[data-state="replaced"]::before,
.status[data-state="backoff"]::before { background: var(--warn); }
.status[data-state="incompatible"]::before { background: var(--bad); }

.face {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 4px 0 8px;
}

.face img, .face canvas {
  width: min(62vw, 34dvh, 320px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
}

/* La foto di riserva fluttua con il CSS; il faccione 3D si muove da sé (ADR-0006). */
.face img { animation: float 6s ease-in-out infinite; }

.face canvas[hidden], .face img[hidden] { display: none; }

.face.thinking img { animation: float 6s ease-in-out infinite, think 1.6s ease-in-out infinite; }
.face.speaking img { animation: float 6s ease-in-out infinite, speak 0.45s ease-in-out infinite alternate; }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes think { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.25) hue-rotate(25deg); } }
@keyframes speak { from { filter: brightness(1); } to { filter: brightness(1.12); } }

@media (prefers-reduced-motion: reduce) {
  .face img, .face.thinking img, .face.speaking img { animation: none; }
}

.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.notice p { margin: 0 0 8px; }
.notice p:last-child { margin-bottom: 0; }
.notice .small { font-size: 14px; color: var(--muted); }
.notice .code {
  font: 600 22px/1.3 ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--accent);
  user-select: all;
}

.log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0 12px;
}

.exchange { margin: 0 0 14px; }

.exchange p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.user {
  margin-left: auto !important;
  max-width: 85%;
  width: fit-content;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px 14px 4px 14px;
  padding: 8px 12px;
  margin-bottom: 8px !important;
}

.user.resumed { color: var(--muted); font-size: 14px; background: none; border-style: dashed; }

.trevor { padding: 0 2px; }
.trevor.waiting { color: var(--muted); }
.trevor.problem { color: var(--warn); }

.composer {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.composer input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 16px; /* sotto i 16px Safari ingrandisce la pagina */
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.composer input:focus { outline: 2px solid var(--accent); outline-offset: 0; }

button {
  font: inherit;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
}

button:disabled { opacity: 0.4; cursor: default; }
button.secondary { color: var(--text); background: var(--line); }
