/* ─────────────────────────────────────────────
   Astra Touch Carousel – CSS
   Compatible Astra / Spectra
   Version 3.0.0
   ───────────────────────────────────────────── */

/* ── Variables par défaut ── */
:root {
    --atc-font-family: inherit;
    --atc-heading-font: inherit;
    --atc-link-color: #0073aa;
    --atc-link-hover: #005a87;
    --atc-title-color: #1e293b;
    --atc-text-color: #475569;
    --atc-arrows-color: #334155;
    --atc-arrows-bg: rgba(255, 255, 255, 0.95);
    --atc-dots-color: #0073aa;
    --atc-card-bg: #ffffff;
    --atc-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
    --atc-shadow-hover: 0 4px 12px rgba(0,0,0,0.1), 0 8px 24px rgba(0,0,0,0.08);
    --atc-transition-speed: 400ms;
    --atc-transition-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Héritage Astra ── */
.atc-astra-inherit {
    --atc-font-family: var(--ast-font-family-body, inherit);
    --atc-heading-font: var(--ast-font-family-h1, var(--ast-font-family-body, inherit));
    --atc-link-color: var(--ast-global-color-0, #0073aa);
    --atc-link-hover: var(--ast-global-color-1, #3a3a3a);
}

/* ── Wrapper ── */
.atc-carousel-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    font-family: var(--atc-font-family);
    box-sizing: border-box;
}

/* ── Viewport ── */
.atc-viewport {
    overflow: hidden;
    width: 100%;
    position: relative;
}

.atc-overflow-visible .atc-viewport {
    overflow: visible;
}

/* ── Track ── */
.atc-track {
    display: flex;
    will-change: transform;
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

.atc-track.is-animating {
    transition: transform var(--atc-transition-speed) var(--atc-transition-ease);
}

/* ── Slide ── */
.atc-slide {
    flex-shrink: 0;
    box-sizing: border-box;
    background: var(--atc-card-bg);
    overflow: hidden;
    position: relative;
    width: calc(
        (100% - (var(--atc-columns, 3) - 1) * var(--atc-gap, 24px))
        / var(--atc-columns, 3)
    );
    margin-right: var(--atc-gap, 24px);
}

.atc-slide:last-child {
    margin-right: 0;
}

.atc-equal-height .atc-slide {
    display: flex;
    flex-direction: column;
}

.atc-equal-height .atc-slide-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.atc-equal-height .atc-slide-excerpt {
    flex: 1;
}

/* ── Shadow ── */
.atc-shadow .atc-slide {
    box-shadow: var(--atc-shadow);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

/* ── Hover Effects ── */
.atc-hover-lift .atc-slide:hover {
    transform: translateY(-6px);
    box-shadow: var(--atc-shadow-hover);
}

.atc-hover-zoom .atc-slide:hover .atc-slide-image img {
    transform: scale(1.08);
}

.atc-hover-fade .atc-slide:hover {
    opacity: 0.85;
}

/* ── Fond des slides ── */
.atc-slide {
    background: var(--atc-slide-bg, var(--atc-card-bg));
}

/* Checkerboard (damier Photoshop) pour images transparentes */
.atc-slide-checkerboard .atc-slide {
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, #e2e2e2 25%, transparent 25%),
        linear-gradient(-45deg, #e2e2e2 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2e2e2 75%),
        linear-gradient(-45deg, transparent 75%, #e2e2e2 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* ── Image ── */
.atc-slide-image {
    position: relative;
    overflow: hidden;
    background: transparent;
}

.atc-slide-image img {
    width: 100%;
    height: 100%;
    object-fit: var(--atc-image-fit, cover);
    display: block;
    transition: transform 0.4s ease;
}

.atc-slide-image-link {
    display: block;
    text-decoration: none;
}

/* ── Légende galerie ── */
.atc-gallery-caption {
    font-family: var(--atc-font-family);
    font-size: var(--atc-caption-font-size, 0.875rem);
    line-height: 1.5;
    color: var(--atc-caption-color, var(--atc-text-color, #475569));
    text-align: var(--atc-caption-align, center);
    padding: var(--atc-caption-padding, 10px 14px);
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.atc-caption-below .atc-gallery-caption {
    background: transparent;
}

.atc-caption-overlay .atc-gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3;
    color: var(--atc-caption-color, #ffffff);
    background: var(--atc-caption-bg, rgba(0, 0, 0, var(--atc-caption-bg-opacity, 0.7)));
    padding: var(--atc-caption-padding, 12px 16px);
    pointer-events: none;
}

.atc-caption-overlay-gradient .atc-gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3;
    color: var(--atc-caption-color, #ffffff);
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(0, 0, 0, calc(var(--atc-caption-bg-opacity, 0.7) * 0.3)) 30%,
        rgba(0, 0, 0, var(--atc-caption-bg-opacity, 0.7)) 100%
    );
    padding: var(--atc-caption-padding, 24px 16px 14px);
    pointer-events: none;
}

.atc-caption-overlay-hover .atc-gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3;
    color: var(--atc-caption-color, #ffffff);
    background: var(--atc-caption-bg, rgba(0, 0, 0, var(--atc-caption-bg-opacity, 0.7)));
    padding: var(--atc-caption-padding, 12px 16px);
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.atc-caption-overlay-hover .atc-slide:hover .atc-gallery-caption {
    opacity: 1;
    transform: translateY(0);
}

.atc-caption-overlay .atc-slide,
.atc-caption-overlay-gradient .atc-slide,
.atc-caption-overlay-hover .atc-slide {
    position: relative;
}

/* ── Lightbox trigger (galerie) ── */
.atc-lightbox-trigger {
    cursor: zoom-in;
    position: relative;
}

.atc-lightbox-trigger::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.2s ease;
    pointer-events: none;
    z-index: 1;
}

.atc-lightbox-trigger:hover::after {
    background: rgba(0, 0, 0, 0.04);
}

/* Icône zoom (visible au hover) */
.atc-lightbox-trigger::before {
    content: '';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: rgba(0,0,0,0.5) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cpolyline points='9 21 3 21 3 15'/%3E%3Cline x1='21' y1='3' x2='14' y2='10'/%3E%3Cline x1='3' y1='21' x2='10' y2='14'/%3E%3C/svg%3E") center/18px no-repeat;
    border-radius: 6px;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2;
    pointer-events: none;
}

.atc-lightbox-trigger:hover::before {
    opacity: 1;
    transform: scale(1);
}

/* ── Contenu ── */
.atc-slide-content {
    padding: 20px;
}

.atc-slide-category {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--atc-link-color);
    text-decoration: none;
    margin-bottom: 8px;
    transition: color 0.2s;
}

.atc-slide-category:hover {
    color: var(--atc-link-hover);
}

.atc-slide-title {
    font-family: var(--atc-heading-font);
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 8px;
    color: var(--atc-title-color);
}

.atc-slide-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.atc-slide-title a:hover {
    color: var(--atc-link-color);
}

.atc-slide-date {
    display: block;
    font-size: 0.8125rem;
    color: #94a3b8;
    margin-bottom: 8px;
}

.atc-slide-excerpt {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--atc-text-color);
    margin: 0 0 16px;
}

.atc-slide-readmore {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--atc-link-color);
    text-decoration: none;
    transition: gap 0.2s, color 0.2s;
}

.atc-slide-readmore:hover {
    gap: 10px;
    color: var(--atc-link-hover);
}

/* ── Flèches ── */
.atc-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    cursor: pointer;
    color: var(--atc-arrows-color);
    background: var(--atc-arrows-bg);
    backdrop-filter: blur(8px);
    transition: all 0.25s ease;
    outline: none;
}

.atc-arrow:hover {
    transform: translateY(-50%) scale(1.08);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.atc-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: translateY(-50%);
}

.atc-arrow-prev { left: 12px; }
.atc-arrow-next { right: 12px; }

/* ── SVG protection (carousel + lightbox) ── */
.atc-arrow svg,
.atc-lightbox-nav svg,
.atc-lightbox-close svg {
    display: block;
    fill: none !important;
    stroke: currentColor !important;
    pointer-events: none;
    flex-shrink: 0;
}

.atc-arrow svg polyline,
.atc-arrow svg path,
.atc-arrow svg line,
.atc-lightbox-nav svg polyline,
.atc-lightbox-nav svg path,
.atc-lightbox-nav svg line,
.atc-lightbox-close svg polyline,
.atc-lightbox-close svg path,
.atc-lightbox-close svg line {
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: inherit;
}

/* Sizes */
.atc-arrow svg {
    width: var(--atc-arrows-size, 20px);
    height: var(--atc-arrows-size, 20px);
    stroke-width: 2.5;
}

.atc-lightbox-nav svg {
    width: 28px;
    height: 28px;
    stroke-width: 2;
}

.atc-lightbox-close svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

/* Circle style */
.atc-arrows-circle .atc-arrow {
    border-radius: 50%;
}

/* Square style */
.atc-arrows-square .atc-arrow {
    border-radius: 8px;
}

/* Minimal style */
.atc-arrows-minimal .atc-arrow {
    background: transparent;
    backdrop-filter: none;
    width: 32px;
    height: 32px;
}

.atc-arrows-minimal .atc-arrow svg {
    width: var(--atc-arrows-size, 24px);
    height: var(--atc-arrows-size, 24px);
    stroke-width: 2.5;
}

/* Bottom position */
.atc-arrows-pos-bottom .atc-arrow {
    top: auto;
    bottom: -48px;
    transform: none;
}
.atc-arrows-pos-bottom .atc-arrow-prev { left: calc(50% - 52px); }
.atc-arrows-pos-bottom .atc-arrow-next { left: calc(50% + 8px); }
.atc-arrows-pos-bottom .atc-arrow:hover { transform: none; }

/* Top-right position */
.atc-arrows-pos-top-right .atc-arrow {
    top: -48px;
    transform: none;
}
.atc-arrows-pos-top-right .atc-arrow-prev { right: 52px; left: auto; }
.atc-arrows-pos-top-right .atc-arrow-next { right: 0; left: auto; }
.atc-arrows-pos-top-right .atc-arrow:hover { transform: none; }

/* ── Dots / Pagination ── */
.atc-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px 0 4px;
}

/* Default dots */
.atc-dots-default .atc-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: #cbd5e1;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
}

.atc-dots-default .atc-dot.is-active {
    background: var(--atc-dots-color);
    transform: scale(1.25);
}

/* Line dots */
.atc-dots-line .atc-dot {
    width: 24px;
    height: 3px;
    border-radius: 2px;
    border: none;
    background: #cbd5e1;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
}

.atc-dots-line .atc-dot.is-active {
    width: 40px;
    background: var(--atc-dots-color);
}

/* Dash dots */
.atc-dots-dash .atc-dot {
    width: 16px;
    height: 4px;
    border-radius: 2px;
    border: none;
    background: #cbd5e1;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
}

.atc-dots-dash .atc-dot.is-active {
    background: var(--atc-dots-color);
}

/* Fraction */
.atc-dots-fraction .atc-fraction {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--atc-text-color);
}

.atc-dots-fraction .atc-fraction-current {
    color: var(--atc-dots-color);
    font-size: 1.25rem;
}

/* ─────────────────────────────────────────────
   LIGHTBOX v3.0 — « one slide per image »
   Aucun swap de src, aucun flash.
   Hidden by default via opacity/visibility.
   ───────────────────────────────────────────── */

.atc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    touch-action: none;
    cursor: grab;
    pointer-events: none;
    transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                visibility 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.atc-lightbox.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Backdrop */
.atc-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 0;
}

/* Viewport — clips the full-width track */
.atc-lb-viewport {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    animation: atcLbZoomIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.atc-lightbox.is-closing .atc-lb-viewport {
    animation: atcLbZoomOut 0.25s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes atcLbZoomIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes atcLbZoomOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.92); }
}

/* Track — N slides side by side, GPU-accelerated
   v3.0: NO fixed width, NO default transform.
   Width and transform are set entirely by JS. */
.atc-lb-track {
    display: flex;
    height: 100%;
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.atc-lb-track.is-animating {
    transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Each slide — 100vw wide (full viewport width)
   v3.0: width is 100vw, not 33.3333%.
   Each slide occupies exactly the visible area. */
.atc-lb-slide {
    width: 100vw;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    box-sizing: border-box;
}

/* Image inside each slide */
.atc-lb-img {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
}

/* Hide images with no src (not yet lazy-loaded) */
.atc-lb-img:not([src]),
.atc-lb-img[src=""] {
    visibility: hidden;
}

/* Toolbar (counter + close) */
.atc-lightbox-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px;
}

/* Close button */
.atc-lightbox-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    outline: none;
}

.atc-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.atc-lightbox-close:focus-visible {
    outline: 2px solid rgba(255,255,255,0.6);
    outline-offset: 2px;
}

/* Counter */
.atc-lightbox-counter {
    font-family: var(--atc-font-family);
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    padding: 6px 14px;
    border-radius: 20px;
    letter-spacing: 0.025em;
}

/* Navigation arrows */
.atc-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    outline: none;
}

.atc-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.05);
}

.atc-lightbox-nav:focus-visible {
    outline: 2px solid rgba(255,255,255,0.6);
    outline-offset: 2px;
}

/* Disabled state (at boundaries) — hide gracefully */
.atc-lightbox-nav:disabled {
    opacity: 0;
    pointer-events: none;
    cursor: default;
}

.atc-lightbox-nav-prev { left: 16px; }
.atc-lightbox-nav-next { right: 16px; }

/* Caption */
.atc-lightbox-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3;
    text-align: center;
    padding: 16px 80px;
    font-family: var(--atc-font-family);
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.85);
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.4));
    pointer-events: none;
    min-height: 20px;
}

.atc-lightbox-caption:empty {
    display: none;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .atc-slide {
        width: calc(
            (100% - (var(--atc-columns-tablet, 2) - 1) * var(--atc-gap, 24px))
            / var(--atc-columns-tablet, 2)
        );
    }
    .atc-arrow { width: 38px; height: 38px; }
    .atc-slide-content { padding: 16px; }
    .atc-slide-title { font-size: 1rem; }
}

@media (max-width: 768px) {
    .atc-slide {
        width: calc(
            (100% - (var(--atc-columns-mobile, 1) - 1) * var(--atc-gap, 24px))
            / var(--atc-columns-mobile, 1)
        );
    }
    .atc-arrow {
        width: 36px;
        height: 36px;
        min-width: 44px;
        min-height: 44px;
        padding: 4px;
    }
    .atc-arrow-prev { left: 4px; }
    .atc-arrow-next { right: 4px; }
    .atc-arrows-minimal .atc-arrow {
        min-width: 40px;
        min-height: 40px;
    }
    .atc-slide-content { padding: 14px; }
    .atc-slide-title { font-size: 0.9375rem; }
    .atc-slide-excerpt { font-size: 0.875rem; }

    /* Lightbox responsive */
    .atc-lb-slide {
        padding: 12px;
    }
    .atc-lb-img {
        max-height: calc(100vh - 80px);
    }
    .atc-lightbox-nav {
        width: 40px;
        height: 40px;
    }
    .atc-lightbox-nav-prev { left: 8px; }
    .atc-lightbox-nav-next { right: 8px; }
    .atc-lightbox-caption {
        padding: 12px 24px;
        font-size: 0.8125rem;
    }
    .atc-lightbox-toolbar {
        padding: 10px 10px;
    }
    .atc-lightbox-close {
        width: 38px;
        height: 38px;
    }

    /* Icone zoom trigger sur petit ecran */
    .atc-lightbox-trigger::before {
        top: 8px;
        right: 8px;
        width: 28px;
        height: 28px;
        background-size: 14px;
    }
}

/* ── Accessibilité ── */
.atc-arrow:focus-visible,
.atc-dot:focus-visible {
    outline: 2px solid var(--atc-link-color);
    outline-offset: 2px;
}

.atc-lightbox-trigger:focus-visible {
    outline: 2px solid var(--atc-link-color);
    outline-offset: 2px;
}

/* ── Masquer navigation sur desktop uniquement ── */
@media (min-width: 769px) {
    .atc-hide-arrows-desktop .atc-arrow {
        display: none !important;
    }
    .atc-hide-dots-desktop .atc-dots {
        display: none !important;
    }
}

/* ── Réduction de mouvement ── */
@media (prefers-reduced-motion: reduce) {
    .atc-track.is-animating { transition: none; }
    .atc-hover-lift .atc-slide:hover { transform: none; }
    .atc-hover-zoom .atc-slide:hover .atc-slide-image img { transform: none; }
    .atc-lightbox { transition: none; }
    .atc-lb-viewport { animation: none; }
    .atc-lb-track { transition: none !important; }
}

/* ── No items message ── */
.atc-no-items {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-style: italic;
}

/* ── Body lock quand lightbox ouverte ── */
body.atc-lightbox-open {
    overflow: hidden;
}

body.atc-lightbox-dragging {
    user-select: none;
    -webkit-user-select: none;
}

body.atc-lightbox-dragging .atc-lightbox {
    cursor: grabbing;
}

body.atc-lightbox-dragging .atc-lb-img {
    pointer-events: none;
}