/* Bandeau d'actualités animé — page d'accueil (contenu généré par scripts/bandeau.py) */

.bandeau {
    --bandeau-h: clamp(420px, 40vw, 560px);
    --bandeau-gutter: max(5%, calc((100% - 1200px) / 2));
    --bandeau-interval: 6500ms;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background: #0b1f4d;
    color: #fff;
}

.bandeau-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.bandeau-viewport {
    position: relative;
    height: var(--bandeau-h);
}

.bandeau-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.9s ease, visibility 0s linear 0.9s;
}

.bandeau-slide.is-active {
    z-index: 1;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.9s ease, visibility 0s;
}

.bandeau-slide::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
        linear-gradient(90deg, rgba(8, 22, 58, 0.92) 0%, rgba(8, 22, 58, 0.7) 38%, rgba(8, 22, 58, 0.25) 100%),
        radial-gradient(circle at 85% 20%, rgba(6, 182, 212, 0.25), transparent 55%);
}

.bandeau-bg {
    position: absolute;
    inset: -8%;
    width: 116%;
    height: 116%;
    object-fit: cover;
    filter: blur(16px) saturate(1.3) brightness(0.8);
    transform: scale(1.05);
}

.bandeau-slide.is-active .bandeau-bg {
    animation: bandeau-drift calc(var(--bandeau-interval) + 2s) ease-in-out both;
}

.bandeau-frame {
    position: absolute;
    z-index: 2;
    top: 50%;
    right: var(--bandeau-gutter);
    width: min(56%, calc(var(--bandeau-h) * 0.84 * var(--ar)));
    aspect-ratio: var(--ar);
    overflow: hidden;
    border-radius: 18px;
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.14);
    transform: translateY(-50%) translateX(24px) scale(0.96);
    transition: transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.bandeau-slide.is-active .bandeau-frame {
    transform: translateY(-50%) translateX(0) scale(1);
}

.bandeau-media {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--focus, 50% 50%);
    transform-origin: var(--focus, 50% 50%);
}

.bandeau-slide.is-active .bandeau-media {
    animation: bandeau-zoom calc(var(--bandeau-interval) + 1.2s) ease-out both;
}

/* Mode plein cadre pour les images panoramiques */
.bandeau-slide[data-fit="cover"] .bandeau-frame {
    z-index: 0;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
    transform: none;
}

.bandeau-slide[data-fit="cover"].is-active .bandeau-media {
    animation-name: bandeau-kenburns;
}

.bandeau-slide:nth-child(even)[data-fit="cover"].is-active .bandeau-media {
    animation-name: bandeau-kenburns-alt;
}

.bandeau-caption {
    position: absolute;
    z-index: 3;
    top: 50%;
    left: var(--bandeau-gutter);
    width: min(38%, 480px);
    transform: translateY(-60%);
}

.bandeau-caption > * {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.6s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.bandeau-slide.is-active .bandeau-caption > * {
    opacity: 1;
    transform: none;
}

.bandeau-slide.is-active .bandeau-caption > :nth-child(1) { transition-delay: 0.25s; }
.bandeau-slide.is-active .bandeau-caption > :nth-child(2) { transition-delay: 0.4s; }
.bandeau-slide.is-active .bandeau-caption > :nth-child(3) { transition-delay: 0.55s; }
.bandeau-slide.is-active .bandeau-caption > :nth-child(4) { transition-delay: 0.7s; }

.bandeau-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border: 1px solid rgba(34, 211, 238, 0.5);
    border-radius: 999px;
    background: rgba(6, 182, 212, 0.18);
    color: #a5f3fc;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.bandeau-tag::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22d3ee;
    animation: bandeau-pulse 1.8s ease-out infinite;
}

.bandeau-title {
    margin: 0.85rem 0 0.75rem;
    color: #fff;
    font-size: clamp(1.5rem, 2.6vw, 2.4rem);
    font-weight: 800;
    line-height: 1.15;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}

.bandeau-text {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.88);
    font-size: clamp(0.95rem, 1.15vw, 1.08rem);
    line-height: 1.6;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.bandeau-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 1.25rem;
    padding: 0.7rem 1.3rem;
    border-radius: 999px;
    background: #fff;
    color: var(--primary-color, #1e40af);
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.5);
}

.bandeau-slide.is-active .bandeau-link:hover {
    transform: translateY(-2px);
    transition-delay: 0s;
}

.bandeau-link:focus-visible,
.bandeau-btn:focus-visible,
.bandeau-dot:focus-visible {
    outline: 3px solid #22d3ee;
    outline-offset: 3px;
}

/* Commandes */
.bandeau-controls {
    position: absolute;
    z-index: 4;
    bottom: 1.5rem;
    left: var(--bandeau-gutter);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.bandeau:not(.is-ready) .bandeau-controls {
    display: none;
}

.bandeau-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.2s ease, transform 0.2s ease;
}

.bandeau-btn:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: scale(1.06);
}

.bandeau-dots {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    max-width: min(60vw, 520px);
}

.bandeau-dot {
    width: 26px;
    height: 24px;
    padding: 9px 0;
    border: 0;
    background: none;
    cursor: pointer;
    transition: width 0.4s ease;
}

.bandeau-dot.is-active {
    width: 54px;
}

.bandeau-dot-track {
    display: block;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.3);
}

.bandeau-dot-bar {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: #fff;
    transform: scaleX(0);
    transform-origin: left center;
}

.bandeau-dot.is-active .bandeau-dot-bar {
    animation: bandeau-progress var(--bandeau-interval) linear forwards;
}

.bandeau-counter {
    margin-left: 0.25rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.bandeau.is-paused .bandeau-dot.is-active .bandeau-dot-bar,
.bandeau.is-paused .bandeau-slide.is-active .bandeau-media,
.bandeau.is-paused .bandeau-slide.is-active .bandeau-bg {
    animation-play-state: paused;
}

@keyframes bandeau-progress {
    to { transform: scaleX(1); }
}

@keyframes bandeau-zoom {
    from { transform: scale(1); }
    to { transform: scale(1.04); }
}

@keyframes bandeau-kenburns {
    from { transform: scale(1) translate(0, 0); }
    to { transform: scale(1.1) translate(-2%, -1%); }
}

@keyframes bandeau-kenburns-alt {
    from { transform: scale(1.1) translate(2%, 1%); }
    to { transform: scale(1) translate(0, 0); }
}

@keyframes bandeau-drift {
    from { transform: scale(1.05) translateX(0); }
    to { transform: scale(1.12) translateX(-2%); }
}

@keyframes bandeau-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.7); }
    70%, 100% { box-shadow: 0 0 0 8px rgba(34, 211, 238, 0); }
}

/* Tablette et mobile : image en haut, légende en dessous */
@media (max-width: 860px) {
    .bandeau {
        --bandeau-media-h: 260px;
        --bandeau-h: 640px;
        --bandeau-gutter: 1.25rem;
    }

    .bandeau-slide::before {
        background: linear-gradient(180deg, rgba(8, 22, 58, 0.35) 0%, rgba(8, 22, 58, 0.85) 48%, rgba(8, 22, 58, 0.96) 100%);
    }

    .bandeau-frame,
    .bandeau-slide[data-fit="cover"] .bandeau-frame {
        z-index: 2;
        inset: auto;
        top: 1.25rem;
        left: 50%;
        width: min(calc(100% - 2.5rem), calc(var(--bandeau-media-h) * var(--ar)));
        height: auto;
        aspect-ratio: var(--ar);
        border-radius: 16px;
        box-shadow: 0 20px 40px -18px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.14);
        transform: translateX(-50%) scale(0.96);
    }

    .bandeau-slide.is-active .bandeau-frame,
    .bandeau-slide[data-fit="cover"].is-active .bandeau-frame {
        transform: translateX(-50%) scale(1);
    }

    .bandeau-caption {
        top: calc(1.25rem + var(--bandeau-media-h) + 1.25rem);
        right: var(--bandeau-gutter);
        width: auto;
        transform: none;
        text-align: center;
    }

    .bandeau-title {
        margin: 0.6rem 0 0.5rem;
        font-size: 1.35rem;
    }

    .bandeau-text {
        font-size: 0.95rem;
        -webkit-line-clamp: 3;
    }

    .bandeau-link {
        margin-top: 0.9rem;
        padding: 0.6rem 1.1rem;
        font-size: 0.9rem;
    }

    .bandeau-controls {
        right: var(--bandeau-gutter);
        bottom: 1rem;
        justify-content: center;
    }

    .bandeau-counter {
        display: none;
    }
}

@media (max-width: 420px) {
    .bandeau {
        --bandeau-media-h: 220px;
        --bandeau-h: 600px;
    }

    .bandeau-btn {
        width: 36px;
        height: 36px;
    }

    .bandeau-dot {
        width: 16px;
    }

    .bandeau-dot.is-active {
        width: 36px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bandeau-slide,
    .bandeau-frame,
    .bandeau-caption > * {
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }

    .bandeau-media,
    .bandeau-bg,
    .bandeau-tag::before {
        animation: none !important;
    }
}
