/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --rubi: #7E0F0D;
  --rubi-dark: #640B0A;
  --merlot: #3D0D11;
  --flamingo: #FFBEC5;
  --crudo: #FFF4EB;
  --ink: #3D0D11;
  --ink-soft: rgba(61, 13, 17, .72);
  --hairline: rgba(126, 15, 13, .22);
  --error: #A3121A;

  --font-serif: 'Bodoni Moda', 'Didot', Georgia, serif;
  --font-script: 'Pinyon Script', 'Snell Roundhand', cursive;
  --font-sans: 'Jost', 'Futura', system-ui, sans-serif;

  /* Textura de papel: ruído fractal escuro (fundos claros) e claro (fundos escuros) */
  --noise-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .2 0 0 0 0 .12 0 0 0 .055 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --noise-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .95 0 0 0 0 .92 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  color-scheme: light;
}

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

/* Fundo da página em merlot: o Safari do iOS pinta as barras com essa cor (ignora theme-color),
   e assim elas emendam com o palco no topo e o rodapé embaixo. O creme fica no body. */
html {
  background-color: var(--merlot);
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--crudo);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 350;
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

p, h1, h2, h3 { margin: 0; }
img, svg { display: block; }

::selection { background: var(--flamingo); color: var(--merlot); }

:focus-visible {
  outline: 2px solid var(--rubi);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.script {
  font-family: var(--font-script);
  font-weight: 400;
  line-height: 1;
}

.eyebrow {
  font-family: var(--font-sans);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .28em;
  text-transform: uppercase;
}

.rule {
  display: block;
  width: 44px;
  height: 1px;
  margin: .7em auto;
  background: currentColor;
  opacity: .5;
}

.paper {
  background-color: var(--crudo);
  background-image: var(--noise-dark);
}

/* ==========================================================================
   1–2 · Palco do envelope
   ========================================================================== */
/* Altura "grande" no celular (barra de endereço recolhida) para o palco fixado nunca deixar uma faixa vazia */
.stage {
  position: relative;
  height: 100vh;
  height: 100lvh;
  min-height: 520px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--crudo);
  background-color: var(--merlot);
  background-image:
    var(--noise-light),
    radial-gradient(ellipse 70% 60% at 50% 48%, #5C161C 0%, var(--merlot) 62%, #26070A 100%);
}

/* O envelope: proporção 1.4, cabe na largura e na altura da tela */
.env {
  position: relative;
  width: min(84vw, 500px, calc(52svh * 1.4));
  aspect-ratio: 1.4;
  perspective: 1400px;
}

.env-back {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: linear-gradient(#DCC6AE, #E8D6C2);
  box-shadow:
    0 40px 70px -24px rgba(0, 0, 0, .6),
    0 14px 24px -12px rgba(0, 0, 0, .45);
}

.env-front {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  border-radius: 3px;
  overflow: hidden;
}

.env-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56%;
  z-index: 4;
  transform-origin: 50% 0;
  transform-style: preserve-3d;
}

.env-flap-face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.env-flap-outer {
  background: linear-gradient(to bottom, #FAF0E4 0%, #EEDFCC 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

/* Face de dentro da aba: já girada, com a ponta para cima para aparecer certa quando a aba abre */
.env-flap-inner {
  background: linear-gradient(to top, #E4D0B9, #D9C2A8);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  transform: rotateX(180deg);
}

.letter {
  position: absolute;
  top: 5%;
  bottom: 5%;
  left: 4%;
  right: 4%;
  z-index: 2;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--ink);
  background-color: var(--crudo);
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(61, 13, 17, .18);
  will-change: transform;
}

/* Textura separada para sumir antes da carta crescer (senão o ruído aparece ampliado) */
.letter-grain {
  position: absolute;
  inset: 0;
  background-image: var(--noise-dark);
}

.letter-content { position: relative; padding: 6%; }

.letter-content .eyebrow {
  font-size: clamp(.55rem, 1.8vw, .68rem);
  color: var(--ink-soft);
}

.letter-name {
  color: var(--rubi);
  font-size: clamp(2.6rem, 12vw, 4.4rem);
  margin-top: .15em;
}

.letter-content .rule { color: var(--rubi); margin: .35em auto .5em; }

.letter-date {
  font-family: var(--font-serif);
  font-size: clamp(.85rem, 3.2vw, 1.15rem);
  letter-spacing: .22em;
}

/* Selo centralizado na ponta da aba. O centro usa `translate` para não brigar com o transform do GSAP */
.seal {
  position: absolute;
  top: 56%;
  left: 50%;
  width: 25%;
  aspect-ratio: 1;
  translate: -50% -50%;
  z-index: 5;
  filter: drop-shadow(0 5px 7px rgba(30, 4, 6, .45));
}

.seal-half {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.seal-left  { clip-path: polygon(0 0, 53% 0, 46% 20%, 56% 38%, 45% 57%, 55% 76%, 48% 100%, 0 100%); }
.seal-right { clip-path: polygon(53% 0, 100% 0, 100% 100%, 48% 100%, 55% 76%, 45% 57%, 56% 38%, 46% 20%); }

/* Textura que aparece sobre a carta já ampliada, para emendar com a seção seguinte */
.stage-grain {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: var(--noise-dark);
  opacity: 0;
}

.scroll-hint {
  position: absolute;
  bottom: max(5svh, 24px);
  bottom: calc(100lvh - 100svh + max(5svh, 24px));
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--crudo);
  opacity: .8;
}

.scroll-line {
  width: 1px;
  height: 42px;
  background: linear-gradient(var(--flamingo), transparent);
  transform-origin: top;
  animation: scroll-line 2.2s cubic-bezier(.65, 0, .35, 1) infinite;
}

@keyframes scroll-line {
  0%   { transform: scaleY(0); opacity: 1; }
  60%  { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

/* Sem animação (reduzir movimento ou GSAP indisponível): envelope já aberto */
.is-static .env-flap { transform: rotateX(180deg); z-index: 1; }
.is-static .letter { transform: translateY(-60%); }
.is-static .seal { display: none; }
.is-static .scroll-hint .scroll-line { animation: none; }

/* ==========================================================================
   3 · Convite
   ========================================================================== */
.invite {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(72px, 12vh, 128px) 20px;
  text-align: center;
}

/* Com animação, o convite cobre a última tela do pin: sobe escondido por cima do palco
   e aparece (fade na timeline) quando a carta já cobriu tudo, já no topo da tela */
.has-motion .invite {
  position: relative;
  z-index: 1;
  margin-top: -100vh;
  margin-top: -100lvh;
  justify-content: flex-start;
  padding-top: clamp(48px, 8vh, 96px);
}

/* A logo é JPG com fundo branco: o multiply some com o branco e deixa o papel (com a textura) aparecer */
.invite-logo {
  width: clamp(132px, 38vw, 184px);
  height: auto;
  margin-bottom: clamp(20px, 4vh, 36px);
  mix-blend-mode: multiply;
}

.invite-lead {
  max-width: 26ch;
  font-size: 1.02rem;
  font-weight: 300;
  color: var(--ink-soft);
}

.invite-title {
  margin-top: .45em;
  color: var(--rubi);
  font-family: var(--font-sans);
  font-size: clamp(2.9rem, 13.5vw, 7rem);
  font-weight: 200;
  line-height: .95;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.invite-de {
  margin-top: .15em;
  color: var(--rubi);
  font-size: clamp(2rem, 7vw, 2.8rem);
}

.invite-name {
  color: var(--rubi);
  font-size: clamp(5rem, 26vw, 10rem);
  line-height: .9;
  margin: -.05em 0 .15em;
  padding: 0 .1em;
}

.invite-full { margin-top: .4em; }

.invite-course {
  margin-top: .4em;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-soft);
}

.date-block {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(14px, 4vw, 28px);
  width: min(100%, 420px);
  margin-top: clamp(36px, 6vh, 56px);
}

.date-side {
  padding: .7em 0;
  border-block: 1px solid var(--hairline);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .25em;
  text-transform: uppercase;
}

.date-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.date-month, .date-year {
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .28em;
  text-transform: uppercase;
}

.date-day {
  font-family: var(--font-serif);
  font-size: clamp(3.6rem, 16vw, 5rem);
  line-height: 1;
  color: var(--rubi);
}

.countdown {
  display: flex;
  justify-content: center;
  gap: clamp(18px, 6vw, 40px);
  margin-top: clamp(32px, 5vh, 48px);
}

.countdown div {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 3ch;
}

.countdown span {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  line-height: 1.1;
  font-variant-numeric: tabular-nums lining-nums;
}

.countdown small {
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.countdown.is-today { font-family: var(--font-script); font-size: 2.6rem; color: var(--rubi); }

/* ==========================================================================
   4 · Detalhes
   ========================================================================== */
.details {
  padding: clamp(40px, 8vh, 80px) 20px clamp(80px, 14vh, 140px);
  text-align: center;
}

.ornament {
  width: 220px;
  max-width: 70%;
  margin: 0 auto clamp(40px, 7vh, 64px);
  color: var(--rubi);
  opacity: .7;
}

.ornament svg { width: 100%; height: auto; }

.section-title {
  color: var(--rubi);
  font-size: clamp(3rem, 13vw, 4.8rem);
  padding: 0 .1em;
}

.detail-list {
  display: grid;
  gap: 0;
  max-width: 880px;
  margin: clamp(28px, 5vh, 48px) auto 0;
}

.detail {
  padding: 32px 8px;
  border-top: 1px solid var(--hairline);
}

.detail:last-child { border-bottom: 1px solid var(--hairline); }

.detail .eyebrow { color: var(--rubi); }

.detail h3 {
  margin: .5em 0 .3em;
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 5vw, 1.7rem);
  font-weight: 400;
  line-height: 1.25;
}

.detail p:not(.eyebrow) { color: var(--ink-soft); }

@media (min-width: 760px) {
  .detail-list {
    grid-template-columns: 1fr 1fr;
    column-gap: 56px;
  }
  .detail:nth-last-child(2) { border-bottom: 1px solid var(--hairline); }
}

.link-btn {
  display: inline-block;
  margin-top: 16px;
  padding: .8em 1.6em;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--rubi);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .24em;
  text-decoration: none;
  text-transform: uppercase;
  transition: background-color .25s, color .25s;
}

.link-btn:hover { background: var(--rubi); color: var(--crudo); }

/* ==========================================================================
   5 · Confirmação de presença
   ========================================================================== */
.rsvp {
  padding: clamp(72px, 12vh, 120px) 16px;
  text-align: center;
  color: var(--crudo);
  background-color: var(--merlot);
  background-image: var(--noise-light);
}

.rsvp .section-title { color: var(--flamingo); }

.rsvp-lead {
  max-width: 34ch;
  margin: 1em auto 0;
  font-weight: 300;
  opacity: .85;
}

.rsvp :focus-visible { outline-color: var(--flamingo); }
.rsvp-card :focus-visible { outline-color: var(--rubi); }

.rsvp-card {
  position: relative;
  max-width: 480px;
  margin: clamp(32px, 6vh, 48px) auto 0;
  padding: clamp(28px, 7vw, 44px) clamp(20px, 6vw, 40px);
  text-align: left;
  color: var(--ink);
  background-color: var(--crudo);
  background-image: var(--noise-dark);
  border-radius: 4px;
  box-shadow: 0 30px 60px -24px rgba(0, 0, 0, .55);
  outline: 1px solid var(--hairline);
  outline-offset: -10px;
}

.rsvp-step { display: grid; gap: 22px; }

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; color: var(--rubi); }

.field { display: grid; gap: 6px; }
.field .eyebrow { color: var(--rubi); }

.field input {
  width: 100%;
  padding: .45em 0;
  border: 0;
  border-bottom: 1px solid rgba(61, 13, 17, .35);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.2rem;
  transition: border-color .2s;
}

.field input::placeholder { color: rgba(61, 13, 17, .35); }

.field input:focus {
  outline: none;
  border-bottom-color: var(--rubi);
  box-shadow: 0 1px 0 var(--rubi);
}

.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  text-align: center;
  text-decoration: none;
  padding: 1.1em 1.4em;
  border: 0;
  border-radius: 999px;
  background: var(--rubi);
  color: var(--crudo);
  font-family: var(--font-sans);
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .24em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color .2s, transform .1s;
}

.btn:hover { background: var(--rubi-dark); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:hover { background: var(--rubi); }
.btn.is-loading { opacity: 1; cursor: progress; }

.btn.is-loading .btn-label { opacity: 0; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  margin: auto;
  border: 2px solid rgba(255, 244, 235, .35);
  border-top-color: var(--crudo);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.text-btn {
  justify-self: center;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: .88rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.form-hint,
.rsvp-note {
  margin-top: -8px;
  font-size: .88rem;
  color: var(--ink-soft);
  text-align: center;
}

.form-error {
  margin-top: -8px;
  color: var(--error);
  font-size: .92rem;
}

.rsvp-hello {
  color: var(--rubi);
  font-size: clamp(2.4rem, 10vw, 3rem);
}

.rsvp-previous {
  margin-top: -10px;
  padding: 10px 14px;
  border-left: 2px solid var(--flamingo);
  background: rgba(255, 190, 197, .22);
  font-size: .9rem;
}

/* Lista de pessoas do grupo, cada uma com um checkbox */
.people { display: grid; }

.person {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 8px 0;
  border-top: 1px solid var(--hairline);
  cursor: pointer;
}

.person:last-child { border-bottom: 1px solid var(--hairline); }

.person input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.person-box {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--rubi);
  border-radius: 50%;
  transition: background-color .2s;
}

.person-box svg {
  width: 12px;
  height: 12px;
  opacity: 0;
  transform: scale(.4);
  transition: opacity .2s, transform .25s cubic-bezier(.34, 1.56, .64, 1);
}

.person input:checked + .person-box { background: var(--rubi); }
.person input:checked + .person-box svg { opacity: 1; transform: none; }
.person input:focus-visible + .person-box { outline: 2px solid var(--rubi); outline-offset: 3px; }

.person-name {
  flex: 1;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.3;
}

.person-tag {
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}


.rsvp-done { justify-items: center; text-align: center; }
.rsvp-done:focus { outline: none; }

.done-seal {
  width: 96px;
  height: 96px;
  filter: drop-shadow(0 6px 8px rgba(30, 4, 6, .35));
}

.rsvp-done-title {
  color: var(--rubi);
  font-size: clamp(2.4rem, 10vw, 3rem);
}

.rsvp-done p:not(.script) { color: var(--ink-soft); }

.calendar-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.calendar-links .link-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 0;
}

.rsvp-done p.rsvp-save { margin-top: 8px; color: var(--rubi); }

/* ==========================================================================
   6 · Rodapé
   ========================================================================== */
.footer {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 24px 20px max(56px, env(safe-area-inset-bottom));
  text-align: center;
  color: var(--crudo);
  background-color: var(--merlot);
  background-image: var(--noise-light);
}

.footer-seal { width: 64px; height: 64px; }

.footer .script {
  color: var(--flamingo);
  font-size: 2.4rem;
}

.footer .eyebrow { opacity: .7; }

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