/* ============================================================
   Architravo Carousel Block
   Version: 2.2.0
   Objectif:
   - Carousel page swipe natif (scroll-snap)
   - Lightbox swipe natif (scroll-snap)
   - UI style iOS (chevrons + croix sans rond), hover zoom
   - Indication cliquable: zoom-in au hover sur l'image (desktop)
   - Fix iOS: suppression "cadre" (styles bouton + img height)
   ============================================================ */


/* ============================================================
   ROOT + VARIABLES
   ============================================================ */

.archi-carousel {
  position: relative;

  /* variables injectées par PHP (style=...) */
  --archi-carousel-h: 420px;
  --archi-carousel-r: 16px;

  /* variables pilotées par JS (config) */
  --archi-carousel-fit: cover;    /* cover | contain */
  --archi-carousel-zoom: 1;       /* zoom base carousel (réglage) */

  /* variable hover pour animer (desktop) */
  --archi-carousel-hover-zoom: 1; /* par défaut pas de zoom */
}


/* ============================================================
   CAROUSEL PAGE: VIEWPORT SWIPE NATIF
   ============================================================ */

.archi-carousel__viewport {
  position: relative; /* IMPORTANT: référentiel des flèches page */

  height: var(--archi-carousel-h);
  border-radius: var(--archi-carousel-r);
  overflow: hidden;

  display: flex;
  overflow-x: auto;
  overflow-y: hidden;

  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;

  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;

  scrollbar-width: none;

  padding: 0;
  background: transparent;
}

.archi-carousel__viewport::-webkit-scrollbar {
  display: none;
}

.archi-carousel__slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: center;
  position: relative;
}

/* ============================================================
   iOS FIX: bouton neutre, pas de tap highlight, pas d'outline
   + unifie le cadre (border-radius + overflow hidden)
   ============================================================ */

.archi-carousel__slideBtn {
  display: block;
  width: 100%;
  height: 100%;

  margin: 0;
  padding: 0;

  border: 0;
  background: transparent;
  cursor: pointer;

  border-radius: inherit;
  overflow: hidden;

  outline: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.archi-carousel__slideBtn:focus,
.archi-carousel__slideBtn:active {
  outline: none;
}

/* ============================================================
   IMAGE CAROUSEL
   - Object-fit + focus point (object-position via JS)
   - Zoom base + zoom hover combinés de manière robuste
   ============================================================ */

.archi-carousel__slideBtn img {
  display: block;

  width: 100% !important;
  height: 100% !important;

  max-width: none !important;
  max-height: none !important;

  object-fit: var(--archi-carousel-fit, cover);
  object-position: center;

  border-radius: inherit;

  transition: transform 220ms ease, filter 220ms ease;
  will-change: transform;

  transform: scale(var(--archi-carousel-zoom)) scale(var(--archi-carousel-hover-zoom));
}

/* Indication "cliquable" au hover (desktop seulement) */
@media (hover: hover) and (pointer: fine) {
  .archi-carousel__slideBtn:hover img {
    --archi-carousel-hover-zoom: 1.06;
  }
}


/* ============================================================
   FLECHES PAGE: STYLE iOS (sans rond) + hover zoom
   Positionnées au bord du viewport (donc au bord du cadre image)
   ============================================================ */

.archi-carousel__arrow {
  appearance: none;
  -webkit-appearance: none;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;

  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;

  width: 48px;
  height: 48px;
  cursor: pointer;

  transition: transform 160ms ease, opacity 160ms ease;
}

.archi-carousel__arrow--prev { left: 6px; }
.archi-carousel__arrow--next { right: 6px; }

.archi-carousel__arrow::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;

  width: 18px;
  height: 18px;

  border-right: 2.5px solid rgba(255,255,255,0.95);
  border-bottom: 2.5px solid rgba(255,255,255,0.95);

  transform-origin: center;
}

.archi-carousel__arrow--prev::before { transform: translate(-50%, -50%) rotate(135deg); }
.archi-carousel__arrow--next::before { transform: translate(-50%, -50%) rotate(-45deg); }

@media (hover: hover) and (pointer: fine) {
  .archi-carousel__arrow:hover,
  .archi-carousel__arrow:focus-visible {
    transform: translateY(-50%) scale(1.18);
  }
}


/* ============================================================
   DOTS (optionnels)
   ============================================================ */

.archi-carousel__dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: none;
  justify-content: center;
  gap: 8px;
  z-index: 6;
}

.archi-carousel__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 0;
  background: rgba(255,255,255,0.45);
  cursor: pointer;
}

.archi-carousel__dot[aria-current="true"] {
  background: rgba(255,255,255,0.95);
}


/* ============================================================
   LIGHTBOX: OVERLAY PLEIN ECRAN
   - On force fixed/inset + z-index très haut
   - Le backdrop capte les clics "hors image"
   ============================================================ */

.archi-lightbox[hidden] {
  display: none !important;
}

.archi-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
}

/* Backdrop plein écran, cliquable */
.archi-lightbox__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
}

/*
  Important pour la fermeture "clic hors image":
  - Le dialog ne capte rien par défaut, donc le clic traverse vers le backdrop
  - Seules les zones interactives (viewport, UI, thumbs) reprennent les events
*/
.archi-lightbox__dialog {
  position: absolute;
  inset: 0;

  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 10px;

  padding: 14px;
  box-sizing: border-box;

  pointer-events: none;
}

.archi-lightbox__viewport,
.archi-lightbox__thumbs,
.archi-lightbox__close,
.archi-lightbox__nav {
  pointer-events: auto;
}


/* ============================================================
   LIGHTBOX: VIEWPORT SWIPE NATIF
   ============================================================ */

.archi-lightbox__viewport {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;

  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;

  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;

  scrollbar-width: none;
}

.archi-lightbox__viewport::-webkit-scrollbar {
  display: none;
}

.archi-lightbox__slide {
  flex: 0 0 100%;
  scroll-snap-align: center;

  display: grid;
  place-items: center;
}

/* Image full screen: toujours contain, jamais crop, pas de radius */
.archi-lightbox__slide img {
  width: auto !important;
  height: auto !important;

  max-width: calc(100vw - 28px) !important;
  max-height: calc(100vh - 28px - 74px) !important;

  object-fit: contain !important;
  border-radius: 0 !important;

  display: block !important;
}


/* ============================================================
   LIGHTBOX: META (caption/desc)
   ============================================================ */

.archi-lightbox__meta {
  color: #fff;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
}

.archi-lightbox__cap {
  font-weight: 600;
  margin-bottom: 4px;
}

.archi-lightbox__desc {
  opacity: 0.9;
}


/* ============================================================
   LIGHTBOX: MINIATURES (taille fixe, anti styles thème)
   ============================================================ */

.archi-lightbox__thumbs {
  height: 64px;
  max-height: 64px;

  display: flex;
  flex-wrap: nowrap;
  gap: 8px;

  overflow-x: auto;
  overflow-y: hidden;

  align-items: center;
  justify-content: flex-start;

  padding: 6px 6px 4px 6px;
  box-sizing: border-box;

  -webkit-overflow-scrolling: touch;

  background: rgba(0,0,0,0.28);
  border-radius: 12px;
}

.archi-lightbox__thumb {
  flex: 0 0 auto;

  width: 56px;
  height: 40px;

  padding: 0;
  margin: 0;

  border: 1px solid rgba(255,255,255,0.20);
  background: rgba(0,0,0,0.20);

  border-radius: 8px;
  overflow: hidden;

  cursor: pointer;
  box-sizing: border-box;
}

.archi-lightbox__thumb img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center !important;
  display: block !important;
  border-radius: 0 !important;
}

.archi-lightbox__thumb[aria-current="true"] {
  border-color: rgba(255,255,255,0.95);
}


/* ============================================================
   LIGHTBOX: CONTROLES STYLE iOS (sans rond) + hover zoom
   ============================================================ */

.archi-lightbox__close,
.archi-lightbox__nav {
  appearance: none;
  -webkit-appearance: none;

  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;

  position: absolute;
  z-index: 3;

  width: 48px;
  height: 48px;

  cursor: pointer;

  transition: transform 160ms ease, opacity 160ms ease;
  transform-origin: center;
}

/* Croix top right */
.archi-lightbox__close {
  top: 14px;
  right: 14px;
}

.archi-lightbox__close::before,
.archi-lightbox__close::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;

  width: 22px;
  height: 2px;

  background: rgba(255,255,255,0.95);
  transform-origin: center;
  border-radius: 2px;
}

.archi-lightbox__close::before { transform: translate(-50%, -50%) rotate(45deg); }
.archi-lightbox__close::after  { transform: translate(-50%, -50%) rotate(-45deg); }

/* Flèches centrées verticalement */
.archi-lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
}

.archi-lightbox__nav--prev { left: 10px; }
.archi-lightbox__nav--next { right: 10px; }

.archi-lightbox__nav::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;

  width: 18px;
  height: 18px;

  border-right: 2.5px solid rgba(255,255,255,0.95);
  border-bottom: 2.5px solid rgba(255,255,255,0.95);

  transform-origin: center;
}

.archi-lightbox__nav--prev::before { transform: translate(-50%, -50%) rotate(135deg); }
.archi-lightbox__nav--next::before { transform: translate(-50%, -50%) rotate(-45deg); }

/* Hover zoom desktop */
@media (hover: hover) and (pointer: fine) {
  .archi-lightbox__nav:hover,
  .archi-lightbox__nav:focus-visible {
    transform: translateY(-50%) scale(1.18);
  }

  .archi-lightbox__close:hover,
  .archi-lightbox__close:focus-visible {
    transform: scale(1.18);
  }
}
