:root {
  --noite: #160c28;
  --ameixa: #2a1648;
  --violeta: #5b2d86;
  --lilas: #c9a6f0;
  --lavanda: #e9d7ff;
  --creme: #fbf6ef;
  --papel: #fffaf4;
  --tinta: #2a1638;
  --tinta-suave: #6a5478;
  --ouro: #e8c56a;
  --ouro-escuro: #b8892c;
  --selo: #7a2e96;
  --aviso: #fff1c7;
  --serif: "Cormorant Garamond", Georgia, serif;
  --script: "Great Vibes", "Segoe Script", cursive;
  --sans: "Outfit", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  background: var(--noite);
}

body {
  position: relative;
  min-height: 100dvh;
  color: var(--lavanda);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, #5a2d88 0%, transparent 58%),
    radial-gradient(circle at 85% 80%, #3a1860 0%, transparent 40%),
    radial-gradient(circle at 12% 70%, #241040 0%, transparent 42%),
    var(--noite);
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.22;
  background-image: 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%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--ouro);
  outline-offset: 4px;
}

button {
  font: inherit;
  color: inherit;
}

.skip {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 40;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--creme);
  color: var(--tinta);
  text-decoration: none;
  transform: translateY(-120%);
}

.skip:focus {
  transform: none;
}

.sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 12%, #f3e0ff 50%, transparent 51%),
    radial-gradient(1px 1px at 32% 42%, #ffe9a8 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 48%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 72%, #e9d7ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 62% 78%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 44% 8%, #fff 50%, transparent 51%);
  animation: twinkle 4.8s ease-in-out infinite;
}

@keyframes twinkle {
  0%,
  100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.confetti,
.pinguins {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.confetti {
  z-index: 30;
}

.pinguins {
  z-index: 35;
}

/* ---------- Capa ---------- */

.capa {
  position: relative;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  min-height: 100dvh;
  padding: calc(28px + var(--safe-top)) 20px calc(36px + var(--safe-bottom));
  gap: 18px;
}

.brilho {
  position: absolute;
  width: min(420px, 80vw);
  height: min(420px, 80vw);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 197, 106, 0.28), transparent 68%);
  filter: blur(8px);
  animation: pulse 5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.08); opacity: 1; }
}

.capa__texto {
  position: relative;
  text-align: center;
  margin-bottom: 8px;
}

.capa__kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--lilas);
}

.capa__titulo {
  margin: 0;
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(42px, 12vw, 64px);
  line-height: 1;
  color: #fff8ee;
  text-shadow: 0 8px 28px rgba(20, 8, 40, 0.45);
}

.capa__de {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--lavanda);
}

.dica {
  position: relative;
  margin: 10px 0 0;
  font-size: 15px;
  font-style: italic;
  color: #d8c4f4;
  animation: bounce-hint 2.4s ease-in-out infinite;
}

@keyframes bounce-hint {
  0%,
  100% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(5px); opacity: 1; }
}

/* ---------- Balões ---------- */

.balao {
  position: absolute;
  width: 34px;
  height: 44px;
  border-radius: 50% 50% 50% 50% / 42% 42% 58% 58%;
  opacity: 0.9;
  animation: float 7s ease-in-out infinite;
}

.balao::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 54px;
  background: linear-gradient(#e9d7ff, transparent);
}

.balao::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  width: 8px;
  height: 8px;
  translate: -50% 0;
  background: inherit;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.balao--a {
  left: 8%;
  top: 14%;
  background: linear-gradient(#f3e0ff, #b57be8);
  animation-delay: -1s;
}

.balao--b {
  right: 10%;
  top: 18%;
  width: 28px;
  height: 38px;
  background: linear-gradient(#ffe9a8, #e0a84a);
  animation-delay: -3s;
}

.balao--c {
  left: 14%;
  bottom: 12%;
  width: 26px;
  height: 36px;
  background: linear-gradient(#ffd6ec, #d46aa8);
  animation-delay: -2s;
}

.balao--d {
  right: 12%;
  bottom: 16%;
  background: linear-gradient(#e4d7ff, #7a5ad0);
  animation-delay: -4.5s;
}

.pinguim {
  position: absolute;
  width: 34px;
  height: 34px;
  background: url("penguin.svg?v=20251113-v2") center / contain no-repeat;
  opacity: 0.88;
  filter: drop-shadow(0 4px 8px rgba(8, 2, 20, 0.35));
  animation: waddle 6s ease-in-out infinite;
}

.pinguim--a {
  left: 6%;
  top: 42%;
  animation-delay: -0.5s;
}

.pinguim--b {
  right: 7%;
  top: 46%;
  width: 28px;
  height: 28px;
  animation-delay: -2.2s;
  transform: scaleX(-1);
}

.pinguim--c {
  right: 22%;
  bottom: 8%;
  width: 24px;
  height: 24px;
  opacity: 0.65;
  animation-delay: -3.8s;
}

@keyframes waddle {
  0%,
  100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-8px) rotate(6deg); }
}

.pinguim--b {
  animation-name: waddle-flip;
}

@keyframes waddle-flip {
  0%,
  100% { transform: scaleX(-1) translateY(0) rotate(-6deg); }
  50% { transform: scaleX(-1) translateY(-8px) rotate(6deg); }
}

@keyframes float {
  0%,
  100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-16px) rotate(5deg); }
}

/* ---------- Envelope ---------- */

.envelope {
  position: relative;
  z-index: 3;
  width: min(360px, 92vw);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.envelope:hover,
.envelope:focus-visible {
  transform: translateY(-6px) rotate(-0.8deg);
}

.envelope__cena {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1.52;
  perspective: 1400px;
  transform-style: preserve-3d;
}

.envelope__papel-env {
  background-color: #ebe2f8;
  background-image:
    linear-gradient(
      155deg,
      rgba(255, 255, 255, 0.65) 0%,
      transparent 42%
    ),
    linear-gradient(330deg, rgba(106, 56, 148, 0.12), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
  box-shadow:
  0 1px 0 rgba(255, 255, 255, 0.85) inset,
  0 22px 48px -22px rgba(10, 4, 24, 0.75);
}

.envelope__papel-env--forro {
  background-color: #ddd0f0;
  background-image:
    linear-gradient(160deg, rgba(122, 70, 170, 0.18), transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
}

.envelope__sombra {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -14%;
  height: 28%;
  background: radial-gradient(ellipse at center, rgba(6, 2, 14, 0.55), transparent 72%);
  filter: blur(12px);
  z-index: 0;
}

.envelope__costas {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  z-index: 1;
}

.envelope__dobra {
  position: absolute;
  inset: 0;
  z-index: 2;
  filter: drop-shadow(0 1px 1px rgba(40, 16, 60, 0.1));
}

.envelope__dobra--esq {
  clip-path: polygon(0 0, 50% 52%, 0 100%);
}

.envelope__dobra--dir {
  clip-path: polygon(100% 0, 50% 52%, 100% 100%);
}

.envelope__cartinha {
  position: absolute;
  left: 11%;
  right: 11%;
  top: 14%;
  height: 58%;
  z-index: 3;
  border-radius: 3px 3px 0 0;
  background:
    linear-gradient(180deg, #fffefb 0%, #f8f2ea 100%);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.9) inset,
    0 -8px 16px rgba(80, 40, 120, 0.08) inset,
    0 6px 14px rgba(20, 8, 40, 0.15);
  transform: translateY(38%) scale(0.96);
  transition:
    transform 1.05s 0.45s cubic-bezier(0.22, 0.82, 0.18, 1),
    box-shadow 0.6s ease;
}

.envelope__cartinha::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 18px;
  height: 3px;
  border-radius: 2px;
  background: rgba(201, 166, 240, 0.55);
}

.envelope__frente {
  position: absolute;
  inset: 0;
  z-index: 4;
  clip-path: polygon(0 34%, 50% 62%, 100% 34%, 100% 100%, 0 100%);
  border-radius: 0 0 6px 6px;
  display: flex;
  align-items: flex-end;
  padding: 0 24px 20px;
}

.envelope__endereco {
  position: relative;
  z-index: 1;
  text-align: left;
}

.envelope__para {
  font-family: var(--script);
  font-size: 19px;
  color: #7c5e99;
  line-height: 1;
}

.envelope__nome {
  font-family: var(--script);
  font-size: clamp(32px, 9.5vw, 42px);
  line-height: 0.95;
  color: var(--tinta);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.envelope__de {
  margin-top: 2px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--tinta-suave);
}

.envelope__aba {
  position: absolute;
  inset: 0 0 auto 0;
  height: 52%;
  z-index: 6;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  border-radius: 6px 6px 0 0;
  filter: drop-shadow(0 4px 3px rgba(30, 12, 50, 0.14));
  transition: transform 0.85s cubic-bezier(0.55, 0.06, 0.22, 1);
}

.envelope__lacre {
  position: absolute;
  left: 50%;
  top: 51%;
  z-index: 8;
  width: 74px;
  height: 74px;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  transition:
    opacity 0.45s ease,
    transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.envelope__lacre-cera {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #e4b8ff, #9b4dc4 42%, #5a1a78 78%, #3d0f55);
  box-shadow:
    inset 0 3px 6px rgba(255, 255, 255, 0.35),
    inset 0 -5px 10px rgba(0, 0, 0, 0.28),
    0 0 0 3px rgba(255, 248, 238, 0.25),
    0 8px 20px rgba(12, 4, 28, 0.45);
}

.envelope__lacre-cera::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.22);
}

.envelope__lacre-pinguim {
  position: relative;
  z-index: 1;
  width: 46px;
  height: 46px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
}

.abrindo .envelope__lacre {
  opacity: 0;
  transform: scale(0.25) rotate(18deg);
}

.abrindo .envelope__aba {
  transform: rotateX(178deg);
  z-index: 2;
}

.abrindo .envelope__frente {
  z-index: 5;
}

.carta-saindo .envelope__cartinha {
  z-index: 12;
  transform: translateY(-72%) scale(1.02) rotate(-1.5deg);
  box-shadow:
    0 24px 40px -12px rgba(20, 8, 40, 0.35),
    0 2px 0 rgba(255, 255, 255, 0.95) inset;
}

.carta-saindo .envelope__cena {
  transform: translateY(10px) scale(0.98);
  transition: transform 0.8s ease;
}

.abrindo .dica,
.abrindo .capa__texto,
.abrindo .balao,
.abrindo .pinguim,
.capa.sumindo {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.capa.sumindo {
  pointer-events: none;
}

/* ---------- Carta ---------- */

.carta {
  position: relative;
  z-index: 2;
  width: min(680px, calc(100% - 28px));
  margin: calc(20px + var(--safe-top)) auto calc(48px + var(--safe-bottom));
  padding: clamp(28px, 7vw, 64px) clamp(22px, 6vw, 64px) clamp(36px, 7vw, 56px);
  color: var(--tinta);
  background-color: var(--papel);
  background-image:
    linear-gradient(90deg, transparent 0, transparent 18px, rgba(201, 166, 240, 0.28) 18px, rgba(201, 166, 240, 0.28) 20px, transparent 20px),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(1.7em - 1px),
      rgba(90, 50, 120, 0.08) calc(1.7em - 1px),
      rgba(90, 50, 120, 0.08) 1.7em
    );
  border-radius: 4px;
  box-shadow:
    0 30px 60px -28px rgba(8, 2, 20, 0.7),
    0 0 0 1px rgba(255, 255, 255, 0.4) inset;
}

.carta.expandindo {
  animation: carta-expandir 0.95s cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

@keyframes carta-expandir {
  from {
    opacity: 0;
    transform: translateY(26vh) scale(0.86);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.fim-carta {
  display: block;
  width: 100%;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.aviso {
  margin: 0 0 1.4em;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--aviso);
  color: #5a4310;
  font-size: 13px;
  line-height: 1.4;
}

.carta__data {
  margin: 0 0 0.4em;
  font-family: var(--script);
  font-size: 24px;
  color: var(--tinta-suave);
  text-align: right;
}

.carta__saudacao {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(32px, 8vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.carta__feliz {
  margin: 0.15em 0 1.1em;
  font-family: var(--script);
  font-size: clamp(34px, 9vw, 48px);
  line-height: 1;
  color: var(--violeta);
}

.carta__texto p {
  margin: 0 0 1.7em;
  font-family: var(--serif);
  font-size: clamp(19px, 4.6vw, 22px);
  line-height: 1.7;
  max-width: 46ch;
}

.carta__assinatura {
  margin: 0.4em 0 1.6em;
}

.carta__assinatura p {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
}

.carta__nome {
  font-family: var(--script) !important;
  font-style: normal !important;
  font-size: 48px !important;
  line-height: 1.1;
  color: var(--violeta);
}

.guardar {
  display: inline-block;
  margin-top: 28px;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--tinta);
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 8px 18px -12px rgba(20, 8, 40, 0.5);
}

.guardar {
  display: block;
  margin: 8px auto 0;
  background: transparent;
  border: 1.5px solid var(--tinta);
  box-shadow: none;
}

.guardar:hover,
.guardar:focus-visible {
  background: var(--tinta);
  color: var(--papel);
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .carta { margin-top: 16px; }
  .capa { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .sparkles,
  .balao,
  .brilho {
    animation: none;
  }

  .dica {
    opacity: 1;
  }
}
