:root {
  --wine-dark: #3d0c19;
  --wine: #5a1526;
  --wine-light: #74213a;

  /* Site : fond blanc cassé, encre bordeaux */
  --page-bg: #f3e8d7;
  --page-bg-light: #faf4ea;
  --page-bg-dark: #e7d9c3;
  --ink: #5a1526;
  --ink-soft: rgba(90, 21, 38, 0.72);
  --ink-faint: rgba(90, 21, 38, 0.18);
  --accent: #a8823f;
  --sage: #7f9a83;
  --relief-light: rgba(255, 255, 255, 0.75);
  --relief-dark: rgba(110, 80, 45, 0.22);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-glide: cubic-bezier(0.16, 1, 0.3, 1);

  --serif-caps: "Cormorant Garamond", Georgia, serif;
  --serif-display: "Bodoni Moda", "Didot", Georgia, serif;
  --script: "Pinyon Script", cursive;
  --names: "Monsieur La Doulaise", "Pinyon Script", cursive;
}

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

/* Les éléments masqués (attribut hidden) restent cachés quel que soit leur style */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

/* Safari sur iPhone colore ses barres avec ce fond */
html,
body {
  background-color: var(--page-bg);
  transition: background-color 1.2s ease;
}

html:has(body.is-closed),
body.is-closed {
  background-color: #290610;
}

/* Une fois ouvert : bordeaux en haut (accueil) */
html:has(body.revealed) {
  background-color: var(--wine);
}

body {
  min-height: 100svh;
  color: var(--ink);
  font-family: var(--serif-caps);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

html:has(body.is-closed),
body.is-closed {
  overflow: hidden;
  touch-action: none;
}

#site {
  background:
    radial-gradient(120% 50svh at 50% 0%, var(--page-bg-light), transparent 70%),
    var(--page-bg);
  transition: transform 2s var(--ease-out);
}

body.is-closed #site {
  transform: scale(1.04);
}

/* Le site reste caché sous l'enveloppe fermée */
body:not(.revealed) #site {
  visibility: hidden;
}

/* ================= Accueil ================= */

.hero {
  /* L'accueil reprend la page bordeaux : encre crème, accents dorés */
  --ink: var(--page-bg);
  --ink-soft: rgba(243, 232, 215, 0.72);
  --accent: #d8bd8c;
  position: relative;
  height: 100svh;
  min-height: 520px;
  display: grid;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(120% 70% at 50% 0%, var(--wine-light), transparent 65%),
    radial-gradient(100% 60% at 50% 110%, var(--wine-dark), transparent 70%),
    var(--wine);
}

/* Double filet ton sur ton, en relief, dessiné depuis le haut au centre */
.frame {
  position: absolute;
  inset: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  overflow: visible;
  pointer-events: none;
}

.frame path {
  fill: none;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
  transition:
    stroke-dashoffset 1.2s cubic-bezier(0.33, 1, 0.68, 1) 0.35s,
    opacity 0.4s ease 0.35s;
}

.frame .hi {
  stroke: rgba(0, 0, 0, 0.32);
  stroke-width: 2.4;
}

.frame .lo {
  stroke: rgba(255, 228, 232, 0.13);
  stroke-width: 2.4;
}

body.revealed .frame path {
  stroke-dashoffset: 0;
  opacity: 1;
}

.ring {
  width: 30px;
  height: 34px;
  fill: none;
  stroke: #d8bd8c;
  stroke-width: 1.1;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.lead {
  margin: 26px 0 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.8;
  letter-spacing: 0.3em;
  padding-left: 0.3em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.flora {
  position: absolute;
  left: 0;
  width: 100%;
  overflow: visible;
  pointer-events: none;
}

/* Photo ovale noir et blanc, dans un anneau en relief ton sur ton */
.oval {
  position: relative;
  margin: clamp(18px, 3.4vh, 30px) 0 0;
  width: min(58vw, 230px, 29svh);
  aspect-ratio: 5 / 4;
  border-radius: 50%;
  background: radial-gradient(80% 80% at 50% 35%, var(--wine-light), var(--wine-dark));
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.45),
    inset 0 -1px 0 rgba(255, 244, 225, 0.2),
    0 1px 0 rgba(255, 244, 225, 0.2);
}

.oval::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 228, 232, 0.13);
  box-shadow: 0 1.5px 1px rgba(0, 0, 0, 0.3), inset 0 1.5px 1px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.oval img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 42%; /* centre le cadrage sur les visages */
  border-radius: 50%;
  filter: grayscale(1) contrast(1.08) brightness(1.02);
  box-shadow: 0 0 0 2.5px rgba(255, 228, 232, 0.13), 0 2px 2px rgba(0, 0, 0, 0.3);
}

.hero .scroll-cue {
  margin-top: clamp(26px, 5vh, 46px);
}

/* ---------- Papier blanc cassé ---------- */

.paper {
  position: relative;
  background:
    radial-gradient(120% 60svh at 50% 0%, var(--page-bg-light), transparent 70%),
    var(--page-bg);
  box-shadow: 0 -10px 30px rgba(30, 5, 12, 0.35);
}

.paper-flora {
  /* Les bouquets du haut débordent sur l'accueil, mais pas sur les côtés */
  overflow: hidden;
  overflow: clip visible;
  top: 0;
  height: 70svh;
  max-height: 620px;
}

.venue-flora {
  /* Pleine largeur de l'écran, même si la section est plus étroite */
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  margin-left: -50vw;
  overflow: hidden;
  overflow: clip visible;
}

#venue > :not(.flora) {
  position: relative;
  z-index: 1;
}

.paper-flora .bloom,
.venue-flora .bloom {
  position: absolute;
  max-width: none;
}

.bloom {
  opacity: 0;
  transform: scale(0.84) rotate(-5deg);
  transition:
    opacity 1.4s ease,
    transform 2.2s var(--ease-glide);
  transition-delay: calc(0.2s + var(--b) * 0.14s);
}

.flora-in .bloom {
  opacity: 1;
  transform: none;
}

/* Les fleurs du lieu attendent leur propre arrivée à l'écran */
.venue-flora:not(.flora-in) .bloom {
  opacity: 0;
  transform: scale(0.84) rotate(-5deg);
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 360px;
}

/* Apparition en cascade de l'accueil */
.r {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition:
    opacity 1.3s ease,
    transform 1.5s var(--ease-glide);
  transition-delay: calc(0.7s + var(--i) * 0.18s);
}

body.revealed .r {
  opacity: 1;
  transform: none;
}

.kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.42em;
  padding-left: 0.42em;
  text-transform: uppercase;
  color: var(--accent);
}

.names {
  margin: 14px 0 0;
  font-family: var(--names);
  font-weight: 400;
  font-size: clamp(46px, 13.5vw, 72px);
  line-height: 1.3;
  white-space: nowrap;
  padding: 0 0.12em; /* les boucles (le « h » de Joseph) dépassent de la lettre */
  color: var(--ink);
}

.names span {
  color: var(--accent);
  font-size: 0.8em;
  margin: 0 0.28em 0 0.06em; /* le J de Joseph déborde à gauche */
}

.tagline {
  margin: 4px 0 0;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
}

.date {
  margin: 26px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.28em;
  padding-left: 0.28em;
  text-transform: uppercase;
  color: var(--ink);
}

/* Chiffres de la date : plus grands, à hauteur de capitale */
.fig {
  font-size: 1.3em;
  line-height: 0;
  letter-spacing: 0.12em;
  font-variant-numeric: lining-nums;
}

.scroll-cue {
  margin-top: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.34em;
  padding-left: 0.34em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
}

.scroll-cue svg {
  width: 16px;
  height: 8px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: nudge 2.2s ease-in-out infinite;
}

@keyframes nudge {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  50% {
    transform: translateY(5px);
    opacity: 1;
  }
}

/* ================= Sections ================= */

.section {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  padding: 72px 24px;
  text-align: center;
}

.paper-flora + .section {
  padding-top: clamp(150px, 30svh, 230px);
}

.section + .section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 36px;
  margin-top: -18px;
  background: linear-gradient(transparent, var(--ink-faint), transparent);
}

/* Apparition au défilement */
.rv {
  opacity: 0;
  transform: translate3d(0, 26px, 0);
  transition:
    opacity 1.5s ease,
    transform 1.8s var(--ease-glide);
  transition-delay: calc(var(--k, 0) * 0.14s);
}

.rv.in {
  opacity: 1;
  transform: none;
}

.ornament {
  display: block;
  width: 170px;
  height: 60px;
  margin: 0 auto 10px;
  overflow: visible;
}

.section h2 {
  margin: 0;
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: clamp(30px, 8.6vw, 38px);
  line-height: 1.15;
  color: var(--ink);
}

.sub {
  margin: 8px 0 0;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
}

.caps {
  margin: 14px 0 0;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  padding-left: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  line-height: 1.7;
}

.body {
  margin: 22px auto 0;
  max-width: 340px;
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
}

.note {
  margin: 22px 0 0;
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
}

.btn {
  display: inline-block;
  margin-top: 30px;
  appearance: none;
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 13px 28px 13px calc(28px + 0.24em);
  background: var(--ink);
  color: var(--page-bg);
  font-family: var(--serif-caps);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(90, 21, 38, 0.18);
  transition:
    background 0.25s ease,
    color 0.25s ease,
    opacity 0.9s ease,
    transform 1.1s var(--ease-glide);
}

.btn:hover,
.btn:focus-visible {
  background: var(--wine-light);
  outline: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
  background: var(--ink);
  color: var(--page-bg);
}

.btn-sm {
  margin-top: 18px;
  padding: 10px 20px 10px calc(20px + 0.24em);
  font-size: 11px;
}

.btn-wide {
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- Compte à rebours ---------- */

.calendar {
  margin: 28px auto 0;
  width: min(100%, 320px);
  padding: 22px 18px 18px;
  border: 1px solid var(--ink-faint);
  border-radius: 18px;
  background: rgba(250, 244, 234, 0.7);
}

.cal-month {
  margin: 0 0 14px;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 20px;
  color: var(--ink);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 6px;
  font-variant-numeric: lining-nums tabular-nums;
}

.cal-wd {
  padding-bottom: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.cal-d {
  position: relative;
  display: grid;
  place-items: center;
  height: 34px;
  font-size: 16px;
  color: var(--ink-soft);
}

/* Le jour J : chiffre en gras, entouré d'un trait dessiné à la main */
.cal-d.is-day {
  font-weight: 600;
  font-size: 18px;
  color: var(--ink);
}

.cal-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 40px;
  margin: -20px 0 0 -23px;
  overflow: visible;
  pointer-events: none;
}

.cal-ring path {
  fill: none;
  stroke: var(--wine);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.4s cubic-bezier(0.65, 0, 0.35, 1) 0.6s;
}

.calendar.in .cal-ring path {
  stroke-dashoffset: 0;
}

.cd-label {
  margin: 30px 0 -16px;
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--accent);
}

.cd-label:empty {
  display: none;
}

.days {
  margin: 26px 0 0;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 10px;
}

.days .num {
  display: inline-block;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 46px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.days .unit {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.tick {
  animation: tick 0.6s var(--ease-out);
}

@keyframes tick {
  from {
    opacity: 0.25;
    transform: translateY(-3px);
  }
}

/* ---------- Lieu ---------- */

.vine {
  display: block;
  width: min(80vw, 280px);
  aspect-ratio: 280 / 118;
  margin: 18px auto 0;
  overflow: visible;
}

.venue-name {
  margin: 26px 0 0;
  font-family: var(--serif-display);
  font-size: 24px;
  color: var(--ink);
}

.time {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.time svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
}

/* ---------- Programme ---------- */

.timeline {
  list-style: none;
  margin: 36px auto 0;
  padding: 0;
  max-width: 340px;
  text-align: left;
  position: relative;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 58px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--ink-faint);
}

.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr;
  column-gap: 26px;
  padding: 0 0 28px;
}

.timeline li:last-child {
  padding-bottom: 0;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: 54px;
  top: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--page-bg);
  border: 1.5px solid var(--ink);
}

.timeline .t {
  grid-row: span 2;
  padding-top: 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.timeline h3 {
  margin: 0;
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: 19px;
  color: var(--ink);
}

.timeline p {
  margin: 4px 0 0;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* ---------- Tenue ---------- */

.swatches {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.swatches li {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c);
  box-shadow:
    0 0 0 3px var(--page-bg),
    0 0 0 4px var(--ink-faint);
}

/* ---------- Hébergement ---------- */

.cards {
  display: grid;
  gap: 18px;
  margin-top: 34px;
}

.card {
  padding: 26px 22px;
  border: 1px solid var(--ink-faint);
  border-radius: 18px;
  background: rgba(250, 244, 234, 0.6);
}

.card h3 {
  margin: 0;
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: 21px;
}

.card p:not(.caps) {
  margin: 8px 0 0;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink-soft);
}

/* ---------- Questions ---------- */

.faq {
  margin-top: 30px;
  text-align: left;
  border-top: 1px solid var(--ink-faint);
}

.faq details {
  border-bottom: 1px solid var(--ink-faint);
}

.faq summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 2px;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 1.4px solid var(--ink-soft);
  border-bottom: 1.4px solid var(--ink-soft);
  transform: translateY(-3px) rotate(45deg);
  transition: transform 0.3s var(--ease-out);
}

.faq details[open] summary::after {
  transform: translateY(2px) rotate(-135deg);
}

.faq details p {
  margin: -4px 2px 18px;
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* ---------- RSVP ---------- */

.rsvp {
  margin-top: 32px;
  text-align: left;
}

.hp {
  position: absolute;
  left: -9999px;
}

.field {
  display: block;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}

.field > span,
.field legend {
  display: block;
  margin-bottom: 8px;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field em {
  text-transform: none;
  letter-spacing: 0.02em;
  font-weight: 400;
}

.field input:not([type="radio"]),
.field select,
.field textarea {
  width: 100%;
  appearance: none;
  border: 1px solid var(--ink-faint);
  border-radius: 12px;
  padding: 13px 14px;
  background: rgba(250, 244, 234, 0.75);
  color: var(--ink);
  font-family: var(--serif-caps);
  font-size: 17px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.field textarea {
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: rgba(90, 21, 38, 0.38);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--ink-soft);
  box-shadow: 0 0 0 3px rgba(90, 21, 38, 0.08);
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--ink-faint);
  border-radius: 12px;
  font-size: 17px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.choice input {
  appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.4px solid var(--ink-soft);
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.choice input::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  transform: scale(0);
  transition: transform 0.2s var(--ease-out);
}

.choice input:checked::after {
  transform: scale(1);
}

.choice:has(input:checked) {
  border-color: var(--ink-soft);
  background: rgba(250, 244, 234, 0.75);
}

.if-yes {
  max-height: 260px;
  overflow: hidden;
  transition: max-height 0.45s var(--ease-out), opacity 0.3s ease;
}

.rsvp.declined .if-yes {
  max-height: 0;
  opacity: 0;
}

.rsvp .btn {
  margin-top: 6px;
}

.form-status {
  min-height: 1.4em;
  margin: 12px 0 0;
  text-align: center;
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
}

.thanks {
  margin: 10px 0 0;
  text-align: center;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 22px;
  line-height: 1.4;
}

/* ---------- Pied de page ---------- */

.footer {
  position: relative;
  height: 380px;
  margin-top: 40px;
  overflow: hidden;
}

.footer-flora {
  bottom: 0;
  height: 230px;
}

.footer-text {
  position: relative;
  text-align: center;
}

.names-sm {
  margin: 0;
  font-size: 46px;
}

.footer .caps {
  margin-top: 0;
}

.insta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--ink);
  text-decoration: none;
}

.insta svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.insta .dot {
  fill: currentColor;
  stroke: none;
}

.closing {
  margin-top: 26px;
  font-size: min(15px, 3.9vw);
  white-space: nowrap;
}

.venue-logo {
  display: block;
  width: 132px;
  height: auto;
  margin: 26px auto 4px;
}

.footer-note {
  margin: 14px 0 0;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
}

/* ================= Enveloppe plein écran ================= */

.envelope {
  --ease-flap: cubic-bezier(0.65, 0, 0.3, 1);
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  /* intérieur de l'enveloppe, sombre, visible quand les rabats s'écartent */
  background:
    radial-gradient(70% 50% at 50% 42%, #3b1a1f 0%, #22100f 60%, #140807 100%);
  transition: opacity 1s ease;
  opacity: 0;
}

body.env-ready .envelope {
  opacity: 1;
  animation: env-in 1.2s var(--ease-glide) both;
}

@keyframes env-in {
  from {
    opacity: 0;
    transform: scale(1.03);
  }
}

/* Teinte du site, qui monte sur l'intérieur sombre pendant que les rabats s'écartent */
.envelope::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 70% at 50% 0%, var(--wine-light), transparent 65%),
    radial-gradient(100% 60% at 50% 110%, var(--wine-dark), transparent 70%),
    var(--wine);
  opacity: 0;
  transition: opacity 1.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.warming .envelope::before {
  opacity: 1;
}

.piece {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  will-change: transform;
  transition: transform 1.35s var(--ease-flap);
}

.piece-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.seal {
  position: absolute;
  left: 50%;
  top: var(--seal-y);
  width: var(--seal-d);
  height: var(--seal-d);
  margin-left: calc(var(--seal-d) / -2);
  display: grid;
  place-items: center;
  isolation: isolate; /* le halo reste derrière la cire, mais au-dessus du rabat */
  transition: transform 0.45s var(--ease-out);
}

.seal-wax {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.35)) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}

.seal-initials {
  position: relative;
  font-family: var(--script);
  font-size: calc(var(--seal-d) * 0.27);
  line-height: 1;
  white-space: nowrap;
  /* initiales pressées dans la cire crème */
  color: #bda57c;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95),
    0 -1px 0 rgba(90, 70, 45, 0.35);
  transform: translateY(2%);
}

.seal-initials em {
  font-style: normal;
  font-size: 0.7em;
}

.sheen {
  position: absolute;
  inset: -20%;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 32%,
    rgba(255, 255, 255, 0.025) 46%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(255, 255, 255, 0.025) 54%,
    transparent 68%
  );
  animation: sheen 8s ease-in-out infinite;
  transition: opacity 0.4s ease;
}

@keyframes sheen {
  0%,
  100% {
    transform: translateX(-40%);
  }
  50% {
    transform: translateX(40%);
  }
}

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(34px, calc(env(safe-area-inset-bottom) + 20px));
  margin: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4em;
  padding-left: 0.4em;
  text-transform: uppercase;
  color: rgba(243, 232, 215, 0.7);
  animation: breathe 2.8s ease-in-out infinite;
  transition: opacity 0.4s ease;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

/* ---------- Scintillement du sceau (3 s avant l'ouverture) ---------- */

.seal-glow,
.spark {
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

/* Halo doré qui respire derrière la cire */
.seal-glow {
  inset: -28%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 216, 140, 0.75) 0%, rgba(255, 175, 90, 0.32) 40%, transparent 68%);
}

/* Petites étoiles dorées autour du sceau */
.spark {
  left: 50%;
  top: 50%;
  width: 15px;
  height: 15px;
  margin: -7.5px 0 0 -7.5px;
  background: radial-gradient(circle, #fff6dc 0%, #f3cf86 40%, transparent 70%);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  transform: rotate(var(--a)) translateY(calc(var(--seal-d) * -0.62)) scale(0.3);
}

body.shimmer .seal-glow {
  animation: glow 3s ease-in-out both;
}

body.shimmer .spark {
  animation: twinkle 1.3s ease-in-out var(--d) 2;
}

@keyframes glow {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
  }
  70% {
    opacity: 1;
    transform: scale(1.06);
  }
  100% {
    opacity: 0.85;
    transform: scale(1);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0;
    transform: rotate(var(--a)) translateY(calc(var(--seal-d) * -0.62)) scale(0.3);
  }
  50% {
    opacity: 1;
    transform: rotate(var(--a)) translateY(calc(var(--seal-d) * -0.66)) scale(1) rotate(45deg);
  }
}

body.shimmer .hint {
  animation: none;
  opacity: 0;
}

/* ---------- Séquence d'ouverture ---------- */

body.opening .hint,
body.opening .sheen {
  animation: none;
  opacity: 0;
}

body.opening .seal {
  transform: scale(0.93);
}

/* La lueur s'éteint quand les rabats s'écartent */
body.opening .seal-glow {
  animation: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

/* Chaque rabat s'écarte dans sa direction */
body.parting .piece-top {
  transform: translateY(-104%);
}

body.parting .piece-bottom {
  transform: translateY(104%);
  transition-delay: 0.12s;
}

body.parting .piece-left {
  transform: translateX(-104%);
  transition-delay: 0.22s;
}

body.parting .piece-right {
  transform: translateX(104%);
  transition-delay: 0.22s;
}

/* L'intérieur, devenu de la teinte du site, s'efface */
body.revealed .envelope {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.6s cubic-bezier(0.4, 0, 0.2, 1);
}

body.done .envelope {
  display: none;
}

/* ================= Bouton musique ================= */

.sound {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
  z-index: 20;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(216, 189, 140, 0.55);
  border-radius: 50%;
  background: rgba(58, 10, 23, 0.9);
  color: #f3e8d7;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  animation: sound-in 0.8s var(--ease-out) 1s both;
}

@keyframes sound-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
}

.sound svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound .spk {
  fill: currentColor;
}

.sound .on,
.sound.is-on .off {
  display: none;
}

.sound.is-on .on {
  display: inline;
}

/* ================= Pétales ================= */

.petals {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 11; /* au-dessus de l'enveloppe, pour tomber pendant l'ouverture */
}

.petal {
  position: absolute;
  top: -40px;
  width: var(--s);
  height: calc(var(--s) * 0.6);
  border-radius: 0 100% 0 100%;
  background: var(--c);
  opacity: 0;
  animation: fall var(--d) linear var(--delay) infinite;
}

@keyframes fall {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  10% {
    opacity: var(--o);
  }
  50% {
    transform: translate3d(var(--x), 55vh, 0) rotate(200deg);
  }
  90% {
    opacity: var(--o);
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(var(--x) * -0.6), 110vh, 0) rotate(420deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.2s !important;
    transition-delay: 0s !important;
  }
  .petals {
    display: none;
  }
}

.venue-logo + .venue-name {
  margin-top: 14px;
}
