/* ============================================================
   WND — Calque de dialogue (signature "Accent pétrole")
   Habillage du système wnd.class.js.
   Réutilise les tokens de core.css (:root).
   Structure DOM (intouchée, voir wnd.class.js Wnd_Box) :
     .wnd > .box > (a.close) + div > (h3) + ([data-html=content]) + (.actions > a.action[.cancel])
   Variantes sur .wnd : .no-action | .fullscreen | .floating | .light | .confs
   ============================================================ */

.wnd {
    --wnd-radius: var(--radius);
    position: fixed;
    inset: 0;
    z-index: 999999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    box-sizing: border-box;
    pointer-events: all !important;

    background: rgba(var(--bleu-petrole-rgb), .45);
    backdrop-filter: blur(8px) saturate(1.1);
    -webkit-backdrop-filter: blur(8px) saturate(1.1);

    animation: wnd-in .22s ease;
}
.wnd.is-closing { animation: wnd-out .18s ease forwards; pointer-events: none; }

/* ----- Carte ----- */
.wnd > .box {
    position: relative;
    z-index: 45;
    min-width: 260px;
    max-width: calc(100vw - 10px);
    max-height: calc(100vh - 30px);
    animation: wnd-card-in .34s cubic-bezier(.16, 1, .3, 1);
}
.wnd.is-closing > .box { animation: wnd-card-out .18s ease forwards; }

.wnd > .box > div {
    position: relative;
    box-sizing: border-box;
    padding: 28px 24px 18px;
    background: var(--card);
    border: 1px solid rgba(var(--bleu-petrole-rgb), .08);
    border-radius: var(--wnd-radius);
    box-shadow: 0 24px 60px -12px rgba(var(--bleu-petrole-rgb), .35),
                0 2px 8px rgba(0, 0, 0, .06);
    overflow: hidden;
}
/* Barre d'accent pétrole → abricot (signature discrète) */
.wnd:not(.fullscreen):not(.floating) > .box > div::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    border-radius: var(--wnd-radius) var(--wnd-radius) 0 0;
    background: linear-gradient(90deg, var(--bleu-petrole), var(--abricot));
    pointer-events: none;
}

/* ----- Titre ----- */
.wnd > .box > div > h3 {
    margin: 0 0 14px;
    padding: 0 40px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 18px;
    line-height: 1.3;
    letter-spacing: -.01em;
    text-align: center;
    text-transform: none;
    color: var(--bleu-petrole);
}
.wnd > .box > div > h3:not(:empty)::after {
    content: "";
    display: block;
    width: 34px;
    height: 3px;
    margin: 8px auto 0;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--bleu-petrole-clair), var(--abricot));
}
.wnd > .box > div > h3:empty { display: none; }

/* ----- Contenu ----- */
.wnd > .box > div > [data-html=content] {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    max-width: 970px;
    max-height: calc(100vh - 160px);
    overflow: auto;
    overflow-x: hidden;
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.6;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--bleu-petrole-rgb), .3) transparent;
    transition: max-width .3s;
}
.wnd > .box > div > h3:empty + [data-html=content] { max-height: calc(100vh - 90px); }
.wnd > .box > div > [data-html=content]::-webkit-scrollbar { width: 8px; }
.wnd > .box > div > [data-html=content]::-webkit-scrollbar-thumb {
    background: rgba(var(--bleu-petrole-rgb), .25);
    border-radius: 4px;
}
.wnd > .box > div > [data-html=content]::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--bleu-petrole-rgb), .4);
}

/* Définitions douces (surchargeables par le CSS métier) */
.wnd [data-html=content] p { margin: .5em 0; }
.wnd [data-html=content] p:first-child { margin-top: 0; }
.wnd [data-html=content] p:last-child { margin-bottom: 0; }
.wnd [data-html=content] strong { color: var(--bleu-petrole); font-weight: 700; }
.wnd [data-html=content] a {
    color: var(--bleu-petrole-clair);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.wnd [data-html=content] a:hover { color: var(--bleu-petrole); }
.wnd [data-html=content] h4,
.wnd [data-html=content] h5,
.wnd [data-html=content] h6 {
    margin: .8em 0 .4em;
    font-family: var(--font);
    font-weight: 600;
    color: var(--text);
}
.wnd [data-html=content] ul,
.wnd [data-html=content] ol { margin: .5em 0; padding-left: 1.3em; }
.wnd [data-html=content] li { margin: .2em 0; }
.wnd [data-html=content] label { display: inline-block; margin-bottom: 4px; font-weight: 600; color: var(--text); }
.wnd [data-html=content] img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }

/* Inputs nus (confirm-mobile, codes de réduction, selects cible/lieuGroupe…).
   Spécificité (0,3,1) : volontairement sous les règles métier plus précises
   (ex. .training-form .stack>div>.top>div>input en 0,4,1) et sous le formulaire
   Scellius (.kr-* rendu en iframe). Pas de width:100% pour ne pas casser les
   dispositions inline des formulaires métier. */
.wnd [data-html=content] input[type="text"],
.wnd [data-html=content] input[type="search"],
.wnd [data-html=content] input[type="email"],
.wnd [data-html=content] input[type="tel"],
.wnd [data-html=content] input[type="telephone"],
.wnd [data-html=content] input[type="number"],
.wnd [data-html=content] input[type="password"],
.wnd [data-html=content] textarea,
.wnd [data-html=content] select {
    box-sizing: border-box;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    transition: border-color .15s, box-shadow .15s;
}
.wnd [data-html=content] input:focus,
.wnd [data-html=content] textarea:focus,
.wnd [data-html=content] select:focus {
    outline: none;
    border-color: var(--bleu-petrole-clair);
    box-shadow: 0 0 0 3px rgba(var(--bleu-petrole-rgb), .15);
}
.wnd > .box > div > [data-html=content] .wide.container { padding: 0; }

/* CTA .button dans le contenu (actuellement sans style) */
.wnd [data-html=content] .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 8px 2px;
    padding: 11px 22px;
    cursor: pointer;
    text-decoration: none;
    font-family: var(--font);
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1.2;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--bleu-petrole);
    color: #fff;
    transition: transform .15s, box-shadow .15s, background .15s;
}
.wnd [data-html=content] .button:hover {
    background: var(--bleu-petrole-moyen);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(var(--bleu-petrole-rgb), .26);
}
.wnd [data-html=content] .button.small,
.wnd [data-html=content] button.small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 4px 2px;
    padding: 7px 14px;
    cursor: pointer;
    text-decoration: none;
    font-family: var(--font);
    font-weight: 600;
    font-size: 12px;
    line-height: 1.2;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--bleu-petrole);
    color: #fff;
    transition: transform .15s, box-shadow .15s, background .15s;
}
.wnd [data-html=content] .button.small:hover,
.wnd [data-html=content] button.small:hover {
    background: var(--bleu-petrole-moyen);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--bleu-petrole-rgb), .24);
}

/* ----- Actions ----- */
.wnd > .box > div > .actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    box-sizing: border-box;
    margin-top: 8px;
    padding: 16px 0 2px;
    user-select: none;
    text-align: center;
}
.wnd > .box > div > .actions > a.action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 96px;
    padding: 11px 22px;
    cursor: pointer;
    text-decoration: none;
    font-family: var(--font);
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1;
    color: #fff;
    background: var(--bleu-petrole);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    transition: transform .15s, box-shadow .15s, background .15s, color .15s;
}
.wnd > .box > div > .actions > a.action:hover {
    background: var(--bleu-petrole-moyen);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(var(--bleu-petrole-rgb), .28);
}
.wnd > .box > div > .actions > a.action:active { transform: translateY(0) scale(.97); }
.wnd > .box > div > .actions > a.action:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--bleu-petrole-rgb), .25);
}
.wnd > .box > div > .actions > a.action.cancel {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.wnd > .box > div > .actions > a.action.cancel:hover {
    background: var(--bg);
    color: var(--text);
    box-shadow: none;
}
/* Alerte à bouton unique : on dismiss via la croix / le voile (comportement historique) */
.wnd > .box > div > .actions > a.action:only-child { display: none; }

.wnd.no-action > .box > div > .actions { display: none; }
.wnd.no-action > .box > div > [data-html=content] { padding-bottom: 0; }

/* ----- Croix ----- */
.wnd a.close,
.wnd a.close-button {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 0;
    padding: 0;
    font-size: 0;
    cursor: pointer;
    border: none;
    border-radius: 50%;
    background: rgba(var(--bleu-petrole-rgb), .06);
    color: var(--bleu-petrole);
    transition: background .15s, color .15s, transform .25s cubic-bezier(.16, 1, .3, 1);
}
.wnd a.close::before,
.wnd a.close::after,
.wnd a.close-button::before,
.wnd a.close-button::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 1.6px;
    border-radius: 2px;
    background: currentColor;
}
.wnd a.close::before,
.wnd a.close-button::before { transform: rotate(45deg); }
.wnd a.close::after,
.wnd a.close-button::after { transform: rotate(-45deg); }
.wnd a.close:hover,
.wnd a.close-button:hover {
    background: rgba(var(--bleu-petrole-rgb), .14);
    color: var(--bleu-petrole-moyen);
    transform: rotate(90deg) scale(1.05);
}
.wnd a.close:focus-visible,
.wnd a.close-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--bleu-petrole-rgb), .25);
}

/* ----- Listes sélectionnables ----- */
.wnd .list { display: flex; flex-direction: column; gap: 2px; }
.wnd .list > a {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
}
.wnd .list > a:hover { background: rgba(var(--bleu-petrole-rgb), .06); }
.wnd .list > a.selected { background: var(--bleu-petrole); color: #fff; }
.wnd .list > a.selected::before {
    content: "";
    width: 5px;
    height: 9px;
    margin-right: 10px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(40deg);
}

/* ----- Recherche de checkboxes (généré par wnd.class.js) ----- */
.wnd .checkboxes-search-area { margin-bottom: 12px; }
.wnd .checkboxes-search-area input {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}
.wnd .checkboxes-search-area input:focus {
    outline: none;
    background: var(--card);
    border-color: var(--bleu-petrole-clair);
    box-shadow: 0 0 0 3px rgba(var(--bleu-petrole-rgb), .15);
}

/* ----- Menu contextuel ----- */
.wnd:has(.contextmenu) { backdrop-filter: none; background: rgba(var(--bleu-petrole-rgb), .25); }
.wnd:has(.contextmenu) > .box { max-width: 600px; }
.wnd:has(.contextmenu) > .box > div > h3 { display: none; }

/* ============================================================
   Variante .fullscreen — visionneuse sombre teintée pétrole
   ============================================================ */
.wnd.fullscreen {
    background: #0e1a1f;
    backdrop-filter: none;
    padding: 0;
}
.wnd.fullscreen > .box {
    box-shadow: none;
    border-radius: 0;
    width: 100%;
    max-height: 100%;
    background: transparent;
}
.wnd.fullscreen > .box > div {
    height: 100%;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}
.wnd.fullscreen > .box [data-html=content] {
    padding: 0;
    width: 100%;
    max-width: 100vw;
    max-height: calc(100% - 40px);
    text-align: center;
    overflow-x: auto;
    touch-action: pan-right manipulation double-tap-zoom;
}
.wnd.fullscreen > .box [data-html=content] img {
    outline: 0;
    margin: 0;
    border: none;
    max-width: 100%;
    max-height: 100%;
}
.wnd.fullscreen > .box [data-html=content] iframe { height: calc(100vh - 100px); }
.wnd.fullscreen > .box > div > .actions {
    position: relative;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 12px 0 0;
    border-top: none;
    background: transparent;
}
.wnd.fullscreen > .box > div > .actions > a.action {
    background: rgba(255, 255, 255, .12);
    color: #fff;
    border-color: rgba(255, 255, 255, .2);
}
.wnd.fullscreen > .box > div > .actions > a.action:hover { background: rgba(255, 255, 255, .22); color: #fff; }
.wnd.fullscreen a.close,
.wnd.fullscreen a.close-button {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}
.wnd.fullscreen a.close:hover,
.wnd.fullscreen a.close-button:hover {
    background: rgba(255, 255, 255, .22);
    color: #fff;
}

/* ============================================================
   Variante .floating — popover positionné (via --x / --y)
   ============================================================ */
.wnd.floating {
    display: block;
    background: transparent;
    backdrop-filter: none;
    padding: 0;
    animation: none;
}
.wnd.floating > .box {
    display: inline-block;
    position: absolute;
    left: var(--x);
    top: var(--y);
    min-width: 0;
    max-width: 320px;
    animation: wnd-card-in .18s ease;
}
.wnd.floating > .box > div {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 32px -8px rgba(var(--bleu-petrole-rgb), .3),
                0 2px 6px rgba(0, 0, 0, .1);
}
.wnd.floating > .box > div > h3 {
    margin: 0 0 6px;
    padding: 0;
    font-size: 14px;
    text-align: left;
}
.wnd.floating > .box > div > h3::after { display: none; }
.wnd.floating > .box > div > [data-html=content] {
    padding: 0;
    max-height: none;
    font-size: 14px;
}
.wnd.floating > .box > div > [data-html=content] > h3 {
    margin: 0 0 5px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* ============================================================
   Variante .light — grande modale (créateur de training)
   ============================================================ */
.wnd.light > .box > div > h3 {
    font-size: 22px;
    font-weight: 600;
    text-align: center;
}
.wnd.light > .box > div > [data-html=content] {
    height: calc(100vh - 200px);
    padding-bottom: 10px;
}
.wnd.light > .box > div > h3:empty + [data-html=content] {
    height: calc(100vh - 140px);
}

/* ============================================================
   Keyframes
   ============================================================ */
@keyframes wnd-in { from { opacity: 0; } }
@keyframes wnd-out { to { opacity: 0; } }
@keyframes wnd-card-in {
    from { opacity: 0; transform: translateY(14px) scale(.94); }
}
@keyframes wnd-card-out {
    to { opacity: 0; transform: translateY(6px) scale(.96); }
}

/* ============================================================
   Accessibilité — mouvements réduits
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .wnd,
    .wnd > .box,
    .wnd.is-closing,
    .wnd.is-closing > .box,
    .wnd a.close,
    .wnd a.close-button {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
    .wnd > .box { transform: none !important; }
}
