/**
 * HubSpot form styles.
 *
 * Foglio di stile base per i form HubSpot incorporati nel network.
 * La struttura segue la gerarchia DOM del markup HubSpot
 * (vedi docs/hs-form-structure-base.html).
 *
 * Scope: tutte le regole e i token sono ancorati a `form.hs-form`, la classe
 * che HubSpot applica sempre. Questo garantisce che gli stili valgano per
 * OGNI form HubSpot (non solo quelli col wrapper .nam-hubspot-form-wrapper)
 * e che le custom properties, essendo dichiarate sul form, vivano solo nel
 * suo sottoalbero: niente inquinamento del sito ospitante, niente collisioni.
 *
 * Organizzazione:
 *   0. Palette di fallback — colori usati solo se il tema non li definisce
 *   1. Token primitivi     — palette, scala tipografica, scala spaziature
 *   2. Token semantici     — variabili di componente che referenziano i primitivi
 *   3. Layout form         — form, fieldset, griglia colonne
 *   4. Campo (field)       — wrapper, label, helper text
 *   5. Input               — text/email/tel, select, textarea, telefono intl
 *   6. Checkbox / privacy  — inputs-list, booleancheckbox
 *   7. Stati               — required, focus, errore, disabled, placeholder
 *   8. Submit              — actions, button
 *
 * Colori, font-size, spaziature e raggio vengono letti dai preset del tema
 * (`--wp--preset--*`, Namirial FSE e child) con fallback sulla palette Namirial
 * definita nella sezione 0: il tema ha sempre la precedenza.
 *
 * Nota cascata: per sovrascrivere un token da fuori (es. pagina Settings) serve
 * specificità >= `form.hs-form` (targettare `form.hs-form`, non basta `:root`).
 *
 * @since 1.0.0
 */

/* Hook opzionale di layout esterno: presente solo sui form renderizzati dal
   nostro shortcode. NON usarlo come fonte dei token (vedi nota di scope). */
.nam-hubspot-form-wrapper {
    /* margini / max-width del blocco nella pagina */
}

form.hs-form {

    /* =====================================================================
     * 0. PALETTE DI FALLBACK
     * Usata SOLO quando il tema non definisce il preset corrispondente
     * (`--wp--preset--color--<slug>`): temi non FSE o senza theme.json.
     * I valori sono quelli del theme.json di Namirial FSE (tema padre), così un
     * sito senza preset resta comunque sulla palette Namirial. Sono valori
     * letterali di ultima risorsa: l'unico posto del plugin dove compaiono
     * colori esadecimali (più il blu di focus del bottone, vedi sotto).
     * Un tema senza preset può ridefinire questi token (specificità >=
     * `form.hs-form`) invece di toccare il resto del CSS.
     * ===================================================================== */
    --nam-hubspot-fallback-white: #ffffff;
    --nam-hubspot-fallback-brand-ground-dark-4: #191a19; /* testo (come main nel tema) */
    --nam-hubspot-fallback-surface-dark-1: #62625f; /* testo secondario, placeholder */
    --nam-hubspot-fallback-neutral-base: #7a7c59; /* bordo in hover */
    --nam-hubspot-fallback-neutral-light-3: #bec19c; /* bordo a riposo */
    --nam-hubspot-fallback-neutral-light-5: #eff1db; /* sfondo disabilitato */
    --nam-hubspot-fallback-accent-light-1: #83c238; /* bordo del bottone */
    --nam-hubspot-fallback-accent-light-2: #9bdf4c; /* bottone in hover */
    --nam-hubspot-fallback-accent-light-3: #abf459; /* bottone premuto */
    --nam-hubspot-fallback-accent-light-4: #c8ff9a; /* sfondo focus / selezionato */
    --nam-hubspot-fallback-accent-dark-1: #508000; /* bordo focus / selezionato */
    --nam-hubspot-fallback-accent-dark-5: #041d00; /* testo del bottone */
    --nam-hubspot-fallback-brand-100: #d6fbad; /* bottone in hover */
    --nam-hubspot-fallback-brand-200: #abf459; /* sfondo del bottone */
    --nam-hubspot-fallback-brand-300: #81e23c; /* bottone premuto */
    --nam-hubspot-fallback-brand-500: #399726; /* bordo del bottone */
    --nam-hubspot-fallback-brand-900: #0c2f0f; /* testo del bottone */
    --nam-hubspot-fallback-negative-base: #e00e4a; /* errore */
    --nam-hubspot-fallback-negative-light-4: #ffafbc; /* sfondo campo in errore */
    /* Blu dell'anello di focus dei bottoni: il tema lo usa come valore fisso
       (assets/src/scss/components/_buttons.scss), non è un preset della palette. */
    --nam-hubspot-focus-ring-button-color: #3a97f9;

    /* =====================================================================
     * 1. TOKEN PRIMITIVI
     * Valori di base, letti dai preset del tema (colori, font-size, spaziature,
     * raggio) con fallback del plugin. Non usare direttamente nei componenti:
     * passare sempre dai token semantici (sezione 2) così il punto di verità
     * è uno. Se il tema cambia (palette del child, rebranding) i form seguono
     * da soli; in caso di slug rinominati si aggiorna solo questa sezione.
     * ===================================================================== */

    /* --- Colori --- */
    --nam-hubspot-color-text: var(--wp--preset--color--brand-ground-dark-4, var(--nam-hubspot-fallback-brand-ground-dark-4)); /* testo label / input */
    --nam-hubspot-color-text-muted: var(--wp--preset--color--surface-dark-1, var(--nam-hubspot-fallback-surface-dark-1)); /* helper text, placeholder */
    --nam-hubspot-color-primary-light: var(--wp--preset--color--accent-light-4, var(--nam-hubspot-fallback-accent-light-4)); /* sfondo input a fuoco / selezionato, bottone */
    --nam-hubspot-color-primary-light-border: var(--wp--preset--color--accent-light-1, var(--nam-hubspot-fallback-accent-light-1)); /* bordo del bottone */
    --nam-hubspot-color-primary-light-hover: var(--wp--preset--color--accent-light-2, var(--nam-hubspot-fallback-accent-light-2)); /* bottone in hover */
    --nam-hubspot-color-primary-light-active: var(--wp--preset--color--accent-light-3, var(--nam-hubspot-fallback-accent-light-3)); /* bottone premuto */
    --nam-hubspot-color-brand-100: var(--wp--preset--color--brand-100, var(--nam-hubspot-fallback-brand-100)); /* bottone in hover */
    --nam-hubspot-color-brand-200: var(--wp--preset--color--brand-200, var(--nam-hubspot-fallback-brand-200)); /* sfondo del bottone */
    --nam-hubspot-color-brand-300: var(--wp--preset--color--brand-300, var(--nam-hubspot-fallback-brand-300)); /* bottone premuto */
    --nam-hubspot-color-brand-500: var(--wp--preset--color--brand-500, var(--nam-hubspot-fallback-brand-500)); /* bordo del bottone */
    --nam-hubspot-color-brand-900: var(--wp--preset--color--brand-900, var(--nam-hubspot-fallback-brand-900)); /* testo del bottone */
    --nam-hubspot-color-on-primary-light: var(--wp--preset--color--accent-dark-5, var(--nam-hubspot-fallback-accent-dark-5)); /* testo del bottone */
    --nam-hubspot-color-error: var(--wp--preset--color--negative-base, var(--nam-hubspot-fallback-negative-base)); /* validazione */
    --nam-hubspot-color-error-light: var(--wp--preset--color--negative-light-4, var(--nam-hubspot-fallback-negative-light-4)); /* sfondo input in errore */
    --nam-hubspot-color-border: var(--wp--preset--color--neutral-light-3, var(--nam-hubspot-fallback-neutral-light-3)); /* bordo input a riposo */
    --nam-hubspot-color-border-hover: var(--wp--preset--color--neutral-base, var(--nam-hubspot-fallback-neutral-base)); /* bordo input in hover */
    --nam-hubspot-color-border-focus: var(--wp--preset--color--accent-dark-1, var(--nam-hubspot-fallback-accent-dark-1)); /* bordo input a fuoco / selezionato */
    --nam-hubspot-color-surface: var(--wp--preset--color--white, var(--nam-hubspot-fallback-white)); /* sfondo input */
    --nam-hubspot-color-surface-disabled: var(--wp--preset--color--neutral-light-5, var(--nam-hubspot-fallback-neutral-light-5)); /* sfondo input disabilitato */

    /* --- Tipografia --- */
    --nam-hubspot-font-family: inherit; /* eredita dal tema (Noto Sans) */
    --nam-hubspot-font-size-sm: var(--wp--preset--font-size--text-sm, 0.8125rem); /* helper text, errori */
    --nam-hubspot-font-size-base: var(--wp--preset--font-size--text-base, 1rem); /* label, input, bottone */
    --nam-hubspot-font-weight-normal: 400; /* label, testo (come il tema) */
    --nam-hubspot-font-weight-semibold: 600; /* bottone, messaggi di errore */
    --nam-hubspot-line-height: 1.5;

    /* --- Spaziature (preset del tema: 8 / 12 / 16 / 24 px) --- */
    --nam-hubspot-space-xs: var(--wp--preset--spacing--10, 0.5rem); /* gap label/input, padding input verticale */
    --nam-hubspot-space-sm: var(--wp--preset--spacing--15, 0.75rem); /* padding input orizzontale */
    --nam-hubspot-space-md: var(--wp--preset--spacing--20, 1rem); /* gap tra colonne / campi */
    --nam-hubspot-space-lg: var(--wp--preset--spacing--30, 1.5rem); /* gap tra fieldset */

    /* --- Bordi / raggi --- */
    --nam-hubspot-border-width: 1px;
    --nam-hubspot-radius: var(--nam-gt-border-radius-xs, 4px); /* input, select, bottone */

    /* =====================================================================
     * 2. TOKEN SEMANTICI
     * Variabili di componente: referenziano i primitivi sopra. Sono questi
     * che i selettori delle sezioni 3-8 consumano.
     * ===================================================================== */

    /* Layout */
    --nam-hubspot-form-gap: var(--nam-hubspot-space-lg); /* tra fieldset */
    --nam-hubspot-columns-gap: var(--nam-hubspot-space-md); /* tra colonne */
    --nam-hubspot-field-gap: var(--nam-hubspot-space-xs); /* label <-> input */

    /* Label */
    --nam-hubspot-label-color: var(--nam-hubspot-color-text);
    --nam-hubspot-label-font-size: var(--nam-hubspot-font-size-base);
    --nam-hubspot-label-font-weight: var(--nam-hubspot-font-weight-normal);

    /* Helper text (legend.hs-field-desc) */
    --nam-hubspot-helper-color: var(--nam-hubspot-color-text-muted);
    --nam-hubspot-helper-font-size: var(--nam-hubspot-font-size-sm);
    --nam-hubspot-helper-spacing: var(--nam-hubspot-space-xs); /* margine sopra/sotto la descrizione */

    /* Messaggi di errore (ul.hs-error-msgs > li > label) */
    --nam-hubspot-error-font-size: var(--nam-hubspot-font-size-sm);
    --nam-hubspot-error-message-color: var(--nam-hubspot-color-error);

    /* Asterisco campo obbligatorio */
    --nam-hubspot-required-color: var(--nam-hubspot-color-error);

    /* Input / select / textarea */
    --nam-hubspot-input-color: var(--nam-hubspot-color-text);
    --nam-hubspot-input-background: var(--nam-hubspot-color-surface);
    --nam-hubspot-input-border-width: var(--nam-hubspot-border-width);
    --nam-hubspot-input-border-color: var(--nam-hubspot-color-border);
    --nam-hubspot-input-border-color-hover: var(--nam-hubspot-color-border-hover);
    /* a fuoco: bordo scuro + sfondo accent chiaro + contorno sottile */
    --nam-hubspot-input-border-color-focus: var(--nam-hubspot-color-border-focus);
    --nam-hubspot-input-background-focus: var(--nam-hubspot-color-primary-light);
    --nam-hubspot-focus-ring-width: 1px;
    --nam-hubspot-focus-ring-color: var(--nam-hubspot-color-border-focus);
    --nam-hubspot-input-radius: var(--nam-hubspot-radius);
    --nam-hubspot-input-padding: var(--nam-hubspot-space-xs) var(--nam-hubspot-space-sm);
    --nam-hubspot-input-font-size: var(--nam-hubspot-font-size-base);
    /* spazio a destra nelle select per non sovrapporre il testo alla freccia
       nativa disegnata dal browser */
    --nam-hubspot-select-arrow-space: 2rem;
    --nam-hubspot-placeholder-color: var(--nam-hubspot-color-text-muted);
    --nam-hubspot-textarea-min-height: 6rem; /* ~4 righe di testo */
    --nam-hubspot-checkbox-size: 1.375rem; /* lato della casella checkbox/radio */
    --nam-hubspot-checkbox-checked-background: var(--nam-hubspot-color-primary-light);
    --nam-hubspot-checkbox-checked-border-color: var(--nam-hubspot-color-border-focus);

    /* Stato disabilitato */
    --nam-hubspot-disabled-background: var(--nam-hubspot-color-surface-disabled);
    --nam-hubspot-disabled-color: var(--nam-hubspot-color-text-muted);
    --nam-hubspot-disabled-opacity: 0.7;

    /* Stato errore */
    --nam-hubspot-error-color: var(--nam-hubspot-color-error);
    --nam-hubspot-error-border-color: var(--nam-hubspot-color-error);
    --nam-hubspot-error-background: var(--nam-hubspot-color-error-light);
    /* Spazio riservato sotto ogni campo per il messaggio di validazione:
       evita il layout shift quando HubSpot inietta .hs-error-msgs.
       ~1 riga di testo small + line-height. */
    --nam-hubspot-error-reserved-space: 1.5rem;

    /* Bottone submit (e ogni altro bottone del form): look "Accent base", taglia
       Standard del Design System (https://lib.namirial.com/buttons/). Valori ripresi
       da namirial-fse/assets/src/scss/components/_buttons.scss ($nam-btn-looks,
       'accent'): testo brand-900, sfondo brand-200, bordo brand-500, hover brand-100,
       active brand-300. */
    --nam-hubspot-form-button-background-color: var(--nam-hubspot-color-brand-200);
    --nam-hubspot-form-button-background-hover: var(--nam-hubspot-color-brand-100);
    --nam-hubspot-form-button-background-active: var(--nam-hubspot-color-brand-300);
    --nam-hubspot-form-button-text-color: var(--nam-hubspot-color-brand-900);
    --nam-hubspot-form-button-border-color: var(--nam-hubspot-color-brand-500);
    /* Il tema fissa a 6px il raggio dei bottoni (nessun token per questo valore). */
    --nam-hubspot-form-button-border-radius: 6px;
    /* Taglia Standard: altezza 48px, padding laterale 24px, testo 16px. */
    --nam-hubspot-form-button-min-height: 3rem;
    --nam-hubspot-form-button-padding: 0 var(--nam-hubspot-space-lg);
    --nam-hubspot-form-button-font-size: var(--nam-hubspot-font-size-base);
    --nam-hubspot-form-button-font-weight: var(--nam-hubspot-font-weight-semibold);
    --nam-hubspot-form-button-text-transform: none;

    /* =====================================================================
     * 3. LAYOUT FORM
     * form.hs-form.stacked > fieldset.form-columns-{1,2}
     * ===================================================================== */

    /* Stacking verticale dei fieldset; spaziatura: --nam-hubspot-form-gap. */

    /* Fieldset = una "riga" del form, gestita come griglia di colonne.
       HubSpot applica width/max-width inline al fieldset: le annulliamo per
       lasciare che la griglia occupi tutta la larghezza disponibile. */
    /* form-columns-0: fieldset senza campi, solo testo (elemento Rich text). */
    fieldset.form-columns-0,
    fieldset.form-columns-1,
    fieldset.form-columns-2 {
        display: grid;
        gap: var(--nam-hubspot-columns-gap);
        /* reset stile fieldset di default del browser */
        margin: 0;
        padding: 0;
        border: 0;
        /* annulla la max-width inline di HubSpot per occupare tutta la riga */
        max-width: none !important;
        width: 100%;

        /* HubSpot dà ai campi width/float inline per il layout a colonne:
           li annulliamo, è la griglia a definire le colonne. */
        > .hs-form-field {
            /* annulla la width inline di HubSpot */
            width: auto !important;
            /* annulla il float inline di HubSpot */
            float: none !important;
        }

        > .hs-fieldtype-checkbox {
            > div.input {
                margin-top: var(--nam-hubspot-space-sm);
            }
        }
    }

    /* Una sola colonna: campo a tutta larghezza. */
    fieldset.form-columns-1 {
        grid-template-columns: 1fr;
    }

    /* Due colonne uguali: ogni campo occupa esattamente metà riga,
       così gli input affiancati hanno la stessa larghezza. */
    fieldset.form-columns-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Su schermo stretto le due colonne collassano in una.
       Breakpoint hardcoded: le custom properties non sono utilizzabili nelle
       condizioni @media in CSS puro. */
    @media (max-width: 600px) {
        fieldset.form-columns-2 {
            grid-template-columns: 1fr;
        }
    }

    /* =====================================================================
     * 4. CAMPO (field)
     * div.hs-form-field > label (> span + span.hs-form-required) +
     * legend.hs-field-desc + div.input
     * ===================================================================== */

    .hs-form-field {
        /* wrapper del singolo campo; gap label/input: --nam-hubspot-field-gap */

        /* Riserva sotto al campo lo spazio per il messaggio di errore: il
           messaggio (posizionato in absolute, vedi sezione 7) compare in
           quest'area senza spingere le righe successive -> niente scatto. */
        position: relative;
        padding-block-end: var(--nam-hubspot-error-reserved-space);

        /* Label del campo. */
        > label {
            /* block + line-height: senza, i discendenti (g, p, y) finiscono sotto l'input */
            display: block;
            line-height: var(--nam-hubspot-line-height);
            color: var(--nam-hubspot-label-color);
            font-size: var(--nam-hubspot-label-font-size);
            font-weight: var(--nam-hubspot-label-font-weight);

            /* testo della label */
            > span:not(.hs-form-required) {
            }

            /* asterisco obbligatorio */
            .hs-form-required {
                color: var(--nam-hubspot-required-color);
            }
        }

        /* Helper / descrizione campo. */
        .hs-field-desc {
            margin-block: var(--nam-hubspot-helper-spacing);
            color: var(--nam-hubspot-helper-color);
            font-size: var(--nam-hubspot-helper-font-size);
        }

        /* =================================================================
         * 5. INPUT
         * div.input > input.hs-input | textarea | select |
         * div.hs-fieldtype-intl-phone
         *
         * Nota: si targetta per ELEMENTO (input/select/textarea) e non il
         * generico .hs-input, perché anche il wrapper del telefono intl e il
         * checkbox portano la classe .hs-input e non devono ricevere lo stile
         * da campo di testo.
         * ================================================================= */

        .input {

            /* Base condivisa: campi di testo, select, textarea.
               Escluso il checkbox (gestito in sezione 6). */
            input.hs-input:not([type="checkbox"]),
            select.hs-input,
            textarea.hs-input {
                /* riempie la cella: stessa larghezza in 1 colonna, esatta metà
                   in form-columns-2. border-box: il padding non sfora il 100% */
                width: 100%;
                box-sizing: border-box;
                color: var(--nam-hubspot-input-color);
                background-color: var(--nam-hubspot-input-background);
                border: var(--nam-hubspot-input-border-width) solid var(--nam-hubspot-input-border-color);
                border-radius: var(--nam-hubspot-input-radius);
                padding: var(--nam-hubspot-input-padding);
                font-size: var(--nam-hubspot-input-font-size);
                font-family: var(--nam-hubspot-font-family);

                &::placeholder {
                    color: var(--nam-hubspot-placeholder-color);
                }

                &:hover:not(:disabled) {
                    border-color: var(--nam-hubspot-input-border-color-hover);
                }

                /* A fuoco: bordo scuro, sfondo accent chiaro e contorno sottile
                   (outline vero: resta visibile anche in alto contrasto). */
                &:focus {
                    border-color: var(--nam-hubspot-input-border-color-focus);
                    background-color: var(--nam-hubspot-input-background-focus);
                    box-shadow: none;
                    outline: var(--nam-hubspot-focus-ring-width) solid var(--nam-hubspot-focus-ring-color);
                    outline-offset: 0;
                }

                &:disabled {
                    background-color: var(--nam-hubspot-disabled-background);
                    color: var(--nam-hubspot-disabled-color);
                    opacity: var(--nam-hubspot-disabled-opacity);
                    cursor: not-allowed;
                }
            }

            /* Textarea: altezza minima e resize solo verticale (l'orizzontale
               sfonderebbe la colonna). */
            textarea.hs-input {
                min-height: var(--nam-hubspot-textarea-min-height);
                resize: vertical;
                line-height: var(--nam-hubspot-line-height);
            }

            /* Select: spazio extra a destra per la freccia nativa, così il
               valore non ci finisce sotto (evidente sulle select corte). */
            select.hs-input {
                padding-inline-end: var(--nam-hubspot-select-arrow-space);
            }

            /* Select in stato "Please Select" (placeholder). */
            select.hs-input.is-placeholder {
                color: var(--nam-hubspot-placeholder-color);
            }

            /* Telefono internazionale: il div .hs-fieldtype-intl-phone è il
               WRAPPER (ha anche .hs-input), dentro select prefisso + input. */
            .hs-fieldtype-intl-phone {
                /* select prefisso + input numero affiancati; il wrapper
                   occupa tutta la cella come gli altri controlli */
                display: flex;
                gap: var(--nam-hubspot-space-xs);
                width: 100%;

                select.hs-input {
                    /* prefisso: larghezza fissa, non si allarga */
                    flex: 0 0 auto;
                    width: auto;
                    /* larghezza minima: lascia respiro a valore + freccia.
                       Nessun token adatto per le larghezze di componente. */
                    min-width: 5rem;
                    /* padding ridotto: sul mobile resta spazio per almeno 3-4
                       caratteri del paese oltre alla freccia nativa */
                    padding-inline-start: var(--nam-hubspot-space-xs);
                    padding-inline-end: 1.75rem;
                    /* nome paese lungo: tagliato senza puntini */
                    text-overflow: clip;

                    /* Da schermi non compatti: più spazio, così il paese
                       (es. "Italy +39") non viene tagliato. Stesso breakpoint
                       hardcoded del layout a colonne (le custom properties non
                       valgono nelle @media). */
                    @media (min-width: 601px) {
                        min-width: 6rem;
                        padding-inline-start: var(--nam-hubspot-space-sm);
                        padding-inline-end: var(--nam-hubspot-select-arrow-space);
                        /* prefisso corto: al massimo un terzo della cella, il numero resta utilizzabile */
                        max-width: 33%;
                        /* dove supportato (Chromium) la select si dimensiona sul
                           paese scelto invece di tagliarlo */
                        field-sizing: content;
                    }
                }

                input.hs-input {
                    /* numero: occupa lo spazio restante */
                    flex: 1 1 auto;
                }
            }
        }

        /* =================================================================
         * 6. CHECKBOX / RADIO (consenso singolo + gruppi multi-opzione)
         * Consenso:  ul.inputs-list > li.hs-form-booleancheckbox >
         *            label.hs-form-booleancheckbox-display > input[checkbox] + span
         * Checkbox:  ul.inputs-list.multi-container > li.hs-form-checkbox >
         *            label.hs-form-checkbox-display > input[checkbox] + span
         * Radio:     ul.inputs-list > li.hs-form-radio >
         *            label.hs-form-radio-display > input[radio] + span
         * ================================================================= */

        /* Liste di scelta: consenso singolo (.hs-form-booleancheckbox), gruppi
           checkbox (.hs-form-checkbox) e gruppi radio (.hs-form-radio). */
        /* ".input >" alza la specificità: nei post singoli il tema applica
           `body.single main .entry-content ul:not(.nam-gt-list)` (list-style
           disc inside + margini) e sovrascriverebbe il reset della lista. */
        .input > .inputs-list {
            /* reset lista + impilamento verticale delle opzioni con spaziatura */
            list-style: none;
            margin: 0;
            padding: 0;
            display: flex;
            flex-direction: column;
            gap: var(--nam-hubspot-space-xs);

            .hs-form-booleancheckbox,
            .hs-form-checkbox,
            .hs-form-radio {
                margin: 0;
            }

            /* Label-riga: casella + testo affiancati, allineati in alto cosi'
               il testo su piu' righe resta indentato e non va sotto la casella. */
            .hs-form-booleancheckbox-display,
            .hs-form-checkbox-display,
            .hs-form-radio-display {
                display: flex;
                align-items: flex-start;
                gap: var(--nam-hubspot-space-sm);
                /* le opzioni non sono in bold come le label di campo */
                font-weight: var(--nam-hubspot-font-weight-normal);
                cursor: pointer;
                margin: 0;

                /* Controlli disegnati da noi (appearance:none): dimensione
                   esplicita e quadrata (annulla width/height/padding che il
                   tema applica a tutti gli input, causa del controllo stirato a
                   "riga verticale"), e soprattutto border-radius coerente anche
                   in stato :checked, che il rendering nativo non garantisce. */
                input[type="checkbox"].hs-input,
                input[type="radio"].hs-input {
                    flex: 0 0 auto;
                    box-sizing: border-box;
                    width: var(--nam-hubspot-checkbox-size);
                    height: var(--nam-hubspot-checkbox-size);
                    min-height: 0;
                    margin: 0;
                    /* allinea otticamente la casella alla prima riga di testo */
                    margin-block-start: 0.15em;
                    padding: 0;
                    cursor: pointer;
                    appearance: none;
                    -webkit-appearance: none;
                    background-color: var(--nam-hubspot-input-background);
                    background-repeat: no-repeat;
                    background-position: center;
                    border: var(--nam-hubspot-input-border-width) solid var(--nam-hubspot-input-border-color);
                    border-radius: var(--nam-hubspot-radius);

                    /* selezionato: sfondo accent chiaro e bordo scuro come nel tema; il segno specifico
                       (spunta o pallino) e' definito nelle regole sotto */
                    &:checked {
                        background-color: var(--nam-hubspot-checkbox-checked-background);
                        border-color: var(--nam-hubspot-checkbox-checked-border-color);
                    }

                    /* Hover come gli altri campi (bordo più scuro). */
                    &:hover:not(:disabled):not(:checked) {
                        border-color: var(--nam-hubspot-input-border-color-hover);
                    }

                    /* Focus coerente col resto del form: stesso contorno dei
                       campi di testo, niente blu di sistema. */
                    &:focus {
                        outline: var(--nam-hubspot-focus-ring-width) solid var(--nam-hubspot-focus-ring-color);
                        outline-offset: 0;
                        box-shadow: none;
                        border-color: var(--nam-hubspot-checkbox-checked-border-color);
                    }
                }

                /* Checkbox selezionata: segno di spunta scuro (nero del tema, come
                   la spunta dei form del tema). Il colore vive dentro l'SVG
                   (data-URI), dove i token CSS non sono referenziabili:
                   percio' e' letterale. */
                input[type="checkbox"].hs-input:checked {
                    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23090908' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E");
                    background-size: 68%;
                }

                /* Radio: tondo; da selezionato un pallino scuro centrato.
                   Colore letterale (nero del tema): nessun token dentro le
                   funzioni immagine. */
                input[type="radio"].hs-input {
                    border-radius: 50%;
                }

                input[type="radio"].hs-input:checked {
                    background-image: radial-gradient(circle, #090908 0 36%, transparent 42%);
                }

                /* Alto contrasto (Windows): torniamo al controllo nativo, gli
                   stili custom sparirebbero rendendolo invisibile. */
                @media (forced-colors: active) {
                    input[type="checkbox"].hs-input,
                    input[type="radio"].hs-input {
                        appearance: auto;
                    }
                }

                > span {
                    /* testo dell'opzione: occupa lo spazio accanto alla casella */
                    flex: 1 1 auto;
                    color: var(--nam-hubspot-color-text);
                    font-size: var(--nam-hubspot-font-size-base);
                    line-height: var(--nam-hubspot-line-height);

                    .hs-form-required {
                        color: var(--nam-hubspot-required-color);
                    }
                }
            }
        }
    }

    /* =====================================================================
     * 7. STATI
     * HubSpot aggiunge classi/markup di validazione a runtime via JS:
     * predisposti qui per quando il form è "live".
     * ===================================================================== */

    /* Campo in errore (HubSpot aggiunge .invalid / .error all'input). */
    .hs-input.invalid,
    .hs-input.error {
        border-color: var(--nam-hubspot-error-border-color);
        background-color: var(--nam-hubspot-error-background);

        /* a fuoco il campo torna chiaro, il bordo resta rosso */
        &:focus {
            border-color: var(--nam-hubspot-error-border-color);
            background-color: var(--nam-hubspot-input-background);
            outline-color: var(--nam-hubspot-error-border-color);
        }
    }

    /* Label del campo in errore. */
    .hs-form-field:has(.hs-input.invalid, .hs-input.error) > label {
        color: var(--nam-hubspot-error-color);
    }

    /* Messaggi di errore (ul.hs-error-msgs > li > label).
       Ancorati appena sotto l'input (top dello spazio riservato in fondo al
       campo, vedi .hs-form-field in sezione 4) e in crescita verso il BASSO:
       - caso tipico a una riga: sta nello spazio riservato -> niente scatto;
       - messaggio su piu' righe: si espande nello spazio sottostante senza mai
         sovrapporsi all'input (a differenza dell'ancoraggio in basso). */
    /* "> ul" + doppia classe alzano la specificità: nei post singoli il tema
       applica `body.single main .entry-content ul:not(.nam-gt-list)` (list-style
       disc + margini) e sovrascriverebbe reset e ancoraggio del messaggio. */
    .hs-form-field > ul.hs-error-msgs.hs-error-msgs {
        position: absolute;
        inset-block-start: calc(100% - var(--nam-hubspot-error-reserved-space));
        inset-block-end: auto;
        inset-inline: 0;
        margin: 0;
        padding: 0;
        list-style: none;
        font-size: var(--nam-hubspot-error-font-size);
        line-height: 1.2;

        /* Solo testo colorato, senza sfondo; il campo in errore è già
           segnalato da bordo, sfondo e label (non solo dal colore del testo). */
        li {
            margin: 0;
            color: var(--nam-hubspot-error-message-color);

            > label {
                color: inherit;
            }
        }
    }

    /* Testo informativo (elemento "Rich text" di HubSpot, es. informativa privacy):
       div.hs-richtext > p. HubSpot gli dà colore, larghezza massima e margini suoi. */
    .hs-richtext {
        /* HubSpot limita la larghezza a 500px: il testo occupa tutta la riga
           (la max-width è sul fieldset padre, vedi sezione 3) */
        max-width: none;
        margin-block: 0 var(--nam-hubspot-space-md);
        color: var(--nam-hubspot-label-color);

        p,
        span,
        li {
            color: inherit;
        }

        p:last-child {
            margin-block-end: 0;
        }
    }

    /* =====================================================================
     * 8. SUBMIT
     * div.hs-submit > div.actions > input.hs-button.primary.large
     * ===================================================================== */

    .hs-submit {

        /* Helper text del submit. HubSpot lo emette con display:none inline:
           quando presente, lo allineiamo agli altri helper text del form. */
        .hs-field-desc {
            margin-block-end: var(--nam-hubspot-space-xs);
            color: var(--nam-hubspot-helper-color);
            font-size: var(--nam-hubspot-helper-font-size);
            line-height: 1.2;
        }

        .actions {
            /* allineamento del bottone */

            .hs-button {
                background-color: var(--nam-hubspot-form-button-background-color);
                color: var(--nam-hubspot-form-button-text-color);
                /* bordo esplicito: senza, il browser disegna quello 3D di
                   default degli <input type="submit"> */
                border: var(--nam-hubspot-border-width) solid var(--nam-hubspot-form-button-border-color);
                font-family: var(--nam-hubspot-font-family);
                border-radius: var(--nam-hubspot-form-button-border-radius);
                min-height: var(--nam-hubspot-form-button-min-height);
                padding: var(--nam-hubspot-form-button-padding);
                font-size: var(--nam-hubspot-form-button-font-size);
                font-weight: var(--nam-hubspot-form-button-font-weight);
                text-transform: var(--nam-hubspot-form-button-text-transform);
                line-height: 1;
                cursor: pointer;
                /* transizione dei bottoni del tema */
                transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1), color 150ms cubic-bezier(0.4, 0, 0.2, 1);

                &:hover {
                    background-color: var(--nam-hubspot-form-button-background-hover);
                }

                &:active {
                    background-color: var(--nam-hubspot-form-button-background-active);
                }

                /* anello di focus solo da tastiera (come i bottoni del tema):
                   alone bianco + blu; outline trasparente per l'alto contrasto */
                &:focus-visible {
                    box-shadow: 0 0 0 2px var(--nam-hubspot-color-surface), 0 0 3px 5px var(--nam-hubspot-focus-ring-button-color);
                    outline: 2px solid transparent;
                    outline-offset: 2px;
                }
            }
        }
    }
}
