/* «Carta viva»: la materia del sito, scelta da David il 28/10/2026.
   Stesso colore di sempre, ma con la grana della carta (o il pelo del feltro sulle pagine scure), l'ombra ai bordi,
   una luce calda di lucerna che accompagna lo scorrere, le bande di feltro che aprono le sezioni della pagina dell'autore
   e il nastro delle pagine scure come striscia di carta.
   html[data-tema] lo scrive bonus/costruisci_sito.py: carta (autore) · feltro (volumi) · ardesia (collana, lista, privacy).
   La luce la crea e la muove assets/materia.js; senza JavaScript restano grana, ombra, bande e nastro.
   Prova delle tre direzioni e misure: bonus/sfondo_direzioni/. */
:root {
  --m-grana: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .30 0 0 0 0 .22 0 0 0 0 .12 1.7 0 0 0 -.66'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  --m-grana-tenue: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .30 0 0 0 0 .22 0 0 0 0 .12 .8 0 0 0 -.33'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  --m-nuvole: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='720' height='720'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.0045 .011' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .42 0 0 0 0 .22 .9 0 0 0 -.42'/%3E%3C/filter%3E%3Crect width='720' height='720' filter='url(%23m)'/%3E%3C/svg%3E");
  --m-pelo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .97 0 0 0 0 .92 0 0 0 0 .82 2.1 0 0 0 -1.08'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23f)'/%3E%3C/svg%3E");
  --m-pelo-tenue: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .97 0 0 0 0 .92 0 0 0 0 .82 1.1 0 0 0 -.6'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23f)'/%3E%3C/svg%3E");
  /* i feltri dei tre volumi cuciti insieme, nell'ordine della home (dal più recente) */
  --m-tre-feltri: linear-gradient(90deg, #181513 0 calc(33.33% - 1px), rgba(0,0,0,.55) 0 calc(33.33% + 1px), #142944 0 calc(66.66% - 1px), rgba(0,0,0,.55) 0 calc(66.66% + 1px), #112F25 0);
}

/* ---------- grana e ombra ai bordi: due strati fissi dietro a tutto (oltre la barra del telefono) ---------- */
html[data-tema] body::before,
html[data-tema] body::after { content: ""; position: fixed; inset: -12vh 0; z-index: -1; pointer-events: none; }
html[data-tema="carta"] body::before { background: var(--m-grana) 0 0 / 240px, var(--m-nuvole) 0 0 / 720px; opacity: .55; }
html[data-tema="carta"] body::after { background: radial-gradient(120% 90% at 50% 40%, transparent 50%, rgba(92,64,22,.16)); }
html[data-tema="feltro"] body::before,
html[data-tema="ardesia"] body::before { background: var(--m-pelo) 0 0 / 260px; opacity: .11; }
html[data-tema="feltro"] body::after,
html[data-tema="ardesia"] body::after { background: radial-gradient(120% 90% at 50% 40%, transparent 45%, rgba(0,0,0,.42)); }

/* ---------- la luce di lucerna (creata da materia.js) ---------- */
.lucerna { position: fixed; inset: -12vh 0; z-index: -1; pointer-events: none; overflow: hidden; contain: strict; }
.lucerna i { position: absolute; left: 0; top: 0; width: var(--m-d, 115vmax); height: var(--m-d, 115vmax); border-radius: 50%; will-change: transform; animation: m-respiro 7s ease-in-out infinite; }
html[data-tema="carta"] .lucerna i { background: radial-gradient(closest-side, rgba(255,251,240,.8), rgba(255,247,228,.38) 42%, rgba(255,245,224,0) 100%); }
html[data-tema="feltro"] .lucerna i,
html[data-tema="ardesia"] .lucerna i { --m-d: 95vmax; background: radial-gradient(closest-side, rgba(255,176,92,.34), rgba(232,150,70,.13) 45%, transparent 100%); mix-blend-mode: screen; }
@keyframes m-respiro { 0%, 100% { opacity: 1; } 38% { opacity: .86; } 52% { opacity: .95; } 70% { opacity: .9; } }

/* ---------- le bande di feltro che aprono le sezioni (h2 class="banda", sulla carta) ----------
   La banda esce dal contenitore e prende tutta la larghezza; il testo resta allineato alla colonna.
   Entrando nello schermo si srotola da sinistra (classe .in, la mette lo script della pagina). */
html[data-tema="carta"] h2.banda {
  position: relative; margin: 0 calc(50% - 50vw) 30px; padding: 30px calc(50vw - 50%) 28px; color: var(--crema, #F6EEDC); font-size: 34px; line-height: 1;
  background: var(--m-pelo-tenue) 0 0 / 260px, linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.22)), var(--m-banda, #26292D);
  box-shadow: 0 22px 34px -26px rgba(40,25,5,.75);
  opacity: 1; transform: none; clip-path: inset(0 100% -60px 0); transition: clip-path 1.3s var(--ease, cubic-bezier(.22,.61,.36,1));
}
html[data-tema="carta"] h2.banda.in { clip-path: inset(0 0 -60px 0); }
html[data-tema="carta"] h2.banda::before,
html[data-tema="carta"] h2.banda::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: repeating-linear-gradient(90deg, rgba(212,172,96,.6) 0 8px, transparent 8px 14px); }
html[data-tema="carta"] h2.banda::before { top: 8px; }
html[data-tema="carta"] h2.banda::after { bottom: 8px; }
html[data-tema="carta"] h2.banda.volumi { --m-banda: var(--m-tre-feltri); }
/* le schede appoggiate sulla carta: ombra calda e più profonda */
html[data-tema="carta"] .collana,
html[data-tema="carta"] .volume { box-shadow: 0 2px 0 rgba(255,255,255,.05) inset, 0 28px 46px -30px rgba(52,34,8,.75), 0 6px 14px -8px rgba(52,34,8,.35); }
html[data-tema="carta"] .lista { background: var(--m-grana-tenue) 0 0 / 240px, var(--carta-chiara, #FBF6EA); box-shadow: 0 24px 44px -34px rgba(52,34,8,.6); }

/* ---------- sulle pagine scure il nastro diventa una striscia di carta, appena inclinata ---------- */
html[data-tema="feltro"] .nastro,
html[data-tema="ardesia"] .nastro {
  background: var(--m-grana) 0 0 / 240px, linear-gradient(180deg, #F8F0DF, #EFE4CC); border: 0; mask-image: none; -webkit-mask-image: none;
  margin: 6px -3vw 84px; padding: 15px 0; transform: rotate(-1.3deg); box-shadow: 0 16px 30px -16px rgba(0,0,0,.85);
}
html[data-tema="feltro"] .nastro span,
html[data-tema="ardesia"] .nastro span { color: #3B342A; }
html[data-tema="feltro"] .nastro span b,
html[data-tema="ardesia"] .nastro span b { color: #8A6726; }
html[data-tema="ardesia"] .nastro span.serie { color: #1A1A1A; }
html[data-tema="feltro"] .scheda-card,
html[data-tema="feltro"] .amazon,
html[data-tema="feltro"] .autore,
html[data-tema="ardesia"] .autore { box-shadow: 0 30px 50px -34px rgba(0,0,0,.9); }

@media (max-width: 760px) {
  html[data-tema="carta"] h2.banda { font-size: 28px; padding-top: 24px; padding-bottom: 22px; }
  html[data-tema="feltro"] .nastro, html[data-tema="ardesia"] .nastro { margin-bottom: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .lucerna i { animation: none; }
  html[data-tema="carta"] h2.banda { clip-path: none; }
}
