/* ============================================================
   POPS — Mini site invitation
   Palette papier · Esprit littéraire · Douceur
   ============================================================ */

:root {
  --paper:        #F5EFE6;
  --paper-dark:   #EDE3D2;
  --paper-darker: #E2D5BC;
  --ink:          #3D2817;
  --ink-soft:     #5C4530;
  --wax:          #8B2A2A;
  --gold:         #B8956A;
  --gold-soft:    #D4BC95;

  --serif: 'EB Garamond', 'Iowan Old Style', Georgia, serif;
  --cursive: 'Petit Formal Script', 'Apple Chancery', cursive;

  --ease-soft: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--serif);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 30% 20%, #FAF5EC 0%, transparent 60%),
    radial-gradient(ellipse at 80% 90%, #EFE5D2 0%, transparent 70%),
    var(--paper);
  position: relative;
}

/* ============================================================
   Texture papier (noise SVG)
   ============================================================ */
.paper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.24, 0 0 0 0 0.16, 0 0 0 0 0.09, 0 0 0 0.18 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ============================================================
   Lettres flottantes
   ============================================================ */
.floating-letters {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.floating-letter {
  position: absolute;
  font-family: var(--serif);
  color: var(--ink);
  user-select: none;
  will-change: transform, opacity;
  animation:
    drift var(--duration, 60s) ease-in-out var(--delay, 0s) infinite alternate,
    fade-in-letter 2s ease-out var(--delay-fade, 0s) backwards;
}

@keyframes drift {
  from {
    transform: translate(0, 0) rotate(var(--r-start, 0deg));
  }
  to {
    transform: translate(var(--dx, 0), var(--dy, 0)) rotate(var(--r-end, 0deg));
  }
}

@keyframes fade-in-letter {
  from { opacity: 0; }
  to   { opacity: var(--final-opacity, 0.12); }
}

/* ============================================================
   Layout général
   ============================================================ */
main {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.screen {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  width: 100%;
  max-width: 720px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.7s var(--ease-soft), transform 0.7s var(--ease-soft);
}

body.state-quotes       .screen-quotes,
body.state-envelope     .screen-envelope,
body.state-invitation   .screen-invitation,
body.state-confirmation .screen-confirmation {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Sortie de l'écran citations vers l'enveloppe */
body.leaving-quotes .screen-quotes {
  opacity: 0;
  transition: opacity 1s var(--ease-soft);
}

/* Apparition douce de l'enveloppe (effet de dépôt) */
body.state-envelope .screen-envelope {
  transition: opacity 1.4s var(--ease-soft), transform 1.4s var(--ease-soft);
}

/* Sortie d'écran (envelope quand on passe à invitation) */
body.leaving-envelope .screen-envelope {
  opacity: 0;
  transform: translateY(-12px) scale(0.96);
  transition: opacity 0.5s var(--ease-soft), transform 0.5s var(--ease-soft);
}

/* ============================================================
   ÉCRAN 0 — Citations d'intro
   ============================================================ */
.screen-quotes {
  padding: 32px;
}

.quote {
  max-width: 640px;
  width: 100%;
  margin: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4em;
  opacity: 0;
  transition: opacity 1s var(--ease-soft), transform 1s var(--ease-soft);
  transform: translateY(8px);
}

.quote.visible {
  opacity: 1;
  transform: translateY(0);
}

.quote-text {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.4rem, 3.6vw, 2rem);
  line-height: 1.55;
  color: var(--ink);
  letter-spacing: 0.005em;
  margin: 0;
}

.quote-text::before { content: '«\00a0'; color: var(--gold); }
.quote-text::after  { content: '\00a0»'; color: var(--gold); }

.quote-text:empty::before,
.quote-text:empty::after { content: ''; }

.quote-author {
  font-family: var(--cursive);
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  color: var(--ink-soft);
  opacity: 0.75;
  letter-spacing: 0.02em;
}

.quote-author::before {
  content: '— ';
  color: var(--gold);
  margin-right: 2px;
}

.quote-author:empty::before { content: ''; }

/* ============================================================
   ÉCRAN 1 — Enveloppe
   ============================================================ */
.for-pauline {
  font-family: var(--cursive);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.hint {
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-soft);
  opacity: 0.6;
  letter-spacing: 0.04em;
  animation: hint-pulse 3s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.75; }
}

.envelope {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  position: relative;
  width: clamp(280px, 70vw, 380px);
  aspect-ratio: 8 / 5;
  perspective: 1200px;
  transition: transform 0.4s var(--ease-soft);
  animation: envelope-breath 5s ease-in-out infinite;
}

.envelope:hover { transform: translateY(-4px); }
.envelope:focus-visible {
  outline: 2px dashed var(--gold);
  outline-offset: 12px;
  border-radius: 4px;
}

@keyframes envelope-breath {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-2px) scale(1.012); }
}

.envelope-body {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  filter: drop-shadow(0 18px 28px rgba(60, 40, 23, 0.18))
          drop-shadow(0 4px 8px rgba(60, 40, 23, 0.1));
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(150deg, var(--paper-dark) 0%, var(--paper-darker) 100%);
  border-radius: 3px;
}

/* Lignes diagonales pour suggérer le triangle de retour */
.envelope-back::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, transparent calc(50% - 0.5px), rgba(60, 40, 23, 0.12) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(45deg,  transparent calc(50% - 0.5px), rgba(60, 40, 23, 0.12) 50%, transparent calc(50% + 0.5px));
  border-radius: 3px;
}

/* Front : moitié basse de l'enveloppe (corps) */
.envelope-front {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 62%;
  background: linear-gradient(170deg, var(--paper-darker) 0%, #DCC9A8 100%);
  border-radius: 0 0 3px 3px;
  z-index: 3;
  box-shadow: inset 0 2px 4px rgba(60, 40, 23, 0.08);
}

/* Liseré or sur le rebord */
.envelope-front::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold-soft) 20%, var(--gold-soft) 80%, transparent);
}

/* Le rabat (triangle) */
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 62%;
  background: linear-gradient(160deg, var(--paper-dark) 0%, var(--paper-darker) 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transform: rotateX(0deg);
  z-index: 4;
  transition: transform 0.9s var(--ease-soft);
  box-shadow: inset 0 -8px 16px rgba(60, 40, 23, 0.06);
}

/* Le sceau de cire */
.envelope-seal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22%;
  aspect-ratio: 1;
  background: radial-gradient(circle at 35% 30%, #A93A3A 0%, var(--wax) 50%, #6E1F1F 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--cursive);
  color: var(--paper);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow:
    inset 0 -2px 4px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.15),
    0 2px 6px rgba(60, 40, 23, 0.4);
  /* Texture irrégulière du sceau */
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.2));
}

.envelope-seal::before {
  content: '';
  position: absolute;
  inset: 6%;
  border: 1px solid rgba(245, 239, 230, 0.35);
  border-radius: 50%;
}

/* Animation d'ouverture */
.envelope.opening {
  animation: envelope-lift 1.4s var(--ease-soft) forwards;
}

.envelope.opening .envelope-flap {
  transform: rotateX(-180deg);
  transition: transform 1s var(--ease-soft);
}

@keyframes envelope-lift {
  0%   { transform: translateY(0)    scale(1); }
  40%  { transform: translateY(-12px) scale(1.02); }
  100% { transform: translateY(-30px) scale(0.94); opacity: 0; }
}

/* ============================================================
   ÉCRAN 2 — Invitation
   ============================================================ */
.letter {
  position: relative;
  background: linear-gradient(175deg, #FAF4E6 0%, var(--paper-dark) 100%);
  padding: clamp(36px, 7vw, 64px) clamp(28px, 6vw, 72px);
  max-width: 580px;
  width: 100%;
  text-align: center;
  border-radius: 2px;
  box-shadow:
    0 2px 4px rgba(60, 40, 23, 0.06),
    0 12px 24px rgba(60, 40, 23, 0.12),
    0 30px 60px rgba(60, 40, 23, 0.08);
  font-size: clamp(1.05rem, 2.4vw, 1.25rem);
  line-height: 1.85;
  color: var(--ink);
}

/* Liseré or fin autour de la lettre */
.letter::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px solid var(--gold-soft);
  pointer-events: none;
  border-radius: 1px;
  opacity: 0.55;
}

.letter p {
  margin-bottom: 0.6em;
}

.letter .opening {
  font-family: var(--cursive);
  font-size: 1.5em;
  color: var(--ink);
  margin-bottom: 1em;
  letter-spacing: 0.02em;
}

.letter strong {
  font-weight: 500;
  font-style: italic;
  color: var(--ink);
  border-bottom: 1px dotted var(--gold);
  padding-bottom: 1px;
}

.letter .question {
  margin-top: 1.4em;
  font-size: 1.1em;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.buttons {
  margin-top: 2.2em;
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
}

.btn {
  appearance: none;
  font-family: var(--serif);
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  letter-spacing: 0.08em;
  padding: 12px 36px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--gold);
  border-radius: 2px;
  cursor: pointer;
  font-weight: 500;
  position: relative;
  transition: all 0.3s var(--ease-soft);
  min-width: 110px;
}

.btn:hover {
  background: rgba(184, 149, 106, 0.12);
  border-color: var(--ink);
}

.btn:focus-visible {
  outline: 2px dashed var(--gold);
  outline-offset: 4px;
}

.btn-yes {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn-yes:hover {
  background: var(--wax);
  border-color: var(--wax);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(60, 40, 23, 0.2);
}

.btn-no {
  position: relative;
  z-index: 20;
  will-change: transform;
}

/* ============================================================
   ÉCRAN 3 — Confirmation
   ============================================================ */
.confirmation {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.8em;
}

.confirmation .big {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink);
  font-style: italic;
  line-height: 1.2;
}

.confirmation .signature {
  font-family: var(--cursive);
  font-size: clamp(1.4rem, 3.5vw, 1.8rem);
  color: var(--ink-soft);
  margin-top: 0.4em;
}

/* Petit ornement sous la confirmation */
.confirmation::after {
  content: '·  ·  ·';
  letter-spacing: 1em;
  color: var(--gold);
  margin-top: 1em;
  font-size: 1.2em;
  opacity: 0.7;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
  main { padding: 16px; }
  .letter { padding: 36px 24px; }
  .buttons { gap: 16px; }
  .btn { padding: 11px 28px; min-width: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .floating-letter { display: none; }
}
