:root {
  --color-background: #1a1a1a;
  --color-text: #f5e6ea;
  --color-primary: #c0392b;
  --color-secondary: #e91e8c;
  --font-sans: 'Playfair Display', serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-cursive: 'Sacramento', cursive;
}

html, body {
  overflow-x: clip; /* clip não cria stacking context, não quebra sticky */
}

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

body {
  background-color: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.6;
}

#site-content {
  transition: filter 420ms ease;
}

body.intro-locked {
  overflow: hidden;
}

body.intro-locked #site-content {
  filter: blur(18px);
  pointer-events: none;
  user-select: none;
}

#intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.96);
  transition: opacity 360ms ease;
  perspective: 1600px;
}

#intro-overlay.is-fading {
  opacity: 0;
}

#intro-overlay.is-hidden {
  display: none;
}

#heart-door {
  width: 90vw;
  max-width: 1200px;
  height: auto;
  border: 0;
  background: transparent;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  -webkit-tap-highlight-color: transparent;
}

#heart-door:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.75);
  outline-offset: 8px;
}

.heart-half {
  width: 45vw;
  max-width: 600px;
  overflow: hidden;
  transition: transform 1250ms cubic-bezier(0.2, 0.85, 0.25, 1),
    filter 850ms ease;
  will-change: transform;
  transform-style: preserve-3d;
  filter: drop-shadow(0 22px 30px rgba(0, 0, 0, 0.35));
}

.heart-half.left {
  transform-origin: left center;
}

.heart-half.right {
  transform-origin: right center;
}

.heart-half svg {
  display: block;
  width: 90vw;
  max-width: 1200px;
  height: auto;
  fill: #c0392b;
}

.heart-half::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 520ms ease;
}

.heart-half.left::after {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0));
}

.heart-half.right::after {
  background: linear-gradient(270deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0));
}

.heart-half.right svg {
  transform: translateX(-50%);
}

#heart-door.is-open .heart-half.left {
  transform: rotateY(-90deg);
  filter: drop-shadow(-8px 18px 20px rgba(0, 0, 0, 0.35));
}

#heart-door.is-open .heart-half.right {
  transform: rotateY(90deg);
  filter: drop-shadow(8px 18px 20px rgba(0, 0, 0, 0.35));
}

#heart-door.is-open .heart-half::after {
  opacity: 1;
}

#intro-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: clamp(0.9rem, 1.7vw, 1.25rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  opacity: 0;
  transition: opacity 260ms ease;
  pointer-events: none;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  z-index: 2;
}

#intro-hint.is-visible {
  opacity: 1;
}

section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px 24px;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

/* 1. Tela de Entrada */
#hero {
  min-height: 100vh;
  justify-content: center;
  text-align: center;
}

.heart-icon {
  margin-bottom: 32px;
}

#hero h1 {
  font-size: 2rem;
  font-weight: 300;
  font-style: italic;
}

/* 2. Contador */
#counter {
  text-align: center;
}

#counter h2 {
  font-size: 1.25rem;
  opacity: 0.8;
  margin-bottom: 16px;
}

.time-display {
  font-size: 2rem;
  font-weight: bold;
  color: var(--color-secondary);
}

/* 3. Carta */
#letter {
  /* Sobrescreve o flex da regra global de section */
  display: block;
  width: 100%;
  padding: 0;
}

/* scroll-container é o trilho do sticky: precisa ocupar largura total e ter altura real */
.scroll-container {
  position: relative;
  width: 100%;
  height: 350vh;
}

.sticky-container {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  perspective: 1200px;
}

.letter-caption {
  display: block;
  padding: 24px 16px 0;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: center;
  color: rgba(245, 230, 234, 0.75);
  font-family: var(--font-mono);
}

.scene {
  position: relative;
  transform-style: preserve-3d;
  transform-origin: center center;
}

.envelope-wrapper {
  width: 320px;
  height: 220px;
  position: relative;
  transform-style: preserve-3d;
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: #d4c5ab;
  border-radius: 4px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  transform: translateZ(-10px);
}

.envelope-front-left {
  position: absolute;
  inset: 0;
  background: #dfd1b7;
  clip-path: polygon(0 0, 50% 50%, 0 100%);
  transform: translateZ(10px);
}

.envelope-front-right {
  position: absolute;
  inset: 0;
  background: #dfd1b7;
  clip-path: polygon(100% 0, 100% 100%, 50% 50%);
  transform: translateZ(10px);
}

.envelope-front-bottom {
  position: absolute;
  inset: 0;
  background: #e8dcc4;
  clip-path: polygon(0 100%, 50% 50%, 100% 100%);
  transform: translateZ(11px);
}

.envelope-flap {
  position: absolute;
  inset: 0;
  transform-origin: top;
  transform-style: preserve-3d;
  transform: translateZ(12px);
}

.flap-face,
.flap-back {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 50% 60%);
  backface-visibility: hidden;
}

.flap-face {
  background: #dccfae;
}

.flap-back {
  background: #c5b699;
  transform: rotateY(180deg);
}

.wax-seal {
  position: absolute;
  left: 50%;
  top: 60%;
  width: 40px;
  height: 40px;
  background: #8b0000;
  border-radius: 50%;
  transform: translate(-50%, -50%) translateZ(1px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  color: #500000;
  font-size: 24px;
  font-family: serif;
  backface-visibility: hidden;
}

.wax-seal::after {
  content: '♥';
}

.paper-wrapper {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  bottom: 10px;
  transform-style: preserve-3d;
  transform: translateZ(0px);
}

.paper {
  position: absolute;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

.paper-middle {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #fdfbf7;
  transform-style: preserve-3d;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.paper-top {
  position: absolute;
  width: 100%;
  height: 100%;
  bottom: calc(100% - 1px);
  left: 0;
  transform-origin: bottom;
  transform-style: preserve-3d;
  transform: rotateX(-178deg);
}

.paper-bottom {
  position: absolute;
  width: 100%;
  height: 100%;
  top: calc(100% - 1px);
  left: 0;
  transform-origin: top;
  transform-style: preserve-3d;
  transform: rotateX(178deg);
}

.paper-face,
.paper-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  /* Cada dobra da carta deve recortar seu próprio conteúdo.
     O texto total é distribuído via JS entre as faces. */
  overflow: hidden;
}

.paper-face {
  background: linear-gradient(135deg, #fdfbf7 0%, #f4ebd8 100%);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.05);
}

.paper-back {
  background: linear-gradient(135deg, #f0e6d2 0%, #e8dcc4 100%);
  transform: rotateX(180deg);
}

.paper-content {
  padding: 14px 18px;
  box-sizing: border-box;
  color: #333;
  font-size: 1rem;
  line-height: 1.6;
  text-align: justify;
}

#letter h2 {
  font-family: var(--font-cursive);
  font-size: 28px;
  margin-top: 0;
  margin-bottom: 10px;
  color: #2c1e16;
}

.paper-content p {
  margin-top: 0;
  margin-bottom: 15px;
  color: #4a3f35;
}

.signature {
  font-family: var(--font-cursive);
  font-size: 24px;
  text-align: right;
  margin-top: 20px;
  color: #2c1e16;
}

/* Mobile: carta maior na tela e envelope ajustado ao viewport vertical */
@media (max-width: 768px) {
  .sticky-container {
    height: 100vh;
    padding: 0 12px;
  }

  .envelope-wrapper {
    width: min(240px, 88vw);
    height: calc(240px * (220 / 320)); /* mantém proporção original */
  }

  .scroll-section {
    /* No mobile também deixamos mais espaço de scroll para a carta */
    height: 140vh;
  }

  /* Texto da carta mais legível no mobile (tamanho menor, SEM cortar linhas) */
  #letter h2 {
    font-size: 24px;
  }

  #letter .paper-content {
    padding: 10px 14px;
    font-size: 0.9rem;
    line-height: 1.5;
  }

  #letter .paper-content p {
    font-size: 0.8rem;
  }

  .letter-caption {
    margin-top: 0px;
    font-size: 0.78rem;
    padding: 0 16px;
  }
}

/* 4–6. Galeria de memórias (baseada em /gallery) */
.scroll-gallery {
  padding: 64px 24px 80px;
}

.scroll-gallery-header {
  text-align: center;
  margin-bottom: 40px;
}

.scroll-gallery-title {
  font-family: var(--font-cursive);
  font-size: 3rem;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.scroll-gallery-subtitle {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.65);
}

.gallery {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22vh;
  padding: 0 8px 24vh;
}

.gallery-item {
  position: relative;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  border-radius: 6px;
}

.gallery-text {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.2rem 1.8rem;
  background-color: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: #f6f1ea;
  line-height: 1.5;
}

.gallery-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background-size: cover;
  background-position: center;
  background-color: #2b2623;
  transform: translateX(100%);
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 1;
}

.gallery-caption {
  font-family: var(--font-serif);
  font-style: italic;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  padding-top: 1.2rem;
  padding-bottom: 0.5rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  transition-delay: 0s;
  position: relative;
  z-index: 2;
  font-size: 1rem;
}

/* 6. Textos / citações finais */
#text-section {
  padding: 56px 24px 80px;
}

#text-section > div {
  max-width: 640px;
  margin: 0 auto 24px; /* espaçamento entre cada bloco */
  text-align: left;
}

#text-section h3 {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.6;
  font-weight: 400;
  color: #f6f1ea;
  margin-bottom: 4px;
}

#text-section p:not(.quote-label) {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: rgba(245, 230, 234, 0.75);
  margin-bottom: 30px;
  text-indent: 15px;
  text-align: justify;
}

#text-section p.quote-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: rgba(245, 230, 234, 0.6);
  margin-top: 2px;
  margin-bottom: 60px;
  text-indent: 0;
  text-align: right;
}

/* Espaçamentos finos dentro do text-section */
#text-section br {
  display: block;
  margin-top: 12px; /* espacinho logo acima da linha quebrada */
}

#text-section hr {
  border: 0;
  border-top: 1px solid rgba(245, 230, 234, 0.25);
  margin: 18px 0 20px; /* espaço acima e abaixo do separador */
}

#text-section h3 {

  margin-top: 50px
}

.gallery-item.is-active .gallery-image {
  transform: translateX(0);
}

.gallery-item.is-active .gallery-caption {
  opacity: 1;
  transition-delay: 0.6s;
}

/* Kirby runner (gif correndo de um lado ao outro) */
.kirby-runner {
  position: relative;
  width: 100%;
  height: 90px; /* altura aproximada do gif */
  margin: 16px 0 8px;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}

.kirby-sprite {
  position: absolute;
  top: 0;
  /* Move o container mais para a esquerda para que
     Yoshi E Kirby comecem totalmente fora da tela */
  left: -160px;
  width: 80px;
  height: auto;
  transform: translateX(0);
  opacity: 0;
}

.kirby-sprite.is-running {
  opacity: 1;
  animation: kirby-run var(--kirby-duration, 2s) linear forwards;
}

.kirby-runner.is-reverse .kirby-sprite {
  left: auto;
  right: -12vw;
}

.kirby-runner.is-reverse .kirby-sprite.is-running {
  animation-name: kirby-run-reverse;
}

.kirby-runner.is-reverse .runner-yoshi,
.kirby-runner.is-reverse .runner-kirby {
  transform: scaleX(-1);
  transform-origin: center;
}

@keyframes kirby-run {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(100vw + 150px));
  }
}

@keyframes kirby-run-reverse {
  0% {
    transform: translateX(0);
  }
  100% {
    /* Garante que Yoshi + Kirby saiam por completo antes de reiniciar */
    transform: translateX(calc(-100vw - 320px));
  }
}

.runner-yoshi,
.runner-kirby {
  position: absolute;
  top: 0;           /* mesma altura */
  width: 80px;
  height: auto;
  image-rendering: pixelated;
}

.runner-yoshi {
  left: 0;
}

.runner-kirby {
  left: 84px;       /* 80px (largura do Yoshi) + 4px de distância */
}

/* 7. Mensagem Final */
#final-message {
  padding: 160px 24px;
  text-align: center;
}

#final-message h2 {
  font-size: 3.5rem;
  color: var(--color-primary);
}

/* 8. Footer */
footer {
  padding: 40px 24px;
  text-align: center;
  opacity: 0.3;
}

footer p {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Responsividade */
@media (min-width: 768px) {
  #hero h1 { font-size: 3rem; }
  .time-display { font-size: 3.5rem; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .polaroid-row { justify-content: center; }
  #final-message h2 { font-size: 6rem; }
}

@media (min-width: 1024px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Corações caindo no fundo (canvas em hearts.js) */
.falling-hearts {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.falling-hearts canvas {
  display: block;
  width: 100%;
  height: 100%;
}
