/* Wizard di avvio: stile del totem (D9). I font Baloo 2 e Figtree li carica l'host.
   Classi di stato (contratto con wizard.js):
     .attiva   scena e frase in corso (le applica wizard.js)
     .fatta    voce del percorso completata (la applica wizard.js da localStorage)
     .corrente voce del percorso mostrata (la mette il server)
     html.js   messa da wizard.js: una scena per volta e comandi visibili; senza, la pagina resta un testo leggibile. */

/* Copia di totem.css: stessi nomi e stessi valori, verificata da StileTotemTests. */
:root {
    --hereiam-primary:        #7e57c2;
    --hereiam-primary-deep:   #4527a0;
    --hereiam-primary-soft:   #ede7f6;
    --hereiam-accent:         #ffca28;
    --hereiam-accent-deep:    #ffb300;
    --hereiam-green:          #aed581;
    --hereiam-green-deep:     #7cb342;
    --hereiam-cream:          #ede8f8;
    --hereiam-text:           #2b1a4b;
    --hereiam-text-muted:     #6e5a8f;
    --hereiam-soft-shadow:    #ddd4f0;
    --hereiam-radius-card:    24px;
    --hereiam-radius-slot:    14px;
    --hereiam-radius-btn:     22px;
    /* Altezza della barra dei comandi fissa su telefono (pallini 48 + pulsanti 52 + spazi e bordo): sotto, la pagina lascia questo vuoto. */
    --wz-barra:               140px;
}

.wz-pagina {
    box-sizing: border-box;
    min-height: 100vh;
    margin: 0;
    padding: 16px 16px 120px;
    background: var(--hereiam-cream);
    color: var(--hereiam-text);
    font-family: 'Figtree', system-ui, sans-serif;
    font-size: 17px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    /* clip e non hidden: hidden fa della pagina un contenitore di scroll e rompe position: sticky del percorso. */
    overflow-x: clip;
}

.wz-pagina *, .wz-pagina *::before, .wz-pagina *::after { box-sizing: border-box; }

.wz-layout { max-width: 1100px; margin: 0 auto; display: grid; gap: 20px; }

.wz-titolo, .wz-sottotitolo {
    font-family: 'Baloo 2', 'Figtree', sans-serif;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: var(--hereiam-primary-deep);
    margin: 0;
}
.wz-titolo { font-size: 30px; line-height: 1.15; }
.wz-sottotitolo { font-size: 20px; margin-bottom: 6px; }
.wz-solo-lettori {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.wz-etichetta { margin: 0 0 4px; color: var(--hereiam-text-muted); font-weight: 600; }

/* Card: bordo morbido e ombra in basso, come .action-card del totem. */
.wz-card, .wz-percorso, .wz-lettore {
    background: #fff;
    border: 2px solid var(--hereiam-primary-soft);
    border-radius: var(--hereiam-radius-card);
    box-shadow: 0 4px 0 0 var(--hereiam-soft-shadow);
    padding: 18px 20px;
}

.wz-passo { display: grid; gap: 18px; }

/* Pulsanti: alti almeno 48 px, ombra piena che si schiaccia al tocco. */
.wz-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 22px;
    border: 2px solid var(--hereiam-primary-soft);
    border-radius: var(--hereiam-radius-btn);
    background: #fff;
    color: var(--hereiam-primary-deep);
    font-family: 'Baloo 2', 'Figtree', sans-serif;
    font-weight: 800;
    font-size: 18px;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 0 0 var(--hereiam-soft-shadow);
    transition: transform 0.1s, box-shadow 0.1s;
}
.wz-btn[data-azione=fatto][aria-pressed=true] {
    background: var(--hereiam-green-deep);
    border-color: var(--hereiam-green-deep);
    color: #fff;
    box-shadow: 0 5px 0 0 var(--hereiam-green-deep);
}
.wz-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 0 var(--hereiam-soft-shadow); }
.wz-btn-primario {
    background: var(--hereiam-primary);
    border-color: var(--hereiam-primary);
    color: #fff;
    box-shadow: 0 5px 0 0 var(--hereiam-primary-deep);
}
.wz-btn-primario:active { box-shadow: 0 2px 0 0 var(--hereiam-primary-deep); }
.wz-btn:focus-visible, .wz-link:focus-visible, .wz-pallino:focus-visible, .wz-voce a:focus-visible {
    outline: 3px solid var(--hereiam-accent-deep);
    outline-offset: 2px;
}

.wz-navigazione { display: flex; flex-wrap: wrap; gap: 14px; }
.wz-navigazione .wz-btn { text-align: center; }

.wz-link { display: inline-block; padding: 12px 0; color: var(--hereiam-primary-deep); font-weight: 700; }
.wz-approfondimenti ul { margin: 0; padding-left: 20px; }
.wz-fatta-quando p { margin: 0 0 14px; }

/* Percorso */
.wz-percorso { padding: 12px; }
.wz-percorso summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 0 6px;
    color: var(--hereiam-primary-deep);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
.wz-percorso summary::-webkit-details-marker { display: none; }
.wz-percorso summary::after { content: "\25BE"; transition: transform 0.15s; }
.wz-percorso[open] summary::after { transform: rotate(180deg); }
.wz-percorso summary:focus-visible { outline: 3px solid var(--hereiam-primary); outline-offset: 2px; }
.wz-percorso[open] ol { margin-top: 8px; }
.wz-percorso ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wz-voce a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 6px 10px;
    border-radius: var(--hereiam-radius-slot);
    color: var(--hereiam-text);
    font-weight: 600;
    text-decoration: none;
}
.wz-voce-numero {
    flex: none;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--hereiam-primary-soft);
    color: var(--hereiam-primary-deep);
    font-family: 'Baloo 2', 'Figtree', sans-serif;
    font-weight: 800;
}
.wz-voce.corrente a { background: var(--hereiam-primary-soft); }
.wz-voce.corrente .wz-voce-numero { background: var(--hereiam-primary); color: #fff; }
.wz-voce.fatta .wz-voce-numero { background: var(--hereiam-green-deep); color: #fff; font-size: 0; }
.wz-voce.fatta .wz-voce-numero::after { content: "\2713"; font-size: 18px; }

/* Lettore. Senza JS: tutte le scene in fila, frasi in elenco, <audio controls> nativo. */
.wz-scena + .wz-scena { margin-top: 14px; }
.wz-scena:not(:first-child) .wz-figura { display: none; }
.wz-figura { margin: 0 0 12px; }
.wz-figura img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--hereiam-radius-slot);
    background: var(--hereiam-primary-soft);
}
.wz-segnaposto {
    display: grid;
    place-items: center;
    min-height: 180px;
    padding: 20px;
    border-radius: var(--hereiam-radius-slot);
    background: var(--hereiam-primary-soft);
    color: var(--hereiam-primary-deep);
    font-family: 'Baloo 2', 'Figtree', sans-serif;
    font-weight: 800;
    font-size: 26px;
    text-align: center;
}
.wz-frasi { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wz-frase { padding: 6px 10px; border-radius: var(--hereiam-radius-slot); }
.wz-frase.attiva { background: var(--hereiam-accent); color: var(--hereiam-text); font-weight: 600; }

.wz-audio { display: block; width: 100%; margin-top: 14px; }
.wz-comandi { display: none; }

/* Con JS: una scena per volta, audio nativo nascosto, comandi visibili. */
html.js .wz-scena { display: none; margin: 0; }
html.js .wz-scena.attiva { display: block; }
html.js .wz-scena:not(:first-child) .wz-figura { display: block; }
html.js .wz-audio { display: none; }
html.js .wz-comandi {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}
html.js .wz-frase:not(.attiva) { color: var(--hereiam-text-muted); }
html.js .wz-frasi { gap: 4px; }

.wz-pallini { display: flex; flex-wrap: wrap; gap: 4px; margin-right: auto; }
/* Il bersaglio del tocco resta di 48 px; il pallino disegnato è più piccolo. */
.wz-pallino {
    position: relative;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}
.wz-pallino::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    transform: translate(-50%, -50%);
    border-radius: 6px;
    background: var(--hereiam-primary-soft);
    border: 2px solid var(--hereiam-primary);
    transition: width 0.15s;
}
.wz-pallino.attiva::before {
    width: 26px;
    background: var(--hereiam-primary);
}

/* Approfondimento in pannello */
.wz-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 18px 20px;
    border: 2px solid var(--hereiam-primary-soft);
    border-radius: var(--hereiam-radius-card);
    background: var(--hereiam-cream);
    color: var(--hereiam-text);
    overflow-y: auto;
}
.wz-dialog::backdrop { background: rgba(43, 26, 75, 0.55); }
.wz-dialog-testa { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.wz-dialog-testa .wz-titolo { font-size: 24px; }

/* Schermo largo: percorso a sinistra, passo a destra. */
@media (min-width: 900px) {
    .wz-pagina { padding: 32px 24px 48px; }
    .wz-layout { grid-template-columns: 300px minmax(0, 1fr); align-items: start; gap: 28px; }
    .wz-percorso-nav { position: sticky; top: 24px; }
    /* Aperto da wizard.js: la riga di sintesi si nasconde solo se l'elenco e' gia' aperto
       (senza JS resta visibile e cliccabile; ::details-content e' solo un miglioramento). */
    .wz-percorso[open] > summary { display: none; }
    .wz-percorso::details-content { content-visibility: visible; display: block; }
    .wz-percorso ol { margin-top: 0; }
}

/* Telefono: comandi della voce fissi in basso, margini di 16 px. */
@media (max-width: 899px) {
    html.js .wz-pagina { padding-bottom: calc(var(--wz-barra) + env(safe-area-inset-bottom)); }
    html.js .wz-comandi {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10;
        margin: 0;
        padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
        background: #fff;
        border-top: 2px solid var(--hereiam-primary-soft);
        box-shadow: 0 -4px 0 0 var(--hereiam-soft-shadow);
    }
    /* La barra comandi fissa del lettore nel pannello non deve coprire le ultime frasi. */
    html.js .wz-dialog { padding-bottom: calc(18px + var(--wz-barra) + env(safe-area-inset-bottom)); }
    html.js .wz-pallini { flex: 1 1 100%; justify-content: center; margin: 0; }
    html.js .wz-comandi .wz-btn { flex: 1 1 0; }
    .wz-titolo { font-size: 26px; }
}
