/* =====================================================================
   Bar Mitzva de NOAM — invitation
   Toutes les cotes sont exprimées dans le repère du PDF (1225 pt de large)
   puis converties avec --u (page) ou --s (pop-up) : pixel perfect à
   n'importe quelle largeur d'écran.
   ===================================================================== */

@font-face {
  font-family: "Porn Star Academy";
  src: url("../media/fonts/porn-star-academy.woff2") format("woff2"),
       url("../media/fonts/porn-star-academy.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  --navy: #171a44;          /* textes */
  --navy-deep: #06203e;     /* save the date + rayures */
  --navy-frame: #0e1c3f;    /* cadres */
  --cream: #eee1d5;         /* fond page */
  --cream-card: #eedfcd;    /* carte réponse */
  --cream-intro: #eeeae1;   /* fond pop-up */
  --placeholder: #bcb2a5;

  --f-text: "Cormorant Garamond", "Cormorant", Garamond, "Times New Roman", serif;
  --f-title: "Porn Star Academy", "Impact", sans-serif;
  --f-italic: "EB Garamond", Garamond, "Times New Roman", serif;

  --w: min(100vw, 540px);
  --u: calc(var(--w) / 1225);

  --vh: 100vh;
}
@supports (height: 100dvh) {
  :root { --vh: 100dvh; }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--navy-frame);
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--navy-frame);
  color: var(--navy);
  font-family: var(--f-text);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
html.is-locked, body.is-locked { overflow: hidden; height: var(--vh); }

img { display: block; max-width: none; -webkit-user-drag: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* =====================================================================
   POP-UP / ENVELOPPE
   ===================================================================== */
.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--cream-intro);
  overflow: hidden;
  touch-action: none;
  --s: min(calc(100vw / 1225), calc(var(--vh) / 1859));
  /* espace libre au-dessus de la scène (écrans plus hauts que la maquette) */
  --gap: calc((var(--vh) - 1859 * var(--s)) * .5);
  transition: opacity .9s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .9s;
}
.intro.is-leaving { opacity: 0; visibility: hidden; pointer-events: none; }

.intro__scene {
  position: absolute;
  left: 50%;
  top: var(--gap);
  width: calc(1225 * var(--s));
  height: calc(1859 * var(--s));
  transform: translateX(-50%);
  transition: transform 1.1s cubic-bezier(.5, 0, .2, 1);
}
.intro.is-leaving .intro__scene { transform: translateX(-50%) scale(1.06); }

/* feuillage : collé en haut de l'écran comme sur la maquette */
.env-leaves {
  position: absolute;
  left: 0;
  top: calc(2.97 * var(--s) - var(--gap));
  width: calc(801.99 * var(--s));
  height: calc(1673.81 * var(--s));
  pointer-events: none;
}

.env {
  position: absolute;
  inset: 0;
  perspective: calc(2600 * var(--s));
  pointer-events: none;
}

.env-body {
  position: absolute;
  left: calc(60 * var(--s));
  top: calc(520 * var(--s));
  width: calc(1105 * var(--s));
  height: calc(740 * var(--s));
  filter: drop-shadow(calc(6 * var(--s)) calc(10 * var(--s)) calc(14 * var(--s)) rgba(60, 45, 30, .16));
}

/* rabat : charnière sur le haut de l'enveloppe (y = 520) */
.env-flap {
  position: absolute;
  left: calc(60 * var(--s));
  top: calc(120 * var(--s));
  width: calc(1105 * var(--s));
  height: calc(400 * var(--s));
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
  transform: rotateX(180deg);
  transition: transform 1.05s cubic-bezier(.65, .02, .25, 1);
  will-change: transform;
}
.env-flap__inside,
.env-flap__outside {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.env-flap__outside {
  transform: rotateX(180deg);
  overflow: visible;
  filter: drop-shadow(0 calc(-8 * var(--s)) calc(10 * var(--s)) rgba(60, 45, 30, .22));
}
.intro.is-open .env-flap { transform: rotateX(0deg); }

/* sceau */
.env-seal {
  position: absolute;
  left: calc(406.78 * var(--s));
  top: calc(738.69 * var(--s));
  width: calc(402.07 * var(--s));
  height: calc(367.44 * var(--s));
  z-index: 3;
  border-radius: 50%;
  transition: transform .35s cubic-bezier(.3, 1.5, .5, 1);
  animation: seal-breathe 2.8s ease-in-out 1.2s infinite;
}
.env-seal img { width: 100%; height: 100%; }
.env-seal:active { transform: scale(.94); }
.intro.is-open .env-seal { animation: seal-pop .5s cubic-bezier(.3, 1.6, .5, 1); }

@keyframes seal-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}
@keyframes seal-pop {
  0% { transform: scale(.92); }
  100% { transform: scale(1); }
}

/* bouton « découvrir l'invitation » */
.env-btn {
  position: absolute;
  left: calc(249 * var(--s));
  top: calc(1452 * var(--s));
  width: calc(728 * var(--s));
  height: calc(180 * var(--s));
  z-index: 3;
  transition: transform .2s ease, opacity .5s ease;
}
.env-btn img { width: 100%; height: 100%; }
.env-btn:active { transform: scale(.97); }
.intro.is-open .env-btn { opacity: 0; transform: translateY(calc(20 * var(--s))); pointer-events: none; }

.env-seal:focus-visible, .env-btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 4px; }

/* =====================================================================
   PAGE INVITATION
   ===================================================================== */
.page {
  position: relative;
  width: var(--w);
  margin: 0 auto;
  background: var(--cream);
  overflow: hidden;
  opacity: 0;
  transform: translateY(calc(40 * var(--u)));
  transition: opacity 1.1s cubic-bezier(.4, 0, .2, 1) .15s, transform 1.3s cubic-bezier(.2, .7, .2, 1) .15s;
}
.page.is-visible { opacity: 1; transform: none; }
@media (min-width: 541px) {
  .page { box-shadow: 0 0 60px rgba(0, 0, 0, .35); }
}

/* ---------- Faire-part ---------- */
.card {
  position: relative;
  height: calc(4150 * var(--u));
}
.card__bg {
  position: absolute;
  left: 0;
  top: calc(var(--y) * var(--u));
  width: 100%;
  height: calc(var(--h) * var(--u) + 1px); /* +1px : évite les liserés entre tranches */
}

/* une ligne de texte = une boîte positionnée sur la ligne du PDF */
.t {
  position: absolute;
  left: calc(var(--x) * var(--u));
  top: calc(var(--y) * var(--u));
  margin: 0;
  font-family: var(--f-text);
  font-weight: 600;
  font-size: calc(var(--fs) * var(--u));
  line-height: 1.222;
  white-space: nowrap;
  /* -50% : centrage sur l'axe de la ligne du PDF ; 2.7u : écart de métriques mesuré */
  transform: translate(-50%, calc(2.7 * var(--u)));
  color: var(--navy);
  font-kerning: normal;
  font-feature-settings: "liga" 1, "kern" 1;
}
.t--title {
  font-family: var(--f-title);
  font-weight: 400;
  line-height: 1.096;
  text-transform: uppercase;
}
.t--light { color: #efdfcd; }

.map {
  position: absolute;
  left: calc(var(--x) * var(--u));
  top: calc(var(--y) * var(--u));
  width: calc(var(--w) * var(--u));
  height: calc(var(--h) * var(--u));
  color: inherit;
  text-decoration: none;
}
.map .t { color: var(--navy); }

/* compte à rebours */
.countdown { position: absolute; inset: 0; pointer-events: none; }
.t--digit {
  top: calc(3846.3 * var(--u));
  font-family: var(--f-title);
  font-weight: 400;
  font-size: calc(72.58 * var(--u));
  line-height: 1.096;
  font-variant-numeric: tabular-nums;
}

/* ---------- RSVP ---------- */
.rsvp {
  position: relative;
  padding: calc(110.7 * var(--u)) 0 calc(124.1 * var(--u));
  background:
    repeating-linear-gradient(90deg,
      var(--navy-deep) 0,
      var(--navy-deep) calc(41.65 * var(--u)),
      var(--cream) calc(41.65 * var(--u)),
      var(--cream) calc(83.05 * var(--u)));
  background-position: calc(1.5 * var(--u)) 0;
}

.rsvp__card {
  position: relative;
  margin-left: calc(178.1 * var(--u));
  width: calc(868.8 * var(--u));
  background: var(--cream-card);
  border: solid var(--navy-deep);
  border-width: 0 calc(5.1 * var(--u)) calc(8.4 * var(--u));
  padding: calc(70.8 * var(--u)) calc(51.1 * var(--u)) calc(150 * var(--u));
}

.rsvp__logo {
  width: calc(96.6 * var(--u));
  height: calc(221.7 * var(--u));
  margin: 0 auto;
}

.rsvp__title {
  margin: calc(110.5 * var(--u)) 0 0;
  font-family: var(--f-title);
  font-weight: 400;
  font-size: calc(60.61 * var(--u));
  line-height: 1.096;
  text-align: center;
  text-transform: uppercase;
  color: var(--navy);
}

.form { margin: 0; }

.field { margin: 0; padding: 0; border: 0; min-width: 0; }
.form > .field:first-child { margin-top: calc(116.2 * var(--u)); }
.form > .field + .field { margin-top: calc(36.4 * var(--u)); }
.form > .field--attend { margin-top: calc(71.1 * var(--u)) !important; }
.form > .field--msg { margin-top: calc(97 * var(--u)) !important; }

.label {
  display: block;
  padding: 0;
  margin: 0 0 calc(19.6 * var(--u));
  font-size: calc(50.51 * var(--u));
  line-height: 1.222;
  color: var(--navy);
}
.label--italic {
  font-family: var(--f-italic);
  font-style: italic;
  font-weight: 400;
  font-size: calc(60.3 * var(--u));
  line-height: 1.255;
  margin-bottom: calc(13.5 * var(--u));
}
legend.label { margin-bottom: calc(25.9 * var(--u)); float: left; width: 100%; }
legend.label + * { clear: both; }

.input,
.select {
  display: block;
  width: 100%;
  height: calc(123.6 * var(--u));
  margin: 0;
  padding: 0 calc(28 * var(--u));
  border: calc(3 * var(--u)) solid var(--navy);
  border-radius: 0;
  background: transparent;
  color: var(--navy);
  font-family: var(--f-text);
  font-weight: 600;
  /* ≥ 16px : empêche le zoom automatique d'iOS au focus */
  font-size: max(16px, calc(50.51 * var(--u)));
  line-height: 1.2;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  transition: box-shadow .2s ease, background-color .2s ease;
}
.input:focus, .select:focus {
  background-color: rgba(255, 255, 255, .35);
  box-shadow: 0 0 0 calc(3 * var(--u)) rgba(23, 26, 68, .18);
}
.input.is-invalid { background-color: rgba(139, 21, 48, .07); border-color: #8b1530; }

.input--msg {
  height: calc(348.5 * var(--u));
  padding: calc(11.5 * var(--u)) calc(27.5 * var(--u));
  font-family: var(--f-italic);
  font-style: italic;
  font-weight: 400;
  font-size: max(16px, calc(60.3 * var(--u)));
  line-height: 1.255;
  resize: none;
}
.input--msg::placeholder { color: var(--placeholder); opacity: 1; }

/* choix « Assisteront » (cases rondes du PDF) */
.choice {
  position: relative;
  display: flex;
  align-items: center;
  min-height: calc(74.3 * var(--u));
  padding-left: calc(115.2 * var(--u));
  margin-top: calc(33 * var(--u));
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
legend + .choice { margin-top: 0; }
.choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.choice__dot {
  position: absolute;
  left: calc(14.8 * var(--u));
  top: 50%;
  width: calc(74.3 * var(--u));
  height: calc(74.3 * var(--u));
  margin-top: calc(-37.15 * var(--u));
  border: calc(3 * var(--u)) solid var(--navy);
  border-radius: 50%;
}
.choice__dot::after {
  content: "";
  position: absolute;
  inset: calc(12 * var(--u));
  border-radius: 50%;
  background: var(--navy);
  transform: scale(0);
  transition: transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
.choice input:checked + .choice__dot::after { transform: scale(1); }
.choice input:focus-visible + .choice__dot { box-shadow: 0 0 0 calc(6 * var(--u)) rgba(23, 26, 68, .2); }
.choice__txt {
  font-size: calc(50.51 * var(--u));
  line-height: 1.222;
  white-space: nowrap;
}
.field--attend.is-invalid .choice__dot { border-color: #8b1530; }

/* nombre d'invités (connecteur logique) */
.guests {
  padding-left: calc(115.2 * var(--u));
  overflow: hidden;
  animation: guests-in .45s cubic-bezier(.2, .7, .2, 1);
}
.guests[hidden] { display: none; }
@keyframes guests-in {
  from { opacity: 0; transform: translateY(calc(-14 * var(--u))); }
  to { opacity: 1; transform: none; }
}
.guests__row {
  display: flex;
  gap: calc(34 * var(--u));
  margin-top: calc(26 * var(--u));
}
.guests__item { flex: 1 1 0; min-width: 0; display: block; }
.guests__lbl {
  display: block;
  margin-bottom: calc(10 * var(--u));
  font-size: calc(42 * var(--u));
  line-height: 1.222;
  opacity: .85;
}
.select {
  height: calc(110 * var(--u));
  padding-right: calc(80 * var(--u));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 9l7 7 7-7' fill='none' stroke='%23171a44' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right calc(26 * var(--u)) center;
  background-size: calc(44 * var(--u));
  cursor: pointer;
}
.select { font-variant-numeric: lining-nums; font-feature-settings: "lnum" 1; }
.select.is-invalid { border-color: #8b1530; }
.guests__names { display: block; margin-top: calc(26 * var(--u)); }
.input--names {
  height: calc(190 * var(--u));
  padding: calc(16 * var(--u)) calc(28 * var(--u));
  resize: none;
}
.input--names::placeholder { color: var(--placeholder); opacity: 1; font-style: italic; font-family: var(--f-italic); font-weight: 400; }

.form__error {
  margin: calc(40 * var(--u)) 0 0;
  font-size: calc(44 * var(--u));
  line-height: 1.25;
  text-align: center;
  color: #8b1530;
}

/* bouton envoyer (même plaque que « découvrir l'invitation ») */
.send {
  position: relative;
  display: block;
  width: calc(560 * var(--u));
  height: calc(140 * var(--u));
  margin: calc(90 * var(--u)) auto 0;
  transition: transform .2s ease, opacity .2s ease;
}
.send__plate { position: absolute; inset: 0; width: 100%; height: 100%; }
.send__txt {
  position: relative;
  display: block;
  font-family: var(--f-italic);
  font-style: italic;
  font-weight: 400;
  font-size: calc(64 * var(--u));
  line-height: calc(140 * var(--u));
  color: #f4e6d3;
  letter-spacing: .01em;
}
.send:active { transform: scale(.97); }
.send:focus-visible { outline: 2px solid var(--navy); outline-offset: 4px; }
.send[disabled] { opacity: .6; pointer-events: none; }

/* confirmation */
.thanks {
  margin-top: calc(110 * var(--u));
  text-align: center;
  outline: none;
  animation: guests-in .7s cubic-bezier(.2, .7, .2, 1);
}
.thanks__title {
  margin: 0;
  font-family: var(--f-title);
  font-size: calc(96 * var(--u));
  line-height: 1.096;
  text-transform: uppercase;
}
.thanks__txt {
  margin: calc(50 * var(--u)) 0 0;
  font-size: calc(54 * var(--u));
  line-height: 1.3;
}
.thanks__hearts {
  margin: calc(60 * var(--u)) 0 0;
  font-size: calc(48 * var(--u));
  letter-spacing: .6em;
  padding-left: .6em;
}

/* ---------- pied de page ---------- */
.foot {
  min-height: calc(533.2 * var(--u));
  padding: calc(240.7 * var(--u)) 0 calc(90 * var(--u) + env(safe-area-inset-bottom));
  background: var(--cream);
  text-align: center;
}
.foot__logo {
  width: calc(67.2 * var(--u));
  height: calc(154.3 * var(--u));
  margin: 0 auto;
}
.foot__credit {
  margin: calc(70 * var(--u)) 0 0;
  font-family: var(--f-italic);
  font-style: italic;
  font-weight: 400;
  font-size: calc(34 * var(--u));
  line-height: 1.2;
  letter-spacing: .04em;
  color: var(--navy);
  opacity: .6;
}
.foot__credit a {
  display: inline-block;
  padding: 8px 12px;
  color: inherit;
  text-decoration: none;
}
.foot__credit a:active { opacity: .6; }
.foot__credit span {
  font-family: var(--f-title);
  font-style: normal;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ---------- bouton son ---------- */
.sound {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--navy-deep);
  color: var(--cream);
  box-shadow: 0 4px 14px rgba(6, 32, 62, .35), inset 0 0 0 2px var(--navy-deep), inset 0 0 0 3.5px rgba(238, 225, 213, .7);
  display: grid;
  place-items: center;
  animation: guests-in .6s ease;
}
@media (min-width: 541px) {
  .sound { right: calc(50vw - 270px + 14px); }
}
.sound[hidden] { display: none; }
.sound svg { width: 22px; height: 22px; fill: currentColor; }
.sound .sound__off { display: none; }
.sound[aria-pressed="false"] .sound__on { display: none; }
.sound[aria-pressed="false"] .sound__off { display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .2s !important; }
}
