/* ══════════════════════════════════════════════════════════════════
   COOKIE CONSENT — Balans
   Stili del banner di consenso e della modale preferenze.
   Tutte le classi sono prefissate "cc-" per evitare conflitti con
   style.css. I colori riusano le variabili del tema (:root e
   [data-theme="dark"]), quindi la dark mode è supportata nativamente.
   ══════════════════════════════════════════════════════════════════ */

/* ───────── Banner (informativa breve) ───────── */

.cc-banner {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 2rem);
    max-width: 760px;
    box-sizing: border-box;
    padding: 1.25rem 2.75rem 1.25rem 1.5rem;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--hairline);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(14, 17, 48, 0.18);
    animation: cc-slide-in .35s ease both;
}

@keyframes cc-slide-in {
    from {
        opacity: 0;
        transform: translate(-50%, 1rem);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.cc-banner h2 {
    margin: 0 0 .5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
}

.cc-text {
    margin: 0 0 1rem;
    font-size: .85rem;
    line-height: 1.55;
    color: var(--ink-2);
}

.cc-text a {
    color: var(--teal-ink);
    font-weight: 600;
    text-decoration: underline;
}

/* Comando X in alto a destra: chiude il banner senza prestare consenso
   (equivale a "Rifiuta tutti", come previsto dall'informativa) */
.cc-close {
    position: absolute;
    top: .65rem;
    right: .65rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--ink-3);
    cursor: pointer;
}

.cc-close:hover {
    background: var(--teal-tint);
    color: var(--ink);
}

/* ───────── Pulsanti ───────── */

.cc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
}

.cc-btn {
    font: inherit;
    font-size: .85rem;
    font-weight: 700;
    padding: .6rem 1.15rem;
    border-radius: 10px;
    cursor: pointer;
    transition: filter .15s ease, background .15s ease;
}

/* "Accetta tutti" e "Rifiuta tutti" hanno pari evidenza grafica
   (nessun dark pattern: stessa gerarchia visiva per le due scelte) */
.cc-btn-solid {
    background: var(--teal);
    border: 1px solid var(--teal);
    color: #FFFFFF;
}

.cc-btn-solid:hover {
    filter: brightness(0.94);
}

.cc-btn-ghost {
    background: transparent;
    border: 1px solid var(--hairline-2);
    color: var(--ink);
}

.cc-btn-ghost:hover {
    background: var(--teal-tint);
}

.cc-btn:focus-visible,
.cc-close:focus-visible {
    outline: 2px solid var(--teal-ink);
    outline-offset: 2px;
}

/* ───────── Modale preferenze ───────── */

.cc-overlay {
    position: fixed;
    inset: 0;
    z-index: 1001;
    background: rgba(14, 17, 48, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.cc-overlay[hidden] {
    display: none;
}

.cc-modal {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 560px;
    max-height: min(85vh, 85dvh);
    overflow-y: auto;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--hairline);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 20px 60px rgba(14, 17, 48, 0.3);
}

.cc-modal h2 {
    margin: 0 0 .5rem;
    font-size: 1.15rem;
    color: var(--ink);
}

.cc-modal-intro {
    margin: 0 0 1.25rem;
    font-size: .85rem;
    line-height: 1.55;
    color: var(--ink-2);
}

.cc-modal-intro a {
    color: var(--teal-ink);
    font-weight: 600;
    text-decoration: underline;
}

/* Singola categoria di cookie */
.cc-cat {
    border-top: 1px solid var(--hairline);
    padding: 1rem 0;
}

.cc-cat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .35rem;
}

.cc-cat-title {
    font-size: .92rem;
    font-weight: 700;
    color: var(--ink);
}

.cc-cat-state {
    font-size: .75rem;
    font-weight: 600;
    color: var(--teal-ink);
    white-space: nowrap;
}

.cc-cat-desc {
    margin: 0;
    font-size: .8rem;
    line-height: 1.5;
    color: var(--ink-3);
}

/* ───────── Interruttore (switch) ───────── */

.cc-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.cc-switch .cc-slider {
    position: absolute;
    inset: 0;
    background: var(--ink-5);
    border-radius: 24px;
    transition: background .2s ease;
    pointer-events: none;
}

.cc-switch .cc-slider::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #FFFFFF;
    border-radius: 50%;
    transition: transform .2s ease;
}

.cc-switch input:checked+.cc-slider {
    background: var(--teal);
}

.cc-switch input:checked+.cc-slider::before {
    transform: translateX(20px);
}

.cc-switch input:disabled {
    cursor: not-allowed;
}

.cc-switch input:disabled+.cc-slider {
    opacity: .55;
}

.cc-switch input:focus-visible+.cc-slider {
    outline: 2px solid var(--teal-ink);
    outline-offset: 2px;
}

.cc-modal .cc-actions {
    margin-top: 1.25rem;
    justify-content: flex-end;
}

/* ───────── Responsive ───────── */

@media (max-width: 600px) {
    .cc-banner {
        left: 0;
        right: 0;
        bottom: 0;
        transform: none;
        width: 100%;
        max-width: none;
        border-radius: 16px 16px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }

    @keyframes cc-slide-in {
        from {
            opacity: 0;
            transform: translateY(1rem);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .cc-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .cc-btn {
        width: 100%;
        text-align: center;
    }
}

/* Rispetta la preferenza di riduzione del movimento */
@media (prefers-reduced-motion: reduce) {

    .cc-banner {
        animation: none;
    }

    .cc-switch .cc-slider,
    .cc-switch .cc-slider::before {
        transition: none;
    }
}
