/* Danilo Allocca - sito personale
   Font: Arial (richiesta dell'autore). Colori: carta fredda, inchiostro, rosso segnale, banda notte. */

:root {
  --paper: #F3F4F2;
  --ink: #14181E;
  --ink-2: #5B6470;
  --rule: #D6D9D3;
  --red: #C4122B;
  --night: #12161B;
  --night-ink: #E8EAE6;
  --night-2: #9AA3AD;
  --max: 1120px;
  --gutter: clamp(20px, 5vw, 64px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--red); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.1; margin: 0 0 0.5em; letter-spacing: -0.015em; }
h1 { font-size: clamp(38px, 6.5vw, 76px); letter-spacing: -0.03em; line-height: 0.98; }
h2 { font-size: clamp(28px, 3.6vw, 42px); }
h3 { font-size: clamp(21px, 2.2vw, 26px); }
p { margin: 0 0 1em; max-width: 68ch; }
ul, ol { padding-left: 1.2em; max-width: 68ch; }
li { margin-bottom: 0.35em; }
strong { font-weight: 700; }
small, .meta { font-size: 14px; color: var(--ink-2); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 48px 0; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Testata ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(243,244,242,0.92);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-weight: 700; text-decoration: none; letter-spacing: -0.01em; display: flex; align-items: center; gap: 12px; }
.nav { display: flex; gap: 28px; }
.nav a { text-decoration: none; font-size: 15px; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--red); }
.nav a[aria-current="page"] { border-bottom-color: var(--red); }
.nav-toggle { display: none; background: none; border: 1px solid var(--rule); border-radius: 4px; padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }
@media (max-width: 900px) {
  .nav-toggle { display: inline-block; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 64px; flex-direction: column; gap: 0; background: var(--paper); border-bottom: 1px solid var(--rule); padding: 8px var(--gutter) 16px; z-index: 20; }
  .nav.open { display: flex; }
  .nav a { padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .nav a[aria-current="page"] { border-bottom-color: var(--red); }
}

/* ---------- Hero ---------- */
.hero { padding: clamp(56px, 10vw, 120px) 0 clamp(40px, 6vw, 72px); }
.hero .kicker { font-size: 15px; color: var(--ink-2); margin-bottom: 20px; }
.hero h1 { max-width: 14ch; margin-bottom: 28px; }
.hero .lede { font-size: clamp(18px, 1.6vw, 21px); max-width: 52ch; color: var(--ink); }
.hero .roles { display: flex; flex-wrap: wrap; gap: 12px 32px; margin-top: 28px; font-size: 15px; color: var(--ink-2); }

/* Firma Morse L G C: l'unico elemento grafico ricorrente del sito */
.morse { margin: 40px 0 0; }
.morse svg { display: block; width: min(100%, 520px); height: auto; }
.morse .dot, .morse .dash { fill: var(--ink); }
.morse figcaption { font-size: 14px; color: var(--ink-2); margin-top: 12px; }
.morse--night .dot, .morse--night .dash { fill: var(--night-ink); }
.morse--night figcaption { color: var(--night-2); }
@keyframes pulse { 0%, 100% { opacity: 0.18; } 50% { opacity: 1; } }
.morse--live .dot, .morse--live .dash { animation: pulse 2.6s ease-in-out 3; }
.morse--live .l { animation-delay: 0s; }
.morse--live .g { animation-delay: 0.45s; }
.morse--live .c { animation-delay: 0.9s; }
@media (prefers-reduced-motion: reduce) { .morse--live .dot, .morse--live .dash { animation: none; } }

/* ---------- Sezioni ---------- */
.section { padding: clamp(48px, 7vw, 96px) 0; border-top: 1px solid var(--rule); }
.section-head { display: grid; grid-template-columns: 1fr; gap: 12px 48px; margin-bottom: 40px; }
@media (min-width: 900px) { .section-head { grid-template-columns: 1fr 1fr; align-items: end; } }
.section-head p { margin: 0; color: var(--ink-2); }

.night { background: var(--night); color: var(--night-ink); border-top: 0; }
.night .meta, .night small, .night .section-head p { color: var(--night-2); }
.night hr { border-top-color: #2A3038; }
.night a:hover { color: #FF6B7A; }

/* ---------- Libri ---------- */
.shelf { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 40px 32px; }
.book { display: flex; flex-direction: column; gap: 16px; }
.book > a { display: block; text-decoration: none; width: 100%; max-width: 260px; }
.book > a:hover .cover { box-shadow: 0 1px 0 rgba(0,0,0,0.12), 0 16px 32px -12px rgba(0,0,0,0.6); }
.book p { margin: 0; }
.book .title { font-weight: 700; font-size: 20px; line-height: 1.2; }
.book .title a { text-decoration: none; }
.book .title a:hover { text-decoration: underline; }

/* Copertina: tipografica di base; se esiste assets/covers/<nome>.jpg viene mostrata sopra */
.cover { position: relative; aspect-ratio: 2 / 3; width: 100%; max-width: 260px; background: var(--night); color: var(--night-ink); overflow: hidden; border-radius: 2px; box-shadow: 0 1px 0 rgba(0,0,0,0.12), 0 12px 28px -12px rgba(0,0,0,0.45); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2; }
.cover .ct { position: absolute; inset: 0; padding: 22px 20px; display: flex; flex-direction: column; justify-content: space-between; }
.cover .ct .series { font-size: 11px; letter-spacing: 0.12em; color: var(--night-2); }
.cover .ct .name { font-weight: 700; font-size: 24px; line-height: 1.02; letter-spacing: -0.02em; }
.cover .ct .name span { display: block; color: var(--red); }
.cover .ct .who { font-size: 12px; color: var(--night-2); }
.cover--red { background: var(--red); }
.cover--red .ct .series, .cover--red .ct .who { color: rgba(255,255,255,0.75); }
.cover--red .ct .name span { color: var(--night); }
.cover--paper { background: #E4E6E1; color: var(--ink); }
.cover--paper .ct .series, .cover--paper .ct .who { color: var(--ink-2); }
.cover--paper .ct .name span { color: var(--red); }

/* Scheda libro estesa */
.book-full { display: grid; grid-template-columns: 1fr; gap: 32px 56px; padding: clamp(40px, 6vw, 72px) 0; border-top: 1px solid var(--rule); }
@media (min-width: 860px) { .book-full { grid-template-columns: 260px 1fr; } }
.book-full .side { display: flex; flex-direction: column; gap: 18px; }
.book-full .side .facts { font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.book-full .side .facts div { padding: 8px 0; border-top: 1px solid var(--rule); }
.book-full .side .facts div:first-child { border-top: 0; }
.book-full h2 { margin-bottom: 4px; }
.book-full .sub { color: var(--ink-2); margin-bottom: 24px; font-size: 18px; }
.excerpt { border-left: 3px solid var(--red); padding: 4px 0 4px 20px; margin: 28px 0; max-width: 62ch; }
.excerpt p { margin-bottom: 0.6em; }
.excerpt .src { font-size: 14px; color: var(--ink-2); }

.btn { display: inline-block; text-decoration: none; font-weight: 700; font-size: 15px; padding: 12px 18px; border: 1.5px solid var(--ink); border-radius: 4px; }
.btn:hover { background: var(--ink); color: var(--paper); }
.btn--red { border-color: var(--red); background: var(--red); color: #fff; }
.btn--red:hover { background: #A30E23; border-color: #A30E23; color: #fff; }
.night .btn { border-color: var(--night-ink); }
.night .btn:hover { background: var(--night-ink); color: var(--night); }

/* ---------- Cronologia (sequenza reale: anni) ---------- */
.timeline { list-style: none; padding: 0; margin: 0; max-width: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px 32px; }
.timeline li { border-top: 2px solid var(--ink); padding-top: 12px; margin: 0; }
.night .timeline li { border-top-color: var(--night-2); }
.timeline .year { font-weight: 700; font-size: 22px; letter-spacing: -0.02em; display: block; margin-bottom: 6px; }
.timeline .fict .year { color: var(--red); }
.timeline p { font-size: 15px; margin: 0; }

/* ---------- Colonne generiche ---------- */
.cols { display: grid; grid-template-columns: 1fr; gap: 32px 48px; }
@media (min-width: 860px) { .cols { grid-template-columns: 1fr 1fr; } .cols--3 { grid-template-columns: 1fr 1fr 1fr; } }
.cols h3 { margin-top: 0; }

/* Percorso professionale: sequenza temporale */
.career { list-style: none; padding: 0; margin: 0; max-width: none; }
.career li { display: grid; grid-template-columns: 130px 1fr; gap: 16px; padding: 16px 0; border-top: 1px solid var(--rule); margin: 0; }
.career li:last-child { border-bottom: 1px solid var(--rule); }
.career .when { color: var(--ink-2); font-size: 15px; }
.career .what { font-weight: 700; }
.career .where { display: block; font-weight: 400; color: var(--ink-2); }
@media (max-width: 560px) { .career li { grid-template-columns: 1fr; gap: 4px; } }

/* Diario */
.entries { list-style: none; padding: 0; margin: 0; max-width: 72ch; }
.entries li { padding: 24px 0; border-top: 1px solid var(--rule); margin: 0; }
.entries .date { color: var(--ink-2); font-size: 14px; display: block; margin-bottom: 6px; }
.entries h3 { font-size: 21px; margin-bottom: 8px; }
.entries p:last-child { margin-bottom: 0; }

/* Master: struttura della sessione (e' una sequenza, quindi numerata) */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; max-width: 72ch; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 48px 1fr; gap: 16px; padding: 18px 0; border-top: 1px solid var(--rule); margin: 0; }
.steps li::before { content: counter(step); font-weight: 700; font-size: 22px; color: var(--red); letter-spacing: -0.02em; line-height: 1.2; }
.steps h3 { font-size: 19px; margin-bottom: 4px; }
.steps p { margin: 0; font-size: 16px; }
.night .steps li { border-top-color: #2A3038; }

.quote { font-size: clamp(22px, 3vw, 34px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; max-width: 22ch; margin: 0 0 24px; }
.quote + .meta { max-width: 40ch; }

/* ---------- Pie' di pagina ---------- */
.foot { border-top: 1px solid var(--rule); padding: 48px 0 40px; }
.foot .wrap { display: grid; grid-template-columns: 1fr; gap: 24px 48px; }
@media (min-width: 760px) { .foot .wrap { grid-template-columns: 2fr 1fr 1fr; } }
.foot .links { list-style: none; padding: 0; margin: 0; }
.foot .links li { margin-bottom: 8px; }
.foot .links a { text-decoration: none; }
.foot .links a:hover { text-decoration: underline; }
.foot .fine { font-size: 14px; color: var(--ink-2); margin-top: 8px; }
.foot .morse { margin: 0 0 16px; }
.foot .morse svg { width: 180px; }

/* ==== Videogiochi (pagina giochi.html) ==== */
.game { display: grid; grid-template-columns: 1fr; gap: 28px; align-items: start; }
.game > * { min-width: 0; }
@media (min-width: 860px) { .game { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 44px; } }
.game-copy h3 { margin: 24px 0 6px; }
.specs { list-style: none; padding: 0; margin: 18px 0 0; max-width: none; font-size: 15px; color: var(--ink-2); }
.specs li { margin: 3px 0; }
.specs li span { display: inline-block; min-width: 108px; color: var(--ink); font-weight: 700; }

/* Carousel: cornice scura come le copertine (--night) per far risaltare gli screenshot */
.carousel { position: relative; max-width: 100%; background: var(--night); border: 1px solid rgba(255,255,255,.08); border-radius: 4px; padding: 10px; }
.track { display: flex; gap: 10px; overflow-x: auto; max-width: 100%; scroll-snap-type: x mandatory; scroll-behavior: smooth; padding-bottom: 6px; }
.track .shot { flex: 0 0 auto; padding: 0; border: 0; background: none; cursor: zoom-in; scroll-snap-align: center; border-radius: 2px; }
.track .shot img { display: block; height: 236px; width: auto; border-radius: 2px; background: #000; }
@media (max-width: 520px) { .track .shot img { height: 172px; } }
.track .shot:focus-visible { outline: 3px solid var(--red); outline-offset: -3px; }
.track::-webkit-scrollbar { height: 8px; }
.track::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; }
.cbtn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,.18); background: rgba(18,22,27,.9); color: var(--night-ink); font-size: 20px; line-height: 1; cursor: pointer; }
.cbtn:hover { background: #1b2028; }
.cbtn.prev { left: 6px; } .cbtn.next { right: 6px; }
.cbtn:focus-visible, .track:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.shot-cap { font-size: 13px; color: var(--ink-2); text-align: center; margin: 8px 0 0; max-width: none; }

.trailer { margin-top: 26px; }
.trailer video { width: 100%; max-width: 100%; max-height: 56vh; height: auto; background: #000; border-radius: 4px; display: block; }
.trailer .shot-cap { text-align: left; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.94); display: none; align-items: center; justify-content: center; z-index: 100; padding: 24px; }
.lightbox.open { display: flex; }
.lightbox[hidden] { display: none; }
body.no-scroll { overflow: hidden; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 2px; }
.lightbox-close { position: absolute; top: 14px; right: 18px; background: none; border: 0; color: #fff; font-size: 34px; line-height: 1; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .track { scroll-behavior: auto; } }

/* QR code nelle schede dei libri */
.qr { margin: 8px 0 0; }
.qr img { display: block; width: 120px; height: 120px; background: #fff; border: 1px solid var(--rule); border-radius: 4px; }
.qr figcaption { font-size: 13px; color: var(--ink-2); margin-top: 6px; max-width: 24ch; }

/* ---------- v03 ---------- */
/* Salta al contenuto: visibile solo quando riceve il focus da tastiera */
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 4px; text-decoration: none; font-weight: 700; }
.skip:focus { top: 8px; color: var(--paper); }

/* Copertina: immagine mancante, resta la versione tipografica */
.cover img.is-missing { display: none; }

/* Home: nota sotto lo scaffale (prima era uno stile inline, vietato dalla CSP) */
.after-shelf { margin-top: 40px; }

/* Cronologia: gli eventi inventati sono segnati anche a parole, non solo dal colore */
.timeline .fict-tag { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; vertical-align: middle; margin-left: 6px; }

/* QR code: utili da schermo grande; sul telefono si e' gia' sul telefono */
@media (max-width: 760px) { .qr { display: none; } }
.timeline .fict-tag { color: var(--ink-2); }
.night .timeline .fict-tag { color: var(--night-2); }

/* ---------- v06 ---------- */
/* Pulsanti d'azione nell'apertura delle pagine */
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
/* Indice rapido nell'apertura (libri, interventi) */
.jump { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 22px; font-size: 15px; }
.jump a { font-weight: 700; }
/* Contatti: percorsi per pubblico */
.percorsi { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 28px; }
.percorsi h3 { margin: 0 0 6px; }
.percorsi p { margin: 0 0 14px; color: var(--ink-2); }

/* ---------- v07 ---------- */
/* Autore: ritratto nell'apertura */
.hero--autore .ritratto { max-width: 240px; margin: 0 0 24px; }
@media (min-width: 900px) {
  .hero--autore .wrap { display: grid; grid-template-columns: minmax(0, 1fr) 240px; column-gap: 56px; align-items: start; }
  .hero--autore .wrap > * { grid-column: 1; }
  .hero--autore .ritratto { grid-column: 2; grid-row: 1 / span 4; margin: 0; }
}
/* Interventi recenti */
.recenti { list-style: none; padding: 0; margin: 0 0 24px; }
.recenti li { padding: 12px 0; border-top: 1px solid var(--rule); }
.recenti .date { display: block; font-size: 14px; font-weight: 700; color: var(--ink-2); margin-bottom: 2px; }

/* ---------- v10: enciclopedia Codice Origine ---------- */
.gruppo { margin: 40px 0 16px; font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.schede { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px 32px; }
.schede li { border-top: 1px solid var(--rule); padding-top: 14px; }
.schede h3 { margin: 0 0 6px; font-size: 19px; }
.schede p { margin: 0 0 8px; }
.libri-tag { display: block; font-size: 13px; color: var(--ink-2); }
.night .libri-tag { color: var(--night-2); }
.reali { columns: 2 280px; padding-left: 18px; }
details.spoiler { margin-top: 6px; }
details.spoiler summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--red); }
.night details.spoiler summary { color: var(--night-ink); text-decoration: underline; }
details.spoiler p { margin: 8px 0 0; }
.glossario { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px 36px; margin: 0; }
.glossario h3 { font-size: 18px; margin: 0 0 6px; }
.glossario p { margin: 0 0 6px; }
.tipo { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; vertical-align: middle; margin-left: 6px; }
.tipo--reale { border: 1px solid var(--night-2); color: var(--night-2); }
.tipo--invenzione { background: var(--red); color: #fff; }

/* ---------- v23 ---------- */

/* ---------- v27 ---------- */
/* Ritratto: cerchio senza cornice (home, Autore, 404). Il fondo chiaro della foto stacca da solo
   dal grigio carta della pagina. */
.ritratto { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 50%; background: var(--rule); }

/* Home: foto a sinistra, testo a destra, hero compatta (CTA sopra la piega a 1280x720) */
.hero--home { padding: 28px 0 32px; }
.hero--home .wrap { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: center; }
.hero--home .ritratto { width: 120px; }
.hero--home .kicker { margin-bottom: 10px; }
.hero--home h1 { font-size: clamp(34px, 5vw, 64px); max-width: 15ch; margin-bottom: 18px; }
.hero--home .lede { font-size: clamp(17px, 1.4vw, 19px); margin-bottom: 0; }
.hero--home .roles { margin-top: 16px; gap: 6px 28px; font-size: 14px; }
.hero--home .hero-cta { margin-top: 22px; }
@media (min-width: 900px) {
  .hero--home { padding: 40px 0 44px; }
  .hero--home .wrap { grid-template-columns: 300px minmax(0, 1fr); column-gap: 64px; }
  .hero--home .ritratto { width: 300px; }
}

/* CTA dell'apertura: piu' grandi, testo normale, senza frecce */
.hero-cta { gap: 14px; }
.hero-cta .btn { font-size: 16px; padding: 14px 22px; }
@media (min-width: 900px) { .hero-cta .btn { font-size: 17px; padding: 15px 28px; } }

/* Firma Morse: fascia di passaggio tra apertura e banda scura, in rosso (a tutta larghezza i segni diventavano alti 25 px: troppo pesanti) */
.morse-band { padding: 0 0 36px; }
.morse-band .morse { margin: 0; }
.morse-band .morse svg { width: min(100%, 640px); }
.morse-band .morse .dot, .morse-band .morse .dash { fill: var(--red); }
.morse-band .morse figcaption { margin-top: 14px; }
.morse-band .morse--live .dot, .morse-band .morse--live .dash { animation-iteration-count: 1; }

/* Autore: ritratto a destra, piu' grande */
.hero--autore .ritratto { max-width: 220px; margin: 0 0 28px; }
@media (min-width: 900px) {
  .hero--autore .wrap { grid-template-columns: minmax(0, 1fr) 280px; }
  .hero--autore .ritratto { max-width: 280px; margin: 0; }
}

/* Copertine: leggero sollevamento al passaggio o al focus, niente zoom */
.book > a .cover { transition: transform 160ms ease-out, box-shadow 160ms ease-out; }
.book > a:hover .cover, .book > a:focus-visible .cover { transform: translateY(-4px); box-shadow: 0 1px 0 rgba(0,0,0,0.12), 0 18px 30px -12px rgba(0,0,0,0.65); }
@media (prefers-reduced-motion: reduce) { .book > a .cover { transition: none; } .book > a:hover .cover, .book > a:focus-visible .cover { transform: none; } }

/* Pagina 404: ritratto glitch nello stesso cerchio, con pulsante per fermarlo */
.hero--404 .glitch { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 28px; }
.hero--404 .glitch .ritratto { margin: 0; }
.glitch-toggle { font: inherit; font-size: 14px; color: var(--ink-2); background: none; border: 0; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.glitch-toggle:hover { color: var(--red); }
@media (min-width: 900px) {
  .hero--404 .glitch { grid-column: 2; grid-row: 1 / span 4; align-items: center; margin: 0; }
}

/* ---------- v30: il sito ha il tempo di Milano ----------
   site.js mette data-meteo e data-luce su <html> leggendo meteo.json. Cambia solo la tinta della
   carta: contrasto testo secondario sempre >= 4,6:1 (WCAG AA), nessuna animazione meteo. */
html[data-meteo="sereno"]    { --paper: #F5F3EE; }
html[data-meteo="nuvoloso"]  { --paper: #F2F3F1; }
html[data-meteo="coperto"]   { --paper: #EEF0EE; }
html[data-meteo="nebbia"]    { --paper: #F0F1F0; }
html[data-meteo="pioggia"]   { --paper: #EBEEF0; }
html[data-meteo="temporale"] { --paper: #E7EAEE; }
html[data-meteo="neve"]      { --paper: #F5F7F9; }
html[data-luce="notte"][data-meteo="sereno"]    { --paper: #E9EAEC; }
html[data-luce="notte"][data-meteo="nuvoloso"]  { --paper: #E7E8E9; }
html[data-luce="notte"][data-meteo="coperto"]   { --paper: #E4E6E7; }
html[data-luce="notte"][data-meteo="nebbia"]    { --paper: #E6E7E7; }
html[data-luce="notte"][data-meteo="pioggia"]   { --paper: #E1E5E9; }
html[data-luce="notte"][data-meteo="temporale"] { --paper: #DEE2E7; }
html[data-luce="notte"][data-meteo="neve"]      { --paper: #ECEFF2; }
body { transition: background-color 900ms ease; }
@media (prefers-reduced-motion: reduce) { body { transition: none; } }
.morse-band .meteo-riga { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.meteo-riga a { color: inherit; }

/* ---------- v32: testata con Cerca, quattro percorsi, cataloghi, ricerca ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.top .wrap { gap: 24px; }
.brand { margin-right: auto; }
.top-tools { display: flex; align-items: center; gap: 12px; }
.cerca-link { font-size: 15px; text-decoration: none; padding: 8px 12px; border: 1px solid var(--rule); border-radius: 4px; min-height: 40px; display: inline-flex; align-items: center; }
.cerca-link:hover { border-color: var(--ink); color: var(--ink); }
.cerca-link[aria-current="page"] { border-color: var(--red); }
@media (max-width: 900px) { .nav-toggle { min-height: 40px; } }

/* Home: quattro percorsi subito sotto la firma Morse */
.mondi-sez { padding: 0 0 clamp(36px, 5vw, 56px); }
.mondi { list-style: none; padding: 0; margin: 0; max-width: none; display: grid; grid-template-columns: 1fr; gap: 0 32px; }
@media (min-width: 640px) { .mondi { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .mondi { grid-template-columns: repeat(4, 1fr); } }
.mondi li { margin: 0; }
.mondi a { display: block; height: 100%; padding: 16px 0 18px; border-top: 2px solid var(--ink); text-decoration: none; }
.mondo-t { display: block; font-weight: 700; font-size: 20px; line-height: 1.2; margin-bottom: 6px; }
.mondo-d { display: block; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.mondi a:hover { border-top-color: var(--red); }
.mondi a:hover .mondo-t { color: var(--red); }
.cols--quattro { gap: 40px 56px; }

/* Catalogo giochi: una scheda = un link */
.section--catalogo { padding-top: 0; border-top: 0; }
.gcards { list-style: none; padding: 0; margin: 0; max-width: none; display: grid; grid-template-columns: 1fr; gap: 28px 24px; }
@media (min-width: 640px) { .gcards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .gcards { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .section--catalogo .gcards { grid-template-columns: repeat(4, 1fr); } }
.gcards li { margin: 0; }
.gcard { display: flex; flex-direction: column; gap: 4px; text-decoration: none; height: 100%; }
.gcard img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; background: var(--night); border-radius: 4px; margin-bottom: 8px; transition: transform 160ms ease-out, box-shadow 160ms ease-out; }
.gcard-t { font-weight: 700; font-size: 18px; line-height: 1.25; }
.gcard-g { font-size: 15px; color: var(--ink-2); }
.gcard-p { font-size: 13px; color: var(--ink-2); }
.gcard:hover .gcard-t { color: var(--red); }
.gcard:hover img, .gcard:focus-visible img { transform: translateY(-3px); box-shadow: 0 14px 26px -14px rgba(0,0,0,0.55); }

/* Catalogo libri per gruppi */
.bgruppi { display: flex; flex-wrap: wrap; gap: 28px 40px; }
.bgruppo h3 { font-size: 15px; font-weight: 700; color: var(--ink-2); margin: 0 0 12px; }
.bcards { list-style: none; padding: 0; margin: 0; max-width: none; display: flex; flex-wrap: wrap; gap: 20px; }
.bcards li { margin: 0; width: 132px; }
.bcard { display: flex; flex-direction: column; gap: 3px; text-decoration: none; }
.bcard .cover { max-width: 132px; margin-bottom: 8px; transition: transform 160ms ease-out, box-shadow 160ms ease-out; }
.bcard .cover .ct { padding: 12px; }
.bcard .cover .ct .name { font-size: 16px; }
.bcard-t { font-weight: 700; font-size: 15px; line-height: 1.25; }
.bcard-d { font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.bcard:hover .bcard-t { color: var(--red); }
.bcard:hover .cover, .bcard:focus-visible .cover { transform: translateY(-3px); box-shadow: 0 1px 0 rgba(0,0,0,0.12), 0 16px 28px -12px rgba(0,0,0,0.6); }
@media (max-width: 479px) { .bgruppo { width: 100%; } .bcards li { width: calc(50% - 10px); } .bcard .cover { max-width: none; } }
@media (prefers-reduced-motion: reduce) {
  .gcard img, .bcard .cover { transition: none; }
  .gcard:hover img, .gcard:focus-visible img, .bcard:hover .cover, .bcard:focus-visible .cover { transform: none; }
}

/* Ricerca */
.hero--cerca { padding-bottom: 24px; }
.cerca-box { margin-top: 24px; max-width: 640px; }
.cerca-box label { display: block; font-size: 15px; color: var(--ink-2); margin-bottom: 8px; }
.cerca-box input { width: 100%; font: inherit; font-size: 19px; padding: 12px 14px; color: var(--ink); background: #fff; border: 1.5px solid var(--ink); border-radius: 4px; }
.cerca-box input:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.cerca-stato { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.section--cerca { padding-top: 16px; border-top: 0; }
.r-gruppo { margin: 0 0 40px; }
.r-gruppo h2 { font-size: 22px; margin-bottom: 8px; }
.r-n { font-weight: 400; color: var(--ink-2); font-size: 16px; }
.r-lista { list-style: none; padding: 0; margin: 0; max-width: 820px; }
.r-lista li { padding: 12px 0; border-top: 1px solid var(--rule); margin: 0; }
.r-lista a { font-weight: 700; font-size: 17px; }
.r-tipo { display: inline-block; margin-left: 10px; font-size: 13px; color: var(--ink-2); }
.r-lista p { margin: 4px 0 0; font-size: 15px; color: var(--ink-2); }
.cerca-vuoto { margin-bottom: 32px; }
/* Contrasto (axe, WCAG 1.4.3): il rosso segnale su fondo notte era 2,99:1. Su fondo scuro si usa
   un rosso piu' chiaro, 5,4:1. Vale per la cronologia dell'enciclopedia e per le copertine
   tipografiche di riserva (visibili solo se manca l'immagine). */
:root { --red-night: #F2556A; }
.night .timeline .fict .year { color: var(--red-night); }
.cover:not(.cover--red):not(.cover--paper) .ct .name span { color: var(--red-night); }
.cover--red .ct .series, .cover--red .ct .who { color: #F9E7EA; }
.cover--red .ct .name span { color: #FFFFFF; }
