/**
 * PrivacyTrustBadge - Reusable Privacy & Trust Micro-Component
 *
 * Architecture à Deux Éléments Visuels :
 * - Élément A : Le Blob Déclencheur (.privacy-trust-badge__blob-btn)
 *   Garde en permanence sa taille (54x54px), sa silhouette galet asymétrique et sa plume.
 *   Au hover : transition de couleur uniquement, sans scale, sans variation de dimension.
 *
 * - Élément B : Le Panneau Latéral (.privacy-trust-badge__panel-wrapper)
 *   Émerge et se déploie horizontalement depuis le blob sans aucune transformation brutale.
 *
 * Mesurable Timing & Easing :
 * - Container Expansion (Open) : 440ms (Cible : 380–500ms)
 * - Container Collapse (Close) : 320ms (Cible : 280–380ms)
 * - Content Appearance (Open)  : 260ms (Cible : 220–300ms)
 * - Content Delay             : 100ms (Cible : 80–140ms)
 * - Séquençage progressif     : ≥ 45ms par niveau
 * - Easing                    : cubic-bezier(0.22, 1, 0.36, 1)
 * - Translation texte max     : ≤ 6px
 * - Variation blob hover      : 0px (≤ 1px)
 */

:root {
    --ptb-bg: #0f172a;               /* Fond normal sombre / anthracite */
    --ptb-bg-hover: #1e293b;         /* Fond hover (couleur subtile : ardoise bleutée / accent) */
    --ptb-text-primary: #ffffff;
    --ptb-text-secondary: #cbd5e1;
    --ptb-text-muted: #94a3b8;
    --ptb-icon-color: #ffffff;
    --ptb-icon-hover-color: #f8fafc;
    --ptb-border: rgba(255, 255, 255, 0.08);
    --ptb-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    --ptb-shadow-hover: 0 4px 14px rgba(0, 0, 0, 0.35);
    --ptb-shadow-open: 0 16px 36px -6px rgba(0, 0, 0, 0.5), 0 8px 16px -4px rgba(0, 0, 0, 0.3);

    /* Forme quadrilatère organique asymétrique (blob à 4 côtés non parallèles et coins très arrondis) */
    --ptb-blob-radius: 42% 58% 63% 37% / 54% 39% 61% 46%;
    --ptb-radius-open: 18px;
    --ptb-z-index: 210;

    /* Mesurable Timing & Easing */
    --ptb-duration-open: 440ms;       /* 380–500 ms */
    --ptb-duration-close: 320ms;      /* 280–380 ms */
    --ptb-duration-content: 260ms;    /* 220–300 ms */
    --ptb-delay-content: 100ms;       /* 80–140 ms */
    --ptb-stagger-step: 45ms;         /* ≥ 40 ms */
    --ptb-easing: cubic-bezier(0.22, 1, 0.36, 1);
    --ptb-transition-color: 200ms ease;
    --ptb-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Container Global Fixed ───────────────────────────── */
.privacy-trust-badge {
    position: fixed;
    bottom: calc(1rem + var(--ptb-safe-bottom));
    z-index: var(--ptb-z-index);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
    pointer-events: none;
    display: flex;
    align-items: flex-end;
}

.privacy-trust-badge *,
.privacy-trust-badge *::before,
.privacy-trust-badge *::after {
    box-sizing: border-box;
}

/* Position variants */
.privacy-trust-badge--bottom-right {
    right: 1.25rem;
    left: auto;
    flex-direction: row-reverse;
}

.privacy-trust-badge--bottom-left {
    left: 1.25rem;
    right: auto;
    flex-direction: row;
}

/* ── ÉLÉMENT A : Le Blob Déclencheur ──────────────────── */
.privacy-trust-badge__blob-btn {
    pointer-events: auto;
    position: relative;
    z-index: 3;
    width: 54px;
    height: 54px;
    min-width: 54px;
    min-height: 54px;
    padding: 0;
    margin: 0;
    border: none;
    background-color: var(--ptb-bg);
    border-radius: var(--ptb-blob-radius);
    box-shadow: var(--ptb-shadow);
    color: var(--ptb-icon-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    flex-shrink: 0;
    /* Transition de couleur au survol stricte sans aucun scale ni resize */
    transition: background-color var(--ptb-transition-color),
                color var(--ptb-transition-color),
                box-shadow var(--ptb-transition-color);
    transform: none !important;
}

/* Hover du blob : couleur uniquement, dimensions et forme 100% stables */
.privacy-trust-badge__blob-btn:hover {
    background-color: var(--ptb-bg-hover);
    box-shadow: var(--ptb-shadow-hover);
    color: var(--ptb-icon-hover-color);
    width: 54px !important;
    height: 54px !important;
    transform: none !important;
}

/* Focus visible accessible sans modification de dimension */
.privacy-trust-badge__blob-btn:focus-visible {
    outline: 2px solid #38bdf8;
    outline-offset: 3px;
    border-radius: var(--ptb-blob-radius);
}

.privacy-trust-badge__blob-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: inherit;
    transition: color var(--ptb-transition-color);
    transform: none !important;
}

.privacy-trust-badge__blob-icon svg {
    width: 24px;
    height: 24px;
    display: block;
}

/* ── ÉLÉMENT B : Le Panneau Latéral Glissant ───────────── */
.privacy-trust-badge__panel-wrapper {
    pointer-events: none;
    position: relative;
    z-index: 2;
    overflow: hidden;
    /* État fermé : largeur 0, masqué avec transition douce */
    max-width: 0;
    opacity: 0;
    visibility: hidden;
    transition: max-width var(--ptb-duration-close) var(--ptb-easing),
                opacity 160ms ease,
                visibility var(--ptb-duration-close) ease;
}

/* Conteneur interne du panneau avec largeur fixe stable pour éviter tout écrasement de texte */
.privacy-trust-badge__panel-inner {
    width: 330px;
    background-color: var(--ptb-bg);
    border: 1px solid var(--ptb-border);
    border-radius: var(--ptb-radius-open);
    box-shadow: var(--ptb-shadow-open);
    color: var(--ptb-text-primary);
    padding: 1rem 1.25rem;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 85vh;
}

/* Décalage élégant par rapport au blob selon la position */
.privacy-trust-badge--bottom-right .privacy-trust-badge__panel-wrapper {
    margin-right: 0.5rem;
}

.privacy-trust-badge--bottom-left .privacy-trust-badge__panel-wrapper {
    margin-left: 0.5rem;
}

/* Éléments internes du panneau (séquençage progressif) */
.privacy-trust-badge__header,
.privacy-trust-badge__commitments,
.privacy-trust-badge__subtitle,
.privacy-trust-badge__links {
    opacity: 0;
    transform: translateY(6px); /* Translation maximale ≤ 8px */
    transition: opacity var(--ptb-duration-content) var(--ptb-easing),
                transform var(--ptb-duration-content) var(--ptb-easing);
}

/* ── État Ouvert : Déploiement Horizontal Fluide (440ms) ─ */
.privacy-trust-badge.is-open .privacy-trust-badge__panel-wrapper {
    pointer-events: auto;
    max-width: 400px;
    opacity: 1;
    visibility: visible;
    transition: max-width var(--ptb-duration-open) var(--ptb-easing),
                opacity 200ms ease;
}

/* En état ouvert, le blob reste visible à côté du panneau */
.privacy-trust-badge.is-open .privacy-trust-badge__blob-btn {
    background-color: var(--ptb-bg-hover);
    box-shadow: var(--ptb-shadow-hover);
}

/* Séquençage du contenu à l'ouverture */
.privacy-trust-badge.is-open .privacy-trust-badge__header {
    opacity: 1;
    transform: translateY(0);
    transition-delay: var(--ptb-delay-content); /* 100ms */
}

.privacy-trust-badge.is-open .privacy-trust-badge__commitments {
    opacity: 1;
    transform: translateY(0);
    transition-delay: calc(var(--ptb-delay-content) + 20ms); /* 120ms */
}

.privacy-trust-badge.is-open .privacy-trust-badge__subtitle {
    opacity: 1;
    transform: translateY(0);
    transition-delay: calc(var(--ptb-delay-content) + var(--ptb-stagger-step) + 20ms); /* 165ms */
}

.privacy-trust-badge.is-open .privacy-trust-badge__links {
    opacity: 1;
    transform: translateY(0);
    transition-delay: calc(var(--ptb-delay-content) + (var(--ptb-stagger-step) * 2) + 20ms); /* 210ms */
}

/* En-tête du panneau ouvert */
.privacy-trust-badge__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}

.privacy-trust-badge__brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.privacy-trust-badge__brand-badge {
    width: 28px;
    height: 28px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: var(--ptb-blob-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ptb-icon-color);
    flex-shrink: 0;
}

.privacy-trust-badge__brand-badge svg {
    width: 16px;
    height: 16px;
}

.privacy-trust-badge__header-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ptb-text-secondary);
    margin: 0;
}

.privacy-trust-badge__close {
    background: transparent;
    border: none;
    color: var(--ptb-text-muted);
    cursor: pointer;
    padding: 0.25rem;
    margin: -0.25rem;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.privacy-trust-badge__close:hover,
.privacy-trust-badge__close:focus-visible {
    color: var(--ptb-text-primary);
    background-color: rgba(255, 255, 255, 0.1);
}

.privacy-trust-badge__close:focus-visible {
    outline: 2px solid #38bdf8;
}

.privacy-trust-badge__close svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Liste des engagements */
.privacy-trust-badge__commitments {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.privacy-trust-badge__commitment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ptb-text-primary);
    line-height: 1.3;
}

.privacy-trust-badge__check-icon {
    width: 16px;
    height: 16px;
    color: #34d399;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.privacy-trust-badge__check-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

/* Sous-texte */
.privacy-trust-badge__subtitle {
    font-size: 0.8125rem;
    color: var(--ptb-text-secondary);
    line-height: 1.45;
    margin: 0 0 0.875rem 0;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Liens du bas */
.privacy-trust-badge__links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    margin: 0;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.privacy-trust-badge__link,
.privacy-trust-badge__links a {
    color: #ffffff !important;
    text-decoration: underline !important;
    text-decoration-color: rgba(255, 255, 255, 0.5) !important;
    text-underline-offset: 3px;
    font-weight: 600;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.privacy-trust-badge__link:hover,
.privacy-trust-badge__links a:hover {
    color: #ffffff !important;
    text-decoration-color: #ffffff !important;
}

.privacy-trust-badge__link:focus-visible,
.privacy-trust-badge__links a:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    border-radius: 2px;
}

.privacy-trust-badge__separator {
    color: rgba(255, 255, 255, 0.6);
    user-select: none;
}

/* ── Mobile adjustments & safe spacing ────────────────── */
@media (max-width: 640px) {
    .privacy-trust-badge {
        bottom: calc(0.75rem + var(--ptb-safe-bottom));
        max-width: calc(100vw - 1.5rem);
    }

    .privacy-trust-badge--bottom-right {
        right: 0.75rem;
    }

    .privacy-trust-badge--bottom-left {
        left: 0.75rem;
    }

    .privacy-trust-badge__panel-wrapper {
        max-width: 0;
    }

    .privacy-trust-badge.is-open .privacy-trust-badge__panel-wrapper {
        max-width: calc(100vw - 1.5rem - 54px - 0.5rem);
    }

    .privacy-trust-badge__panel-inner {
        width: min(320px, calc(100vw - 1.5rem - 54px - 0.5rem));
        min-width: 250px;
        padding: 0.875rem 1rem;
        max-height: 75vh;
        font-size: 0.8125rem;
    }

    .privacy-trust-badge__commitment-item {
        font-size: 0.875rem;
        gap: 0.4rem;
    }

    .privacy-trust-badge__subtitle {
        font-size: 0.75rem;
        margin-bottom: 0.625rem;
    }

    .privacy-trust-badge__links {
        font-size: 0.75rem;
    }

    /* Éviter de masquer un sticky cta mobile */
    body:has(.mobile-sticky-cta) .privacy-trust-badge {
        bottom: calc(4.75rem + var(--ptb-safe-bottom));
    }
}

@media (max-width: 380px) {
    .privacy-trust-badge {
        right: 0.5rem;
        bottom: calc(0.5rem + var(--ptb-safe-bottom));
        max-width: calc(100vw - 1rem);
    }

    .privacy-trust-badge.is-open .privacy-trust-badge__panel-wrapper {
        max-width: calc(100vw - 1rem - 48px - 0.35rem);
    }

    .privacy-trust-badge__panel-inner {
        width: calc(100vw - 1rem - 48px - 0.35rem);
        min-width: 210px;
        padding: 0.75rem 0.875rem;
    }

    .privacy-trust-badge__blob-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }

    .privacy-trust-badge__blob-btn:hover {
        width: 48px !important;
        height: 48px !important;
    }
}

/* ── Accessibilité : Reduced motion ───────────────────── */
@media (prefers-reduced-motion: reduce) {
    :root {
        --ptb-duration-open: 80ms;
        --ptb-duration-close: 60ms;
        --ptb-duration-content: 80ms;
        --ptb-delay-content: 0ms;
        --ptb-stagger-step: 0ms;
    }

    .privacy-trust-badge__blob-btn,
    .privacy-trust-badge__panel-wrapper,
    .privacy-trust-badge__panel-inner,
    .privacy-trust-badge__header,
    .privacy-trust-badge__commitments,
    .privacy-trust-badge__subtitle,
    .privacy-trust-badge__links {
        transition-duration: 80ms !important;
        transition-delay: 0ms !important;
        transform: none !important;
    }
}
