/* ==========================================================================
   CONSENTEMENT AUX COOKIES (vue/snippets/cookies.php, js/cookies.js)
   Bandeau en bas d'écran et panneau de préférences, aux couleurs de la charte (css/chavigny.css)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Bandeau
   -------------------------------------------------------------------------- */
.ck-banner {
    position: fixed;
    right: 24px;
    bottom: 24px;
    left: 24px;
    z-index: 1400;
    display: flex;
    justify-content: center;
    pointer-events: none;
    animation: ck-up .35s var(--ch-ease, ease) both;
}

.ck-banner[hidden] {
    display: none;
}

/* Arrivée en glissant, sans fondu : le bandeau reste visible même si l'animation est interrompue par le navigateur */
@keyframes ck-up {
    from { transform: translateY(16px); }
    to { transform: none; }
}

.ck-banner-inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px 22px;
    width: 100%;
    max-width: 1180px;
    padding: 20px 24px;
    border: 1px solid var(--ch-border, #dcdcde);
    border-top: 4px solid var(--ch-red, #d0343a);
    border-radius: var(--ch-radius-lg, 20px);
    background: var(--ch-white, #fff);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .18);
    color: var(--ch-text, #2a2b2e);
    font-family: var(--ch-font, Arial, sans-serif);
    pointer-events: auto;
}

.ck-banner-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--ch-red-soft, #fbeaeb);
    color: var(--ch-red, #d0343a);
    font-size: 1.45rem;
}

.ck-banner-text p {
    margin: 0;
    color: var(--ch-grey-dark, #4a4b4f);
    font-size: .9rem;
    line-height: 1.55;
}

.ck-banner-text .ck-banner-title {
    margin-bottom: 4px;
    color: var(--ch-text, #2a2b2e);
    font-size: 1.02rem;
    font-weight: 700;
}

.ck-banner-text a,
.ck-panel a {
    color: var(--ch-red-dark, #b0272d);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ck-banner-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* --------------------------------------------------------------------------
   Boutons (même forme que les boutons du site)
   -------------------------------------------------------------------------- */
.ck-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 20px;
    border: 1.5px solid transparent;
    border-radius: var(--ch-radius-pill, 999px);
    font-family: inherit;
    font-size: .92rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .2s var(--ch-ease, ease), border-color .2s var(--ch-ease, ease), color .2s var(--ch-ease, ease);
}

.ck-btn:focus-visible {
    outline: 3px solid rgba(208, 52, 58, .35);
    outline-offset: 2px;
}

.ck-btn-primary {
    background: var(--ch-red, #d0343a);
    color: var(--ch-white, #fff);
}

.ck-btn-primary:hover {
    background: var(--ch-red-dark, #b0272d);
}

/* « Tout refuser » : même visibilité que « Tout accepter » (recommandation CNIL) */
.ck-btn-outline {
    border-color: var(--ch-text, #2a2b2e);
    background: var(--ch-white, #fff);
    color: var(--ch-text, #2a2b2e);
}

.ck-btn-outline:hover {
    border-color: var(--ch-red, #d0343a);
    color: var(--ch-red, #d0343a);
}

.ck-btn-link {
    padding-right: 8px;
    padding-left: 8px;
    background: transparent;
    color: var(--ch-grey-dark, #4a4b4f);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ck-btn-link:hover {
    color: var(--ch-red, #d0343a);
}

/* --------------------------------------------------------------------------
   Panneau de préférences
   -------------------------------------------------------------------------- */
.ck-panel {
    margin: auto; /* centrée à l'écran (marges remises à zéro par la feuille de style globale) */
    width: min(620px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100vh - 32px);
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: var(--ch-radius-lg, 20px);
    background: var(--ch-white, #fff);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
    color: var(--ch-text, #2a2b2e);
    font-family: var(--ch-font, Arial, sans-serif);
}

.ck-panel::backdrop {
    background: rgba(20, 20, 22, .55);
}

.ck-panel-form {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 32px);
    margin: 0;
}

.ck-panel-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--ch-grey-light, #efefef);
    border-top: 4px solid var(--ch-red, #d0343a);
}

.ck-panel-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ch-red-soft, #fbeaeb);
    color: var(--ch-red, #d0343a);
    font-size: 1.15rem;
}

.ck-panel-kicker {
    margin: 0 0 2px;
    color: var(--ch-red, #d0343a);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.ck-panel-title {
    margin: 0;
    color: var(--ch-text, #2a2b2e);
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 700;
}

.ck-panel-close {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: auto;
    border: 1px solid var(--ch-border, #dcdcde);
    border-radius: 50%;
    background: var(--ch-white, #fff);
    color: var(--ch-text, #2a2b2e);
    font-size: 1.05rem;
    cursor: pointer;
}

.ck-panel-close:hover,
.ck-panel-close:focus-visible {
    border-color: var(--ch-red, #d0343a);
    color: var(--ch-red, #d0343a);
}

.ck-panel-body {
    padding: 18px 22px 6px;
    overflow-y: auto;
}

.ck-panel-intro {
    margin: 0 0 16px;
    color: var(--ch-grey-dark, #4a4b4f);
    font-size: .92rem;
    line-height: 1.55;
}

.ck-category {
    margin-bottom: 12px;
    padding: 16px 18px;
    border: 1px solid var(--ch-border, #dcdcde);
    border-radius: var(--ch-radius, 12px);
}

.ck-category-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.ck-category-title {
    margin: 0 0 4px;
    color: var(--ch-text, #2a2b2e);
    font-size: .98rem;
    font-weight: 700;
}

.ck-category-desc {
    margin: 0;
    color: var(--ch-grey-dark, #4a4b4f);
    font-size: .86rem;
    line-height: 1.5;
}

.ck-always {
    flex-shrink: 0;
    padding: 4px 12px;
    border-radius: var(--ch-radius-pill, 999px);
    background: #eaf5ee;
    color: #1e7b4a;
    font-size: .76rem;
    font-weight: 700;
    white-space: nowrap;
}

/* Interrupteur */
.ck-switch {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.ck-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.ck-switch-track {
    position: relative;
    width: 50px;
    height: 28px;
    border-radius: 999px;
    background: var(--ch-border, #dcdcde);
    transition: background-color .2s var(--ch-ease, ease);
}

.ck-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ch-white, #fff);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
    transition: transform .2s var(--ch-ease, ease);
}

.ck-switch input:checked + .ck-switch-track {
    background: var(--ch-red, #d0343a);
}

.ck-switch input:checked + .ck-switch-track .ck-switch-thumb {
    transform: translateX(22px);
}

.ck-switch input:focus-visible + .ck-switch-track {
    outline: 3px solid rgba(208, 52, 58, .35);
    outline-offset: 2px;
}

.ck-switch-state {
    color: var(--ch-grey-dark, #4a4b4f);
    font-size: .72rem;
    font-weight: 700;
}

.ck-details {
    margin-top: 10px;
    font-size: .84rem;
}

.ck-details summary {
    color: var(--ch-grey-dark, #4a4b4f);
    font-weight: 600;
    cursor: pointer;
}

.ck-details ul {
    margin: 8px 0 0;
    padding-left: 18px;
    color: var(--ch-grey-dark, #4a4b4f);
    line-height: 1.6;
}

.ck-panel-more {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 6px 0 14px;
    color: var(--ch-grey-dark, #4a4b4f);
    font-size: .84rem;
    line-height: 1.5;
}

.ck-panel-more i {
    margin-top: 3px;
}

.ck-panel-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px 20px;
    border-top: 1px solid var(--ch-grey-light, #efefef);
    background: #fafafa;
}

/* Lien « Gestion des cookies » du pied de page (bouton présenté comme les liens voisins) */
.ch-footer-cookies {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.ch-footer-cookies:hover,
.ch-footer-cookies:focus-visible {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .ck-banner-inner {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .ck-banner-actions {
        grid-column: 1 / -1;
        justify-content: stretch;
    }

    .ck-banner-actions .ck-btn {
        flex: 1 1 auto;
    }
}

@media (max-width: 575.98px) {
    .ck-banner {
        right: 8px;
        bottom: 8px;
        left: 8px;
    }

    .ck-banner-inner {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        padding: 16px;
        border-radius: var(--ch-radius, 12px);
    }

    .ck-banner-icon {
        display: none;
    }

    .ck-banner-text p {
        font-size: .86rem;
    }

    /* Accepter et refuser côte à côte, Personnaliser dessous */
    .ck-banner-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .ck-banner-actions [data-cookies-open] {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .ck-btn {
        white-space: normal;
    }

    .ck-panel-head,
    .ck-panel-body,
    .ck-panel-foot {
        padding-right: 16px;
        padding-left: 16px;
    }

    .ck-panel-foot .ck-btn {
        flex: 1 1 100%;
    }

    .ck-category-head {
        flex-direction: column;
    }

    .ck-switch {
        flex-direction: row;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ck-banner {
        animation: none;
    }

    .ck-switch-track,
    .ck-switch-thumb,
    .ck-btn {
        transition: none;
    }
}

@media print {
    .ck-banner,
    .ck-panel {
        display: none !important;
    }
}
