/* =============================================================
   Calendario de Adviento — estilos
   ============================================================= */

:root {
  --bosque-950: #08170f;
  --bosque-900: #0b1f17;
  --bosque-800: #10291f;
  --bosque-700: #173a2c;
  --bosque-600: #22503d;

  --crema: #f4ecdc;
  --marfil: #fbf7ee;
  --papel: #f6eedb;
  --tinta: #2f2a21;
  --tinta-suave: #5a5040;

  --oro: #c9a45c;
  --oro-claro: #e6cd93;
  --oro-oscuro: #7a5a22;

  --serif-display: "Cormorant Garamond", "Cormorant", Garamond, Georgia, serif;
  --serif-texto: "EB Garamond", Garamond, Georgia, "Times New Roman", serif;
  --script: "Pinyon Script", "Snell Roundhand", "Apple Chancery", cursive;

  --suave: cubic-bezier(.22, .7, .2, 1);
  --radio: 14px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bosque-900);
}

html.bloqueo { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--crema);
  font-family: var(--serif-texto);
  font-size: 1.0625rem;
  line-height: 1.6;
  background:
    radial-gradient(120% 70% at 50% -12%, rgba(230, 190, 115, .20), transparent 62%),
    radial-gradient(90% 60% at 50% 115%, rgba(34, 80, 61, .55), transparent 70%),
    linear-gradient(180deg, var(--bosque-800) 0%, var(--bosque-900) 55%, var(--bosque-950) 100%);
  background-attachment: fixed;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }

[hidden] { display: none !important; }

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

.solo-lector {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Ambiente: nieve y halo cálido ---------- */

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

.halo {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(60% 40% at 50% 8%, rgba(255, 214, 150, .10), transparent 70%),
    radial-gradient(140% 100% at 50% 50%, transparent 55%, rgba(3, 10, 7, .55) 100%);
}

main { position: relative; z-index: 1; }

/* ---------- Tipografía compartida ---------- */

.antetitulo {
  margin: 0;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--oro-claro);
}

.filete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  color: var(--oro);
}

.filete span {
  display: block;
  width: 4.5rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, currentColor);
}

.filete span:last-child { background: linear-gradient(90deg, currentColor, transparent); }

.filete svg { width: .8rem; height: .8rem; flex: none; }

.filete--corto span { width: 2.75rem; }

/* ---------- Vistas ---------- */

.vista { animation: aparecer .9s var(--suave) both; }

@keyframes aparecer {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* ===================== PORTADA ===================== */

.portada {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(3rem, env(safe-area-inset-top)) 1.5rem max(3rem, env(safe-area-inset-bottom));
  overflow: hidden;
  text-align: center;
}

.portada__rama {
  position: absolute;
  width: min(62vw, 360px);
  aspect-ratio: 224 / 124;
  color: var(--oro);
  opacity: .32;
  pointer-events: none;
}

.portada__rama--a { top: 2%; left: -8%; transform: rotate(14deg); }
.portada__rama--b { bottom: 3%; right: -8%; transform: rotate(194deg); }

.portada__contenido {
  position: relative;
  max-width: 30rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.portada__contenido > * {
  animation: subir 1.1s var(--suave) both;
}
.portada__contenido > :nth-child(2) { animation-delay: .12s; }
.portada__contenido > :nth-child(3) { animation-delay: .24s; }
.portada__contenido > :nth-child(4) { animation-delay: .42s; }
.portada__contenido > :nth-child(5) { animation-delay: .54s; }
.portada__contenido > :nth-child(6) { animation-delay: .68s; }

@keyframes subir {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

.portada__estrella {
  width: 2.1rem;
  height: 2.1rem;
  margin-bottom: 1.75rem;
  color: var(--oro-claro);
  filter: drop-shadow(0 0 10px rgba(240, 205, 130, .65)) drop-shadow(0 0 28px rgba(240, 205, 130, .35));
}

.portada__estrella { animation: subir 1.1s var(--suave) both, titilar 5s ease-in-out 1.2s infinite; }

@keyframes titilar {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .78; transform: scale(.92); }
}

.portada__titulo {
  margin: .25rem 0 1.9rem;
  font-weight: 400;
  line-height: 1;
}

.portada__titulo-serif {
  display: block;
  font-family: var(--serif-display);
  font-weight: 500;
  font-size: clamp(2.9rem, 14.5vw, 5.6rem);
  letter-spacing: .01em;
  color: var(--marfil);
}

.portada__titulo-script {
  display: block;
  margin-top: .15em;
  font-family: var(--script);
  font-size: clamp(3.2rem, 16vw, 6.4rem);
  line-height: 1.05;
  color: var(--oro-claro);
  text-shadow: 0 0 30px rgba(230, 190, 115, .28);
}

.portada__filete { margin-bottom: 2.75rem; }

.portada__filete span { width: 5.5rem; }

.boton {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  padding: .85rem 2.1rem;
  border: 1px solid rgba(230, 205, 147, .75);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(230, 205, 147, .14), rgba(230, 205, 147, .04));
  color: var(--marfil);
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: .98rem;
  letter-spacing: .12em;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 0 4px rgba(230, 205, 147, .06), 0 10px 30px -12px rgba(230, 190, 115, .55);
  transition: background .4s var(--suave), color .4s var(--suave), box-shadow .4s var(--suave), transform .4s var(--suave);
}

.boton:hover {
  background: linear-gradient(180deg, var(--oro-claro), var(--oro));
  color: var(--bosque-900);
  box-shadow: 0 0 0 6px rgba(230, 205, 147, .12), 0 14px 36px -12px rgba(230, 190, 115, .8);
}

.boton:active { transform: scale(.98); }

/* ===================== CALENDARIO ===================== */

.calendario {
  max-width: 64rem;
  margin: 0 auto;
  padding: max(2.75rem, env(safe-area-inset-top)) 1.1rem max(2.5rem, env(safe-area-inset-bottom));
}

.cal__cabecera {
  text-align: center;
  margin-bottom: 2rem;
}

.cal__inicio {
  margin: 0 0 1.25rem;
}

.cal__titulo {
  margin: .3rem 0 .6rem;
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(2.5rem, 11vw, 4rem);
  line-height: 1.15;
  text-wrap: balance;
  color: var(--oro-claro);
  text-shadow: 0 0 26px rgba(230, 190, 115, .25);
}

.cal__estado {
  margin: .9rem 0 0;
  min-height: 1.6em;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 1.15rem;
  color: rgba(244, 236, 220, .85);
}

.cal__estado--contador { margin-top: .1rem; }

.rejilla {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .7rem;
  max-width: 28rem;
}

@media (min-width: 640px) {
  .calendario { padding-left: 2rem; padding-right: 2rem; }
  .rejilla { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1rem; max-width: 46rem; }
}

@media (min-width: 1024px) {
  .rejilla { gap: 1.1rem; max-width: 42rem; }
}

.rejilla > li {
  animation: subir .8s var(--suave) both;
  animation-delay: calc(var(--i, 0) * 35ms + .1s);
}

/* ---------- Casilla ---------- */

.casilla {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 5 / 6;
  padding: 0;
  border: 0;
  border-radius: var(--radio);
  background: transparent;
  cursor: pointer;
  perspective: 700px;
  touch-action: manipulation;
}

.casilla:focus-visible { outline-offset: 4px; }

/* Interior que se ve al abrir la puerta */
.casilla__interior {
  position: absolute;
  inset: 0;
  border-radius: var(--radio);
  background:
    radial-gradient(circle at 50% 55%, rgba(255, 220, 160, .95), rgba(214, 160, 80, .55) 45%, rgba(80, 50, 20, .9) 100%);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, .45);
}

.casilla__puerta {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radio);
  transform-origin: left center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  transition: transform .7s var(--suave), box-shadow .4s var(--suave), background .4s var(--suave);
}

.casilla__num {
  font-family: var(--serif-display);
  font-weight: 500;
  font-size: clamp(1.75rem, 8vw, 2.5rem);
  line-height: 1;
  font-variant-numeric: lining-nums;
}

.casilla__icono {
  width: .85rem;
  height: .85rem;
  margin-top: .45rem;
}

.casilla__marca {
  position: absolute;
  top: .5rem;
  right: .5rem;
  width: .6rem;
  height: .6rem;
  color: var(--oro);
}

/* Disponible: puerta de papel crema con filete dorado */
.casilla.es-disponible .casilla__puerta {
  background:
    radial-gradient(120% 90% at 30% 10%, rgba(255, 255, 255, .7), transparent 60%),
    linear-gradient(160deg, #faf3e4 0%, #efe2c6 100%);
  color: var(--oro-oscuro);
  box-shadow:
    inset 0 0 0 4px rgba(250, 243, 228, .9),
    inset 0 0 0 5px rgba(201, 164, 92, .55),
    0 10px 22px -12px rgba(0, 0, 0, .7),
    0 2px 0 rgba(0, 0, 0, .12);
}

.casilla.es-disponible:hover .casilla__puerta {
  transform: rotateY(-14deg);
  box-shadow:
    inset 0 0 0 4px rgba(250, 243, 228, .9),
    inset 0 0 0 5px rgba(201, 164, 92, .7),
    0 16px 30px -12px rgba(0, 0, 0, .75);
}

/* Hoy: halo cálido */
.casilla.es-hoy::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: calc(var(--radio) + 4px);
  border: 1px solid rgba(230, 205, 147, .85);
  box-shadow: 0 0 22px rgba(240, 200, 120, .45);
  pointer-events: none;
  animation: latir 3.2s ease-in-out infinite;
}

@keyframes latir {
  0%, 100% { opacity: .55; }
  50%      { opacity: 1; }
}

/* Ya visitada: la puerta queda entreabierta */
.casilla.es-abierta .casilla__puerta { transform: rotateY(-22deg); }
.casilla.es-abierta:hover .casilla__puerta { transform: rotateY(-30deg); }

/* Bloqueada: cristal verde, número tenue y candado */
.casilla.es-bloqueada { cursor: not-allowed; }

.casilla.es-bloqueada .casilla__interior { display: none; }

.casilla.es-bloqueada .casilla__puerta {
  background: linear-gradient(160deg, rgba(34, 80, 61, .55), rgba(16, 41, 31, .55));
  color: rgba(244, 236, 220, .62);
  box-shadow:
    inset 0 0 0 1px rgba(230, 205, 147, .2),
    inset 0 1px 0 rgba(255, 255, 255, .05);
}

.casilla.es-bloqueada .casilla__icono { color: rgba(230, 205, 147, .55); }

.casilla.agitar .casilla__puerta { animation: agitar .45s ease-in-out; }

@keyframes agitar {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-3px); }
  50%      { transform: translateX(3px); }
  75%      { transform: translateX(-2px); }
}

/* Abriendo: la puerta gira */
.casilla.abriendo .casilla__puerta,
.casilla.abriendo:hover .casilla__puerta { transform: rotateY(-105deg); }

.cal__nota {
  margin: 2.25rem auto 0;
  text-align: center;
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 1rem;
  color: rgba(244, 236, 220, .7);
}

/* ===================== SORPRESA ===================== */

.sorpresa {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(6, 18, 12, .86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity .5s var(--suave);
}

.sorpresa.visible { opacity: 1; }

.sorpresa__barra {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(.75rem, env(safe-area-inset-top)) 1rem .75rem;
  background: rgba(8, 23, 15, .94);
  border-bottom: 1px solid rgba(230, 205, 147, .14);
}

.volver {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 2.75rem;
  padding: .45rem 1rem .45rem .7rem;
  border: 1px solid rgba(230, 205, 147, .45);
  border-radius: 999px;
  background: rgba(16, 41, 31, .85);
  color: var(--crema);
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: .03em;
  cursor: pointer;
  transition: background .3s var(--suave), border-color .3s var(--suave);
}

.volver:hover { background: rgba(34, 80, 61, .9); border-color: var(--oro-claro); }

.volver svg { width: 1.15rem; height: 1.15rem; color: var(--oro-claro); }

.sorpresa__fecha {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--oro-claro);
  text-align: right;
}

.sorpresa__escena {
  padding: 2.25rem .9rem max(3rem, env(safe-area-inset-bottom));
}

/* ---------- Papel ---------- */

.papel {
  position: relative;
  max-width: 36rem;
  margin: 0 auto;
  padding: clamp(3rem, 9vw, 4rem) clamp(1.6rem, 6.5vw, 3.4rem) clamp(2.5rem, 7vw, 3.25rem);
  border-radius: 6px;
  color: var(--tinta);
  background-color: var(--papel);
  background-image:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 252, 244, .85), transparent 65%),
    radial-gradient(100% 80% at 50% 120%, rgba(214, 190, 140, .35), transparent 60%),
    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 .45 0 0 0 0 .36 0 0 0 0 .22 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  box-shadow:
    0 40px 70px -30px rgba(0, 0, 0, .75),
    0 0 60px -10px rgba(240, 200, 120, .18),
    0 0 0 1px rgba(122, 90, 34, .12);
  transform-origin: 50% 0;
  opacity: 0;
  transform: translateY(28px) scale(.97);
  transition: opacity .8s var(--suave) .08s, transform .9s var(--suave) .08s;
}

.sorpresa.visible .papel { opacity: 1; transform: none; }

/* Filete interior dorado */
.papel::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(156, 122, 60, .38);
  border-radius: 3px;
  pointer-events: none;
}

.papel__sello {
  position: absolute;
  top: -24px;
  left: 50%;
  width: 48px;
  height: 48px;
  margin-left: -24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f1d9a0, #c9a45c 55%, #8f6c2c 100%);
  box-shadow: 0 6px 14px -4px rgba(0, 0, 0, .55), inset 0 0 0 3px rgba(255, 240, 205, .35), inset 0 -2px 4px rgba(90, 60, 20, .4);
  color: #fff6df;
}

.papel__sello svg { width: 18px; height: 18px; }

.papel__esquina {
  position: absolute;
  width: 92px;
  aspect-ratio: 224 / 124;
  color: var(--oro);
  opacity: .45;
  pointer-events: none;
}

.papel__esquina--a { top: 18px; left: 16px; transform: rotate(-8deg); }
.papel__esquina--b { bottom: 20px; right: 18px; width: 70px; transform: rotate(172deg); }

/* Contenido del papel, aparece en cascada */
.papel > .pieza {
  position: relative;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .9s var(--suave), transform .9s var(--suave);
  transition-delay: calc(.35s + var(--i, 0) * .12s);
}

.sorpresa.visible .papel > .pieza { opacity: 1; transform: none; }

.papel__tipo {
  margin: 0 0 .6rem;
  text-align: center;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: .75rem;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--oro-oscuro);
}

.papel__titulo {
  margin: .4rem 0 0;
  text-align: center;
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.85rem, 7vw, 2.45rem);
  line-height: 1.15;
  color: #3a2f1c;
  text-wrap: balance;
}

.papel .filete {
  margin: 1.1rem 0 1.9rem;
  color: var(--oro);
}

.papel .filete span { width: 3.5rem; }

.papel__saludo {
  margin: 0 0 1rem;
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.6rem;
  line-height: 1.3;
  color: #3a2f1c;
}

.papel__parrafo {
  margin: 0 0 1.05em;
  font-size: clamp(1.1rem, 4.4vw, 1.2rem);
  line-height: 1.75;
  color: var(--tinta);
  text-wrap: pretty;
}

.papel__figura {
  margin: 1.5rem 0;
}

.papel__figura img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 12px 24px -14px rgba(0, 0, 0, .55), 0 0 0 6px #fffaf0, 0 0 0 7px rgba(156, 122, 60, .35);
}

.papel__figura figcaption {
  margin-top: .9rem;
  text-align: center;
  font-style: italic;
  font-size: 1rem;
  color: var(--tinta-suave);
}

.papel__audio { display: block; width: 100%; margin: 1.25rem 0; }

.papel__accion {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0 .5rem;
}

.papel__enlace {
  display: inline-flex;
  align-items: center;
  min-height: 2.9rem;
  padding: .7rem 1.6rem;
  border-radius: 999px;
  background: var(--bosque-700);
  color: var(--marfil);
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: 0 8px 18px -10px rgba(11, 31, 23, .9);
  transition: background .3s var(--suave);
}

.papel__enlace:hover { background: var(--bosque-600); }

.papel__nota {
  margin: 1.25rem 0 0;
  text-align: center;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--tinta-suave);
}

.papel__pie {
  margin: 2rem 0 0;
  padding-top: 1.25rem;
  text-align: center;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--oro-oscuro);
}

.papel__pie::before {
  content: "";
  display: block;
  width: 3rem;
  height: 1px;
  margin: 0 auto 1.25rem;
  background: rgba(156, 122, 60, .55);
}

/* Día sin contenido todavía */
.papel--vacio {
  max-width: 26rem;
  margin-top: 8vh;
  text-align: center;
}

.papel__vacio-estrella {
  display: block;
  width: 1.4rem;
  height: 1.4rem;
  margin: 0 auto 1.1rem;
  color: var(--oro);
}

.papel__vacio-texto {
  margin: 0;
  font-family: var(--serif-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.45rem;
  line-height: 1.35;
  color: #3a2f1c;
}

/* ===================== AVISO ===================== */

.aviso {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 20;
  max-width: calc(100% - 2rem);
  padding: .7rem 1.25rem;
  border: 1px solid rgba(230, 205, 147, .45);
  border-radius: 999px;
  background: rgba(11, 31, 23, .95);
  color: var(--crema);
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 1.05rem;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .8);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .4s var(--suave), transform .4s var(--suave);
  pointer-events: none;
}

.aviso.visible { opacity: 1; transform: translate(-50%, 0); }

.sin-js {
  position: relative;
  z-index: 2;
  margin: 2rem;
  text-align: center;
}

/* ===================== MOVIMIENTO REDUCIDO ===================== */

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

  .casilla.es-disponible:hover .casilla__puerta,
  .casilla.es-abierta .casilla__puerta,
  .casilla.es-abierta:hover .casilla__puerta { transform: none; }

  .nieve { display: none; }
}
