/**
 * Composant partagé : carrousel de galerie + lightbox « Vie de l'établissement ».
 *
 * Extrait de school-page.css pour être réutilisable hors des pages école
 * (ex. page « Éducation à la paix »). Le markup vit dans
 * template-parts/school/gallery.php et le comportement dans
 * assets/js/school-gallery-carousel.js.
 *
 * Toutes les classes sont préfixées .school-gallery* / .school-lightbox* :
 * aucun risque de collision avec les styles d'une autre page.
 */

/* Conteneur du composant (repris de school-page.css pour rester autonome) */
.school-page__container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

/* Gallery Section */
.school-gallery {
  padding: 80px 0;
}

/* School Gallery Carousel */
.school-gallery--carousel {
  position: relative;
  overflow: hidden;
}

.school-gallery__carousel-wrapper {
  position: relative;
  max-width: 100%;
  margin: 0 auto;
}

.school-gallery__carousel {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  aspect-ratio: 16 / 9;
}

.school-gallery__track {
  display: flex;
  height: 100%;
  transition: transform 0.5s ease;
  will-change: transform;
}

.school-gallery__slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: #000;
}

.school-gallery__media {
  position: relative;
  width: 100%;
  height: 100%;
}

.school-gallery__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.4s ease;
}

/* Portrait photos in a 16:9 frame: fill the sides with a blurred copy
   of the photo instead of hard black bars. */
.school-gallery__backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  object-fit: cover !important;
  filter: blur(26px) brightness(0.62) saturate(1.1);
  transform: scale(1.2);
  transition: none !important;
  pointer-events: none;
}

.school-gallery__image {
  position: relative;
  z-index: 1;
}

.school-gallery__slide:hover .school-gallery__image {
  transform: scale(1.05);
}

.school-gallery__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.1),
    rgba(0, 0, 0, 0.6)
  );
  z-index: 1;
}

.school-gallery__content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2rem;
  z-index: 2;
  color: #ffffff;
  text-align: left;
}

.school-gallery__title {
  font-size: 1.4rem;
  line-height: 1.2;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: #ffffff;
}

.school-gallery__text {
  font-size: 1rem;
  line-height: 1.5;
  margin: 0 0 0.5rem;
  font-weight: 400;
}

.school-gallery__author {
  font-size: 0.85rem;
  opacity: 0.8;
  font-style: italic;
}

/* Navigation controls */
.school-gallery__nav {
  position: absolute;
  top: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  min-width: 46px;
  min-height: 46px;
  padding: 0;
  aspect-ratio: 1 / 1;            /* garantit un cercle, jamais écrasé */
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(31, 42, 68, 0.14);
  border-radius: 50%;
  color: #1f2a44;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transform: translateY(-50%);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.school-gallery__nav:hover {
  background: #ffffff;
  border-color: #009c8e;
  color: #009c8e;
  box-shadow: 0 6px 22px rgba(0, 156, 142, 0.20);
}

.school-gallery__nav:active {
  transform: translateY(-50%) scale(0.96);
}

.school-gallery__nav:focus-visible {
  outline: 2px solid #009c8e;
  outline-offset: 3px;
}

.school-gallery__nav--prev {
  left: -18px;
}

.school-gallery__nav--next {
  right: -18px;
}

@media (max-width: 600px) {
  .school-gallery__nav {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }
  .school-gallery__nav--prev {
    left: 6px;
  }
  .school-gallery__nav--next {
    right: 6px;
  }
}

.school-gallery__nav svg {
  width: 20px;
  height: 20px;
  display: block;
  color: inherit;
}

.school-gallery__nav-icon {
  font-size: 22px;
  font-weight: 600;
  color: inherit;
  display: block;
  line-height: 1;
}

/* Zoom trigger on each slide */
.school-gallery__zoom {
  display: block;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  -webkit-appearance: none;
  appearance: none;
}

.school-gallery__zoom-icon {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  box-sizing: border-box;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #1f2a44;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease, color 0.2s ease;
  pointer-events: none;
}

.school-gallery__zoom-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.school-gallery__slide:hover .school-gallery__zoom-icon,
.school-gallery__zoom:focus-visible .school-gallery__zoom-icon {
  opacity: 1;
  transform: translateY(0);
}

.school-gallery__zoom:focus-visible {
  outline: 2px solid #009c8e;
  outline-offset: -4px;
  border-radius: 16px;
}

/* Touch devices: no hover, keep the affordance visible */
@media (hover: none) {
  .school-gallery__zoom-icon {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Progress bar + counter (replaces the dots when there are many photos) */
.school-gallery__progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.school-gallery__progress-track {
  position: relative;
  width: min(260px, 45vw);
  height: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.school-gallery__progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #009c8e;
  transition: width 0.4s ease;
}

.school-gallery__counter {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #1f2a44;
  white-space: nowrap;
}

.school-gallery__counter-sep,
.school-gallery__counter-total {
  color: rgba(31, 42, 68, 0.5);
  font-weight: 500;
}

/* Lightbox */
.school-lightbox {
  position: fixed;
  inset: 0;
  /* above #sr-launcher-btn (999998) so no floating button sits on the photo */
  z-index: 1000000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.school-lightbox[hidden] {
  display: none;
}

.school-lightbox.is-open {
  opacity: 1;
}

.school-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 25, 0.92);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  cursor: zoom-out;
}

.school-lightbox__figure {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 0;
  max-width: 100%;
  max-height: 100%;
}

.school-lightbox__image {
  display: block;
  max-width: min(1100px, 100%);
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  background: #0a0f19;
  transition: opacity 0.2s ease;
}

.school-lightbox__image.is-loading {
  opacity: 0.35;
}

.school-lightbox__caption {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.92rem;
  line-height: 1.4;
  max-width: 720px;
}

.school-lightbox__counter {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}

.school-lightbox__close,
.school-lightbox__nav {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  padding: 0;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #ffffff;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.school-lightbox__close svg,
.school-lightbox__nav svg {
  display: block;
}

.school-lightbox__close:hover,
.school-lightbox__nav:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.6);
}

.school-lightbox__close:active,
.school-lightbox__nav:active {
  transform: scale(0.94);
}

.school-lightbox__close:focus-visible,
.school-lightbox__nav:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.school-lightbox__close {
  top: clamp(12px, 3vw, 28px);
  right: clamp(12px, 3vw, 28px);
}

.school-lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
}

.school-lightbox__nav:active {
  transform: translateY(-50%) scale(0.94);
}

.school-lightbox__nav--prev {
  left: clamp(8px, 3vw, 32px);
}

.school-lightbox__nav--next {
  right: clamp(8px, 3vw, 32px);
}

@media (max-width: 600px) {
  .school-lightbox__nav {
    width: 40px;
    height: 40px;
    top: auto;
    bottom: clamp(12px, 4vw, 24px);
    transform: none;
  }
  .school-lightbox__nav:active {
    transform: scale(0.94);
  }
  .school-lightbox__image {
    max-height: calc(100vh - 200px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .school-lightbox,
  .school-lightbox__image,
  .school-gallery__progress-fill,
  .school-gallery__zoom-icon {
    transition: none;
  }
}

/* Indicators (legacy dots, kept for galleries that still render them) */
.school-gallery__indicators {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  padding: 0;
  background: none;
}

.school-gallery__indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.school-gallery__indicator:focus-visible {
  outline: 2px solid #009c8e;
  outline-offset: 2px;
  border-radius: 50%;
}

.school-gallery__indicator-dot {
  display: block;
  width: 8px;
  height: 8px;
  background: rgba(15, 23, 42, 0.3);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.school-gallery__indicator.active .school-gallery__indicator-dot,
.school-gallery__indicator:hover .school-gallery__indicator-dot {
  background: #009c8e;
  transform: scale(1.2);
}

/* Fallback for static grid */
.school-gallery:not(.school-gallery--carousel) .school-gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.school-gallery:not(.school-gallery--carousel) .school-gallery__item {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 16px;
  background: #e5e7eb;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.school-gallery:not(.school-gallery--carousel) .school-gallery__item:hover {
  transform: scale(1.02);
}

.school-gallery:not(.school-gallery--carousel) .school-gallery__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.school-gallery:not(.school-gallery--carousel) .school-gallery__item:hover img {
  transform: scale(1.05);
}

.school-gallery__title {
  margin: 0 0 48px;
  font-size: clamp(2rem, 3vw, 2.5rem);
  line-height: 1.2;
  color: #111827;
  text-align: center;
}

/* Ajustements mobile de la galerie (repris du bloc @media de school-page.css
   pour que le composant reste cohérent hors des pages école). */
@media (max-width: 767px) {
  .school-gallery {
    padding: 56px 0;
  }
  .school-gallery__title {
    margin-bottom: 32px;
  }
  .school-gallery__grid {
    grid-template-columns: 1fr;
  }
}
