/* === RESET === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
  color: #444; line-height: 1.7;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
  background-color: #2a3a2c;   /* filet de sécurité, le dégradé est sur .sparkles */
}
img { max-width: 100%; height: auto; }

/* === HERO === */
.hero {
  min-height: 100vh;
  background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative;
  padding: 32px 48px 60px;
  margin-bottom: -140px;
  padding-bottom: 360px;   /* laisse la place à la flèche puis au switch */
  z-index: 1;
}

/* === FOND FIXE — dégradé + mêmes ronds scintillants ===
   Calque collé à la fenêtre : il ne défile jamais, tout le site glisse
   par-dessus. Le dégradé est porté par ce calque plutôt que par
   background-attachment: fixed, mal supporté par Safari iOS. */
.sparkles {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
  background: linear-gradient(160deg, #5a7a5e 0%, #445747 35%, #374938 75%, #2a3a2c 100%);
}
.sparkle {
  position: absolute; background: rgba(255,255,255,0.65); border-radius: 50%;
  opacity: 0;
  animation: sparkle-twinkle var(--dur) ease-in-out infinite both;
}
@keyframes sparkle-twinkle {
  0%, 100% { opacity: 0.08; transform: scale(0.6); }
  50% { opacity: var(--max-o, 0.8); transform: scale(1.2); }
}

/* === HERO CONTENU === */
.hero-content {
  position: relative; z-index: 5;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  max-width: 900px;
}
.hero-logo { width: 150px; height: 150px; object-fit: contain; margin-bottom: 28px; }
.hero-merci {
  font-family: 'Carattere', cursive; font-weight: 400;
  font-size: clamp(84px, 17vw, 210px);
  line-height: 0.95; color: #fff; letter-spacing: 1px;
  text-shadow: 0 6px 40px rgba(0,0,0,0.25);
}
.hero-heart {
  color: rgba(255,255,255,0.9); width: 55px; height: 50px;
  margin: 18px 0 26px;
  animation: heart-beat 2.6s ease-in-out infinite;
}
.hero-heart svg { display: block; width: 100%; height: 100%; }
@keyframes heart-beat {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.14); }
  24% { transform: scale(1); }
  36% { transform: scale(1.09); }
  48% { transform: scale(1); }
}
.hero-sub {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic; font-weight: 300; font-size: 28px;
  color: rgba(255,255,255,0.9); line-height: 1.7; max-width: 620px;
}
.hero-sign {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic; font-weight: 300; font-size: 25px;
  color: rgba(255,255,255,0.6); margin-top: 10px;
}

/* === SCROLL DOWN === */
.scroll-down {
  position: absolute; bottom: 215px; left: 50%;
  transform: translateX(-50%);
  width: 112px; height: 112px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.6); text-decoration: none;
  background: rgba(255,255,255,0.05);
  transition: background 0.3s, border-color 0.3s;
  animation: bounce-gentle 2s ease-in-out infinite; z-index: 10;
}
.scroll-down svg { width: 48px; height: 48px; }
.scroll-down:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.45); }
@keyframes bounce-gentle {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(10px); }
}

/* === GALERIE EN VRAC === */
.gallery {
  position: relative; z-index: 2;
  padding: 0 26px 60px;
  background: transparent;   /* laisse voir le fond fixe et son scintillement */
  --row-h: 235px;            /* hauteur de rangée visée — voir media queries */
}
/* === SWITCH Photographe / Photobooth === */
.gallery-head {
  display: flex; justify-content: center;
  margin: 0 0 42px; position: relative; z-index: 3;
}
.gallery-tabs {
  position: relative; display: inline-flex; padding: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  border: 1.5px solid rgba(255,255,255,0.25);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.22);
}
.tab {
  position: relative; z-index: 2;
  flex: 1 1 0; min-width: 162px;
  padding: 13px 26px; border: 0; background: none; cursor: pointer;
  font-family: 'Open Sans', sans-serif; font-size: 15px; letter-spacing: 0.6px;
  color: rgba(255,255,255,0.72); border-radius: 999px;
  transition: color 0.3s ease;
}
.tab:hover { color: rgba(255,255,255,0.95); }
.tab.is-active { color: #3c5040; font-weight: 600; }
.tab:focus-visible { outline: 2px solid rgba(255,255,255,0.7); outline-offset: 3px; }
/* Le curseur blanc glisse d'un onglet à l'autre. Sa largeur vaut exactement
   celle d'un onglet, d'où le calc() qui retire le padding du conteneur. */
.tab-slider {
  position: absolute; z-index: 1;
  top: 5px; bottom: 5px; left: 5px; width: calc(50% - 5px);
  background: #fff; border-radius: 999px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.25);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.gallery-tabs[data-active="photobooth"] .tab-slider { transform: translateX(100%); }

/* === BOUTON RETOUR EN HAUT (dernière photo atteinte) === */
.back-top {
  display: flex; align-items: center; gap: 11px;
  margin: 26px auto 0; padding: 14px 28px;
  border-radius: 999px; cursor: pointer;
  background: rgba(255,255,255,0.10);
  border: 1.5px solid rgba(255,255,255,0.28);
  color: rgba(255,255,255,0.85);
  font-family: 'Open Sans', sans-serif; font-size: 15px; letter-spacing: 0.4px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  animation: bounce-up 2s ease-in-out infinite;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}
.back-top[hidden] { display: none; }
.back-top svg { width: 20px; height: 20px; }
.back-top:hover {
  background: rgba(255,255,255,0.2); color: #fff; border-color: rgba(255,255,255,0.5);
}
@keyframes bounce-up {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

/* Rangées justifiées : les photos se suivent de gauche à droite, puis passent
   à la ligne. Chaque rangée est étirée pour tomber pile sur la largeur.
   Comme flex-basis ET flex-grow sont proportionnels au ratio de l'image,
   toutes les photos d'une rangée grandissent du même facteur et finissent
   donc à la même hauteur, sans qu'aucun ratio ne soit déformé. */
.gallery-grid {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  max-width: 1900px; margin: 0 auto;
}
/* Absorbe l'espace restant de la dernière rangée, sinon 2 photos esseulées
   s'étireraient sur toute la largeur de l'écran. */
.g-filler { flex: 999 999 0px; height: 0; margin: 0; }

/* --- Les 4 inclinaisons du « vrac ». -------------------------------------
   Tout se règle ici : --tilt = angle, --shift = décalage horizontal,
   --lift = décalage vertical. Monte les angles (ex. 15deg / 35deg) pour
   un vrac plus violent, mais il faudra alors augmenter .g-item{margin}
   sous peine de photos qui se mangent entre elles.                        */
.g-item--a { --tilt: -6.5deg; --shift: -11px; --lift:  6px; }
.g-item--b { --tilt:  2.4deg; --shift:   9px; --lift: -8px; }
.g-item--c { --tilt: -2.2deg; --shift:  10px; --lift:  9px; }
.g-item--d { --tilt:  6.8deg; --shift: -10px; --lift: -6px; }

.g-item {
  display: block; position: relative;
  /* --r = largeur/hauteur de la photo, posé en ligne par le JS */
  flex-grow: var(--r, 1.5);
  flex-shrink: 1;    /* permet à un panoramique isolé de rentrer sur mobile */
  flex-basis: calc(var(--r, 1.5) * var(--row-h));
  margin: 0 -7px -16px;     /* négatif = chevauchement horizontal et vertical */
  transform: rotate(var(--tilt)) translate(var(--shift), var(--lift));
  cursor: pointer;
}
.g-item:hover, .g-item:focus-visible { z-index: 60; outline: none; }

.g-frame {
  position: relative; display: block; overflow: hidden;
  background: #dfd9cf;                 /* fond pendant le chargement */
  border: 5px solid #fff;              /* bords blancs, comme la frise */
  border-radius: 5px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.28), 0 1px 4px rgba(0,0,0,0.18);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.g-item:hover .g-frame,
.g-item:focus-visible .g-frame {
  transform: scale(1.12) rotate(calc(var(--tilt) * -1));  /* grossit et se redresse */
  box-shadow: 0 14px 44px rgba(0,0,0,0.42);
}
.g-frame img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.45s ease;
}
.g-frame img.is-loaded { opacity: 1; }
.g-item--error { display: none; }

.gallery-sentinel { height: 1px; }
.gallery-status {
  text-align: center; margin-top: 34px;
  font-family: 'Cormorant Garamond', Georgia, serif; font-style: italic;
  font-size: 20px; color: rgba(255,255,255,0.45);
}

/* === LISEUSE === */
.viewer { position: fixed; inset: 0; z-index: 1000; display: flex; }
.viewer[hidden] { display: none; }
.viewer-backdrop {
  position: absolute; inset: 0;
  background: rgba(20,29,21,0.93);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  animation: viewer-fade 0.25s ease-out;
}
@keyframes viewer-fade { from { opacity: 0; } to { opacity: 1; } }

.viewer-stage {
  position: relative; z-index: 2;
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 76px 72px 118px;
  pointer-events: none;
}
.viewer-img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto; object-fit: contain;
  border-radius: 3px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  opacity: 0; transition: opacity 0.3s ease;
  pointer-events: auto;
}
.viewer-img.is-ready { opacity: 1; }
.viewer-spinner {
  position: absolute; width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18); border-top-color: rgba(255,255,255,0.75);
  animation: viewer-spin 0.8s linear infinite; opacity: 0; transition: opacity 0.2s;
}
.viewer-spinner.is-on { opacity: 1; }
@keyframes viewer-spin { to { transform: rotate(360deg); } }

.viewer-close, .viewer-btn {
  position: absolute; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.85);
  border-radius: 50%; cursor: pointer; text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, color 0.2s;
}
.viewer-close:hover, .viewer-btn:hover {
  background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.45);
  color: #fff; transform: scale(1.07);
}
.viewer-close { top: 24px; right: 28px; width: 52px; height: 52px; }
.viewer-close svg { width: 24px; height: 24px; }

.viewer-bar {
  position: absolute; z-index: 5; bottom: 32px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 20px;
}
.viewer-bar .viewer-btn { position: static; width: 56px; height: 56px; }
.viewer-bar .viewer-btn svg { width: 24px; height: 24px; }
.viewer-btn--download {
  width: 66px !important; height: 66px !important;
  background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.4);
}
.viewer-btn--download svg { width: 27px !important; height: 27px !important; }
.viewer-btn--download:hover { background: #fff; color: #445747; border-color: #fff; }
.viewer-btn[aria-disabled="true"] { opacity: 0.25; pointer-events: none; }

.viewer-counter {
  position: absolute; z-index: 5; bottom: 12px; left: 50%; transform: translateX(-50%);
  font-family: 'Open Sans', sans-serif; font-size: 12px; letter-spacing: 1.5px;
  color: rgba(255,255,255,0.35);
}
body.viewer-open { overflow: hidden; }

/* === FOOTER === */
.footer { background: rgba(30,43,30,0.82); padding: 44px 56px; text-align: center; position: relative; z-index: 2; }
.footer-logo { width: 150px; height: 150px; object-fit: contain; margin-bottom: 14px; }
.footer-contact { margin-bottom: 8px; }
.footer-contact a {
  color: rgba(255,255,255,0.7); font-family: 'Open Sans', sans-serif;
  font-size: 18px; text-decoration: none; transition: color 0.2s;
}
.footer-contact a:hover { color: rgba(255,255,255,0.95); }
.footer-address { font-family: 'Open Sans', sans-serif; font-size: 14px; color: rgba(255,255,255,0.35); }

/* === RESPONSIVE === */
@media (max-width: 1500px) { .gallery { --row-h: 205px; } }

@media (max-width: 1100px) {
  .hero { padding: 32px 36px 290px; margin-bottom: -110px; }
  .hero-logo { width: 120px; height: 120px; }
  .hero-sub { font-size: 22px; } .hero-sign { font-size: 20px; }
  .scroll-down { width: 80px; height: 80px; bottom: 165px; }
  .scroll-down svg { width: 36px; height: 36px; }
  .gallery { padding: 0 18px 48px; --row-h: 180px; }
  .g-frame { border-width: 4px; }
}

@media (max-width: 700px) {
  .hero { padding: 60px 24px 210px; min-height: 100svh; margin-bottom: -80px; }
  .hero-logo { width: 96px; height: 96px; margin-bottom: 18px; }
  .hero-heart { width: 41px; height: 38px; margin: 12px 0 18px; }
  .hero-sub { font-size: 18px; max-width: 340px; } .hero-sign { font-size: 17px; }
  .scroll-down { bottom: 118px; width: 64px; height: 64px; }
  .scroll-down svg { width: 28px; height: 28px; }
  .gallery { padding: 0 10px 40px; --row-h: 125px; }
  .g-item { margin: 0 -4px -10px; }
  .g-frame { border-width: 3px; }
  /* vrac plus doux sur petit écran, sinon ça déborde */
  .g-item--a { --tilt: -4deg; --shift: -5px; --lift: 4px; }
  .g-item--b { --tilt: 1.8deg; --shift: 4px; --lift: -5px; }
  .g-item--c { --tilt: -1.6deg; --shift: 5px; --lift: 5px; }
  .g-item--d { --tilt: 4.2deg; --shift: -4px; --lift: -4px; }
  .viewer-stage { padding: 66px 14px 108px; }
  .viewer-close { top: 16px; right: 16px; width: 44px; height: 44px; }
  .viewer-bar { gap: 14px; bottom: 26px; }
  .viewer-bar .viewer-btn { width: 48px; height: 48px; }
  .viewer-btn--download { width: 58px !important; height: 58px !important; }
  .footer-logo { width: 120px; height: 120px; }
}

/* === ACCESSIBILITÉ === */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sparkle, .hero-heart, .scroll-down, .back-top { animation: none; }
  .tab-slider { transition: none; }
  .g-frame, .viewer-img, .g-frame img { transition: none; }
}
