@font-face {
  font-family: "PoliceGW";
  src: url("fonts/gw.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "PoliceHV";
  src: url("fonts/hv.otf") format("opentype");
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background-color: #173553;
}

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  color: #3f302d;
  font-family: "PoliceHV", Georgia, serif;
  background-color: #173553;
}

/* Fond animé commun à l’accueil et à toute la carte */
body::before {
  content: "";
  position: fixed;
  inset: -6%;
  z-index: -1;
  pointer-events: none;
  background-image: url("images/fond.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  will-change: transform;
  animation: mouvement-fond 14s ease-in-out infinite alternate;
}

[hidden] {
  display: none !important;
}

/* Accueil */
.accueil {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: transparent;
  opacity: 1;
  transition: opacity 700ms ease;
}

.accueil.disparait {
  opacity: 0;
  pointer-events: none;
}

.accueil-cadre {
  position: relative;
  width: min(100vw, 56.25svh);
  aspect-ratio: 1080 / 1920;
  perspective: 1400px;
  transform-style: preserve-3d;
}

.image-accueil {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bouton-ouvrir {
  position: absolute;
  left: 31.96517%;
  bottom: 23.63477%;
  width: 35.64815%;
  height: 6.015625%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.bouton-ouvrir img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.compte-a-rebours {
  position: absolute;
  left: 50%;
  bottom: 17.4987%;
  width: 90%;
  height: 3.04338%;
  max-height: 3.04338%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
  transform: translateX(-50%);
  color: #3f302d;
  text-align: center;
  white-space: nowrap;
  font-family: "PoliceGW", Georgia, serif;
  font-size: clamp(11px, 3vw, 28px);
  line-height: 1;
}

/* Invitation avec fond animé en continu */
.invitation {
  position: relative;
  isolation: isolate;
  display: none;
  width: 100%;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: transparent;
  opacity: 0;
  transition: opacity 700ms ease;
}

.invitation.visible {
  display: block;
  opacity: 0;
}

.invitation.visible.apparait {
  opacity: 1;
}

.pages {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-snap-type: y mandatory;
  background: transparent;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 4%,
    #000 96%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 4%,
    #000 96%,
    transparent 100%
  );
}

/* Slides */
.page {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 12px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.page > img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100svh - 24px);
  object-fit: contain;
}

/* Fondu et léger zoom des slides */
.page:not(.page-rsvp) > img,
.page-slide-2 .slide-2-cadre {
  opacity: 0.65;
  transform: scale(1.04);
  transition:
    opacity 900ms ease,
    transform 1200ms ease;
}

.page.active:not(.page-rsvp) > img,
.page-slide-2.active .slide-2-cadre {
  opacity: 1;
  transform: scale(1);
}

/* Slide 2 et bouton Waze */
.slide-2-cadre {
  position: relative;
  width: min(calc(100vw - 24px), 56.25svh);
  aspect-ratio: 1080 / 1920;
}

.slide-2-cadre > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bouton-waze {
  position: absolute;
  left: 50%;
  bottom: 6.24255%;
  width: 36.06966%;
  height: 6.08675%;
  display: block;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 700ms ease, transform 700ms ease;
}

.bouton-waze.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.bouton-waze img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

/* Points de navigation à droite */
.navigation-pages {
  position: absolute;
  z-index: 3;
  top: 50%;
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 2px;
  transform: translateY(-50%);
}

.point-navigation {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.point-navigation::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fbfbfb;
  opacity: 0.85;
  transition:
    width 250ms ease,
    height 250ms ease,
    background-color 250ms ease,
    opacity 250ms ease;
}

.point-navigation.actif::before {
  width: 9px;
  height: 9px;
  background: #f7beca;
  opacity: 1;
}

.point-navigation:focus-visible {
  outline: 1px solid #f7beca;
  outline-offset: 1px;
  border-radius: 50%;
}

/* Slide RSVP */
.page-rsvp {
  align-content: center;
}

.rsvp-cadre {
  position: relative;
  width: min(calc(100vw - 24px), 56.25svh);
  aspect-ratio: 1080 / 1920;
  container-type: inline-size;
}

.rsvp-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* Position du formulaire dans la zone de rsvp.png */
.rsvp-form,
.confirmation-personnalisee {
  position: absolute;
  left: 18.66%;
  top: 35.5%;
  bottom: auto;
  width: 62.59%;
  height: 48.93%;
  transform: none;
}

.rsvp-form {
  display: grid;
  align-content: start;
  gap: 0.45em;
  overflow-y: auto;
  padding: 1%;
  background: transparent;
  font-family: "PoliceHV", Arial, sans-serif;
  font-size: clamp(16px, 2.2cqw, 21px);
  opacity: 1;
  transition: opacity 700ms ease;
}

.rsvp-form.fade-out {
  opacity: 0;
}

.rsvp-form label {
  display: block;
  color: #1e3a5f;
}

.rsvp-form input[type="text"],
.rsvp-form input[type="number"],
.rsvp-form textarea {
  display: block;
  width: 100%;
  margin-top: 0.25em;
  padding: 0.35em 0.45em;
  border: 1px solid #f7beca;
  border-radius: 0.3em;
  color: #1e3a5f;
  background: rgba(255, 255, 255, 0.88);
  font: inherit;
}

.rsvp-form input:disabled {
  color: #1e3a5f;
  background: rgba(238, 232, 228, 0.88);
}

.rsvp-form fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8em;
  min-width: 0;
  padding: 0.35em 0.45em;
  border: 1px solid #f7beca;
  border-radius: 0.3em;
  color: #1e3a5f;
  background: transparent;
}

.rsvp-form fieldset label {
  display: flex;
  align-items: center;
  gap: 0.3em;
  white-space: nowrap;
}

.rsvp-form input[type="radio"] {
  accent-color: #f7beca;
}

.rsvp-form textarea {
  min-height: 3.5em;
  resize: vertical;
}

.rsvp-form button {
  padding: 0.4em;
  border: 1px solid #f7beca;
  border-radius: 0.3em;
  color: #fbfbfb;
  background: #f7beca;
  font: inherit;
  cursor: pointer;
}

/* Confirmation et compte à rebours sous merci.png */
.confirmation-personnalisee:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 700ms ease;
}

.confirmation-personnalisee.visible {
  opacity: 1;
}

.image-merci {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.confirmation-compte-a-rebours {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 100%;
  height: auto;
  max-height: none;
  min-height: 24px;
  transform: translateX(-50%);
  gap: 3px;
  overflow: visible;
  color: #1e3a5f;
  font-size: clamp(20px, 5.6cqw, 36px);
}

/* Ajustement du RSVP sur les petits iPhone en portrait */
@media (max-width: 600px) and (orientation: portrait) {
  .rsvp-form {
    top: 35.5%;
    bottom: auto;
    left: 18.66%;
    width: 62.59%;
    height: 48.93%;
    padding: 2px;
    gap: 3px;
    align-content: start;
    font-size: clamp(12px, 3.1vw, 14px);
    overflow-y: auto;
  }

  .rsvp-form > label {
    line-height: 1.1;
  }

  .rsvp-form input[type="text"],
  .rsvp-form input[type="number"],
  .rsvp-form textarea {
    margin-top: 2px;
    padding: 4px 5px;
    font-size: 16px;
    line-height: 1.1;
  }

  .rsvp-form input[type="text"],
  .rsvp-form input[type="number"] {
    min-height: 34px;
  }

  .rsvp-form fieldset {
    min-width: 0;
    gap: 8px;
    padding: 4px 6px;
  }

  .rsvp-form fieldset label {
    white-space: nowrap;
  }

  .rsvp-form textarea {
    height: 50px;
    min-height: 50px;
    resize: none;
  }

  .rsvp-form button {
    min-height: 32px;
    padding: 5px;
    font-size: 13px;
  }
}

/* Volets de l’animation d’ouverture */
.accueil-cadre::before,
.accueil-cadre::after {
  content: "";
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  background-image: url("images/accueil.png");
  background-repeat: no-repeat;
  background-size: 200% 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.accueil-cadre::before {
  left: 0;
  background-position: left center;
  transform-origin: right center;
}

.accueil-cadre::after {
  right: 0;
  background-position: right center;
  transform-origin: left center;
}

.accueil.deplie {
  pointer-events: none;
}

.accueil.deplie .accueil-cadre::before {
  animation: ouvrir-volet-gauche 800ms ease-in forwards;
}

.accueil.deplie .accueil-cadre::after {
  animation: ouvrir-volet-droit 800ms ease-in forwards;
}

@keyframes ouvrir-volet-gauche {
  0% {
    opacity: 1;
    transform: rotateY(0deg);
  }

  100% {
    opacity: 0;
    transform: rotateY(-100deg);
  }
}

@keyframes ouvrir-volet-droit {
  0% {
    opacity: 1;
    transform: rotateY(0deg);
  }

  100% {
    opacity: 0;
    transform: rotateY(100deg);
  }
}

/* Mouvement diagonal continu du fond */
@keyframes mouvement-fond {
  from {
    transform: translate3d(-1.3%, -0.8%, 0) scale(1.06);
  }

  to {
    transform: translate3d(1.3%, 0.8%, 0) scale(1.06);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
  }
}