/*
Theme Name: Story
Theme URI: https://cristiantommaselli.it
Author: Cristian Tommaselli
Author URI: https://cristiantommaselli.it
Description: A custom WordPress theme.
Version: 1.4.4
Text Domain: story
Domain Path: /languages
*/

/* ===========================
   Reset & Base
   =========================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Testo solo per screen reader (usato da WordPress core e WooCommerce, es. prezzi
   scontati): il tema non eredita da _s/underscores, quindi va definito qui. */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute !important;
    width: 1px;
    word-wrap: normal !important;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    color: #333;
    background-color: #fff;
    max-width: 100vw;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: #0073aa;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===========================
   Layout
   =========================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.site {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-content {
    flex: 1;
    padding: 3rem 0;
}

.content-area {
    width: 100%;
}

@media (min-width: 768px) {
    .has-sidebar .content-area {
        float: left;
        width: 65%;
    }

    .has-sidebar .widget-area {
        float: right;
        width: 30%;
    }
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* ===========================
   Header
   =========================== */
.site-header {
    background: transparent;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-branding .site-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.site-branding .site-title a {
    color: #2b2013;
    text-decoration: none;
}

.site-branding .site-description {
    font-size: 0.875rem;
    color: #6b5a42;
    margin: 0;
}

/* ===========================
   Navigation
   =========================== */
.main-navigation ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.main-navigation a {
    color: #6b5a42;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

.main-navigation a:hover,
.main-navigation .current-menu-item > a {
    color: #0073aa;
    text-decoration: none;
}

/* ===========================
   Posts & Pages
   =========================== */
.entry {
    margin-bottom: 3rem;
}

.entry-header {
    margin-bottom: 1.5rem;
}

.entry-title {
    font-size: 2rem;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.entry-title a {
    color: #1a1a1a;
}

.entry-title a:hover {
    color: #0073aa;
    text-decoration: none;
}

.entry-meta {
    font-size: 0.875rem;
    color: #777;
}

.entry-meta a {
    color: #777;
}

.entry-content {
    line-height: 1.8;
}

.entry-content p,
.entry-content ul,
.entry-content ol,
.entry-content blockquote,
.entry-content pre {
    margin-bottom: 1.5rem;
}

.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
    margin: 2rem 0 1rem;
    line-height: 1.3;
}

.entry-content blockquote {
    border-left: 4px solid #0073aa;
    padding-left: 1.5rem;
    color: #555;
    font-style: italic;
}

.entry-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    font-size: 0.875rem;
    color: #777;
}

/* ===========================
   Archive / Blog
   =========================== */
.post-thumbnail {
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.post-thumbnail img {
    width: 100%;
    transition: transform 0.3s;
}

.post-thumbnail:hover img {
    transform: scale(1.02);
}

/* ===========================
   Pagination
   =========================== */
.navigation {
    margin: 2rem 0;
    text-align: center;
}

.page-numbers {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    margin: 0 0.2rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    font-size: 0.875rem;
}

.page-numbers.current,
.page-numbers:hover {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
    text-decoration: none;
}

/* ===========================
   Sidebar & Widgets
   =========================== */
.widget-area {
    padding-left: 2rem;
}

.widget {
    margin-bottom: 2.5rem;
}

.widget-title {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #1a1a1a;
}

.widget ul {
    list-style: none;
}

.widget ul li {
    padding: 0.4rem 0;
    border-bottom: 1px solid #f0f0f0;
}

/* ===========================
   Comments
   =========================== */
.comments-area {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid #eee;
}

.comments-title,
.comment-reply-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.comment-list {
    list-style: none;
    margin-bottom: 2rem;
}

.comment {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: #f9f9f9;
    border-radius: 4px;
}

.comment-meta {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    color: #777;
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 1rem;
    font-family: inherit;
}

.comment-form textarea {
    min-height: 150px;
    resize: vertical;
}

/* ===========================
   Buttons & Forms
   =========================== */
button,
input[type="submit"],
.button,
.wp-block-button__link {
    display: inline-block;
    padding: 0.65rem 1.5rem;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

button:hover,
input[type="submit"]:hover,
.button:hover {
    background: #005a87;
}

/* ===========================
   Search Form
   =========================== */
.search-form {
    display: flex;
    gap: 0.5rem;
}

.search-field {
    flex: 1;
    padding: 0.65rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* ===========================
   404
   =========================== */
.error-404 {
    text-align: center;
    padding: 4rem 0;
}

.error-404 .page-title {
    font-size: 6rem;
    line-height: 1;
    color: #a89878;
    margin-bottom: 1rem;
}

/* ===========================
   Footer
   =========================== */
.site-footer {
    background: #f7f2e5;
    color: #6b5a42;
    border-top: 1px solid #e2d6b8;
    padding: 2rem 0;
    font-size: 0.875rem;
    ul {
        display: flex;
        gap: .5vw;
    }
}

@media(max-width:750px){
    .site-footer ul {
        gap: 5vw;
        a {
            line-height: 1.2em;
            text-align: center;
            display: block;
        }
    }
}

.site-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}
@media(max-width: 750px){
    .site-footer .container {
        justify-content: center;
    }
}

.site-footer a {
    color: #2b2013;
}

.site-footer a:hover {
    color: #0073aa;
}
#footer-menu {
    li {
        background: none; border: none; padding: 0;
        font: inherit; font-size: inherit; color: #2b2013; cursor: pointer;
        list-style: none;
        &:hover { color: #0073aa; }
    }
}

/* ===========================================================================
   Modale Contatti (usato sia nel footer delle pagine generiche sia nel menu
   account della Story App): fuori dallo scoping "body.story-app-page" qui sotto,
   perché deve funzionare anche sulle pagine generiche, che non hanno quella
   classe sul <body> — quindi con la sua palette fissa, non quella del tema chiaro
   generico né quella (dinamica, per genere) della Story App.
   =========================================================================== */
.simple-modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 600;
    background: rgba(43,32,19,0.5); align-items: center; justify-content: center;
    padding: 1.5rem;
}
@media(max-width:750px){
    .simple-modal-overlay {
        padding: 10px;
    }
}
.simple-modal-overlay.open { display: flex; }
.simple-modal-box {
    background: #f7f2e5; border: 1px solid #d9c5a0; border-radius: 6px;
    padding: 2rem; width: min-content; min-width: 50vw; max-width: 90vw;
    max-height: 90vh; overflow-y: auto; position: relative;
    font-family: Georgia, "Times New Roman", serif; color: #2b2013;
}
/* Modale "Scarica l'app" (istruzioni manuali, vedi installApp() in main.js): a
   differenza degli altri .simple-modal-box, largo quanto lo spazio disponibile
   (fino a max-width: 90vw sopra) invece che dimensionato sul contenuto. */
@media(max-width:750px){
    .simple-modal-box { width: 100%; min-width:90vw}
} 
.simple-modal-box h2 { font-size: 1.2rem; color: #8b6914; margin-bottom: 1rem; letter-spacing: 0.02em; }
.simple-modal-close {
    position: absolute; top: 1rem; right: 1.2rem;
    background: none; border: none; color: #6b5a42; font-size: 1.4rem; cursor: pointer;
}
.simple-modal-close:hover { color: #2b2013; }
.simple-modal-box .wpcf7-form-control {
    width: 100%; padding: 0.6rem; margin-bottom: 0.9rem;
    border: 1px solid #d9c5a0; border-radius: 4px;
    font-family: inherit; font-size: 0.95rem; color: #2b2013; background: #fff;
}
.simple-modal-box .wpcf7-form-control:focus { outline: none; border-color: #8b6914; }
.simple-modal-box textarea.wpcf7-form-control { min-height: 120px; resize: vertical; }
.simple-modal-box input.wpcf7-submit {
    width: auto; background: #8b6914; color: #f7f2e5; border: none;
    padding: 0.6rem 1.4rem; border-radius: 3px; cursor: pointer; transition: opacity 0.2s;
}
.simple-modal-box input.wpcf7-submit:hover { opacity: 0.85; }
.simple-modal-box .wpcf7-not-valid-tip { color: #a8492a; font-size: 0.8rem; margin-top: -0.6rem; margin-bottom: 0.6rem; }
.simple-modal-box .wpcf7-response-output { border-radius: 4px; font-size: 0.85rem; margin-top: 1rem; }

/* ===========================================================================
   WooCommerce (carrello, checkout, ringraziamento)

   Le pagine gestite dai blocchi Cart/Checkout di WooCommerce arrivano con il
   loro stile di default (font sans-serif, bottoni scuri, pannelli bianchi):
   qui le riportiamo alla stessa identità visiva del resto del sito e dei
   modali (pergamena chiara, testo scuro leggibile, accento oro, serif).
   Le classi "wc-block-*"/"wc-blocks-*" sono quelle pubbliche esposte da
   WooCommerce Blocks proprio per essere restilizzate da un tema.
   =========================================================================== */
body.woocommerce-page {
    --titolo:     #8b6914;
    --testo:      #2b2013;
    --elementi:   #8a7355;
    --risalto:    #efe6d1;
    --panel-line: #d9c5a0;
    --ink:        #f7f2e5;

    background: var(--ink);
}

body.woocommerce-page .entry-title { color: var(--titolo); font-family: Georgia, "Times New Roman", serif; }
body.woocommerce-page .entry-content { font-family: Georgia, "Times New Roman", serif; color: var(--testo); }

/* ── Titoli e step ── */
body.woocommerce-page .wc-block-components-title,
body.woocommerce-page .wc-block-components-checkout-step__title,
body.woocommerce-page .wc-block-components-checkout-order-summary__title-text,
body.woocommerce-page .wc-block-cart__totals-title {
    font-family: Georgia, serif;
    color: var(--titolo);
    letter-spacing: 0.02em;
}
body.woocommerce-page .wc-block-components-checkout-step { border-color: var(--panel-line); }

/* ── Campi modulo (contatti, indirizzo) ── */
body.woocommerce-page .wc-block-components-text-input input,
body.woocommerce-page .wc-blocks-components-select__select,
body.woocommerce-page textarea {
    font-family: Georgia, serif;
    background: #fff;
    border: 1px solid var(--panel-line);
    border-radius: 3px;
    color: var(--testo);
}
body.woocommerce-page .wc-block-components-text-input input:focus,
body.woocommerce-page .wc-blocks-components-select__select:focus {
    border-color: var(--titolo);
    outline: none;
}
body.woocommerce-page .wc-block-components-text-input label,
body.woocommerce-page .wc-blocks-components-select__label {
    font-family: Georgia, serif;
    color: var(--elementi);
}

/* ── Pulsanti ── */
body.woocommerce-page .wc-block-components-button,
body.woocommerce-page .wc-block-cart__submit-button,
body.woocommerce-page .wc-block-components-checkout-place-order-button {
    background: var(--titolo);
    border-color: var(--titolo);
    color: #fff;
    font-family: Georgia, serif;
    letter-spacing: 0.04em;
    border-radius: 3px;
    box-shadow: none;
}
body.woocommerce-page .wc-block-components-button:hover,
body.woocommerce-page .wc-block-cart__submit-button:hover,
body.woocommerce-page .wc-block-components-checkout-place-order-button:hover {
    opacity: 0.85;
    background: var(--titolo);
    color: var(--testo);
}

/* ── Riepilogo ordine / totali ── */
body.woocommerce-page .wc-block-components-sidebar,
body.woocommerce-page .wc-block-components-order-summary,
body.woocommerce-page .wc-block-components-totals-wrapper,
body.woocommerce-page .wc-block-components-panel {
    background: var(--risalto);
    border-color: var(--panel-line);
}
body.woocommerce-page .wc-block-components-totals-item__label,
body.woocommerce-page .wc-block-components-totals-item__value {
    font-family: Georgia, serif;
    color: var(--testo);
}
body.woocommerce-page .wc-block-components-formatted-money-amount,
body.woocommerce-page .wc-block-formatted-money-amount {
    color: var(--titolo);
}
body.woocommerce-page .wc-block-components-product-price__regular,
body.woocommerce-page del {
    color: var(--elementi);
    opacity: 0.75;
}

/* ── Voci nel carrello / riepilogo ── */
body.woocommerce-page .wc-block-components-order-summary-item__description,
body.woocommerce-page .wc-block-cart-item__product,
body.woocommerce-page .wc-block-components-product-name {
    font-family: Georgia, serif;
    color: var(--testo);
}

/* ── Pagina di ringraziamento ── */
body.woocommerce-order-received .woocommerce-order,
body.woocommerce-order-received .woocommerce-thankyou-order-received {
    font-family: Georgia, serif;
    color: var(--testo);
}
body.woocommerce-order-received .woocommerce-order table {
    background: var(--risalto);
    border: 1px solid var(--panel-line);
}
body.woocommerce-order-received .button {
    background: var(--titolo);
    color: var(--testo);
    font-family: Georgia, serif;
    border-radius: 3px;
}

/* ===========================================================================
   Story App (template front-page.php)

   Tutto ciò che segue è racchiuso in "body.story-app-page" (aggiunta tramite
   body_class() solo in front-page.php) per non influenzare le altre pagine
   del tema, che usano il tema chiaro generico definito sopra.
   =========================================================================== */
html:has(body.story-app-page) {
    height: 100%;
}

body.story-app-page {
    /* ── Variabili colore (tema chiaro: sfondo pergamena, testi scuri leggibili) ── */
    --ink:        #f7f2e5; /* sfondo pagina */
    --testo:      #2b2013; /* testo principale (campo ACF "testo") */
    --titolo:     #8b6914; /* colore accento (campo ACF "titolo") */
    --fade:       #6b5a42; /* testo secondario/attenuato */
    --elementi:   #efe6d1;
    --risalto:    #8a7355;
    --panel-line: #d9c5a0; /* bordi su pannelli e sfondo */

    /* Modali e popup (menu profilo, finestre di dialogo): colori SEMPRE fissi,
       indipendenti dal genere della storia. Il genere sovrascrive queste
       variabili solo su <body> (vedi setStoryTheme() in main.js); ridichiarandole
       qui, ogni elemento discendente di .modal-overlay / #badge-dropdown calcola
       il proprio valore da questa regola invece di ereditare quello del body,
       garantendo testo sempre leggibile qualunque sia il tema attivo. */
    .modal-overlay,
    #badge-dropdown {
        --titolo:     #8b6914;
        --testo:      #2b2013;
        --fade:       #6b5a42;
        --elementi:   #efe6d1;
        --risalto:    #8a7355;
        --panel-line: #d9c5a0;
    }

    height: 100%;
    background: var(--elementi);
    color: var(--testo);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.05rem;
    line-height: 1.85;

    /* ── Header ── */
    #story-header {
        position: fixed; top: 0; left: 0; right: 0; z-index: 100;
        display: flex; align-items: center; justify-content: space-between;
        padding: 0.9rem 1.5rem;
        pointer-events: none;
    }
    #header-title {
        font-size: 0.68rem; letter-spacing: 0.28em; text-transform: uppercase;
        color: var(--titolo); opacity: 0.75; pointer-events: none;
    }

    /* ── Gettoni (dentro il pulsante di invio) ── */
    #coin-display {
        display: none; align-items: center; gap: 0.4rem;
        margin-left: 0.7rem; padding-left: 0.7rem;
        border-left: 1px solid currentColor; opacity: 0.85;
    }
    #coin-display.visible { display: inline-flex; }
    .coin-icon {
        width: 18px; height: 18px; flex-shrink: 0;
        transition: transform 0.25s ease;
    }
    .coin-icon.spin { animation: coin-spin 0.5s ease; }
    #coin-count {
        font-size: 0.82rem; color: currentColor; min-width: 1.6em;
        transition: color 0.3s ease;
    }
    #coin-count.flash { color: #a5720f; }

    /* ── Profile badge (burger menu) ── */
    #profile-badge { pointer-events: all; position: relative; }
    #badge-btn {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 5px; width: 34px; height: 34px; padding: 0;
        background: none; border: 1px solid var(--titolo); border-radius: 50%;
        cursor: pointer; transition: border-color 0.2s;
    }
    #badge-btn:hover { border-color: var(--titolo); }
    .burger-bar {
        display: block;
        width: 16px;
        height: 1px;
        background: var(--titolo);
        transition: background 0.2s;
    }
    #badge-btn:hover .burger-bar { background: var(--titolo); }

    #badge-dropdown {
        display: none;
        position: absolute;
        bottom: calc(100% + 8px);
        left: 50%;
        transform: translateX(-50%);
        background: #ffffffed;
        border-radius: 20px;
        box-shadow: 6px 6px 12px #00000040;
        min-width: 180px;
        padding: .5vw;
        z-index: 200;
        backdrop-filter: blur(10px);
    }
    #badge-dropdown.open { display: block; }
    .dd-header { padding: 0.6rem 1rem 0.4rem;
        font-size: 0.75rem; color: #222; }
    .dd-header strong { display: block; color: #222; font-size: 0.88rem; }
    .dd-btn {
        display: block; width: 100%; text-align: left; padding: 0.55rem 1rem;
        background: none; border: none; color: #444;
        font-family: Georgia, serif; font-size: 0.85rem; cursor: pointer;
        text-decoration: none; box-sizing: border-box;
        border-radius: 10px;
    }
    .dd-btn:hover { 
        background: #f5f5f5;
        color: #333;
        text-decoration: none;
    }
    .dd-separator { border: none; border-top: 1px solid var(--panel-line); margin: 0.3rem 0; }

    /* ── Copertina ambientazione ── */
    #story-cover { display: none; position: relative; width: 100%; height: 70vh; overflow: hidden; z-index: -1;}
    #story-cover.visible { display: block; }
    #story-cover-img { width: 100%; height: 100%; background-size: cover; background-position: center; }
    #story-cover::after {
        content: ''; position: absolute; inset: 0;
        background: linear-gradient(to bottom, rgba(247,242,229,0) 0%, var(--elementi) 92%);
        /* Animata da GSAP (playIntroSequence() in main.js) tramite questa custom
           property: un ::after non è un nodo DOM raggiungibile direttamente. */
        opacity: var(--cover-after-opacity, 1);
    }
    @media (max-width: 640px) {
        #story-cover { height: 50vh;}
        #story-cover::after {
            background: linear-gradient(to bottom, var(--elementi) 0%, rgba(247, 242, 229, 0) 50%, var(--elementi) 80%);
        }
    }

    /* ── Story area ── */
    #page-wrap { display: flex; flex-direction: column; align-items: center;
        min-height: 100vh; padding: 5rem 1.5rem 0; margin-top: -40vh; }
    
    #story-title {
        display: none; 
        margin-bottom: 2rem;
        text-align: center;
        font-family: Georgia, serif;
        font-size: 4vw;
        font-style: italic;
        color: var(--titolo);
        letter-spacing: 0.02em;
        line-height: 1.2em;
    }
    #story-title.visible { display: block; }
    #story { width: 100%; max-width: 50vw; flex: 1; padding-bottom: 140px; }

    /* ── Riassunto (resume card) e turni ── */
    .turn-resume {
        border-radius: 20px;
        padding: 1.2rem 1.4rem;
        background: #ffffff80;
        backdrop-filter: blur(10px);
        margin-bottom: 2.5rem;
    }
    .resume-label {
        font-size: 0.65rem; letter-spacing: 0.22em; text-transform: uppercase;
        color: var(--testo); margin-bottom: 0.75rem; display: block;
    }
    .turn-summary {
        color: var(--testo); font-size: 0.95rem; line-height: 1.75;
        font-style: italic; margin-bottom: 1rem;
    }
    .turn-resume .turn-question {
        color: var(--risalto); font-style: italic;
        padding-top: 0.75rem; border-top: 1px solid var(--panel-line);
    }

    .turn { margin-bottom: 2.5rem; }
    .turn-choice { font-size: 0.78rem; color: var(--titolo); letter-spacing: 0.12em;
        text-transform: uppercase; margin-bottom: 0.75rem; opacity: 0.75; }
    .turn-narrative { color: var(--testo); margin-bottom: 1rem; }
    .turn-question { color: var(--titolo); font-style: italic; font-size: 0.97rem; }

    /* ── Input bar ── */
    #input-area {
        position: fixed;
        bottom: 15px;
        left: 50%;
        background-color: #f5f5f570;
        box-shadow: 3px 3px 10px #00000030;
        backdrop-filter: blur(10px);
        padding: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        transition: opacity 0.3s;
        border-radius: 20px;
        width: fit-content;
        transform: translateX(-50%);
        /* Nascosta finché non si è scelta un'avventura: playIntroSequence() (main.js)
           la rivela con GSAP (autoAlpha) come ultimo passo della sua sequenza. */
        opacity: 0;
        visibility: hidden;
    }
    #input-area.busy { opacity: 0.3; pointer-events: none; }
    .loading-dots { display: flex; gap: 4px; }
    .loading-dots span {
        width: 5px; height: 5px; border-radius: 50%; background: var(--titolo); opacity: 0.3;
        animation: dot-pulse 1.2s ease-in-out infinite;
    }
    .loading-dots span:nth-child(2) { animation-delay: 0.2s; }
    .loading-dots span:nth-child(3) { animation-delay: 0.4s; }
    .story-loading { display: flex; justify-content: center; padding: 3rem 0; }
    .story-loading .loading-dots span { width: 8px; height: 8px; }
    #input-inner { width: 100%;}
    #response-input {
        width: 100%;
        background: transparent;
        border: none;
        color: var(--titolo);
        font-family: Georgia, serif;
        font-size: 1.05rem;
        line-height: 1.2em;
        padding: 0.3rem 0;
        outline: none;
        resize: none;
        min-height: 2.4rem;
        width: 50vw;
        caret-color: var(--titolo);
    }
    #response-input::placeholder { color: var(--titolo); font-size: .8em; opacity: .7;}
    #response-input:disabled { opacity: 0.4; }
    /* ── Progress bar caratteri (sostituisce il border-bottom della textarea) ── */
    #char-progress { width: 100%; height: 2px; background: #fff; margin-top: -10px;}
    #char-progress-bar {
        height: 100%; width: 0%; background: var(--titolo);
        transition: width 0.15s ease, background 0.15s ease;
    }
    #char-progress-bar.over { background: #a8492a; }
    #char-limit-msg {
        display: none; margin-top: 0.4rem; font-size: 0.72rem;
        font-style: italic; color: #a8492a;
    }
    #char-limit-msg.visible { display: block; }
    #submit-error-msg {
        display: none; margin-top: 0.4rem; font-size: 0.72rem;
        font-style: italic; color: #a8492a;
    }
    #submit-error-msg.visible { display: block; }
    #input-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 0.6rem; }
    #submit-btn {
        background: none; border: 1px solid var(--titolo); color: var(--titolo);
        font-family: Georgia, serif; font-size: 0.82rem; letter-spacing: 0.12em;
        padding: 0.35rem 1rem; cursor: pointer; transition: background 0.2s, color 0.2s;
        display: inline-flex; align-items: center;
    }
    #submit-btn:hover { background: var(--titolo); color: #fff; }
    /* Solo nell'aspetto: resta cliccabile per poter mostrare l'errore (vedi main.js) */
    #submit-btn.disabled { opacity: 0.4; }
    #submit-btn.disabled:hover { background: none; color: var(--titolo); }

    /* ── Modals ── */
    .modal-overlay {
        display: none; position: fixed; inset: 0; z-index: 500;
        background: rgba(43,32,19,0.5); align-items: center; justify-content: center;
        padding: 1.5rem;
    }
    @media(max-width:750px){
        .modal-overlay {
            display: none; position: fixed; inset: 0; z-index: 500;
            background: rgba(43,32,19,0.5); align-items: center; justify-content: center;
            padding: 10px;
        }
        .modal-box {
            padding: 20px !important;
            max-width: none !important;
        }
    }
    .modal-overlay.open { display: flex; }
    .modal-box {
        background: #ffffffc9;
        border-radius: 20px;
        padding: 2rem;
        width: fit-content;
        min-width: 50vw;
        max-width: 90vw;
        max-height: 90vh;
        overflow-y: auto;
        backdrop-filter: blur(10px);
        #settings-list {
            display: grid;
            gap: 1vw;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        }
    }
    
    .modal-box h2 { font-size: 1.1rem; color: #222; margin-bottom: 0.4rem; letter-spacing: 0.06em; }
    .modal-box .modal-subtitle { font-size: 0.85rem; color: var(--fade); margin-bottom: 1.5rem; max-width: 600px;line-height: 1.5em;}
    /* Pulsante di chiusura e pulsante filtri (#settings-genre-filter, definito più
       sotto insieme alla sezione Ambientazioni): stesso identico aspetto — tondi,
       bordo 1px, padding 10px, icona centrata via flex, colore icona = colore
       bordo — per restare visivamente intercambiabili ovunque compaiano insieme. */
    .modal-close {
        float: right;
        display: flex; align-items: center; justify-content: center;
        box-sizing: border-box; width: 36px; height: 36px; padding: 10px;
        border: 1px solid #8b6914; border-radius: 50%;
        background: none; color: #8b6914;
        font-size: 14px; line-height: 1; cursor: pointer;
        transition: background-color .2s, color .2s;
    }
    .modal-close:hover { background-color: #8b6914; color: #fff; }
    .field { margin-bottom: 1rem; }
    .field label { display: block; font-size: 0.78rem; color: var(--fade);
        letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.35rem; }
    .field input[type="text"], .field input[type="email"], .field input[type="password"] {
        width: 100%; background: transparent; border: none;
        border-bottom: 1px solid var(--panel-line); color: var(--testo);
        font-family: Georgia, serif; font-size: 0.95rem; padding: 0.35rem 0;
        outline: none;
    }
    .field input:focus { border-bottom-color: var(--titolo); }
    .modal-submit {
        width: 100%; margin-top: 1.2rem; padding: 0.7rem;
        background: var(--titolo); color: var(--elementi); border: none;
        font-family: Georgia, serif; font-size: 0.9rem; letter-spacing: 0.08em;
        cursor: pointer; border-radius: 3px; transition: opacity 0.2s;
    }
    .modal-submit:hover { opacity: 0.85; }
    .modal-alt { margin-top: 1rem; font-size: 0.82rem; color: var(--fade); text-align: center; }
    .modal-alt a, .modal-alt button {
        background: none; border: none; padding: 0; font-size: inherit;
        color: var(--testo); font-family: Georgia, serif; cursor: pointer;
    }
    .modal-alt a:hover, .modal-alt button:hover { color: var(--titolo); }

    /* ── Modale "Il narratore sta scrivendo" (copertina + pubblicità) ── */
    /* Dissolvenza in apertura gestita via GSAP (autoAlpha) in showLoadingModal(),
       main.js — nessuna transizione/animazione CSS qui. Le slide (1a = copertina/
       titolo dell'avventura, le altre = ripetitore ACF "pubblicita") sono costruite
       e lo Swiper stesso è (ri)inizializzato da buildLoadingSwiper() in main.js. */
    .modal-box--loading { min-width: 0; width: 400px; text-align: center; padding: 1.5rem; }
    #loading-title { color: var(--risalto); font-style: italic; font-size: 0.88rem;
        display: flex; align-items: center; justify-content: center; gap: 0.5rem;
        letter-spacing: 0.05em; margin: 0; }

    .loading-swiper {
        margin-top: 1.2rem;
        aspect-ratio: 1 / 1;
        border-radius: 10px;
        overflow: hidden;
    }
    .loading-swiper.is-empty { display: none; }

    /* Slide "pubblicità": intera immagine cliccabile, apre il link in una nuova scheda. */
    .loading-slide-link { display: block; width: 100%; height: 100%; }
    .loading-slide-link img {
        width: 100%; height: 100%; object-fit: cover; display: block;
    }

    /* Slide "copertina": immagine di sfondo dell'avventura + titolo in overlay, con
       sfumatura scura verso il basso per restare leggibile su qualunque foto. */
    .loading-slide-cover {
        position: relative;
        display: flex;
        align-items: flex-end;
    }
    .loading-slide-img {
        position: absolute; inset: 0;
        background-size: cover;
        background-position: center;
    }
    .loading-slide-cover::after {
        content: '';
        position: absolute; inset: 0;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0) 60%);
    }
    .loading-slide-caption {
        position: relative; z-index: 1;
        width: 100%;
        padding: 1rem 1.1rem;
        color: #fff;
        font-family: Georgia, serif;
        font-style: italic;
        font-size: 1.05rem;
        line-height: 1.3;
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    }

    /* Pallini di paginazione: solo indicazione visiva, non cliccabili (vedi
       buildLoadingSwiper() in main.js, pagination.clickable: false). */
    .loading-swiper-pagination {
        position: static;
        margin-top: 0.8rem;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
    }
    .loading-swiper-pagination.is-empty { display: none; }
    .loading-swiper-pagination .swiper-pagination-bullet {
        width: 6px; height: 6px;
        background: var(--panel-line);
        opacity: 1;
        pointer-events: none;
        margin: 0;
    }
    .loading-swiper-pagination .swiper-pagination-bullet-active {
        background: var(--titolo);
    }

    /* ── Promemoria "Scarica l'app" nel modale di attesa (una tantum, vedi
       buildLoadingSwiper()/buildInstallPromo() in main.js): al posto dello slider. ── */
    .loading-promo { display: none; margin-top: 1.2rem; }
    .loading-promo.visible { display: block; }
    .loading-promo-title {
        color: var(--titolo); font-family: Georgia, serif; font-style: italic;
        font-size: 1.05rem; margin-bottom: 0.5rem;
    }
    .loading-promo-subtitle {
        color: var(--fade); font-size: 0.85rem; line-height: 1.5; margin-bottom: 1rem;
    }
    .loading-promo-btn {
        width: 100%; padding: 0.7rem;
        background: var(--titolo); color: var(--elementi); border: none;
        font-family: Georgia, serif; font-size: 0.9rem; letter-spacing: 0.08em;
        cursor: pointer; border-radius: 3px; transition: opacity 0.2s;
    }
    .loading-promo-btn:hover { opacity: 0.85; }
    .loading-promo-tutorial {
        text-align: left; color: var(--testo); font-size: 0.85rem; line-height: 1.5;
    }
    .loading-promo-tutorial p { margin-bottom: 0.6rem; }
    .loading-promo-tutorial ol { padding-left: 1.2rem; }
    .loading-promo-tutorial li { margin-bottom: 0.3rem; }

    /* ── Elenco storie salvate ── */
    .story-card {
        display: flex; align-items: center; justify-content: space-between;
        padding: 0.8rem 0;  border-bottom: 1px solid #f5f5f5; gap: 0.5rem;
    }
    .story-card:last-child { border-bottom: none; }
    .story-info { flex: 1; min-width: 0; }
    .story-info strong { display: block; font-size: 0.92rem; color: var(--testo);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .story-info span { font-size: 0.75rem; color: var(--fade); }
    .story-card-btns { display: flex; gap: 0.4rem; flex-shrink: 0; }
    .btn-load-story {
        background: #f5f5f5;
        color: #444;
        font-family: Georgia, serif;
        font-size: 0.75rem;
        padding: 0.25rem 0.6rem;
        cursor: pointer;
        border-radius: 5px;
    }
    .btn-load-story:hover {
        background: #fff;
        color: #222;
    }
    .btn-del-story {
                background: #f5f5f5;
        /* border: 1px solid var(--panel-line); */
        color: #444;
        font-family: Georgia, serif;
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        cursor: pointer;
        border-radius: 5px;
    }
    .btn-del-story:hover {
        background: #fff;
        color: #222;
     }
    /* Storia salvata col formato precedente (s.legacy): al posto di "Continua",
       vedi openStoriesModal() in main.js. */
    .story-card-notice {
        font-family: Georgia, serif; font-style: italic; font-size: 0.72rem;
        color: var(--fade); max-width: 12em; line-height: 1.3;
    }
    #btn-new-story {
        width: fit-content;
        text-align: left;
        padding: 1vw 2vw;
        background: #f5f5f5;
        color: #444;
        font-family: Georgia, serif;
        font-size: 0.88rem;
        cursor: pointer;
        letter-spacing: 0.06em;
        border-radius: 10px;
    }
    #btn-new-story:hover { 
        color: #222;
        background-color: #fff;
     }

    /* ── Ambientazioni ── */
    /* <select> nativo reso come pulsante tondo — stessa forma/misura di .modal-close
       sopra — con una sola icona (mask-image, stesso colore del bordo). Il bordo vive
       su .icon-select-frame, un elemento SENZA mask dietro al select: mask-image
       ritaglia tutto ciò che è dipinto sull'elemento a cui è applicato — bordo
       compreso — quindi un bordo messo direttamente sul <select> mascherato spariva.
       Il select resta sopra, invisibile a parte l'icona (color:transparent nasconde
       il testo dell'opzione scelta), e riceve lui i click/il focus. */
    .icon-select-frame {
        float: right;
        margin-right: 0.5rem;
        position: relative;
        display: flex; align-items: center; justify-content: center;
        box-sizing: border-box; width: 36px; height: 36px;
        border: 1px solid #8b6914;
        border-radius: 50%;
        transition: background-color .2s;
    }
    /* .active: filtro genere impostato su qualcosa di diverso da "Tutti i generi"
       (classe aggiunta/tolta in renderSettingsFilter(), main.js) — resta nello stesso
       aspetto dell'hover anche a mouse fuori, per segnalare che un filtro è attivo. */
    .icon-select-frame:hover,
    .icon-select-frame:focus-within,
    .icon-select-frame.active { background-color: #8b6914; }
    /* Icona bianca in hover/focus/attivo: cambia il colore mascherato del <select>
       (che sta sopra), non quello della cornice (che non ha mask e resta il
       bordo/riempimento). */
    .icon-select-frame:hover #settings-genre-filter.icon-select,
    .icon-select-frame:focus-within #settings-genre-filter.icon-select,
    .icon-select-frame.active #settings-genre-filter.icon-select {
        background-color: #fff;
    }
    #settings-genre-filter.icon-select {
        position: absolute;
        inset: 0;
        width: 100%; height: 100%;
        margin: 0; padding: 10px;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border: none;
        border-radius: 50%;
        background-color: #8b6914; /* colore dell'icona (mascherata sotto) = colore del bordo della cornice */
        transition: background-color .2s;
        -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cline x1='4' y1='6' x2='20' y2='6'/%3E%3Cline x1='4' y1='12' x2='20' y2='12'/%3E%3Cline x1='4' y1='18' x2='20' y2='18'/%3E%3C/g%3E%3Ccircle cx='9' cy='6' r='2' fill='%23000'/%3E%3Ccircle cx='15' cy='12' r='2' fill='%23000'/%3E%3Ccircle cx='7' cy='18' r='2' fill='%23000'/%3E%3C/svg%3E");
        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cline x1='4' y1='6' x2='20' y2='6'/%3E%3Cline x1='4' y1='12' x2='20' y2='12'/%3E%3Cline x1='4' y1='18' x2='20' y2='18'/%3E%3C/g%3E%3Ccircle cx='9' cy='6' r='2' fill='%23000'/%3E%3Ccircle cx='15' cy='12' r='2' fill='%23000'/%3E%3Ccircle cx='7' cy='18' r='2' fill='%23000'/%3E%3C/svg%3E");
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-size: 14px 14px;
        mask-size: 14px 14px;
        color: transparent; /* nasconde il testo dell'opzione selezionata dentro il pulsante */
        text-indent: 1px;
        cursor: pointer;
        outline: none;
    }
    #settings-genre-filter.icon-select option { color: var(--testo); } /* leggibili nel menu aperto */
                               .setting-card {
        padding: 1rem;
        border-radius: 10px;
        margin-bottom: 0.8rem;
        cursor: pointer;
        transition: all .4s ease-in-out;
        overflow: hidden;
        background-color: #f5f5f5;
        line-height: 1.2em;
    }
    .setting-card:hover {background: #fff; transform: translateY(-5px); box-shadow:  3px 1px 6px #00000020; }
    .setting-card-img {
        position: relative;
        width: calc(100% + 2rem); height: 250px; margin: -1rem -1rem 0.8rem;
        background-size: cover; background-position: center;
    }
    /* Etichetta di genere: sovrapposta in alto a sinistra sulla copertina (dentro
       .setting-card-img, position:relative sopra) o, senza copertina, come normale
       etichetta prima del titolo — stesso stile fisso in entrambi i casi. */
    .setting-card-badge {
        display: inline-block;
        padding: 0.25rem 0.7rem;
        border-radius: 20px;
        background: rgba(0,0,0,0.55);
        color: #fff;
        font-size: 0.7rem;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        backdrop-filter: blur(4px);
    }
    .setting-card-img .setting-card-badge { position: absolute; top: 0.6rem; left: 0.6rem; }
    .setting-card > .setting-card-badge { margin-bottom: 0.6rem; }
    .setting-card strong { display: block; color: var(--testo); font-size: 0.98rem; margin-bottom: 0.4rem; }
    .setting-card p { color: var(--fade); font-size: 0.85rem; line-height: 1.5; margin: 0; }

    /* ── Acquisto gettoni ── */
    .coin-package-card {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem;
        border-radius: 10px;
        margin-bottom: 0.8rem;
        cursor: pointer;
        transition: background .2s;
        background-color: #f5f5f5;
    }
    .coin-package-card:hover {background: #fff; }
    .coin-package-card strong { color: #333; font-size: 0.98rem; }
    .coin-package-card > span { display: flex; align-items: baseline; gap: 0.4rem; font-size: 0.95rem; }
    .coin-package-card .woocommerce-Price-amount { color: #444; font-family: Georgia, serif; }
    .coin-package-card del { color: #555; opacity: 0.75; text-decoration: line-through; }
    .coin-package-card del .woocommerce-Price-amount { color: inherit; font-size: 0.85em; }
    .coin-package-card ins { text-decoration: none; }

    /* ── Anon gate overlay ── */
    #anon-gate { display: none; }
    #anon-gate.open { display: flex; }

    /* ── Errori ── */
    .story-error { color: #a8492a; font-style: italic; margin-bottom: 1.5rem; }

}

/* La palette per genere non è più codificata qui: viene applicata dinamicamente
   come variabili CSS inline sul <body> (vedi setStoryTheme() in main.js), con
   i colori letti dai campi color picker ACF sulla categoria WP dell'ambientazione
   (gruppo "Contenuto Genere" in story_get_genre_colors(), story-api.php). --ink
   (sfondo) resta fisso: solo accento/testo/pannelli variano per genere. */

/* Keyframe: le animazioni sono registrazioni globali, non annidabili in un selettore */
@keyframes coin-spin {
    0%   { transform: rotateY(0deg) scale(1); }
    40%  { transform: rotateY(180deg) scale(1.15); }
    100% { transform: rotateY(360deg) scale(1); }
}
@keyframes dot-pulse {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.85); }
    40%           { opacity: 1;   transform: scale(1); }
}

@media (max-width: 640px) {
        #page-wrap  { 
            margin-top: -25vh !important;
         }
        #story-title {
            font-size: 8vw !important;
        }
        #story {
            max-width: none !important;
        }
        #response-input {
            width: 83vw !important;
            min-height: 3.4rem !important;
        }
        #badge-dropdown {
            transform: translateX(-10%) !important;
        }
    }

.woocommerce-MyAccount-navigation {
    padding: 20px;
    border-radius: 20px;
    background-color: #f5f5f5;
    box-shadow: 5px 5px 10px #00000005;
    li {
        list-style: none;
        a {
            color: #333;
            transition: all .4s ease-in-out;
            &:hover {
                color:#000;
            }
        }
    }
}

.iub__us-widget, #body  .iubenda-tp-btn{
    display: none !important;
}

/* ── "Il mio account": pulsante di ritorno (footer.php) ──
   Stessa posizione fissa/centrata in basso di #input-area nella Story App (vedi sopra,
   dentro body.story-app-page), ma qui fuori — questa pagina non porta quella classe. */
.account-back-btn {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    background-color: #f5f5f570;
    box-shadow: 3px 3px 10px #00000030;
    backdrop-filter: blur(10px);
    padding: 0.9rem 1.8rem;
    border-radius: 20px;
    font-family: Georgia, serif;
    font-size: 0.95rem;
    color: #2b2013;
    text-decoration: none;
    transition: opacity 0.2s;
}
.account-back-btn:hover { opacity: 0.8; text-decoration: none; }

/* Spazio extra in fondo, perché il pulsante fisso sopra non copra l'ultima parte del
   contenuto WooCommerce (form, tabelle ordini, riepilogo ordine, ecc.) — le classi
   sotto sono quelle che WooCommerce aggiunge da sé al <body> di queste pagine. */
.woocommerce-account .site-content,
.woocommerce-checkout .site-content { padding-bottom: 6rem; }

#modal-contact {
    .simple-modal-box {
        width: 100%;
        max-width: 400px;
    }
}

@media(max-width:750px){
    #modal-contact {
        .simple-modal-box {
            padding: 20px;
        }
    }
}