/* Temi di Ritrovo (ricerca/design.md): stessa struttura, cambiano colori, forme, font e movimento.
   data-tema = aurora | galleria | piazza | essenziale (il primo stile); data-modo = chiaro | scuro; data-effetti = pieni | ridotti. */
@font-face { font-family: "Mona Sans"; font-weight: 200 900; font-stretch: 75% 125%; font-display: swap; src: url("/font/mona/mona-sans-latin-wdth-normal.woff2") format("woff2"); }
@font-face { font-family: "Geist"; font-weight: 100 900; font-display: swap; src: url("/font/geist/geist-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 300 900; font-display: swap; src: url("/font/figtree/figtree-latin-wght-normal.woff2") format("woff2"); }

:root {
  --bolla-mia: var(--mio); --testo-bolla-mia: var(--text); --bolla-altrui: var(--raised); --testo-bolla-altrui: var(--text);
  --bordo-bolla-altrui: transparent; --ombra-bolla: none; --r-bolla: 14px; --r-bolla-unita: 6px;
  --online: #2f9e6a; --primary-bordo: var(--primary); --r-bottone: var(--radius-control); --molla: cubic-bezier(.2, .9, .3, 1.25);
}

/* ---------- A · Aurora: notte verde-nera, lampo di lime ---------- */
:root[data-tema="aurora"] {
  --font: "Mona Sans", "Segoe UI Variable Text", system-ui, sans-serif;
  --radius-sheet: 20px; --radius-card: 12px; --radius-control: 999px; --r-bottone: 999px; --r-bolla: 22px; --r-bolla-unita: 6px;
  --ground: #f1f5ef; --surface: #ffffff; --raised: #e6ede4; --active: #e0e9dd; --hover: #eef3ec;
  --border: #dce5d9; --rule: #e8eee6; --control: #c5d1c1;
  --text: #0b1410; --muted: #4f6158; --faint: #56685f;
  --primary: #c5f536; --on-primary: #0b1410; --primary-bordo: #9cc51c;
  --accent: #3f6a00; --accent-pale: #eaf7c9; --accent-ink: #2e4d00;
  --bolla-mia: #c5f536; --testo-bolla-mia: #0b1410; --bolla-altrui: #ffffff; --testo-bolla-altrui: #0b1410; --bordo-bolla-altrui: #dce5d9;
  --online: #0e8f7a; --stage: #040807; --stage-tile: #0e1916;
}
:root[data-tema="aurora"][data-modo="scuro"] {
  --ground: #07100e; --surface: #0e1916; --raised: #16231f; --active: #1f2e29; --hover: #132019;
  --border: #1d2b26; --rule: #17231f; --control: #2c3d37;
  --text: #e3ece6; --muted: #93a89f; --faint: #8aa096;
  --primary: #c5f536; --on-primary: #0a1408; --primary-bordo: #c5f536;
  --accent: #c5f536; --accent-pale: #1b2a14; --accent-ink: #d6fb6a;
  --bolla-mia: #c5f536; --testo-bolla-mia: #0a1408; --bolla-altrui: #16231f; --testo-bolla-altrui: #e3ece6; --bordo-bolla-altrui: transparent;
  --online: #2de2c4;
}

/* ---------- B · Galleria: pareti neutre, un solo pigmento, il Blu Klein ---------- */
:root[data-tema="galleria"] {
  --font: "Geist", "Segoe UI Variable Text", system-ui, sans-serif;
  --radius-sheet: 12px; --radius-card: 10px; --radius-control: 8px; --r-bottone: 8px; --r-bolla: 14px; --r-bolla-unita: 4px;
  --ground: #f4f4f5; --surface: #ffffff; --raised: #ebecee; --active: #e6e7ea; --hover: #f2f2f4;
  --border: #e3e4e7; --rule: #eeeff1; --control: #cfd1d6;
  --text: #111216; --muted: #5e636d; --faint: #5e636d;
  --primary: #002fa7; --on-primary: #ffffff; --primary-bordo: #002fa7;
  --accent: #002fa7; --accent-pale: #e6ecfa; --accent-ink: #002fa7;
  --bolla-mia: #002fa7; --testo-bolla-mia: #ffffff; --bolla-altrui: #ffffff; --testo-bolla-altrui: #111216; --bordo-bolla-altrui: #e3e4e7;
  --online: #1e8a5a; --stage: #08090b; --stage-tile: #131417;
}
:root[data-tema="galleria"][data-modo="scuro"] {
  --ground: #0c0d0f; --surface: #131417; --raised: #1a1c20; --active: #23262b; --hover: #17191c;
  --border: #26282d; --rule: #1e2024; --control: #34373e;
  --text: #edeef0; --muted: #a0a5ae; --faint: #8d929b;
  --primary: #1a4bd6; --on-primary: #ffffff; --primary-bordo: #1a4bd6;
  --accent: #5b8cff; --accent-pale: #16203a; --accent-ink: #9db7ff;
  --bolla-mia: #1a4bd6; --testo-bolla-mia: #ffffff; --bolla-altrui: #1a1c20; --testo-bolla-altrui: #edeef0; --bordo-bolla-altrui: transparent;
  --online: #3fb27f;
}

/* ---------- C · Piazza: piazza d'estate, girasole e anguria ---------- */
:root[data-tema="piazza"] {
  --font: "Figtree", "Segoe UI Variable Text", system-ui, sans-serif;
  --radius-sheet: 24px; --radius-card: 16px; --radius-control: 999px; --r-bottone: 999px; --r-bolla: 22px; --r-bolla-unita: 8px;
  --ground: #f7f6f3; --surface: #ffffff; --raised: #efede8; --active: #eae6de; --hover: #f5f3ef;
  --border: #e8e4dc; --rule: #f0ede7; --control: #d6d0c4;
  --text: #22201c; --muted: #6b665d; --faint: #6b665d;
  --primary: #ffc93c; --on-primary: #22201c; --primary-bordo: #e8ad10;
  --accent: #c8364f; --accent-pale: #fbe7ea; --accent-ink: #9e2238;
  --bolla-mia: #ffc93c; --testo-bolla-mia: #22201c; --bolla-altrui: #ffffff; --testo-bolla-altrui: #22201c;
  --ombra-bolla: 0 1px 2px rgb(60 45 20 / .06), 0 4px 14px rgb(60 45 20 / .07);
  --online: #1f9d5f; --stage: #1a1610; --stage-tile: #2a251d;
}
:root[data-tema="piazza"][data-modo="scuro"] {
  --ground: #17140f; --surface: #1f1b15; --raised: #2a251d; --active: #332d23; --hover: #241f18;
  --border: #2f291f; --rule: #28231b; --control: #4a4134;
  --text: #f6efe3; --muted: #b2a794; --faint: #b2a794;
  --primary: #ffc93c; --on-primary: #22201c; --primary-bordo: #ffc93c;
  --accent: #ff7a8a; --accent-pale: #3a1f24; --accent-ink: #ffb3bc;
  --bolla-mia: #ffc93c; --testo-bolla-mia: #22201c; --bolla-altrui: #2a251d; --testo-bolla-altrui: #f6efe3; --ombra-bolla: none;
  --online: #2bb673; --stage: #0f0c08;
}

/* ---------- componenti comuni ai temi ---------- */
.bottone.primario { border-color: var(--primary-bordo); border-radius: var(--r-bottone); font-weight: 600; }
.bottone { border-radius: var(--r-bottone); }
.avatar[data-online="true"]::after { background: var(--online); }
.pill-live::before { background: var(--online); }
.conteggio { box-shadow: inset 0 0 0 1px var(--primary-bordo); }
[data-tema="aurora"] .elenco-testa h1, [data-tema="aurora"] .chat-titolo h2, [data-tema="aurora"] .marchio b, [data-tema="aurora"] .accesso-modulo h1 { font-stretch: 125%; font-weight: 760; letter-spacing: -.01em; }
[data-tema="aurora"] .elenco-testa h1 { font-size: 26px; }
[data-tema="piazza"] .elenco-testa h1, [data-tema="piazza"] .chat-titolo h2 { font-weight: 800; }
[data-tema="piazza"] body, [data-tema="piazza"] .msg .testo { font-size: 15px; line-height: 22px; }
[data-tema="galleria"] .lato-blocco h2 { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
[data-tema="galleria"] .msg time, [data-tema="galleria"] .stanza time { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
/* avatar: Aurora con la sua piccola aurora personale, Piazza con i gruppi a forma di biscotto */
[data-tema="aurora"] .avatar, [data-tema="aurora"] .tile .iniziale { background: linear-gradient(140deg, var(--tinta), var(--tinta2, var(--tinta))); }
[data-tema="piazza"] .avatar.gruppo { border-radius: 42% 58% 52% 48% / 50% 44% 56% 50%; }
[data-tema="aurora"] .avatar.gruppo, [data-tema="galleria"] .avatar.gruppo { border-radius: 30%; }
/* riga attiva dell'elenco: Aurora con una barretta lime */
[data-tema="aurora"] .stanza[aria-current="true"] { box-shadow: inset 3px 0 0 var(--primary); }
[data-tema="piazza"] .stanza { border-radius: 18px; }

/* ---------- bolle dei messaggi (Aurora e Piazza sempre, Galleria nelle chat a due) ---------- */
.messaggi.bolle .msg { padding: 2px 8px; }
.messaggi.bolle .msg:hover, .messaggi.bolle .msg.scelto { background: none; }
.messaggi.bolle .msg .testo, .messaggi.bolle .msg.mio .testo { justify-self: start; width: fit-content; max-width: min(600px, 88%); padding: 8px 14px; border-radius: var(--r-bolla); background: var(--bolla-altrui); color: var(--testo-bolla-altrui); box-shadow: var(--ombra-bolla), inset 0 0 0 1px var(--bordo-bolla-altrui); }
.messaggi.bolle .msg.unito .testo { border-top-left-radius: var(--r-bolla-unita); }
.messaggi.bolle .msg .testo a { color: inherit; text-decoration: underline; }
.messaggi.bolle .msg .testo code { background: rgb(0 0 0 / .08); }
.messaggi.bolle .msg.mio { grid-template-columns: minmax(0, 1fr); justify-items: end; }
.messaggi.bolle .msg.mio > .avatar, .messaggi.bolle .msg.mio header b { display: none; }
.messaggi.bolle .msg.mio > * { grid-column: 1; justify-self: end; }
.messaggi.bolle .msg.mio .testo { justify-self: end; background: var(--bolla-mia); color: var(--testo-bolla-mia); box-shadow: none; }
.messaggi.bolle .msg.mio.unito .testo { border-top-left-radius: var(--r-bolla); border-top-right-radius: var(--r-bolla-unita); }
.messaggi.bolle .msg.mio .reazioni { justify-content: flex-end; }
.messaggi.bolle .msg.mio .barra-msg { right: auto; left: 8px; }
.messaggi.bolle .msg .immagine, .messaggi.bolle .msg .file-card { border-radius: var(--r-bolla); }
[data-tema="galleria"] .messaggi.bolle .msg .testo { padding: 7px 12px; }
/* Piazza: reazioni come adesivi */
[data-tema="piazza"] .reazioni button { border: 2px solid var(--surface); background: var(--raised); box-shadow: 0 2px 6px rgb(60 45 20 / .12); }
[data-tema="piazza"] .reazioni button:nth-child(odd) { transform: rotate(-3deg); }
[data-tema="piazza"] .reazioni button:nth-child(even) { transform: rotate(3deg); }

/* ---------- decorazioni (solo dove non si legge) ---------- */
/* Aurora: una luce sfocata dietro la cornice, mai dietro i messaggi; ferma, cambia solo l'intensità */
[data-tema="aurora"] .app { position: relative; isolation: isolate; }
[data-tema="aurora"][data-effetti="pieni"] .app::before {
  content: ""; position: absolute; z-index: -1; left: -6%; top: -18%; width: 70%; height: 62%; pointer-events: none;
  background: radial-gradient(closest-side, rgb(197 245 54 / .9), transparent) 0 10% / 42% 75% no-repeat,
              radial-gradient(closest-side, rgb(45 226 196 / .85), transparent) 35% 0 / 45% 80% no-repeat,
              radial-gradient(closest-side, rgb(28 107 255 / .8), transparent) 75% 0 / 45% 70% no-repeat;
  filter: blur(70px); opacity: .5; animation: respira-aurora 14s ease-in-out infinite alternate;
}
[data-tema="aurora"][data-modo="chiaro"][data-effetti="pieni"] .app::before { opacity: .28; }
@keyframes respira-aurora { from { opacity: .38; } to { opacity: .62; } }
[data-tema="aurora"] .foglio, [data-tema="aurora"] .io { background: var(--surface); }
/* palco della chiamata: luce ambiente intorno e comandi come dock fluttuante */
[data-tema="aurora"] .palco-area { box-shadow: 0 0 0 1px rgb(197 245 54 / .08), 0 30px 80px -30px rgb(45 226 196 / .45); }
[data-tema="galleria"] .palco-area { box-shadow: 0 0 0 1px var(--border); }
[data-tema="piazza"] .palco-area { padding: 0; border: 12px solid var(--stage-tile); border-radius: 24px; }
:root:not([data-tema="essenziale"]) .comandi { width: fit-content; margin: 0 auto 12px; padding: 8px; border-radius: 30px; background: rgb(255 255 255 / .06); }
:root:not([data-tema="essenziale"])[data-effetti="pieni"] .comandi { backdrop-filter: blur(14px); }
[data-tema="aurora"] .tondo.attivo { background: var(--primary); color: var(--on-primary); }
/* chi parla: anello lime con un alone (Aurora), bordo Klein (Galleria), girasole (Piazza) */
.tile { transition: box-shadow 160ms ease; }
[data-tema="aurora"] .tile.parla { box-shadow: inset 0 0 0 2px #c5f536, 0 0 28px -4px rgb(45 226 196 / .6); }
[data-tema="galleria"] .tile.parla { box-shadow: inset 0 0 0 2px #5b8cff; }
[data-tema="piazza"] .tile.parla { box-shadow: inset 0 0 0 3px #ffc93c; }
.diretta { margin-bottom: 6px; }
[data-tema="piazza"] .tondo.attivo { background: var(--primary); color: var(--on-primary); }
[data-tema="galleria"] .tondo.attivo { background: #1a4bd6; }
[data-tema="galleria"] .tile.schermo { box-shadow: inset 0 0 0 2px #1a4bd6; }

/* ---------- micro-animazioni ---------- */
.msg.arrivo { animation: arrivo 280ms var(--molla); }
[data-tema="galleria"] .msg.arrivo { animation: arrivo-quieto 160ms ease-out; }
[data-tema="piazza"] .msg.arrivo { animation: pop 320ms var(--molla); }
@keyframes arrivo { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes arrivo-quieto { from { opacity: 0; transform: translateY(4px); } }
@keyframes pop { 0% { opacity: 0; transform: scale(.8) rotate(-1deg); } 70% { transform: scale(1.04); } }
.messaggi.bolle .msg.mio.arrivo { transform-origin: bottom right; }
.reazioni button { transition: transform 160ms var(--molla); }
.reazioni button:active { transform: scale(1.25) !important; }
.reazioni button.appena { animation: timbro 360ms var(--molla); }
@keyframes timbro { 0% { transform: scale(1.6) rotate(-8deg); } 60% { transform: scale(.92); } }
.scrive .puntini { display: inline-flex; gap: 3px; margin-right: 6px; vertical-align: middle; }
.scrive .puntini i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: onda 1s infinite ease-in-out; }
.scrive .puntini i:nth-child(2) { animation-delay: .15s; }
.scrive .puntini i:nth-child(3) { animation-delay: .3s; }
@keyframes onda { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.scrivi .invia:active svg { animation: lancio 300ms ease-out; }
@keyframes lancio { 50% { transform: translate(3px, -3px) scale(.85); } }
@media (prefers-reduced-motion: reduce) {
  .msg.arrivo, .reazioni button.appena, .scrive .puntini i, .scrivi .invia:active svg, [data-tema="aurora"] .app::before { animation: none !important; }
}
[data-effetti="ridotti"] .msg.arrivo, [data-effetti="ridotti"] .scrive .puntini i { animation: none; }

/* ---------- scelta del tema ---------- */
.menu-tema { position: fixed; z-index: 30; display: grid; gap: 4px; width: 260px; padding: 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 16px 40px rgb(0 0 0 / .18); }
.menu-tema h3 { font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 6px 2px; }
.menu-tema button { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 8px; border: 0; border-radius: 8px; background: none; text-align: left; }
.menu-tema button:hover, .menu-tema button[aria-checked="true"] { background: var(--active); }
.menu-tema .campione { width: 22px; height: 22px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .12); }
.menu-tema .modi { display: flex; gap: 4px; }
.menu-tema .modi button { flex: 1; justify-content: center; height: 32px; }
