/* Schermo del Master — le copertine (Sdm\Copertine, tappa 45, 22 nov. 2026): fronte e retro di qualunque risultato
   (avventura, dungeon o edificio, insediamento, locanda, luogo). Una pagina è un A4 vero in millimetri: nelle anteprime si
   rimpicciolisce con --cpt-k, in stampa esce così com'è. I colori sono quelli dei moduli d'epoca: un disegno, non il tema.
   Tre stili sullo stesso HTML: cpt-s-modulo (fondo sfumato, fascia arancio), cpt-s-mono (carta colorata, un inchiostro),
   cpt-s-pagina (illustrazione a tutta pagina). Caricato dal layout su tutte le pagine. */

.cpt-pag { box-sizing: border-box; width: 210mm; height: 297mm; position: relative; overflow: hidden; display: flex; flex-direction: column; color: #fff; text-align: center;
  font-family: "Libre Baskerville", Georgia, "Times New Roman", serif; line-height: 1.2; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.cpt-pag * { box-sizing: border-box; }
.cpt-c-notte { --cpt-1: #0e1722; --cpt-2: #1c2c3d; --cpt-3: #33506a; --cpt-carta: #c5d3de; --cpt-tinta: #1c2c3d; }
.cpt-c-sangue { --cpt-1: #150405; --cpt-2: #5a0d10; --cpt-3: #c3161c; --cpt-carta: #efb7a0; --cpt-tinta: #7a1216; }
.cpt-c-bosco { --cpt-1: #05140b; --cpt-2: #123d24; --cpt-3: #2f8248; --cpt-carta: #bcdab4; --cpt-tinta: #174a2b; }
.cpt-c-abisso { --cpt-1: #060b1c; --cpt-2: #14245a; --cpt-3: #2a4290; --cpt-carta: #b4cbea; --cpt-tinta: #14245a; }
.cpt-c-incanto { --cpt-1: #0d0716; --cpt-2: #33194f; --cpt-3: #5c3a8a; --cpt-carta: #d6c4e8; --cpt-tinta: #3b1d5c; }
.cpt-c-pietra { --cpt-1: #0b0c0d; --cpt-2: #2a2e32; --cpt-3: #50575d; --cpt-carta: #dcd8cf; --cpt-tinta: #2a2e32; }
.cpt-c-terra { --cpt-1: #120a04; --cpt-2: #4a2b10; --cpt-3: #87531f; --cpt-carta: #f1d887; --cpt-tinta: #5a3410; }
.cpt-pag { background: linear-gradient(180deg, var(--cpt-1) 0%, var(--cpt-2) 50%, var(--cpt-3) 100%); }

/* --- le parti, nello stile «modulo» */
.cpt-fascia { flex: none; height: 12mm; background: #ee8a2c; color: #1a1208; display: flex; align-items: center; justify-content: space-between; gap: 4mm; padding: 0 9mm; font: 700 10.5pt "Segoe UI", Helvetica, Arial, sans-serif; letter-spacing: .01em; }
.cpt-sg { font: 700 13pt Georgia, serif; white-space: nowrap; }
.cpt-lv { flex: 1; text-align: center; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cpt-nm { white-space: nowrap; }
.cpt-testata { flex: none; margin-top: 7mm; line-height: .92; text-shadow: 0 1px 0 rgb(0 0 0 / .35); display: flex; flex-direction: column; align-items: center; }
.cpt-logo { display: block; width: 78%; max-width: 150mm; height: auto; margin: 0 auto; }
.cpt-logo + .cpt-testo { display: none; }
.cpt-a1 { font: 700 38pt "Libre Baskerville", Georgia, serif; letter-spacing: -.01em; display: block; }
.cpt-a2 { font: 700 40pt "Libre Baskerville", Georgia, serif; letter-spacing: -.02em; white-space: nowrap; display: block; }
.cpt-amp { font-style: italic; color: #f1d9a6; font-size: .82em; margin: 0 .1em; position: relative; top: -.04em; }
.cpt-dicitura { flex: none; font: 400 12pt "Libre Baskerville", Georgia, serif; margin-top: 3.2mm; letter-spacing: .02em; }
.cpt-filetto { flex: none; width: 112mm; height: 0; border-top: .5mm solid rgb(255 255 255 / .9); margin: 2.4mm auto; }
.cpt-titolo { flex: none; font: 700 25pt/1.08 "Libre Baskerville", Georgia, serif; margin: 0 14mm; text-wrap: balance; overflow-wrap: anywhere; }
.cpt-autore { flex: none; font: italic 400 10.5pt "Libre Baskerville", Georgia, serif; margin-top: 1.6mm; }
.cpt-livelli { display: none; flex: none; }
.cpt-cornice { flex: 1 1 0; min-height: 40mm; margin: 2mm 11mm 0; position: relative; border: 1.1mm solid #0b0b0b; border-radius: 5mm; overflow: hidden; box-shadow: 0 0 0 .45mm rgb(255 255 255 / .55), 0 2mm 6mm rgb(0 0 0 / .5); background: #222; }
.cpt-cornice img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cpt-pianta { background: #fff; }
.cpt-pianta img { inset: 3mm; width: calc(100% - 6mm); height: calc(100% - 6mm); object-fit: contain; }
.cpt-credito { flex: none; margin: .8mm 13mm 0; text-align: right; font: 400 6pt "Segoe UI", Helvetica, Arial, sans-serif; opacity: .7; }
.cpt-frase { flex: none; margin: 4mm 22mm 0; font: 400 10pt/1.42 "Libre Baskerville", Georgia, serif; text-wrap: balance; }
/* tappa 51: in fondo al fronte la sigla «SdM» (un SVG che prende il colore del testo), al posto del riquadro «AD&D 2ª ed.» */
.cpt-sdm { flex: none; margin: 5mm auto 9mm; line-height: 0; }
.cpt-sdm svg { display: block; width: 19mm; height: auto; }
/* senza illustrazione: un fregio con la sigla al posto della cornice, la frase più grande */
.cpt-fregio { flex: 1 1 0; min-height: 40mm; display: flex; align-items: center; justify-content: center; }
.cpt-fregio span { width: 78mm; height: 78mm; border-radius: 50%; border: 2.2mm double currentColor; display: flex; align-items: center; justify-content: center; font: 700 44pt Georgia, serif; letter-spacing: .02em; opacity: .9; }
.cpt-senza .cpt-frase { font-size: 12.5pt; margin-left: 28mm; margin-right: 28mm; }
/* retro */
.cpt-retro .cpt-testata { margin-top: 16mm; }
.cpt-sinossi { flex: 1 1 0; overflow: hidden; margin: 9mm auto 0; width: 126mm; font: 400 11pt/1.5 "Libre Baskerville", Georgia, serif; text-align: left; }
.cpt-sinossi p { margin: 0 0 4.2mm; }
.cpt-piede { flex: none; margin: 6mm 24mm 30mm; border-top: .35mm solid currentColor; padding-top: 2.5mm; display: flex; justify-content: space-between; gap: 4mm; font: 400 7.5pt "Segoe UI", Helvetica, Arial, sans-serif; opacity: .9; }

/* --- stile «monocromo»: carta colorata, inchiostro nero, la sigla in una banda di traverso nell'angolo */
.cpt-s-mono { background: var(--cpt-carta); color: #121212; }
.cpt-s-mono .cpt-fascia { position: absolute; left: -38mm; top: 15mm; width: 130mm; height: 13mm; transform: rotate(-35deg); background: var(--cpt-tinta); color: #fff; justify-content: center; padding: 0; }
.cpt-s-mono .cpt-lv, .cpt-s-mono .cpt-nm { display: none; }
.cpt-s-mono .cpt-sg::before { content: "MODULO "; font: 700 8.5pt "Segoe UI", Helvetica, Arial, sans-serif; letter-spacing: .16em; }
.cpt-s-mono .cpt-testata { margin-top: 34mm; text-shadow: none; display: block; line-height: 1.1; }
.cpt-s-mono.cpt-retro .cpt-testata { margin-top: 34mm; }
/* tappa 51: anche nel monocromo il logo, non la scritta: quello di AD&D (a colori) esce in grigio */
.cpt-s-mono .cpt-logo { filter: grayscale(1) contrast(1.15); width: 60%; max-width: 120mm; }
.cpt-s-mono .cpt-a1, .cpt-s-mono .cpt-a2 { display: inline; font: 700 15pt "Libre Baskerville", Georgia, serif; text-transform: uppercase; letter-spacing: .14em; }
.cpt-s-mono .cpt-a1::after { content: " "; }
.cpt-s-mono .cpt-amp { color: inherit; font-size: 1em; top: 0; }
.cpt-s-mono .cpt-dicitura { font: 400 9pt "Segoe UI", Helvetica, Arial, sans-serif; text-transform: uppercase; letter-spacing: .24em; margin-top: 2.4mm; }
.cpt-s-mono .cpt-filetto { width: 150mm; border-top-color: #121212; margin: 3mm auto; }
.cpt-s-mono .cpt-titolo { font-size: 32pt; }
.cpt-s-mono .cpt-livelli { display: block; font: 700 9.5pt "Segoe UI", Helvetica, Arial, sans-serif; text-transform: uppercase; letter-spacing: .1em; margin-top: 2.6mm; }
.cpt-s-mono .cpt-cornice { margin: 1mm 16mm 0; border: .8mm solid #121212; border-radius: 0; box-shadow: none; background: #fff; }
.cpt-s-mono .cpt-cornice:not(.cpt-pianta) img { filter: grayscale(1) contrast(1.12); }
.cpt-s-mono .cpt-frase { font-size: 10.5pt; }
/* il logo di BECMI (tappa 48) è una sagoma bianca: sui fondi scuri così com'è; nel monocromo in nero, al posto della scritta */
.cpt-logo-becmi { width: 64%; max-width: 128mm; }
.cpt-s-mono .cpt-logo-becmi { display: block; filter: brightness(0); width: 56%; max-width: 112mm; }
.cpt-s-mono .cpt-logo-becmi + .cpt-testo { display: none; }

/* --- stile «a tutta pagina»: l'illustrazione fa da fondo, i testi ci stanno sopra */
.cpt-s-pagina.cpt-fronte:not(.cpt-senza) .cpt-cornice { position: absolute; inset: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; z-index: 0; }
.cpt-s-pagina.cpt-fronte:not(.cpt-senza) .cpt-cornice::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgb(0 0 0 / .8) 0%, rgb(0 0 0 / .5) 24%, rgb(0 0 0 / 0) 44%, rgb(0 0 0 / 0) 64%, rgb(0 0 0 / .86) 100%); }
.cpt-s-pagina.cpt-fronte:not(.cpt-senza) > :not(.cpt-cornice) { position: relative; z-index: 1; }
.cpt-s-pagina.cpt-fronte:not(.cpt-senza) .cpt-filetto-2 { margin-bottom: auto; }
.cpt-s-pagina.cpt-fronte:not(.cpt-senza) > .cpt-credito { position: absolute; right: 5mm; bottom: 2.5mm; margin: 0; }
.cpt-s-pagina.cpt-fronte .cpt-frase { font-size: 11pt; text-shadow: 0 1px 2px rgb(0 0 0 / .8); }
.cpt-s-pagina.cpt-fronte .cpt-titolo { font-size: 30pt; text-shadow: 0 1px 3px rgb(0 0 0 / .7); }

/* --- anteprime: la stessa pagina, rimpicciolita */
.cpt-ant { --cpt-k: .4; width: calc(210mm * var(--cpt-k)); height: calc(297mm * var(--cpt-k)); margin: 0; flex: none; overflow: hidden; border-radius: 3px; box-shadow: 0 2px 10px rgb(0 0 0 / .35); }
.cpt-ant > .cpt-pag { transform: scale(var(--cpt-k)); transform-origin: 0 0; }
.cpt-anteprime { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: center; }
.cpt-anteprime[aria-busy="true"] { opacity: .75; }

/* --- la finestra «📕 Copertina» */
.finestra-modulo:has(.cpt-finestra) { width: min(72rem, calc(100vw - 1rem)); }
.cpt-tit { margin: 0 0 .7rem; }
.cpt-tit .sub { font-weight: normal; font-size: .75em; opacity: .75; margin-left: .4em; }
.cpt-modulo { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.cpt-sx { display: grid; gap: .5rem; justify-items: center; min-width: 0; }
.cpt-lati { display: inline-flex; border: 1px solid var(--filetto); border-radius: var(--raggio); overflow: hidden; }
.cpt-modulo .cpt-lati label { display: block; margin: 0; font-weight: 600; cursor: pointer; }
.cpt-lati input { position: absolute; opacity: 0; pointer-events: none; }
.cpt-lati span { display: block; padding: .25rem .9rem; }
.cpt-lati input:checked + span { background: var(--accento); color: #fff; }
.cpt-lati input:focus-visible + span { outline: 2px solid var(--accento); outline-offset: -4px; }
.cpt-sx:has(input[value="f"]:checked) .cpt-ant:nth-child(2), .cpt-sx:has(input[value="r"]:checked) .cpt-ant:nth-child(1) { display: none; }
.cpt-nota-ant { margin: 0; }
.cpt-campi { display: grid; gap: .8rem; min-width: 0; }
.cpt-campi .largo { display: grid; gap: .2rem; }
.cpt-campi textarea, .cpt-campi input[type="text"] { width: 100%; box-sizing: border-box; }
.cpt-campi .riga-campi { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.cpt-colori { display: flex; flex-wrap: wrap; gap: .3rem .9rem; align-items: center; }
.cpt-pallino { display: inline-block; width: 1.15rem; height: 1.15rem; border-radius: 50% 0 0 50%; vertical-align: middle; background: linear-gradient(180deg, var(--cpt-1), var(--cpt-3)); }
.cpt-pallino-carta { border-radius: 0 50% 50% 0; background: var(--cpt-carta); margin-left: -.5rem; }
.cpt-galleria { display: flex; flex-wrap: wrap; gap: .35rem; max-height: 15rem; overflow: auto; padding: 2px; }
.cpt-modulo .cpt-galleria label { position: relative; display: block; width: 4.6rem; aspect-ratio: 1.25; overflow: hidden; border-radius: 4px; margin: 0; cursor: pointer; outline: 2px solid transparent; }
.cpt-galleria img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cpt-galleria input { position: absolute; top: .15rem; left: .15rem; margin: 0; }
.cpt-galleria label:has(input:checked) { outline-color: var(--accento); }
.cpt-modulo .cpt-galleria .cpt-gal-auto { display: flex; align-items: center; justify-content: center; text-align: center; padding: 1.1rem .2rem .2rem; font-size: .78rem; font-weight: 600; border: 1px dashed var(--filetto); }
/* l'elenco dei dipinti serve solo se l'illustrazione è un dipinto; il livello solo con la pianta */
.cpt-modulo:has(select[name="fonte"] option:not([value=""]):checked) .cpt-solo-dipinto { display: none; }
.cpt-modulo:not(:has(select[name="fonte"] option[value="pianta"]:checked)) .cpt-solo-pianta { display: none; }
.cpt-pulsanti { display: flex; flex-wrap: wrap; gap: .5rem .7rem; align-items: center; position: sticky; bottom: -1.4rem; background: var(--carta); padding: .6rem 0 .8rem; border-top: 1px solid var(--filetto); }
.cpt-pulsanti .spunta { flex: 1 1 100%; }
@media (min-width: 58rem) {
  .cpt-modulo { grid-template-columns: auto minmax(0, 1fr); }
  .cpt-sx { position: sticky; top: 0; }
  .cpt-finestra .cpt-ant { --cpt-k: .43; }
}
@media (max-width: 30rem) { .cpt-finestra .cpt-ant { --cpt-k: .34; } }

/* --- la voce di campagna: la copertina si apre da un «📕 Copertina» in testa */
.cpt-voce { margin: 0 0 .8rem; }
.cpt-voce > summary { cursor: pointer; display: inline-block; padding: .25rem .6rem; border: 1px solid var(--filetto); border-radius: var(--raggio); background: var(--carta); }
.cpt-voce .cpt-anteprime { margin: .7rem 0 .4rem; }

/* --- stampa: le due pagine attorno alla scheda (copertina.js le porta in testa e in fondo al body), o da sole («Stampa solo la copertina») */
.cpt-stampa, .cpt-solo-pagine { display: none; }
@media print {
  @page copertina { size: A4; margin: 0; }
  .cpt-stampa { display: block; page: copertina; }
  .cpt-stampa-fronte { break-after: page; }
  .cpt-stampa-retro { break-before: page; }
  .cpt-voce, .cpt-finestra { display: none !important; }
  /* con la copertina la stampa è un fascicolo: fronte per primo, retro per ultimo, niente testata del sito, titolo della
     pagina, briciole, legami della voce, piede */
  body:has(.cpt-stampa) > header, body:has(.cpt-stampa) > footer, body:has(.cpt-stampa) main > .avviso,
  body:has(.cpt-stampa) .generatore > :not(.gen), body:has(.cpt-stampa) .voce-campagna > :not(.scheda-pg-contenitore),
  body:has(.cpt-stampa) .bozza-riprendi { display: none !important; }
  html.cpt-fascicolo, html.cpt-fascicolo body { margin: 0 !important; padding: 0 !important; border: 0 !important; }
  /* e niente margine in fondo ai contenitori: con l'ultima pagina piena finirebbe da solo su una pagina vuota prima del retro */
  html.cpt-fascicolo main, html.cpt-fascicolo .foglio, html.cpt-fascicolo .gen, html.cpt-fascicolo #risultato, html.cpt-fascicolo .scheda-pg-contenitore,
  html.cpt-fascicolo #risultato > :last-child { padding-bottom: 0 !important; margin-bottom: 0 !important; border-bottom: 0 !important; min-height: 0 !important; }
  html.cpt-solo body > *:not(.cpt-solo-pagine) { display: none !important; }
  html.cpt-solo .cpt-solo-pagine { display: block; }
  html.cpt-solo .cpt-solo-pagine .cpt-pag { page: copertina; break-after: page; }
}
