/* =========================================================
   Page "Commandes personnalisées" — galerie à défilement infini
   (s'appuie sur les variables de oiseau_front.css)
   ========================================================= */

:root {
  --gallery-gap: 12vh; /* espace vertical entre les vignettes */
  --thumb-ratio: 4 / 5; /* format des vignettes et de l'aperçu */
}

/* ---------- Mise en page : header fixe, galerie sur le reste de l'écran ---------- */
.page-commande .site-header {
  background-color: var(--color-bg);
}

.gallery-page {
  position: relative;
}

/* Mode boucle (JS actif, animations autorisées) : la page ne défile plus,
   c'est la galerie qui tourne */
.gallery-loop .page-commande {
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}
.gallery-loop .gallery-page {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Masque la galerie le temps du chargement des images */
.js .page-commande.loading .gallery {
  opacity: 0;
}

/* ---------- Galerie ---------- */
.gallery {
  position: relative; /* référence des offsetTop pour la boucle */
  display: grid;
  justify-items: center;
  row-gap: var(--gallery-gap);
  padding: 8vh 0 0;
  transition: opacity 0.4s;
}

.gallery__slide {
  width: var(--img-w);
  margin: 0;
  transform: translateX(var(--stagger));
  cursor: pointer;
  &:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 6px;
  }
}

.gallery__img-wrapper {
  aspect-ratio: var(--thumb-ratio);
  overflow: hidden;
}

.gallery__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s;
}

.gallery__slide:hover .gallery__img {
  transform: scale(1.04);
}

.gallery__slide figcaption {
  margin-top: 0.7em;
  font-size: clamp(0.6rem, 0.8vw, 0.8rem);
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Aucune commande en base */
.gallery-empty {
  margin: 0;
  padding: 20vh 1.5rem;
  text-align: center;
  font-style: italic;
  text-transform: uppercase;
}

/* ---------- Vue détaillée ---------- */
.content {
  display: none; /* affichée par Transition.js */
  position: absolute;
  inset: 0;
  z-index: 3;
}

/* Sans boucle, la page défile : la vue détaillée couvre l'écran */
html:not(.gallery-loop) .content {
  position: fixed;
  z-index: 20;
  background-color: var(--color-bg);
}

.content-wrapper {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 5vw;
  padding: 5vh 7vw;
}

.content__preview-img {
  justify-self: end;
  height: min(75vh, 100%);
  aspect-ratio: var(--thumb-ratio);
  margin: 0;
  overflow: hidden;
  & img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.2);
  }
}

.content__group-list {
  max-width: 42ch;
}

.content__back {
  margin-bottom: 2.5rem;
  padding: 0.25em 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.75rem;
  font-style: italic;
  text-transform: uppercase;
  cursor: pointer;
  &:hover,
  &:focus-visible {
    text-decoration: underline;
    text-underline-offset: 0.25em;
  }
  &:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 4px;
  }
}

.content__group {
  display: none;
  &.active {
    display: block;
  }
}

.content__title {
  margin: 0 0 1.2rem;
  font-size: clamp(1.2rem, 2.4vw, 2.2rem);
  font-style: italic;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1.15;
}

.content__description {
  margin: 0;
  font-size: clamp(0.8rem, 1vw, 0.95rem);
  line-height: 1.7;
}

/* Lien vers la page détail (portfolio) */
.content__link {
  display: inline-block;
  margin-top: 1.8rem;
  padding: 0.5em 1.1em;
  border: 1px solid currentColor;
  border-radius: 2em;
  color: inherit;
  font-size: 0.8rem;
  font-style: italic;
  text-transform: uppercase;
  text-decoration: none;
  transition:
    background-color 0.2s,
    color 0.2s;
  &:hover,
  &:focus-visible {
    background-color: var(--color-text);
    color: var(--color-bg);
  }
  &:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 3px;
  }
}

/* ---------- Portrait / écrans étroits ---------- */
@media (orientation: portrait), (max-width: 900px) {
  :root {
    --gallery-gap: 14vh;
  }

  .gallery__slide {
    width: max(var(--img-w), 42vw);
    transform: translateX(calc(var(--stagger) * 0.5));
  }

  .gallery__slide figcaption {
    font-size: 0.7rem;
  }

  .content-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    align-items: start;
    gap: 1.5rem;
    padding: 1.5rem;
    overflow-y: auto;
  }

  .content__preview-img {
    justify-self: center;
    height: 45vh;
  }

  .content__group-list {
    max-width: none;
  }

  .content__back {
    margin-bottom: 1.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery,
  .gallery__img,
  .content__link {
    transition: none;
  }
  .gallery__slide:hover .gallery__img {
    transform: none;
  }
}
