/**
 * DanIT Lens Transition - Front CSS
 * Animation en fondu entre verres clairs et solaires.
 *
 * Robuste face aux overrides CSS de modules tiers (Theme Warehouse,
 * danit_productpage, etc.) grâce à des !important ciblés sur le positionnement.
 *
 * @author DanIT - Jordane Allouche
 */

/* Hôte (la <picture> ou la slide) doit être en position relative */
.dlt-host {
    position: relative !important;
    display: block !important;
}

/* Image native cachée mais elle garde son layout (visibility: hidden plutôt que display: none) */
.dlt-host img.dlt-native-hidden {
    visibility: hidden !important;
}

/* Conteneur de l'overlay : occupe toute la zone de l'image native */
.dlt-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none; /* Laisse les clics passer vers le zoom/expander */
    overflow: hidden;
    z-index: 2; /* Au-dessus de l'image native cachée */
    /* NOTE : pas de --dlt-cycle / --dlt-fade ici ! Sinon ils masqueraient les valeurs
     * propagées depuis .dlt-host (qui contient les settings BO). Les fallbacks par défaut
     * sont passés au site d'usage via la syntaxe var(--dlt-cycle, 6000ms) plus bas. */
}

.dlt-overlay .dlt-img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    will-change: opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    max-width: none !important;
    max-height: none !important;
}

/*
 * Variante miniatures : on utilise des <div> avec background-image pour
 * échapper au reformatage que le module DanIT product-page applique sur
 * toutes les <img> de carte produit (qui casserait notre absolute).
 */
.dlt-overlay--bg > div.dlt-img {
    display: block !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: contain !important;
    inset: 0 !important;
}

/*
 * Animation : 1 cycle complet = clear → fade vers sun → sun → fade vers clear
 *  - 0%  : clear=1, sun=0
 *  - 25% : clear=1, sun=0 (fin du hold clear)
 *  - 50% : clear=0, sun=1 (sun visible)
 *  - 75% : clear=0, sun=1 (fin du hold sun)
 *  - 100%: clear=1, sun=0
 */

@keyframes dltClearCycle {
    0%   { opacity: 1; }
    25%  { opacity: 1; }
    50%  { opacity: 0; }
    75%  { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes dltSunCycle {
    0%   { opacity: 0; }
    25%  { opacity: 0; }
    50%  { opacity: 1; }
    75%  { opacity: 1; }
    100% { opacity: 0; }
}

.dlt-overlay .dlt-img-clear {
    opacity: 1;
    animation: dltClearCycle var(--dlt-cycle, 6000ms) ease-in-out infinite;
}

.dlt-overlay .dlt-img-sun {
    opacity: 0;
    animation: dltSunCycle var(--dlt-cycle, 6000ms) ease-in-out infinite;
}

/* État de départ inversé (sun en premier) : on décale les animations de 50% */
.dlt-overlay.dlt-start-sun .dlt-img-clear {
    animation-delay: calc(var(--dlt-cycle, 6000ms) / -2);
}
.dlt-overlay.dlt-start-sun .dlt-img-sun {
    animation-delay: calc(var(--dlt-cycle, 6000ms) / -2);
}

/* Masque la slide/miniature dupliquée par la paire animée (clear + sun) */
.dlt-pair-hidden {
    display: none !important;
}

/* Conteneur de la galerie d'images : contexte de positionnement pour le repli */
.dlt-photochromic-host {
    position: relative !important;
}

/*
 * Quand le chip est posé dans .dpp-brand-header (logo de marque),
 * on aligne logo + chip sur la même ligne sans toucher au sizing du logo
 * (géré par l'autre module).
 */
.dpp-brand-header:has(> .dlt-photochromic-badge) {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    flex-wrap: wrap !important;
justify-content: space-between;
}

/*
 * Chip « Verres photochromiques » : pastille + titre + sous-titre.
 * Posé à droite du logo de marque dans .dpp-brand-header.
 */
.dlt-photochromic-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 6px 12px !important;
    border-radius: 5px !important;
    background: #eef1f8 !important;
    border: 1px solid #dde2ee !important;
    color: #2a3358 !important;
    vertical-align: middle !important;
}

.dlt-photochromic-badge .dlt-photochromic-badge__icon {
    position: relative !important;
    flex: 0 0 auto !important;
    display: block !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 5px !important;
    overflow: hidden !important;
    background-image: url("../photochromique.png") !important;
    background-size: cover !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    animation: dltBadgeAdapt 3500ms ease-in-out infinite !important;
}

/*
 * Démo « photochromique » : voile teinté qui fond/disparaît en boucle.
 */
.dlt-photochromic-badge .dlt-photochromic-badge__icon::after {
    content: "" !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: inherit !important;
    background: rgba(8, 18, 12, 0.7) !important;
    opacity: 0 !important;
    animation: dltBadgeTint 3500ms ease-in-out infinite !important;
}

@keyframes dltBadgeAdapt {
    0%   { filter: brightness(1.4) saturate(0.7); }
    25%  { filter: brightness(1.4) saturate(0.7); }
    50%  { filter: brightness(0.55) saturate(1.25); }
    75%  { filter: brightness(0.55) saturate(1.25); }
    100% { filter: brightness(1.4) saturate(0.7); }
}

@keyframes dltBadgeTint {
    0%   { opacity: 0; }
    25%  { opacity: 0; }
    50%  { opacity: 1; }
    75%  { opacity: 1; }
    100% { opacity: 0; }
}

.dlt-photochromic-badge .dlt-photochromic-badge__text {
    display: flex !important;
    flex-direction: column !important;
    line-height: 1.2 !important;
}

.dlt-photochromic-badge .dlt-photochromic-badge__title {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #1e2a78 !important;
    letter-spacing: .01em !important;
}

.dlt-photochromic-badge .dlt-photochromic-badge__desc {
    font-size: 11.5px !important;
    font-weight: 400 !important;
    color: #5b6592 !important;
}

/* Variante de repli (sans logo de marque) : reste en bandeau inline */
.product-information .dlt-photochromic-badge--inline {
    display: inline-flex !important;
    margin: 0 0 14px 0 !important;
}

/*
 * Petit badge photochromique en haut-droite des miniatures et des cartes
 * de variante. Icône = views/photochromique.png. Tooltip rendu via un
 * élément flottant unique attaché au <body> (cf. .dlt-floating-tip plus bas) :
 * on évite ainsi le clipping par overflow:hidden des cartes mega menu.
 */
.dlt-mini-icon-host {
    position: relative !important;
}

.dlt-mini-icon {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    z-index: 10 !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
    background-image: url("../photochromique.png") !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    box-shadow: 0 2px 8px rgba(20, 30, 80, 0.28) !important;
    cursor: help !important;
    display: block !important;
    pointer-events: auto !important;
    outline: none !important;
}

.dlt-mini-icon:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1e2a78, 0 2px 8px rgba(20, 30, 80, 0.28) !important;
}

/* Variante compacte pour les .dpp-lens-card (cartes plus petites) */
.dpp-lens-card .dlt-mini-icon {
    top: 5px !important;
    right: 5px !important;
    width: 22px !important;
    height: 22px !important;
    border-radius: 6px !important;
}

/* -----------------------------------------------------------------------
 * Tooltip flottant : 1 seul élément <div class="dlt-floating-tip"> dans
 * le <body>, repositionné par JS (position: fixed). Immune aux overflow:hidden.
 * ----------------------------------------------------------------------- */
.dlt-floating-tip {
    position: fixed !important;
    top: 0;
    left: 0;
    background: #1e2a78 !important;
    color: #fff !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
    letter-spacing: .01em !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 24px rgba(20, 30, 80, 0.32) !important;
    pointer-events: none !important;
    opacity: 0;
    transform: scale(0.94);
    transition: opacity .15s ease, transform .15s ease;
    z-index: 2147483647 !important; /* au-dessus de tout, mega menu inclus */
    max-width: 220px !important;
    white-space: normal !important;     /* autorise le wrap (évite que le texte déborde de la box) */
    word-wrap: break-word !important;
    text-align: center !important;
    --dlt-arrow-x: 50%;
}

.dlt-floating-tip--visible {
    opacity: 1;
    transform: scale(1);
}

/* Flèche en HAUT du tooltip (tooltip est SOUS le badge → pointe vers le haut) */
.dlt-floating-tip[data-arrow="top"]::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: var(--dlt-arrow-x);
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 7px solid transparent;
    border-bottom-color: #1e2a78;
}

/* Flèche en BAS du tooltip (tooltip est AU-DESSUS du badge → pointe vers le bas) */
.dlt-floating-tip[data-arrow="bottom"]::after {
    content: "";
    position: absolute;
    top: 100%;
    left: var(--dlt-arrow-x);
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border: 7px solid transparent;
    border-top-color: #1e2a78;
}

/* Accessibilité : respect des préférences de réduction d'animation */
@media (prefers-reduced-motion: reduce) {
    .dlt-overlay .dlt-img-clear,
    .dlt-overlay .dlt-img-sun {
        animation: none !important;
    }
    .dlt-overlay .dlt-img-clear {
        opacity: 1 !important;
    }
    .dlt-overlay .dlt-img-sun {
        opacity: 0 !important;
    }
    .dlt-photochromic-badge .dlt-photochromic-badge__icon,
    .dlt-photochromic-badge .dlt-photochromic-badge__icon::after {
        animation: none !important;
    }
    .dlt-photochromic-badge .dlt-photochromic-badge__icon::after {
        opacity: 0 !important;
    }
}
