/* =========================================================================
   "Para ti" — corcho de recuerdos de cafeteria
   Mobile-first (base 375-430px) -> escala con media queries min-width.
   ========================================================================= */

:root {
  /* Paleta exacta */
  --corcho:   #AD8558;
  --polaroid: #FAF6EC;
  --espresso: #2B1D14;
  --caramelo: #D68C3E;
  --vino:     #7A3B34;
  --musgo:    #6E7A4F;

  /* Derivados utiles */
  --corcho-oscuro: #96714a;
  --sombra: 0 8px 22px rgba(43, 29, 20, 0.28);
  --sombra-suave: 0 3px 10px rgba(43, 29, 20, 0.2);

  /* Tipografia */
  --f-mano:  "Caveat", "Segoe Script", cursive;
  --f-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --f-mono:  "Space Mono", ui-monospace, "Courier New", monospace;

  /* Easing personalizados (segun spec) */
  --ease-reveal: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-rebote: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--espresso);
  font-family: var(--f-serif);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;

  /* Fondo de corcho: color base + textura sutil de puntitos (radial-gradients),
     sin imagenes externas. */
  background-color: var(--corcho);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.05) 0 1.5px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(43,29,20,0.06) 0 1.5px, transparent 2px),
    radial-gradient(circle at 45% 85%, rgba(43,29,20,0.05) 0 1.5px, transparent 2px),
    radial-gradient(circle at 85% 15%, rgba(255,255,255,0.04) 0 1.5px, transparent 2px);
  background-size: 120px 120px, 90px 90px, 140px 140px, 110px 110px;
}

img { max-width: 100%; display: block; }

/* -------------------------------------------------------------------------
   Estructura general de secciones
   ------------------------------------------------------------------------- */
main { display: block; }

section {
  padding: clamp(2.5rem, 9vw, 5rem) 1.25rem;
  position: relative;
}

.seccion-titulo {
  font-family: var(--f-serif);
  font-weight: 600;
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  text-align: center;
  color: var(--polaroid);
  margin: 0 0 2.5rem;
  text-shadow: 0 1px 2px rgba(43,29,20,0.35);
}
.seccion-titulo--chico { font-size: clamp(1.2rem, 5vw, 1.6rem); margin-bottom: 1.5rem; }

/* -------------------------------------------------------------------------
   Polaroid base
   ------------------------------------------------------------------------- */
.polaroid {
  background: var(--polaroid);
  padding: 12px 12px 0;
  margin: 0;
  border-radius: 3px;
  box-shadow: var(--sombra);
  position: relative;
  width: 100%;
  /* pequeno giro por defecto; se sobreescribe con --tilt por JS */
  transform: rotate(var(--tilt, 0deg));
}

.polaroid__foto {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--corcho-oscuro);
  overflow: hidden;
  border-radius: 2px;
}
.polaroid__foto img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.polaroid__pie {
  padding: 0.55rem 0.35rem 0.85rem;
  text-align: center;
}

.nota {
  font-family: var(--f-mano);
  font-size: 1.5rem;
  line-height: 1.15;
  color: var(--espresso);
}
.nota--portada { font-size: 1.65rem; color: var(--vino); }
.nota--grande  { font-size: 2rem; }

.fecha {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--vino);
  background: rgba(122, 59, 52, 0.08);
  padding: 2px 8px;
  border-radius: 2px;
  margin-bottom: 0.35rem;
}

/* Washi tape (verde musgo semitransparente, ligeramente girado) */
.washi {
  position: absolute;
  width: 78px;
  height: 26px;
  background: repeating-linear-gradient(
    45deg,
    rgba(110, 122, 79, 0.85) 0 8px,
    rgba(110, 122, 79, 0.65) 8px 16px
  );
  box-shadow: 0 1px 3px rgba(43,29,20,0.25);
  opacity: 0.9;
  z-index: 3;
}
.washi::after { /* bordes irregulares tipo cinta */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0.15), transparent 30%, transparent 70%, rgba(255,255,255,0.15));
}
.washi--tl { top: -12px; left: -10px; transform: rotate(-38deg); }
.washi--tr { top: -12px; right: -10px; transform: rotate(38deg); }

/* Chincheta / pin */
.pin {
  position: absolute;
  top: -10px;
  left: 50%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #b9524a, var(--vino) 70%);
  box-shadow: 0 3px 5px rgba(43,29,20,0.4), inset 0 -2px 3px rgba(0,0,0,0.25);
  z-index: 3;
}

/* -------------------------------------------------------------------------
   SECCION 1 — Portada
   ------------------------------------------------------------------------- */
.portada {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  text-align: center;
}
.polaroid--grande { max-width: 300px; }

.titular {
  font-family: var(--f-mano);
  font-weight: 700;
  font-size: clamp(3rem, 16vw, 5rem);
  line-height: 0.95;
  color: var(--polaroid);
  margin: 0;
  text-shadow: 0 2px 4px rgba(43,29,20,0.4);
}

.scroll-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--polaroid);
  opacity: 0.8;
  margin-top: 0.5rem;
}
.scroll-hint__flecha { font-size: 1.2rem; animation: flotar 1.8s var(--ease-reveal) infinite; }
@keyframes flotar {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(6px); }
}

/* -------------------------------------------------------------------------
   SECCION 2 — Galeria (corcho con polaroids dispersas + cordel)
   ------------------------------------------------------------------------- */
.galeria { padding-bottom: clamp(2rem, 8vw, 4rem); }

.cordel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.galeria__grid {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(1.5rem, 6vw, 2.5rem);
  max-width: 340px;
  margin: 0 auto;
}

/* Cada item de galeria: polaroid + fecha/nota debajo */
.recuerdo {
  width: 76%;
  align-self: center;
}
/* Alternamos alineacion para que "serpenteen" como en un corcho real */
.recuerdo:nth-child(odd)  { align-self: flex-start; }
.recuerdo:nth-child(even) { align-self: flex-end; }

.recuerdo .polaroid__pie { padding-bottom: 0.5rem; }

/* -------------------------------------------------------------------------
   SECCION 3 — Boleto
   ------------------------------------------------------------------------- */
.giro {
  min-height: 90dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.boleto {
  --dientes: 12px;
  width: 100%;
  max-width: 360px;
  background: var(--polaroid);
  color: var(--espresso);
  border-radius: 10px;
  box-shadow: var(--sombra);
  overflow: hidden;
  position: relative;
  /* borde dentado tipo perforacion de ticket, arriba y abajo */
  -webkit-mask:
    radial-gradient(var(--dientes) at 0 50%, transparent 98%, #000) -0 50%/51% 100% repeat-y,
    radial-gradient(var(--dientes) at 100% 50%, transparent 98%, #000) 100% 50%/51% 100% repeat-y;
          mask:
    radial-gradient(var(--dientes) at 0 50%, transparent 98%, #000) 0 50%/51% 100% repeat-y,
    radial-gradient(var(--dientes) at 100% 50%, transparent 98%, #000) 100% 50%/51% 100% repeat-y;
}

/* Stub superior del boleto con la etiqueta ADMIT ONE y linea perforada */
.boleto__stub {
  background: var(--vino);
  color: var(--polaroid);
  text-align: center;
  padding: 0.75rem 1rem;
  border-bottom: 2px dashed rgba(250,246,236,0.45);
}
.boleto__etiqueta {
  font-family: var(--f-mono);
  font-weight: 700;
  letter-spacing: 0.35em;
  font-size: 0.8rem;
  padding-left: 0.35em;
}

.boleto__cuerpo {
  padding: 1.75rem 1.5rem 2rem;
  text-align: center;
}
.boleto__kicker {
  font-family: var(--f-mano);
  font-size: 1.25rem;
  color: var(--vino);
  margin: 0 0 0.5rem;
}
.boleto__pregunta {
  font-family: var(--f-serif);
  font-weight: 700;
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  line-height: 1.1;
  margin: 0 0 1.75rem;
}

/* Contenedor de acciones: es el "campo de juego" del boton No */
.boleto__acciones {
  position: relative;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-si {
  font-family: var(--f-serif);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--polaroid);
  background: var(--caramelo);
  border: none;
  border-radius: 999px;
  padding: 1rem 2rem;
  min-height: 56px;
  min-width: 220px;
  cursor: pointer;
  box-shadow: var(--sombra-suave), inset 0 -3px 0 rgba(43,29,20,0.18);
  transition: transform 160ms var(--ease-reveal);
  touch-action: manipulation;
}
.btn-si:hover  { transform: translateY(-2px); }
.btn-si:active { transform: translateY(1px); }

/* Boton No: esquinita chica que escapa. Se mueve con translate por JS. */
.btn-no {
  font-family: var(--f-mono);
  font-size: 0.9rem;
  color: var(--espresso);
  background: transparent;
  border: 1.5px solid rgba(43,29,20,0.35);
  border-radius: 8px;
  min-width: 46px;
  min-height: 46px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: transform 200ms var(--ease-rebote);
  touch-action: manipulation;
  will-change: transform;
}
/* Cuando empieza a escapar, lo posicionamos absoluto dentro del contenedor */
.btn-no.escapando {
  position: absolute;
  left: 0;
  top: 0;
}

/* -------------------------------------------------------------------------
   SECCION 4 — Celebracion
   ------------------------------------------------------------------------- */
.celebracion {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
}
.celebracion__tarjeta {
  background: var(--polaroid);
  border-radius: 12px;
  box-shadow: var(--sombra);
  padding: 2rem 1.5rem;
  text-align: center;
  max-width: 360px;
}
.celebracion__titulo {
  font-family: var(--f-mano);
  font-weight: 700;
  font-size: clamp(2rem, 9vw, 2.8rem);
  color: var(--vino);
  margin: 0 0 0.75rem;
}
.celebracion__texto { margin: 0; font-size: 1.05rem; }

/* Boton para descargar el album PDF (aparece solo tras el "Si") */
.btn-album {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  font-family: var(--f-serif);
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--polaroid);
  background: var(--vino);
  border-radius: 999px;
  padding: 0.85rem 1.6rem;
  min-height: 48px;
  box-shadow: var(--sombra-suave), inset 0 -3px 0 rgba(43,29,20,0.22);
  transition: transform 160ms var(--ease-reveal);
  touch-action: manipulation;
}
.btn-album:hover  { transform: translateY(-2px); }
.btn-album:active { transform: translateY(1px); }

/* -------------------------------------------------------------------------
   SECCION 5 — Easter egg (flip 3D + fotos de broma)
   ------------------------------------------------------------------------- */
.easter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  width: 100%;
}
.easter__pista {
  font-family: var(--f-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--polaroid);
  opacity: 0.85;
  margin: 0;
}

.flip {
  width: 220px;
  perspective: 1200px;
  cursor: pointer;
  background: none;
  border: none;
}
.flip__inner {
  position: relative;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform 700ms var(--ease-reveal);
}
.flip.volteado .flip__inner { transform: rotateY(180deg); }

.flip__cara {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flip__frente { position: relative; }
.flip__reverso {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}

.polaroid--flip { width: 220px; }

.polaroid__foto--sorpresa,
.polaroid__foto--reverso {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--corcho);
  text-align: center;
  padding: 1rem;
}
.polaroid__foto--reverso { background: var(--vino); }
.polaroid__foto--reverso .nota { color: var(--polaroid); }
.sorpresa-emoji { font-size: 3.5rem; }

.broma { width: 100%; max-width: 360px; margin-top: 1rem; }
.broma__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
.broma .polaroid__foto { aspect-ratio: 1 / 1; }
.broma .nota { font-size: 1.15rem; }

/* -------------------------------------------------------------------------
   Pie de pagina
   ------------------------------------------------------------------------- */
.pie-pagina {
  text-align: center;
  padding: 2rem 1rem 2.5rem;
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--polaroid);
  opacity: 0.7;
}

/* -------------------------------------------------------------------------
   Confetti canvas — fijo, cubre todo, no captura clics
   ------------------------------------------------------------------------- */
#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 60;
  pointer-events: none;
}

/* -------------------------------------------------------------------------
   Reveal (blur+opacidad -> nitido) via IntersectionObserver
   Se anima SOLO transform y opacity + filter(blur). El blur no es GPU-cheap
   pero es breve y puntual; el movimiento usa transform.
   ------------------------------------------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(24px) rotate(var(--tilt, 0deg)) scale(0.97);
  filter: blur(8px);
  transition:
    opacity 600ms var(--ease-reveal),
    transform 600ms var(--ease-reveal),
    filter 600ms var(--ease-reveal);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0) rotate(var(--tilt, 0deg)) scale(1);
  filter: blur(0);
}

/* -------------------------------------------------------------------------
   Placeholder cuando falta la imagen (degradado suave con inicial)
   ------------------------------------------------------------------------- */
.polaroid__foto--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--corcho-oscuro), var(--vino));
}
.polaroid__foto--placeholder::after {
  content: "📷";
  font-size: 2rem;
  opacity: 0.55;
}

/* =========================================================================
   Escalado a pantallas mas grandes (tablet / desktop)
   ========================================================================= */
@media (min-width: 700px) {
  body { font-size: 18px; }

  .galeria__grid {
    max-width: 620px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem 2rem;
    align-items: start;
  }
  .recuerdo { width: 100%; align-self: auto !important; }
  .recuerdo:nth-child(even) { margin-top: 2.5rem; }

  .polaroid--grande { max-width: 340px; }
  .broma__grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
  .galeria__grid { max-width: 760px; }
}

/* =========================================================================
   Accesibilidad: sin movimiento agresivo
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: rotate(var(--tilt, 0deg));
    filter: none;
    transition: none;
  }
  .flip__inner { transition: none; }
  .scroll-hint__flecha { animation: none; }
  .btn-si, .btn-no, .btn-album { transition: none; }
}
