/* =========================================================
   Ana & Jorge — Save the Date
   Referência: template Canva "Save the Date" (envelope de renda,
   selo de cera, nomes em manuscrito, foto em arco, contagem, RSVP).

   O envelope é conduzido por scroll através de variáveis CSS que o
   script.js reescreve a cada frame: --flap, --fade, --std.
   ========================================================= */

:root {
  --paper:     #efe7db;   /* fundo, marfim quente          */
  --paper-2:   #e7dccb;
  --env-a:     #f1e9dc;   /* envelope, topo do gradiente   */
  --env-b:     #e1d4bf;   /* envelope, base                */
  --env-flap:  #e9dccb;
  --ink:       #4b463d;   /* texto, carvão quente          */
  --ink-soft:  #8c8274;
  --line:      #d9ccb6;
  --wax:       #ede3d3;   /* selo de cera, pérola          */
  --gold:      #b79a68;   /* detalhe subtil                */
  --accent:    #5f584c;   /* secção RSVP                   */
  --accent-2:  #6d6555;

  --script: "Pinyon Script", "Segoe Script", cursive;
  --serif:  "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans:   "Jost", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --measure: 34rem;
  --ease:    cubic-bezier(.22, .61, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-behavior: smooth; background: var(--paper); }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 1.0625rem;
  line-height: 1.75;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 400; }
p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }
a { color: inherit; }

/* etiquetas pequenas em maiúsculas espaçadas (o estilo "WITH COUNTDOWN…") */
.eyebrow, .std__join, .clock__lbl, .subnav, .dock__btn, .btn,
.footer, .rsvp label {
  font-family: var(--sans);
  letter-spacing: .24em;
  text-transform: uppercase;
}

.script-title {
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(2.6rem, 8vw, 4rem);
  line-height: 1;
  color: var(--ink);
  text-align: center;
  margin-bottom: 1.6rem;
}
.script-title--light { color: var(--paper); }

.lead { max-width: var(--measure); margin-inline: auto; }
.small { font-size: .88rem; color: var(--ink-soft); }

.link {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(183, 154, 104, .4);
  transition: border-color .2s;
}
.link:hover { border-bottom-color: var(--gold); }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 2px; }


/* =========================================================
   BOTÕES FLUTUANTES (relógio + calendário da referência)
   ========================================================= */

.dock {
  position: fixed;
  top: 50%;
  left: clamp(.6rem, 2vw, 1.4rem);
  translate: 0 -50%;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: .8rem;
}
.dock__btn {
  width: 3rem; height: 3rem;
  display: grid; place-items: center;
  background: rgba(255, 253, 249, .85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 8px 20px -10px rgba(75, 70, 61, .5);
  color: var(--ink);
  transition: transform .25s var(--ease), background-color .25s;
}
.dock__btn:hover { transform: scale(1.08); background: #fff; }
.dock__btn svg {
  width: 1.25rem; height: 1.25rem;
  fill: none; stroke: currentColor; stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
}


/* =========================================================
   ABERTURA
   Base (sem JS) = sem envelope; o "Save the Date" é conteúdo normal.
   ========================================================= */

.reveal { position: relative; }
.envelope, .reveal__hint { display: none; }

.js .reveal {
  height: 200vh;
  --flap: 0;   /* 0..1  aba a abrir              */
  --fade: 0;   /* 0..1  envelope a desvanecer    */
  --std:  0;   /* 0..1  save the date a aparecer */
}

.js .envelope { display: flex; }
.js .reveal__hint { display: flex; }

.js .reveal__sticky {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 4vh, 2.4rem);
  overflow: hidden;
}


/* ---------- ENVELOPE FECHADO ---------- */

.envelope {
  position: relative;
  width: min(88vw, 23rem);
  height: min(84svh, 42rem);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 1600px;
  flex-direction: column;
  /* afasta-se e desvanece à medida que abre */
  opacity: calc(1 - var(--fade));
  scale: calc(1 - var(--fade) * .12);
  translate: 0 calc(var(--fade) * -4vh);
  animation: float 8s ease-in-out infinite;
  /* promove a camada de GPU: o telemóvel compõe transform/opacity
     sem repintar os gradientes de ecrã inteiro a cada frame */
  will-change: transform, opacity;
}
@keyframes float { 0%,100% { translate: 0 0; } 50% { translate: 0 -8px; } }

/* No telemóvel ocupa o ecrã inteiro. */
@media (max-width: 46rem) {
  .envelope { width: 100vw; height: 100svh; animation: none; }
  .js .reveal__sticky { gap: 0; }
  .reveal__hint { position: absolute; bottom: clamp(1.4rem, 5vh, 2.5rem); }
}

.envelope__shadow {
  position: absolute; inset: 0;
  border-radius: 6px;
  box-shadow: 0 40px 70px -30px rgba(75, 70, 61, .55);
}

/* corpo texturado */
.envelope__body {
  position: absolute; inset: 0;
  z-index: 2;
  border-radius: 6px;
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255,255,255,.5), transparent 60%),
    linear-gradient(160deg, var(--env-a), var(--env-b));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(3.5rem, 13vh, 7rem) 1.5rem 0;
}
/* textura de papel muito subtil (sem mix-blend-mode: em telemóvel o
   blend força renderização fora do compositor e causa stutter) */
.envelope__body::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(90deg, rgba(75,70,61,.022) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(0deg, rgba(75,70,61,.022) 0 2px, transparent 2px 4px);
}
@media (max-width: 46rem) { .envelope__body { border-radius: 0; } }

.envelope__eyebrow {
  font-family: var(--sans);
  font-size: clamp(.6rem, 2.6vw, .72rem);
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .8rem;
}
.envelope__names {
  font-family: var(--script);
  font-size: clamp(3.2rem, 11vw, 4.2rem);
  line-height: .95;
  color: var(--ink);
  text-align: center;
}
.envelope__names em { font-style: normal; display: block; font-size: .5em; color: var(--gold); }

/* nomes e eyebrow ficam por cima do desenho SVG */
.envelope__eyebrow, .envelope__names { position: relative; z-index: 2; }

/* desenho do envelope: preenche o corpo, por trás do texto */
.env-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
  perspective: 900px;   /* dá profundidade à dobra da frente */
}

/* frente do envelope: dobra para baixo/fora ao abrir (--flap) */
.env-front {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: rotateX(calc(var(--flap) * 158deg));
  backface-visibility: hidden;
  will-change: transform;
}


/* ---------- indicação ---------- */

.reveal__hint {
  flex-direction: column;
  align-items: center;
  gap: .8rem;
  margin: 0;
  font-family: var(--sans);
  font-size: .66rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: clamp(0, calc(1 - var(--flap) * 3), 1);
}
.reveal__hint-line {
  width: 1px; height: 2.2rem;
  background: linear-gradient(to bottom, transparent, var(--gold));
  animation: hint 2.2s var(--ease) infinite;
  transform-origin: top;
}
@keyframes hint { 0%,100% { scale: 1 .3; opacity: .35; } 50% { scale: 1 1; opacity: 1; } }


/* =========================================================
   SAVE THE DATE (revelado no mesmo palco)
   ========================================================= */

/* Base (sem JS): conteúdo normal, centrado, sem sobreposição. */
.std {
  max-width: 40rem;
  margin-inline: auto;
  padding: clamp(3rem, 10vh, 6rem) 1.5rem;
  text-align: center;
}

/* Com JS entra no palco sticky, por cima do envelope, e aparece
   à medida que o envelope se desvanece. */
.js .std {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 5vh, 3rem);
  opacity: var(--std);
  scale: calc(.96 + var(--std) * .04);
  visibility: hidden;      /* ligado pelo script quando aparece */
  will-change: transform, opacity;
}
.js .reveal.std-on .std { visibility: visible; }

.std__inner { position: relative; width: min(92vw, 30rem); }

/* foto em arco */
.arch {
  position: relative;
  width: min(66vw, 15rem);
  margin: 0 auto 1.4rem;
  translate: 0 calc((1 - var(--std)) * 2rem);   /* sobe ao aparecer */
  will-change: transform;
}
.arch__photo {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 50% 50% 8px 8px / 42% 42% 6px 6px;   /* topo em arco */
  border: 6px solid #fff;
  box-shadow: 0 18px 40px -18px rgba(75,70,61,.5);
  overflow: hidden;
}
.arch__photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 30%;   /* mantém os rostos enquadrados */
  display: block;
  /* aquece a foto (originalmente em tons frios) para condizer com o marfim */
  filter: sepia(.24) saturate(.9) contrast(.97) brightness(1.03);
}
/* véu quente por cima, muito ligeiro */
.arch__photo::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(183,154,104,.22), rgba(239,231,219,.14));
  mix-blend-mode: soft-light;
  pointer-events: none;
}
.arch__seal {
  position: absolute;
  right: -.4rem; bottom: 1.4rem;
  width: 4.4rem; height: 4.4rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(60% 55% at 40% 32%, #fdfaf4, var(--wax) 55%, #d9cdb7);
  box-shadow: 0 6px 14px rgba(75,70,61,.3), inset 0 2px 4px rgba(255,255,255,.7);
  font-family: var(--script);
  font-size: 1.05rem;
  line-height: .9;
  color: #9c8c6f;
  text-align: center;
}

/* polaroids soltas, encostadas ao arco */
.polaroid {
  position: absolute;
  width: 5rem;
  padding: .35rem .35rem .9rem;
  background: #fff;
  box-shadow: 0 12px 26px -12px rgba(75,70,61,.5);
  z-index: 2;
}
.polaroid span {
  display: block;
  aspect-ratio: 1;
  background-size: cover;
  background-position: center;
  /* mesmo tratamento quente do arco */
  filter: sepia(.24) saturate(.9) contrast(.97) brightness(1.03);
}
.polaroid--1 { top: -1.4rem; right: -2.6rem; rotate: 8deg; }
.polaroid--1 span { background-image: url("img/photo2_mini.png"); background-position: 46% 30%; }
.polaroid--2 { bottom: -1rem; left: -2.6rem; rotate: -7deg; }
.polaroid--2 span { background-image: url("img/photo3_mini.png"); background-position: 50% 48%; }

/* No telemóvel encolhem e encostam-se mais ao arco, para caberem no ecrã. */
@media (max-width: 30rem) {
  .polaroid { width: 3.9rem; padding: .28rem .28rem .7rem; }
  .polaroid--1 { top: -.8rem; right: -1.2rem; }
  .polaroid--2 { bottom: -.6rem; left: -1.2rem; }
}

.std__names {
  font-family: var(--script);
  font-size: clamp(3rem, 13vw, 4.6rem);
  line-height: 1;
  margin-bottom: .5rem;
  color: var(--ink);
}
.std__names em { font-style: normal; color: var(--gold); }
.std__names:focus { outline: none; }

.std__date {
  display: flex; align-items: center; justify-content: center;
  gap: .6rem;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  letter-spacing: .08em;
  color: var(--ink);
  margin-bottom: 1.4rem;
}
.std__date i { color: var(--gold); font-style: normal; }

.std__join {
  font-size: .66rem; letter-spacing: .28em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: .3rem;
}
.std__place {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  letter-spacing: .18em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.std__note { font-family: var(--serif); font-style: italic; color: var(--ink-soft); }


/* =========================================================
   CONTAGEM DECRESCENTE
   ========================================================= */

.countdown { text-align: center; }
.clock {
  display: flex;
  justify-content: center;
  gap: clamp(1rem, 5vw, 3rem);
  max-width: 40rem;
  margin: 0 auto;
}
.clock__unit { display: flex; flex-direction: column; align-items: center; }
.clock__num {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 11vw, 4.2rem);
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.clock__lbl {
  font-size: .62rem; letter-spacing: .24em; text-transform: uppercase;
  color: var(--ink-soft); margin-top: .5rem;
}
.clock__done { font-family: var(--serif); font-style: italic; font-size: 1.3rem; margin-top: 1.5rem; }


/* =========================================================
   NAV + SECÇÕES
   ========================================================= */

.subnav {
  position: sticky; top: 0; z-index: 40;
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: .25rem 1.6rem;
  padding: 1rem 1.5rem;
  background: rgba(239, 231, 219, .9);
  backdrop-filter: blur(10px);
  border-block: 1px solid var(--line);
  font-size: .64rem; letter-spacing: .2em;
}
.subnav a { text-decoration: none; color: var(--ink-soft); transition: color .2s; }
.subnav a:hover { color: var(--gold); }

.section { padding: clamp(3.5rem, 11vh, 6.5rem) 1.5rem; }
.section > *:not(.clock):not(form) { max-width: var(--measure); margin-inline: auto; }
.section p { text-align: center; }

.section--tint { background: var(--paper-2); }
.section--accent { background: var(--accent); color: var(--paper); }
.section--accent .lead strong { color: #fff; }
.section--accent .small { color: rgba(239,231,219,.75); }
.section--accent .link { color: #e8dcc4; border-bottom-color: rgba(232,220,196,.5); }

.schedule { margin-inline: auto; }
.schedule__row {
  display: grid; grid-template-columns: 5.5rem 1fr; gap: 1.25rem;
  padding: 1.15rem 0; border-top: 1px solid var(--line); text-align: left;
}
.schedule__row:last-child { border-bottom: 1px solid var(--line); }
.schedule dt { font-family: var(--serif); font-size: 1.4rem; color: var(--gold); }
.schedule dd { margin: 0; }
.schedule dd strong { font-weight: 400; letter-spacing: .04em; }

.plain-list { list-style: none; padding: 0; margin: 0 auto 1.1em; max-width: var(--measure); }
.plain-list li { padding: .55rem 0; border-bottom: 1px solid var(--line); text-align: center; }


/* =========================================================
   RSVP
   ========================================================= */

.btn {
  display: inline-block;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .2em;
  text-decoration: none; cursor: pointer;
  padding: 1em 2.6em;
  border: 1px solid currentColor;
  background: transparent;
  color: var(--ink);
  transition: background-color .3s, color .3s;
}
.btn--light { color: var(--paper); }
.btn--light:hover { background: var(--paper); color: var(--accent); }

.rsvp {
  max-width: 34rem;
  margin: 2rem auto 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem 1.4rem;
  text-align: left;
}
.rsvp__field { display: flex; flex-direction: column; gap: .4rem; }
.rsvp__field--full { grid-column: 1 / -1; }
.rsvp label { font-size: .6rem; color: rgba(239,231,219,.85); }
.rsvp input, .rsvp select, .rsvp textarea {
  font-family: var(--sans); font-size: 1rem; font-weight: 300;
  color: var(--paper);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(239,231,219,.35);
  border-radius: 3px;
  padding: .7em .8em;
}
.rsvp input:focus, .rsvp select:focus, .rsvp textarea:focus {
  outline: none; border-color: var(--paper); background: rgba(255,255,255,.12);
}
.rsvp select option { color: #333; }
.rsvp__hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.rsvp__status { margin: .8rem 0 0; font-size: .9rem; min-height: 1.2em; }
@media (max-width: 34rem) { .rsvp { grid-template-columns: 1fr; } }


/* =========================================================
   RODAPÉ
   ========================================================= */

.footer {
  text-align: center; padding: 4rem 1.5rem;
  font-size: .66rem; letter-spacing: .18em; color: var(--ink-soft);
  border-top: 1px solid var(--line);
}
.footer__names {
  font-family: var(--script);
  font-size: 2.4rem; letter-spacing: 0; text-transform: none;
  color: var(--ink); margin-bottom: .3rem;
}
.footer p { margin-bottom: .4em; }


/* ---------- aparecer ao entrar no ecrã ---------- */
.js [data-anim] {
  opacity: 0; translate: 0 1.4rem;
  transition: opacity .8s var(--ease), translate .8s var(--ease);
}
.js [data-anim].in { opacity: 1; translate: 0 0; }


/* =========================================================
   Movimento reduzido — sem envelope, sem deslizes.
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .js .envelope, .js .reveal__hint { display: none; }
  .js .reveal { height: auto; }
  .js .reveal__sticky { position: static; height: auto; overflow: visible; padding: 2rem 0; }
  .js .std { position: static; inset: auto; opacity: 1; visibility: visible; scale: 1; display: block; }
  .js .arch { translate: 0 0; }
  .js [data-anim] { opacity: 1; translate: 0 0; transition: none; }

  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
