/* Banner cookie.

   Deve convivere con due fogli molto diversi: styles.css (index.html), che ha
   regole globali su div/p/label e ragiona su un guscio scalato da JavaScript, e
   demo.css (area demo e informativa), che e' un foglio normale. Per questo tutto
   e' agganciato a #hteConsent, che con specificita' 1-0-x vince sui selettori di
   elemento di styles.css, e il markup evita <p> (che li' e' !important).

   Il banner sta in fondo a <body>, fuori da #MainWrapperDiv: cosi' la scala che
   index.js applica al guscio sul telefono non lo rimpicciolisce. */

#hteConsent {
    --hc-ink: #101010;
    --hc-ink-soft: #5a5a5a;
    --hc-bg: #ffffff;
    --hc-bg-alt: #f6f6f6;
    --hc-line: #e2e2e2;
    --hc-accent: #ff8c00;
    --hc-sans: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    --hc-mono: "Roboto Mono", ui-monospace, Consolas, monospace;

    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2147483000; /* sopra il popup profilo di styles.css, che sta a 999999 */
    display: flex;
    justify-content: center;
    padding: clamp(10px, 2vw, 22px);
    padding-bottom: calc(clamp(10px, 2vw, 22px) + env(safe-area-inset-bottom, 0px));
    background: none;
    pointer-events: none; /* solo la card intercetta i clic */
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#hteConsent.hc-open {
    opacity: 1;
    transform: none;
}

/* l'attributo hidden deve vincere sul display:flex qui sopra */
#hteConsent[hidden] {
    display: none !important;
}

/* azzeramento dell'eredita' dei due fogli ospiti */
#hteConsent *,
#hteConsent *::before,
#hteConsent *::after {
    box-sizing: border-box;
    font-family: var(--hc-sans);
    background: none;
    grid-gap: 0;
    gap: 0;
}

#hteConsent ul,
#hteConsent li {
    margin: 0;
    padding: 0;
    list-style: none;
    display: block;
}

#hteConsent .hc-card {
    pointer-events: auto;
    position: relative;
    display: block;
    width: 100%;
    max-width: 720px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: clamp(18px, 3vw, 26px);
    padding-right: clamp(40px, 5vw, 52px); /* spazio per la X */
    background: var(--hc-bg);
    color: var(--hc-ink);
    border: 1px solid var(--hc-line);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
    font-size: 15px;
    line-height: 1.55;
    text-align: left;
}

/* riceve il fuoco all'apertura solo per portarci dentro lettori di schermo e
   tastiera: non e' un comando, quindi niente contorno */
#hteConsent .hc-card:focus {
    outline: none;
}

#hteConsent .hc-title {
    display: block;
    margin: 0 0 8px 0;
    font-family: var(--hc-mono);
    font-size: 19px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--hc-ink);
}

#hteConsent .hc-text {
    display: block;
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--hc-ink-soft);
}

#hteConsent .hc-text a {
    color: var(--hc-ink);
    text-decoration: underline;
    text-underline-offset: 2px;
}

#hteConsent .hc-text a:hover {
    color: var(--hc-accent);
}

/* ------------------------------------------------------------------ X */

#hteConsent .hc-close {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: none;
    color: var(--hc-ink-soft);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

#hteConsent .hc-close:hover {
    background: var(--hc-bg-alt);
    color: var(--hc-ink);
}

#hteConsent .hc-close-x {
    display: block;
    font-family: var(--hc-sans);
}

/* -------------------------------------------------------------- bottoni */

#hteConsent .hc-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

#hteConsent .hc-btn {
    font-family: var(--hc-sans);
    font-size: 15px;
    line-height: 1.2;
    cursor: pointer;
    border-radius: 11px;
    transition: background 0.18s ease, border-color 0.18s ease;
}

/* "Rifiuta tutti" e "Accetta tutti" condividono questa sola classe: stessa
   dimensione, stesso colore, stesso peso. Rifiutare deve costare un clic come
   accettare, e deve sembrarlo. */
#hteConsent .hc-btn--equal {
    flex: 1 1 160px;
    min-height: 44px;
    padding: 11px 18px;
    font-weight: 600;
    color: #ffffff;
    background: var(--hc-ink);
    border: 1px solid var(--hc-ink);
}

#hteConsent .hc-btn--equal:hover {
    background: #2a2a2a;
    border-color: #2a2a2a;
}

#hteConsent .hc-btn--link {
    flex: 0 0 auto;
    order: -1;
    min-height: 44px;
    padding: 11px 4px;
    margin-right: auto;
    color: var(--hc-ink-soft);
    background: none;
    border: none;
    text-decoration: underline;
    text-underline-offset: 3px;
}

#hteConsent .hc-btn--link:hover {
    color: var(--hc-ink);
}

#hteConsent .hc-save {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-top: 10px;
    padding: 11px 18px;
    font-weight: 600;
    color: var(--hc-ink);
    background: var(--hc-bg-alt);
    border: 1px solid var(--hc-line);
}

#hteConsent .hc-save:hover {
    border-color: #c9c9c9;
}

#hteConsent .hc-save[hidden] {
    display: none !important;
}

#hteConsent .hc-btn:focus-visible,
#hteConsent .hc-close:focus-visible {
    outline: 2px solid var(--hc-accent);
    outline-offset: 2px;
}

/* ---------------------------------------------------------- preferenze */

#hteConsent .hc-prefs {
    display: block;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--hc-line);
}

#hteConsent .hc-prefs[hidden] {
    display: none !important;
}

#hteConsent .hc-cat + .hc-cat {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--hc-line);
}

#hteConsent .hc-cat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 28px;
}

#hteConsent .hc-cat-name {
    display: block;
    font-weight: 600;
    font-size: 15px;
    color: var(--hc-ink);
}

#hteConsent .hc-cat-always {
    display: block;
    font-size: 13px;
    color: var(--hc-ink-soft);
}

#hteConsent .hc-cat-desc {
    display: block;
    margin-top: 5px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--hc-ink-soft);
}

#hteConsent .hc-vendors {
    margin-top: 8px;
}

#hteConsent .hc-vendor {
    display: block;
    padding: 3px 0 3px 14px;
    font-size: 13px;
    color: var(--hc-ink-soft);
    position: relative;
}

#hteConsent .hc-vendor::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 11px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--hc-accent);
}

/* ---------------------------------------------------------- interruttore */

#hteConsent .hc-switch {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    width: 46px;
    height: 26px;
    font-size: 15px; /* neutralizza label{font-size:1.5em} di styles.css */
    cursor: pointer;
}

#hteConsent .hc-switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

#hteConsent .hc-switch-track {
    display: block;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: #d4d4d4;
    transition: background 0.18s ease;
}

#hteConsent .hc-switch-track::after {
    content: "";
    display: block;
    width: 20px;
    height: 20px;
    margin: 3px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.18s ease;
}

#hteConsent .hc-switch input:checked + .hc-switch-track {
    background: var(--hc-accent);
}

#hteConsent .hc-switch input:checked + .hc-switch-track::after {
    transform: translateX(20px);
}

#hteConsent .hc-switch input:focus-visible + .hc-switch-track {
    outline: 2px solid var(--hc-accent);
    outline-offset: 2px;
}

/* ------------------------------------------------------------- telefono

   Il banner sta in fondo a <body>, fuori da #MainWrapperDiv, quindi la scala
   che index.js applica al guscio sul telefono non lo tocca: mentre il sito
   intorno e' disegnato su 1100px e poi ridotto, il banner resta a dimensione
   reale e sembra minuscolo al confronto.

   C'e' di peggio: su index.html la larghezza di impaginazione non coincide con
   lo schermo. Misurato su un telefono vero, la card occupava il 71% della
   larghezza pur avendo max-width 720px, cioe' il browser stava impaginando su
   circa 1010px e riducendo tutto. Una misura in px, li', arriva all'occhio
   ridotta della stessa proporzione.

   Da qui --hc-base in vw, come per l'informativa: essendo una frazione della
   larghezza di impaginazione, restituisce la stessa dimensione fisica sia che
   quella larghezza coincida con lo schermo sia che non lo faccia. Il tetto
   serve solo a non gonfiare il banner su un tablet tattile, e viene tolto
   quando lo schermo e' davvero piccolo. */

@media (max-width: 768px), (pointer: coarse), (any-pointer: coarse), (hover: none) {
    #hteConsent { --hc-base: clamp(15px, 4.1vw, 19px); }
}

@media (max-device-width: 520px) {
    #hteConsent { --hc-base: max(15px, 4.1vw); }
}

@media (max-width: 768px), (pointer: coarse), (any-pointer: coarse), (hover: none) {

    /* sul telefono la card usa tutta la larghezza disponibile: lasciarla a
       720px dentro un'impaginazione larga la fa sembrare un riquadro sperduto */
    #hteConsent .hc-card {
        max-width: none;
        border-radius: calc(var(--hc-base) * 1.1);
        padding: calc(var(--hc-base) * 1.25);
        padding-right: calc(var(--hc-base) * 2.9);
        font-size: var(--hc-base);
    }

    #hteConsent .hc-title { font-size: calc(var(--hc-base) * 1.27); }
    #hteConsent .hc-text { font-size: var(--hc-base); }

    #hteConsent .hc-close {
        width: calc(var(--hc-base) * 2.3);
        height: calc(var(--hc-base) * 2.3);
        font-size: calc(var(--hc-base) * 1.5);
        border-radius: calc(var(--hc-base) * 0.7);
    }

    /* i comandi restano larghi quanto la card e alti abbastanza da centrarli
       col pollice */
    #hteConsent .hc-actions { gap: calc(var(--hc-base) * 0.7); }

    #hteConsent .hc-btn { border-radius: calc(var(--hc-base) * 0.75); }

    #hteConsent .hc-btn--equal {
        flex: 1 1 100%;
        min-height: calc(var(--hc-base) * 3);
        padding: calc(var(--hc-base) * 0.75) calc(var(--hc-base) * 1.2);
        font-size: var(--hc-base);
    }

    #hteConsent .hc-btn--link {
        order: 0;
        width: 100%;
        margin-right: 0;
        text-align: center;
        min-height: calc(var(--hc-base) * 2.8);
        font-size: var(--hc-base);
    }

    #hteConsent .hc-save {
        min-height: calc(var(--hc-base) * 3);
        padding: calc(var(--hc-base) * 0.75) calc(var(--hc-base) * 1.2);
        font-size: var(--hc-base);
    }

    /* pannello delle categorie */
    #hteConsent .hc-cat-name { font-size: var(--hc-base); }
    #hteConsent .hc-cat-always { font-size: calc(var(--hc-base) * 0.87); }
    #hteConsent .hc-cat-desc { font-size: calc(var(--hc-base) * 0.93); }
    #hteConsent .hc-vendor { font-size: calc(var(--hc-base) * 0.87); }

    #hteConsent .hc-switch,
    #hteConsent .hc-switch-track {
        width: calc(var(--hc-base) * 3.1);
        height: calc(var(--hc-base) * 1.75);
    }

    #hteConsent .hc-switch { font-size: var(--hc-base); }

    #hteConsent .hc-switch-track::after {
        width: calc(var(--hc-base) * 1.35);
        height: calc(var(--hc-base) * 1.35);
        margin: calc(var(--hc-base) * 0.2);
    }

    #hteConsent .hc-switch input:checked + .hc-switch-track::after {
        transform: translateX(calc(var(--hc-base) * 1.35));
    }
}

@media (prefers-reduced-motion: reduce) {
    #hteConsent,
    #hteConsent .hc-btn,
    #hteConsent .hc-switch-track,
    #hteConsent .hc-switch-track::after {
        transition: none;
    }
}
