/* ===== Tokens ===== */
:root {
  /* Cores */
  --wine: #7a0d2b;
  --paper: #fffdfb;
  --bg: #e9e4dd;

  /* Layout */
  --invite-max: 1000px;
  --pad-card: clamp(12px, 3vw, 28px);
  --pad-border: clamp(14px, 3.5vw, 34px);
  --pad-inner: clamp(20px, 5vw, 56px);
  --gap-section: clamp(20px, 4.5vw, 44px);
  --gap-section-sm: clamp(12px, 3vw, 24px);

  /* Bordas */
  --bd-outer: 2px solid var(--wine);
  --bd-inner: 1px solid var(--wine);

  /* Entrada / envelope / selo */
  --env: #7a0d2b;
  --env-light: #94203f;
  --env-dark: #5c0820;
  --env-seam: rgba(0, 0, 0, .22);
  --gold: #c79a3c;
  --gold-dark: #8f6a1f;
  --gold-light: #ecd28a;
  --env-max: 460px;
  --seal-size: clamp(96px, 26vw, 150px);
  --dur-open: 1.1s;
  --dur-trans: .5s;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --fs-script: clamp(46px, 12vw, 92px);

  /* Tipografia */
  --fs-verse: clamp(16px, 2.6vw, 24px);
  --fs-blessing: clamp(14px, 2.3vw, 22px);
  --fs-parents: clamp(14px, 2.2vw, 21px);
  --fs-names: clamp(48px, 13vw, 96px);
  --fs-invite: clamp(14px, 2.3vw, 22px);
  --fs-day: clamp(36px, 8vw, 64px);
  --fs-year: clamp(30px, 6.5vw, 54px);
  --fs-month: clamp(11px, 1.8vw, 17px);
  --fs-place: clamp(16px, 2.6vw, 25px);
  --fs-rsvp: clamp(15px, 2.4vw, 23px);
}

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

html, body { overflow-x: hidden; }

body {
  background: var(--bg);
  font-family: 'Cormorant Garamond', serif;
  color: var(--wine);
  display: flex;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px) clamp(12px, 3vw, 32px);
  min-height: 100vh;
}

/* ===== Cartão ===== */
.invite {
  background: var(--paper);
  width: 100%;
  max-width: var(--invite-max);
  padding: var(--pad-card);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
}

.border {
  border: var(--bd-outer);
  padding: var(--pad-border);
}

.inner {
  border: var(--bd-inner);
  padding: var(--pad-inner);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--gap-section);
}

/* ===== Seções ===== */
.verse {
  font-size: var(--fs-verse);
  font-style: italic;
  line-height: 1.35;
}
.verse .ref { font-style: normal; }

.blessing {
  font-size: var(--fs-blessing);
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.3;
}

.parents {
  display: flex;
  flex-direction: column;
  gap: var(--gap-section-sm);
  width: 100%;
  font-size: var(--fs-parents);
  line-height: 1.3;
}
.parents-row {
  display: flex;
  justify-content: space-between;
  gap: clamp(16px, 5vw, 48px);
}
.parents-row span { flex: 1; }
.parents-row span:last-child { text-align: right; }

.names {
  font-family: 'Playfair Display', serif;
  font-weight: 800;
  font-size: var(--fs-names);
  line-height: 1.02;
  letter-spacing: .01em;
}
.names .amp { font-weight: 700; }

.invite-line {
  font-size: var(--fs-invite);
  letter-spacing: .05em;
  text-transform: uppercase;
  line-height: 1.35;
}

.date {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: 'Playfair Display', serif;
}
.date .day { font-size: var(--fs-day); font-weight: 700; }
.date .sep { width: 2px; align-self: stretch; background: var(--wine); }
.date .my { text-align: left; line-height: 1; }
.date .month { font-size: var(--fs-month); letter-spacing: .35em; }
.date .year { font-size: var(--fs-year); font-weight: 700; }

.place {
  font-size: var(--fs-place);
  line-height: 1.45;
}
.place .first { font-weight: 600; }

.actions {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: clamp(14px, 4vw, 44px);
  width: 100%;
}
.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: clamp(72px, 19vw, 104px);
  text-decoration: none;
  color: var(--wine);
  transition: transform .2s var(--ease);
}
.action:hover, .action:focus-visible { transform: translateY(-3px); outline: none; }
.action:focus-visible .action-ico { box-shadow: 0 0 0 3px rgba(122, 13, 43, .35); }
.action-ico {
  width: clamp(58px, 15vw, 80px);
  height: clamp(58px, 15vw, 80px);
  border-radius: 50%;
  background: var(--wine);
  color: var(--paper);
  display: grid;
  place-items: center;
}
.action-ico svg { width: 56%; height: 56%; }
.action-label {
  font-size: clamp(13px, 2.2vw, 17px);
  text-align: center;
  line-height: 1.25;
}

/* ===== Telas estreitas ===== */
@media (max-width: 480px) {
  .parents { gap: var(--gap-section-sm) clamp(8px, 3vw, 20px); }
  .actions { gap: clamp(10px, 3vw, 20px); }
}

/* ============================================================
   TELA DE ENTRADA (envelope + selo)
   ============================================================ */
.page-entry { align-items: center; }

.entry {
  width: 100%;
  max-width: var(--env-max);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(18px, 4vw, 32px);
  padding: clamp(8px, 3vw, 24px) 0;
}

.entry-names {
  font-family: 'Tangerine', cursive;
  font-weight: 700;
  font-size: var(--fs-script);
  line-height: .9;
}

.entry-footer {
  font-size: clamp(14px, 2.4vw, 19px);
  text-transform: uppercase;
  letter-spacing: .12em;
  line-height: 1.5;
  opacity: .85;
}

/* Envelope */
.envelope {
  width: 100%;
  max-width: var(--env-max);
  perspective: 1400px;
}
.env-body {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: linear-gradient(160deg, var(--env-light), var(--env-dark));
  border: 1px solid var(--env-dark);
  border-radius: 6px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, .28);
}

/* Carta que sobe ao abrir (escondida atrás dos flaps até abrir) */
.letter {
  position: absolute;
  inset: 7% 7% auto 7%;
  height: 88%;
  background: var(--paper);
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
  z-index: 1;
}

/* Flaps laterais + inferior: 4 cunhas a partir do centro (selo de envelope) */
.env-pocket {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: conic-gradient(
    var(--env) 315deg 45deg,
    var(--env-dark) 45deg 135deg,
    var(--env-light) 135deg 225deg,
    var(--env-dark) 225deg 315deg
  );
}
/* Seams diagonais (cantos) */
.env-pocket::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top right, transparent calc(50% - .5px), var(--env-seam) 50%, transparent calc(50% + .5px)),
    linear-gradient(to top left, transparent calc(50% - .5px), var(--env-seam) 50%, transparent calc(50% + .5px));
}

/* Aba superior (abre no clique) */
.env-flap {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 56%;
  z-index: 4;
  transform-origin: top center;
  transform: rotateX(0deg);
  background: linear-gradient(to bottom, var(--env-light), var(--env));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
  transition: transform var(--dur-trans) var(--ease);
  backface-visibility: hidden;
}

/* Selo de cera (botão) */
.seal {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: var(--seal-size);
  height: var(--seal-size);
  z-index: 5;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  transition: transform .25s var(--ease), filter .25s var(--ease);
}
.seal:hover, .seal:focus-visible {
  transform: translate(-50%, -50%) scale(1.06);
  filter: brightness(1.05);
  outline: none;
}
.seal:focus-visible .seal-wax { box-shadow: 0 0 0 3px rgba(199, 154, 60, .6), inset 0 3px 6px rgba(255,255,255,.4), inset 0 -6px 12px rgba(0,0,0,.3); }

.seal-text {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: var(--gold-dark);
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  letter-spacing: 1px;
  animation: spin 22s linear infinite;
}

.seal-wax {
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold) 55%, var(--gold-dark) 100%);
  box-shadow: inset 0 3px 6px rgba(255, 255, 255, .45), inset 0 -6px 12px rgba(0, 0, 0, .3), 0 4px 10px rgba(0, 0, 0, .3);
}
.seal-icon {
  width: 58%;
  height: 58%;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25));
}

/* Estado: abrindo */
.envelope.is-opening .env-flap { transform: rotateX(178deg); z-index: 1; }
.envelope.is-opening .seal {
  animation: seal-pop .45s var(--ease) forwards;
  pointer-events: none;
}
.envelope.is-opening .letter { z-index: 6; animation: letter-rise var(--dur-open) var(--ease) .35s forwards; }

/* ============================================================
   ANIMAÇÕES
   ============================================================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes seal-pop {
  0%   { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  40%  { transform: translate(-50%,-50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%,-120%) scale(.5) rotate(-12deg); opacity: 0; }
}
@keyframes letter-rise {
  0%   { transform: translateY(0) scale(1); }
  55%  { transform: translateY(-34%) scale(1.02); }
  100% { transform: translateY(-150%) scale(1.05); opacity: 0; }
}
@keyframes appear { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

/* Entrada animada do envelope ao carregar */
.envelope { animation: appear .7s var(--ease) both; }
.entry-names  { animation: appear .6s var(--ease) both; }
.entry-footer { animation: appear .6s var(--ease) .12s both; }

/* Stagger fade-in das seções do convite */
.page-convite .stagger { opacity: 0; animation: appear .7s var(--ease) both; }
.page-convite .stagger:nth-child(1) { animation-delay: .05s; }
.page-convite .stagger:nth-child(2) { animation-delay: .14s; }
.page-convite .stagger:nth-child(3) { animation-delay: .23s; }
.page-convite .stagger:nth-child(4) { animation-delay: .32s; }
.page-convite .stagger:nth-child(5) { animation-delay: .41s; }
.page-convite .stagger:nth-child(6) { animation-delay: .50s; }
.page-convite .stagger:nth-child(7) { animation-delay: .59s; }
.page-convite .stagger:nth-child(8) { animation-delay: .68s; }
.page-convite .stagger:nth-child(9) { animation-delay: .77s; }

.back-link {
  margin-top: var(--gap-section-sm);
  font-size: var(--fs-rsvp);
  color: var(--wine);
  text-decoration: none;
  opacity: .7;
  letter-spacing: .04em;
}
.back-link:hover { opacity: 1; }

/* ============================================================
   TRANSIÇÕES SWUP
   ============================================================ */
.transition-main { transition: opacity var(--dur-trans) var(--ease), transform var(--dur-trans) var(--ease); }
html.is-changing .transition-main { opacity: 0; transform: translateY(14px); }
html.is-rendering .transition-main { opacity: 0; transform: translateY(-14px); }

/* ============================================================
   ACESSIBILIDADE: sem movimento
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, .envelope, .seal, .seal-text, .entry-kicker, .entry-names, .entry-footer,
  .page-convite .stagger, .transition-main {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
