/*
 * NICOTIX-PATCH : bandeau cookies, fenetre centree (sans illustrations).
 * Remplace modules/pm_advancedcookiebanner/views/css/front.css (reference v4.3.0).
 *
 * ATTENTION, specifique a chabrand : ce fichier n'est PAS charge par le mecanisme de
 * surcharge habituel. Le correctif de cache de pages charge le CSS du bandeau par un
 * <link> code en dur dans templates/_partials/stylesheets.tpl, qui pointe desormais ici.
 * Si ce <link> repasse sur modules/pm_advancedcookiebanner/, l'ancien habillage revient
 * et casse la fenetre centree (son @media max-767px impose width: inherit !important).
 *
 * Balisage et script : ../templates/hook/footer.tpl
 */

/* ---------- Conteneur : voile clair plein ecran, fenetre centree, bouton rond en bas a gauche ---------- */

#acb-banner.nx-acb {
    /* Charte chabrand : noir de marque, anthracite, gris de filets */
    --nx-acb-title: #222222;
    --nx-acb-text: #565656;
    --nx-acb-btn-text: #565656;
    --nx-acb-line: #dddddd;
    --nx-acb-toggle-off: #a0a0a0;
    --nx-acb-accent: #222222;
    --nx-acb-accent-dark: #000000;
    /* Bleu OM, deja utilise par le theme pour les anneaux de focus : plus lisible que le noir */
    --nx-acb-focus: #0B61AC;
    --nx-acb-pad: 20px;
    --nx-acb-toggle: 48px;

    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Garde la fenetre a distance du bouton rond, en haut comme en bas */
    padding: calc(var(--nx-acb-toggle) + 28px) 20px;
    color: var(--nx-acb-text);
    /* Police du site (chargee par @font-face dans custom.css). Pile explicite et non inherit :
       le bandeau est rendu dans le pied de page, et custom.scss applique "body *". */
    font-family: "Futura Md BT", Arial, Helvetica, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
    /* Le conteneur lui-meme ne capte rien : ce sont le voile, la fenetre et le bouton rond qui captent les clics */
    pointer-events: none;
}

/* Voile clair derriere la fenetre : il bloque les clics sur la page tant que la fenetre est ouverte.
   Le defilement de la page reste possible. */
#acb-banner.nx-acb::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(50vh, #eee, #fff) 50% 50%;
    opacity: 0.6;
    pointer-events: auto;
    transition: opacity 0.2s;
}

#acb-banner.hide,
#acb-banner.d-none {
    display: none !important;
}

.nx-acb *,
.nx-acb *::before,
.nx-acb *::after {
    box-sizing: border-box;
}

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

.nx-acb a:focus-visible,
.nx-acb [tabindex="-1"]:focus-visible,
.nx-acb__toggle:focus-visible {
    outline: 3px solid var(--nx-acb-focus);
    outline-offset: 3px;
}

/* La fenetre recoit le focus a l'ouverture : pas de contour sur toute la fenetre */
.nx-acb .nx-acb__card:focus,
.nx-acb .nx-acb__card:focus-visible {
    outline: none;
}

/* ---------- Fenetre ---------- */

.nx-acb__card {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(420px, 100%);
    max-height: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.05);
    pointer-events: auto;
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

/* Fenetre repliee : le voile disparait et la page redevient cliquable */
#acb-banner.nx-acb.is-collapsed::before {
    opacity: 0;
    pointer-events: none;
}

.nx-acb.is-collapsed .nx-acb__card {
    visibility: hidden;
    opacity: 0;
    transform: scale(0.97);
}

#acb-banner .nx-acb__screen[hidden] {
    display: none !important;
}

/* Contenu qui defile si besoin, barre de boutons toujours visible en bas */
.nx-acb__screen {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.nx-acb__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: var(--nx-acb-pad) var(--nx-acb-pad) 16px;
    overflow-x: hidden;
    overflow-y: auto;
}

.nx-acb__title {
    margin: 0 0 12px;
    color: var(--nx-acb-title);
    font-family: "Futura Md BT", Arial, Helvetica, sans-serif;
    font-size: 17px;
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: normal;
    text-transform: none;
}

.nx-acb__title--center {
    margin-bottom: 10px;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}

/* ---------- Ecran d'accueil ---------- */

.nx-acb__text p,
.nx-acb__text ul,
.nx-acb__text ol {
    margin: 0 0 0.75em;
    color: inherit;
    font-size: inherit;
}

.nx-acb__text ul,
.nx-acb__text ol {
    padding-left: 1.75em;
}

.nx-acb__text li {
    margin: 0;
}

.nx-acb__text > :last-child,
.nx-acb__text p:last-child {
    margin-bottom: 0;
}

/* Le texte saisi en configuration commence par son propre titre en gras : on le traite comme tel */
.nx-acb__text strong,
.nx-acb__text b {
    color: var(--nx-acb-title);
}

.nx-acb__text p:first-child strong {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 17px;
    font-weight: 700;
}

/* #acb-banner : le bandeau est dans le pied de page, dont le theme colore souvent les liens */
#acb-banner .nx-acb__text a,
#acb-banner .nx-acb__text a:hover {
    color: var(--nx-acb-accent);
    text-decoration: underline;
}

/* ---------- Barre de boutons, collee au bas de la fenetre ---------- */

.nx-acb__bar {
    display: grid;
    flex: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--nx-acb-line);
}

.nx-acb__bar-btn {
    min-height: 44px;
    margin: 0;
    padding: 10px 8px;
    border: 0;
    border-right: 1px solid var(--nx-acb-line);
    border-radius: 0;
    background: #fff;
    color: var(--nx-acb-btn-text);
    font-family: inherit;
    font-size: 14px;
    /* Futura Md BT n'est chargee qu'en 400 et 700 : pas de 500 ni de 600, sinon faux gras */
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: normal;
    text-transform: none;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

/* custom.scss attenue les deux boutons par leur id (#acb-deny-all-button, #acb-close-button :
   opacity 0.5). On annule par specificite, l'ordre de chargement des feuilles variant selon
   que Creative Elements rend la page ou non. */
#acb-banner #acb-deny-all-button.nx-acb__bar-btn,
#acb-banner #acb-close-button.nx-acb__bar-btn,
#acb-banner #acb-accept-all-button.nx-acb__bar-btn {
    opacity: 1;
}

.nx-acb__bar-btn:last-child {
    border-right: 0;
}

.nx-acb__bar-btn:hover {
    background: #f9f9f9;
    color: var(--nx-acb-title);
}

.nx-acb__bar-btn--primary,
.nx-acb__bar-btn--primary:hover {
    color: #fff;
    font-weight: 700;
}

.nx-acb__bar-btn--primary {
    background: var(--nx-acb-accent);
}

.nx-acb__bar-btn--primary:hover {
    background: var(--nx-acb-accent-dark);
}

.nx-acb__bar-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -6px;
}

/* ---------- Ecran Personnaliser ---------- */

.nx-acb__intro {
    margin: 0 0 16px;
    color: var(--nx-acb-text);
    font-size: 13px;
    line-height: 1.5;
}

.nx-acb__all {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.nx-acb__all-label {
    margin: 0;
    color: var(--nx-acb-text);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.nx-acb__options {
    border: 1px solid var(--nx-acb-line);
    border-radius: 8px;
}

/* Titre et interrupteur sur une ligne, description en dessous */
.nx-acb__option {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "title switch"
        "desc  switch";
    align-items: center;
    column-gap: 16px;
    row-gap: 4px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--nx-acb-line);
}

.nx-acb__option:last-child {
    border-bottom: 0;
}

.nx-acb__option-title {
    grid-area: title;
    margin: 0;
    color: var(--nx-acb-text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    cursor: pointer;
}

.nx-acb__option-desc {
    grid-area: desc;
    margin: 0;
    color: var(--nx-acb-text);
    font-size: 12px;
    line-height: 1.4;
}

/* Interrupteur : vraie case a cocher, invisible, posee sur le dessin.
   Piste fine, pastille blanche plus grande qui deborde, avec une croix (non) ou une coche (oui). */
.nx-acb__switch {
    grid-area: switch;
    position: relative;
    display: inline-block;
    flex: none;
    width: 40px;
    height: 24px;
}

.nx-acb__switch input {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.nx-acb__switch-track {
    position: absolute;
    top: 3px;
    right: 2px;
    bottom: 3px;
    left: 2px;
    border-radius: 999px;
    background: var(--nx-acb-toggle-off);
    transition: background-color 0.2s;
}

.nx-acb__switch-track::before,
.nx-acb__switch-track::after {
    content: "";
    position: absolute;
    top: -3px;
    left: -2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: transform 0.2s;
}

.nx-acb__switch-track::before {
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* Icone de la pastille, coloree par background (masque SVG) */
.nx-acb__switch-track::after {
    background: var(--nx-acb-btn-text);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M9 9l6 6M15 9l-6 6'/%3E%3C/svg%3E") center / 100% no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M9 9l6 6M15 9l-6 6'/%3E%3C/svg%3E") center / 100% no-repeat;
}

.nx-acb__switch input:checked + .nx-acb__switch-track {
    background: var(--nx-acb-accent);
}

.nx-acb__switch input:checked + .nx-acb__switch-track::before,
.nx-acb__switch input:checked + .nx-acb__switch-track::after {
    transform: translateX(16px);
}

.nx-acb__switch input:checked + .nx-acb__switch-track::after {
    background: var(--nx-acb-accent);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 12.5l2.7 2.7L16.2 9.6'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 12.5l2.7 2.7L16.2 9.6'/%3E%3C/svg%3E");
}

.nx-acb__switch input:focus-visible + .nx-acb__switch-track {
    outline: 3px solid var(--nx-acb-focus);
    outline-offset: 4px;
}

/* ---------- Bouton rond : replie / rouvre la fenetre ---------- */

.nx-acb__toggle {
    position: absolute;
    left: 20px;
    bottom: 20px;
    width: var(--nx-acb-toggle);
    height: var(--nx-acb-toggle);
    padding: 0;
    border: 0;
    /* Forme de galet, legerement irreguliere */
    border-radius: 46% 54% 52% 48% / 55% 47% 53% 45%;
    background: var(--nx-acb-accent);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.2s, background-color 0.2s;
}

.nx-acb__toggle:hover {
    background: var(--nx-acb-accent-dark);
    transform: scale(1.06);
}

.nx-acb__toggle-icon {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity 0.2s, transform 0.2s;
}

/* Fenetre ouverte : croix ; fenetre repliee : le cookie */
.nx-acb:not(.is-collapsed) .nx-acb__toggle-icon--cookie {
    opacity: 0;
    transform: scale(0.6);
}

.nx-acb.is-collapsed .nx-acb__toggle-icon--close {
    opacity: 0;
    transform: rotate(-90deg);
}

/* ---------- Mobile : fenetre pleine largeur ---------- */

@media (max-width: 480px) {
    #acb-banner.nx-acb {
        --nx-acb-pad: 18px;
        --nx-acb-toggle: 44px;

        padding-right: 0;
        padding-left: 0;
    }

    .nx-acb__card {
        width: 100%;
        border-radius: 0;
    }

    .nx-acb__bar-btn {
        padding-right: 4px;
        padding-left: 4px;
    }

    .nx-acb__toggle {
        left: 12px;
        bottom: 12px;
    }
}

/* Ecran bas et assez large (telephone a l'horizontale) : la fenetre ne croise pas le bouton rond,
   elle peut prendre toute la hauteur */
@media (max-height: 500px) and (min-width: 560px) {
    #acb-banner.nx-acb {
        padding-top: 12px;
        padding-bottom: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #acb-banner.nx-acb::before,
    .nx-acb *,
    .nx-acb *::before,
    .nx-acb *::after {
        transition: none !important;
    }
}

/* ---------- Bouton rond masque ---------- */

/* La fenetre devient une fenetre modale simple : le visiteur choisit parmi les trois
   boutons de la barre, il n'y a plus de galet flottant pour la replier.
   Pour retablir le bouton, supprimer ce bloc et rien d'autre : le template et le script
   gerent les deux cas (piege a focus et touche Echap s'adaptent a sa visibilite). */
#acb-banner.nx-acb .nx-acb__toggle {
    display: none;
}

/* Sans le galet, la marge qui lui etait reservee en haut et en bas n'a plus lieu d'etre.
   Bloc place en fin de fichier pour passer apres les media queries ci-dessus. */
#acb-banner.nx-acb {
    --nx-acb-toggle: 0px;

    padding-top: 28px;
    padding-bottom: 28px;
}

@media (max-height: 500px) and (min-width: 560px) {
    #acb-banner.nx-acb {
        padding-top: 12px;
        padding-bottom: 12px;
    }
}
