/* =========================================================================
   Save the Date — 12 juin 2027
   1. Fondations      2. Mise en page      3. Typographie
   4. Photomaton      5. Bande photo       6. CTA
   7. Animations      8. Grands écrans     9. Préférences & repli
   ========================================================================= */

/* 1. Fondations ---------------------------------------------------------- */

:root {
  --ivory: #f4f1ec;
  --ivory-deep: #ebe6de;
  --ink: #1b1a18;
  --ink-soft: #6a655e;

  --serif: 'Cormorant Garamond', 'Iowan Old Style', Garamond, Georgia, 'Times New Roman', serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
    sans-serif;

  /* Hauteur de référence du photomaton : toute la scène en découle. */
  --booth-h: min(58dvh, 480px);

  --ease-soft: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh; /* repli pour les navigateurs sans dvh */
  min-height: 100dvh;
  background:
    radial-gradient(120% 80% at 50% 0%, #fbf9f5 0%, var(--ivory) 46%, var(--ivory-deep) 100%)
      no-repeat,
    var(--ivory);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
}

/* 2. Mise en page -------------------------------------------------------- */

.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.1rem, 3.4dvh, 2.1rem);

  width: 100%;
  max-width: 30rem;
  margin-inline: auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-block: calc(env(safe-area-inset-top, 0px) + clamp(1.25rem, 4dvh, 2.5rem))
    calc(env(safe-area-inset-bottom, 0px) + clamp(1.25rem, 4dvh, 2.5rem));
  padding-inline: max(1.25rem, env(safe-area-inset-left, 0px))
    max(1.25rem, env(safe-area-inset-right, 0px));
}

/* 3. Typographie --------------------------------------------------------- */

.teaser {
  margin: 0;
  font-size: clamp(1.6rem, 6.8vw, 2.1rem);
  font-weight: 300;
  line-height: 1.25;
  letter-spacing: 0.01em;
  text-align: center;
  text-wrap: balance;
}

.announce {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.5rem, 1.6dvh, 0.9rem);
  text-align: center;
}

.eyebrow {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(0.8rem, 3.6vw, 0.95rem);
  font-weight: 500;
  letter-spacing: 0.42em;
  text-indent: 0.42em; /* compense le tracking final */
  text-transform: uppercase;
  color: var(--ink-soft);
}

.date {
  margin: 0;
  font-size: clamp(1.75rem, 8vw, 2.35rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: 0.015em;
}

/* 4. Photomaton ---------------------------------------------------------- */

/* La machine est une photo (assets/img/booth.webp) dont la bande incrustée a
   été effacée. Tous les repères ci-dessous sont mesurés sur cette image
   (708 × 1342 px) et exprimés en pourcentages : la scène reste fidèle à
   n'importe quelle taille. */

.booth {
  /* Largeur = source de vérité : tout ce qui est à l'intérieur en dérive. */
  --bw: min(calc(var(--booth-h) * 0.5276), 74vw);

  position: relative;
  flex: 0 0 auto;
  width: var(--bw);
  aspect-ratio: 708 / 1342;
  filter: drop-shadow(0 calc(var(--bw) * 0.045) calc(var(--bw) * 0.08) rgba(27, 26, 24, 0.26));
}

.booth__machine {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

/* Zone de sortie : ce qui déborde est « resté dans la machine ».
   Le haut correspond exactement à l'arête où le plafond de la chambre
   rencontre la paroi du fond : la bande sort de cette ombre. */
.booth__stage {
  position: absolute;
  top: 9.54%; /* y = 128 px sur l'image */
  right: 15%;
  bottom: 10.73%; /* y = 1198 px : début du plancher */
  left: 15%;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

/* 5. Bande photo --------------------------------------------------------- */

.strip-pivot {
  position: absolute;
  top: 0;
  display: flex;
  justify-content: center;
  width: 100%;
  transform-origin: 50% 0; /* pivote depuis la fente */
  will-change: transform;
}

.strip {
  /* 248 px de large sur une machine de 708 px. */
  --strip-w: calc(var(--bw) * 0.3503);

  position: relative;
  display: flex;
  flex-direction: column;
  gap: calc(var(--strip-w) * 0.125); /* 31 px */
  width: var(--strip-w);
  /* Marges de la bande d'origine : 33 px en haut, 22 px sur les côtés,
     80 px en bas (le talon caractéristique d'une bande de photomaton). */
  padding: calc(var(--strip-w) * 0.133) calc(var(--strip-w) * 0.0887)
    calc(var(--strip-w) * 0.3226);
  background: linear-gradient(184deg, #f8f4ef 0%, #f4f0eb 62%, #ece7e0 100%);
  box-shadow:
    0 calc(var(--strip-w) * 0.06) calc(var(--strip-w) * 0.13) rgba(0, 0, 0, 0.42),
    0 calc(var(--strip-w) * 0.01) calc(var(--strip-w) * 0.02) rgba(0, 0, 0, 0.25);
  transform: translateY(-102%); /* état initial : entièrement dans la machine */
  will-change: transform;
}

.strip__frame {
  position: relative;
  margin: 0;
  aspect-ratio: 205 / 195;
  overflow: hidden;
  /* Fond de secours : la bande reste crédible si une photo tarde à charger. */
  background: linear-gradient(160deg, #dedad3 0%, #c8c3bb 55%, #b7b2a9 100%);
}

.strip__photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.strip__photo.is-loaded {
  opacity: 1;
}

/* 6. CTA ----------------------------------------------------------------- */

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem; /* > 44 px de zone tactile */
  margin-top: clamp(0.35rem, 1.2dvh, 0.75rem);
  padding: 0.85rem 1.9rem;

  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ivory);

  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 16px;
  transition:
    transform 0.18s var(--ease-soft),
    background-color 0.18s ease,
    color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.cta:hover {
  background: #000;
}

.cta:active {
  transform: scale(0.98);
}

.cta:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.fallback {
  max-width: 22rem;
  margin: 0;
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.fallback a {
  color: var(--ink);
}

.fallback[hidden] {
  display: none;
}

/* 7. Animations ---------------------------------------------------------- */

/* État initial, uniquement si JS est actif (sinon tout reste visible). */
.js .teaser,
.js .announce {
  opacity: 0;
}

.js .announce {
  transform: translateY(0.5rem);
}

.is-ready .teaser {
  animation: fade-up 0.9s var(--ease-soft) 0.1s both;
}

/* Sortie de la bande : poussées successives entrecoupées de micro-pauses,
   comme un mécanisme qui imprime puis éjecte photo après photo. */
.is-ready .strip {
  animation: print-strip 2.05s 0.55s both;
}

.is-ready .strip-pivot {
  animation: settle 1s var(--ease-soft) 2.25s both;
}

.is-ready .announce {
  animation: fade-up 0.85s var(--ease-soft) 2.5s both;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes print-strip {
  0% {
    transform: translateY(-102%);
    animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
  }
  7% {
    transform: translateY(-98.5%);
    animation-timing-function: cubic-bezier(0.3, 0, 0.35, 1);
  }
  26% {
    transform: translateY(-76.5%);
    animation-timing-function: linear;
  }
  31% {
    transform: translateY(-75.8%);
    animation-timing-function: cubic-bezier(0.3, 0, 0.35, 1);
  }
  50% {
    transform: translateY(-51%);
    animation-timing-function: linear;
  }
  55% {
    transform: translateY(-50.3%);
    animation-timing-function: cubic-bezier(0.3, 0, 0.35, 1);
  }
  72% {
    transform: translateY(-25.5%);
    animation-timing-function: linear;
  }
  77% {
    transform: translateY(-24.8%);
    animation-timing-function: cubic-bezier(0.32, 0, 0.3, 1);
  }
  96% {
    transform: translateY(-0.6%);
    animation-timing-function: cubic-bezier(0.33, 0, 0.67, 1);
  }
  100% {
    transform: translateY(0);
  }
}

/* Balancement amorti de la bande, pivot à la fente. */
@keyframes settle {
  0% {
    transform: rotate(0deg);
  }
  28% {
    transform: rotate(-0.85deg);
  }
  55% {
    transform: rotate(0.5deg);
  }
  78% {
    transform: rotate(-0.22deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

/* 8. Grands écrans ------------------------------------------------------- */

@media (min-width: 48rem) and (min-height: 40rem) {
  :root {
    --booth-h: min(60dvh, 500px);
  }

  .page {
    gap: clamp(1.6rem, 4dvh, 2.6rem);
  }

  .booth {
    --bw: min(calc(var(--booth-h) * 0.5276), 17.5rem);
  }
}

/* Écrans très courts : on autorise un léger défilement plutôt que d'écraser
   la composition. */
@media (max-height: 34rem) {
  :root {
    --booth-h: 19rem;
  }

  .page {
    justify-content: flex-start;
  }
}

/* 9. Préférences & repli ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .is-ready .teaser,
  .is-ready .announce {
    animation: fade-in 0.25s ease both;
  }

  .is-ready .strip {
    animation: none;
    transform: translateY(0);
  }

  .is-ready .strip-pivot {
    animation: none;
  }

  .strip__photo {
    transition: none;
  }

  .cta {
    transition: none;
  }

  @keyframes fade-in {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}

/* Sans JavaScript : état final directement affiché. */
html:not(.js) .strip {
  transform: translateY(0);
}

html:not(.js) .strip__photo {
  opacity: 1;
}
