/* Comunicazioni: notifiche recenti (campanella), messaggi, «Chiedi info», posta di info@. Caricato per ultimo. */

/* ---------- notifiche recenti: riquadro di altezza fissa (4 notifiche), le altre scorrendo ---------- */
.notif-section h2 { margin: 0 0 12px; }
.nr-list { list-style: none; margin: 0 0 10px; padding: 4px; display: grid; gap: 8px; align-content: start;
  height: 430px; overflow-y: auto; overscroll-behavior: contain; scroll-snap-type: y proximity;
  border: 1px solid var(--line); border-radius: var(--radius); background: rgba(0, 0, 0, .18); }
.nr { position: relative; height: 96px; scroll-snap-align: start; border-radius: 12px; overflow: hidden;
  transition: height .25s ease, margin .25s ease, opacity .25s ease; }
.nr.chiusa { height: 0 !important; margin-top: -8px; opacity: 0; }
.nr-sotto { position: absolute; inset: 0; display: flex; align-items: center; padding-left: 18px; gap: 8px; border-radius: 12px;
  background: linear-gradient(90deg, #8f2a20, rgba(143, 42, 32, .35)); color: #fff; font-weight: 800; opacity: 0;
  transition: opacity .15s, background .15s; }
.nr.pronta .nr-sotto { background: #c0392b; }
.nr-card { position: relative; height: 100%; display: flex; gap: 10px; align-items: flex-start; padding: 10px 44px 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; touch-action: pan-y; user-select: none;
  transition: transform .22s ease, opacity .22s ease; }
.nr.trascina .nr-card { transition: none; cursor: grabbing; }
.nr-card.nuova { border-color: var(--gold); }
.nr-card.errore { border-left: 4px solid #e05a4f; }
.nr-icona { font-size: 1.15rem; line-height: 1.3; }
.nr-main { display: grid; gap: 1px; min-width: 0; }
.nr-testo { font-weight: 700; font-size: .93rem; line-height: 1.3; color: var(--ink); text-decoration: none; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.nr-link::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }   /* tutta la notifica è cliccabile */
.nr-card:has(.nr-link) { cursor: pointer; padding-right: 64px; }
.nr-card:has(.nr-link):hover { border-color: var(--gold); }
.nr-card:has(.nr-link)::before { content: "→"; position: absolute; right: 14px; bottom: 10px; color: var(--gold); font-size: 1.1rem; }
.nr-card:has(.nr-link):hover .nr-testo { color: var(--gold); }
.nr-det { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nr-quando { color: var(--muted); font-size: .78rem; }
.nr-x-form { position: absolute; right: 6px; top: 6px; margin: 0; z-index: 2; }
.nr-x { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: transparent; color: var(--muted);
  cursor: pointer; font-size: .85rem; line-height: 1; }
.nr-x:hover, .nr-x:focus-visible { color: #fff; border-color: #c0392b; background: #c0392b; }
@media (prefers-reduced-motion: reduce) { .nr, .nr-card, .nr-sotto { transition: none; } }

/* ---------- messaggi ---------- */
.msg-list { display: grid; gap: 8px; }
.msg { display: grid; gap: 4px; width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.msg:hover { border-color: var(--gold); }
.msg.nuovo { border-color: var(--gold); border-left: 4px solid var(--gold); }
.msg-testa { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.msg-quando { color: var(--muted); font-size: .8rem; }
.msg-anteprima { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-line; overflow-wrap: anywhere; }
.msg.nuovo .msg-anteprima { color: var(--ink); }
.msg-stato { font-size: .75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.msg-stato.nuovo { color: var(--gold); }
.msg-dialog { width: min(640px, calc(100vw - 32px)); max-height: 82vh; padding: 20px; border: 1px solid var(--gold);
  border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.msg-dialog[open] { animation: ingrandisci .2s ease-out; }
.msg-dialog::backdrop { background: rgba(5, 12, 9, .75); backdrop-filter: blur(3px); }
.msg-dialog-testa { display: grid; gap: 2px; margin: 0 0 12px; }
.msg-dialog-testo { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.6; font-size: 1.05rem; margin-bottom: 18px; }
@keyframes ingrandisci { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.msg-scrivi { max-width: 640px; }
.scegli { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
.scegli legend { font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
.scegli-lista { display: grid; gap: 4px; align-content: start; padding: 4px; border: 1px solid var(--line); border-radius: 12px;
  max-height: calc(4 * 42px + 3 * 4px + 10px); overflow-y: auto; overscroll-behavior: contain; }   /* 4 voci, le altre scorrendo */
.form .scegli-voce:not([hidden]) { display: flex; }
.scegli-voce { align-items: center; gap: 10px; height: 42px; box-sizing: border-box; padding: 0 10px; overflow: hidden; white-space: nowrap; border-radius: 8px; cursor: pointer; }
.scegli-voce input { width: auto; accent-color: var(--gold); }
.scegli-voce:has(input:checked) { background: var(--surface-2); outline: 1px solid var(--gold); }
.scegli-voce.tutti { border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; margin-bottom: 2px; }
.destinatario { background: var(--bg); }
.dest-scelto { margin-left: auto; color: var(--gold); font-weight: 700; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.destinatario > summary::after { margin-left: 8px; }
.msg.a-tutti { border-color: #6fa3d8; border-left: 4px solid #6fa3d8; }
.msg-tutti { justify-self: start; margin: 0 0 4px; padding: 3px 10px; border-radius: 999px; background: #6fa3d8; color: #08121d;
  font-size: .75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }

/* ---------- posta di info: nuove in evidenza, lette sbiadite ---------- */
.mail-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.mail { display: grid; gap: 3px; padding: 12px 14px; border-radius: 12px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.mail:hover { border-color: var(--gold); opacity: 1; }
.mail.nuova { border-color: var(--gold); border-left: 4px solid var(--gold); background: var(--surface-2); }
.mail.nuova .mail-da, .mail.nuova .mail-ogg { font-weight: 800; }
.mail.letta { opacity: .55; }
.mail-riga { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.mail-da { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mail-quando { flex: none; color: var(--muted); font-size: .8rem; }
.mail-ogg { overflow-wrap: anywhere; }
.mail-tag { justify-self: start; font-size: .7rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #3fae7a; }
.mail-tag.nuova { color: var(--gold-ink); background: var(--gold); border-radius: 999px; padding: 1px 8px; }
.mail-aperta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; min-width: 0; }
.mail-testata { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 14px; }
.mail-titolo { font-size: clamp(1.35rem, 5vw, 1.9rem); margin: 0 0 8px; overflow-wrap: anywhere; }
.mail-chi { margin: 0 0 2px; overflow-wrap: anywhere; }
.mail-testata .small { margin: 0; }
.mail-corpo { white-space: pre-line; overflow-wrap: anywhere; line-height: 1.6; }
.mail-allegati { margin: 14px 0 0; }
.mail-risposta .form { margin: 0; }
