/* CAPPS — bandeau cookies et panneau « Personnaliser » (lot GADS, G2).
   Discret, en bas de page, non bloquant ; thème clair/sombre via les variables de site_v2.css ;
   propriétés logiques pour l'arabe (dir="rtl"). Balisage : pages/_consentement.php ; logique : assets/js/capps/consentement.js. */

.cc {
    --cc-radius: 18px;
    position: fixed;
    inset-inline: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 60;                      /* au-dessus de la barre mobile et du bouton WhatsApp (30), sous les fenêtres modales (99+) */
    display: flex;
    justify-content: center;
    pointer-events: none;             /* seule la carte capte les clics : la page reste utilisable */
    font-family: inherit;
}
.cc[hidden] { display: none; }

.cc-card {
    pointer-events: auto;
    width: 100%;
    max-width: 960px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 20px;
    border-radius: var(--cc-radius, 18px);
    border: 1px solid var(--line, #e4e4ee);
    background: var(--surface, #fff);
    background: color-mix(in srgb, var(--surface, #fff) 94%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    color: var(--text, #0f172a);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 24px 48px -20px rgba(15, 23, 42, .35);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px 24px;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity .28s ease, transform .28s cubic-bezier(.2, .8, .2, 1);
}
.cc.is-visible .cc-card { opacity: 1; transform: none; }

/* Panneau ouvert : une colonne, actions en bas */
.cc[data-state="panel"] .cc-card { grid-template-columns: minmax(0, 1fr); max-width: 640px; }

.cc-head { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
.cc-icon {
    flex: 0 0 auto; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
    background: var(--brand-soft, #eef0ff); color: var(--brand, #4f46e5);
}
.cc-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cc-icon svg circle { fill: currentColor; stroke: none; }
.cc-intro { min-width: 0; flex: 1; }
.cc-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; letter-spacing: -.1px; color: var(--text, #0f172a); }
.cc-text { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--muted, #5b6475); }
.cc-link { color: var(--brand, #4f46e5); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.cc-link:hover { text-decoration-thickness: 2px; }

.cc-close {
    flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; margin-block-start: -6px; margin-inline-end: -8px;
    border: 0; border-radius: 10px; background: transparent; color: var(--muted, #5b6475); cursor: pointer;
}
.cc-close[hidden] { display: none; }
.cc-close:hover { background: var(--surface-2, #f1f1f8); color: var(--text, #0f172a); }
.cc-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* Catégories */
.cc-panel { display: grid; gap: 10px; }
.cc-panel[hidden] { display: none; }
.cc-panel-title { margin: 4px 0 2px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted, #5b6475); }
.cc-panel-title:focus { outline: none; }
.cc-panel-title:focus-visible { outline: 2px solid var(--brand, #4f46e5); outline-offset: 3px; border-radius: 4px; }
.cc-cat {
    display: flex; align-items: center; gap: 16px; padding: 14px 16px;
    border: 1px solid var(--line, #e4e4ee); border-radius: 14px; background: var(--surface, #fff);
}
.cc-cat-text { flex: 1; min-width: 0; }
.cc-cat-name { display: block; margin: 0 0 2px; font-size: 14.5px; font-weight: 700; color: var(--text, #0f172a); cursor: default; }
label.cc-cat-name { cursor: pointer; }
.cc-cat-desc { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted, #5b6475); }
.cc-badge {
    flex: 0 0 auto; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
    background: color-mix(in srgb, var(--ok, #059669) 14%, transparent); color: var(--ok, #059669);
}

/* Interrupteur accessible (case à cocher native, role="switch") */
.cc-switch {
    -webkit-appearance: none; appearance: none; flex: 0 0 auto; position: relative; margin: 0;
    width: 46px; height: 26px; border-radius: 999px; cursor: pointer;
    background: var(--line, #e4e4ee); border: 1px solid color-mix(in srgb, var(--muted, #5b6475) 30%, transparent);
    transition: background-color .2s ease;
}
.cc-switch::after {
    content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 20px; height: 20px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s ease;
}
.cc-switch:checked { background: var(--brand-btn, #4f46e5); border-color: var(--brand-btn, #4f46e5); }
.cc-switch:checked::after { transform: translateX(20px); }
[dir="rtl"] .cc-switch:checked::after { transform: translateX(-20px); }
.cc-switch:focus-visible { outline: 2px solid var(--brand, #4f46e5); outline-offset: 3px; }

/* Boutons : « Tout refuser » et « Tout accepter » ont exactement le même style (même poids visuel) */
.cc-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.cc-btn {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
    border-radius: 12px; border: 1px solid transparent; font: inherit; font-size: 14.5px; font-weight: 600; line-height: 1.2;
    white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s, transform .15s;
}
.cc-btn[hidden] { display: none; }
.cc-btn:active { transform: translateY(1px); }
.cc-btn:focus-visible, .cc-link:focus-visible, .cc-close:focus-visible, .foot-cookies:focus-visible {
    outline: 2px solid var(--brand, #4f46e5); outline-offset: 2px;
}
.cc-btn--choice { min-width: 140px; background: var(--brand-btn, #4f46e5); border-color: var(--brand-btn, #4f46e5); color: #fff; }
.cc-btn--choice:hover { background: #4338ca; border-color: #4338ca; }
.cc-btn--ghost { background: transparent; border-color: var(--line, #e4e4ee); color: var(--text, #0f172a); }
.cc-btn--ghost:hover { border-color: var(--brand, #4f46e5); color: var(--brand, #4f46e5); }

/* Lien « Gérer les cookies » du pied de page : aspect identique aux autres liens légaux */
.foot-cookies {
    padding: 0; margin: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; text-align: start;
}
.foot-cookies:hover { color: var(--text, #0f172a); }

.cc-sr {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Tablette : texte au-dessus, actions en dessous */
@media (max-width: 900px) {
    .cc-card { grid-template-columns: minmax(0, 1fr); }
    .cc-actions { justify-content: stretch; }
    .cc-actions .cc-btn--choice { flex: 1 1 0; min-width: 0; }
}

/* Téléphone : feuille ancrée en bas, pleine largeur */
@media (max-width: 640px) {
    .cc { inset-inline: 0; bottom: 0; }
    .cc-card {
        border-radius: var(--cc-radius, 18px) var(--cc-radius, 18px) 0 0; border-bottom: 0;
        padding: 16px 16px calc(14px + env(safe-area-inset-bottom));
        max-height: 85vh; max-height: 85dvh; gap: 12px;
    }
    .cc-icon { display: none; }       /* place gagnée pour le texte sur petit écran */
    .cc-text { font-size: 13px; }
    .cc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .cc-actions .cc-btn--choice { min-width: 0; }
    .cc-actions .cc-btn--ghost { grid-column: 1 / -1; order: 3; min-height: 40px; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
    .cc-cat { padding: 12px; gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .cc-card, .cc-switch, .cc-switch::after { transition: none; }
}

@media print {
    .cc, .foot-cookies { display: none !important; }
}
