:root {
  --noche: #13293d;      /* azul pino de fondo */
  --noche-hondo: #0d1e2e;
  --escarcha: #e9f1f3;   /* vidrio helado, texto claro */
  --bruma: #93acbb;      /* texto secundario */
  --vela: #f3c66f;       /* dorado de la ventanita de hoy */
  --baya: #c94a6d;       /* rojo rosado del interior */
  --ease: cubic-bezier(.22, .9, .3, 1);
  --display: "Gloock", Georgia, serif;
  --texto: "Figtree", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--noche-hondo); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--escarcha);
  font: 400 1rem/1.55 var(--texto);
  background:
    radial-gradient(120% 70% at 50% -10%, #234863 0%, transparent 60%),
    linear-gradient(180deg, var(--noche) 0%, var(--noche-hondo) 100%);
  -webkit-font-smoothing: antialiased;
}

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

.hero, main, .pie { position: relative; z-index: 1; }

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: clamp(4rem, 12vh, 8rem) 1.5rem clamp(2.5rem, 6vh, 4rem);
}

.nombre {
  margin: 0;
  font: 400 clamp(4rem, 15vw, 10rem)/.9 var(--display);
  letter-spacing: -.02em;
  display: inline-flex;
  align-items: baseline;
  gap: .25em;
}
.nombre .para {
  font: 400 .22em/1 var(--texto);
  color: var(--bruma);
  letter-spacing: .02em;
  transform: translateY(-1.6em);
}
.nombre #nombre {
  background: linear-gradient(180deg, #fff 30%, #b9d3de 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub { margin: 1.25rem 0 0; color: var(--bruma); font-size: 1.125rem; }
.estado { margin: .5rem 0 0; color: var(--vela); font-weight: 500; min-height: 1.55em; }

/* Entrada de la página: un solo momento orquestado */
.hero > * { animation: aparecer 1.1s var(--ease) both; }
.hero .sub { animation-delay: .25s; }
.hero .estado { animation-delay: .4s; }
@keyframes aparecer { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } }

/* ---------- Calendario ---------- */
main { padding: 0 clamp(1rem, 4vw, 3rem) 4rem; }

.calendario {
  max-width: 1040px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: clamp(96px, 13vw, 140px);
  grid-auto-flow: dense;
  gap: clamp(.5rem, 1.2vw, .9rem);
}

.puerta.ancha  { grid-column: span 2; }
.puerta.alta   { grid-row: span 2; }
.puerta.grande { grid-column: span 2; grid-row: span 2; }

.puerta {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  perspective: 900px;
  border-radius: 6px;
  animation: caer .9s var(--ease) both;
  animation-delay: calc(.5s + var(--i) * 35ms);
}
@keyframes caer { from { opacity: 0; transform: translateY(-10px) scale(.98); } }

.puerta:focus-visible { outline: 2px solid var(--vela); outline-offset: 4px; }

/* lo que hay detrás de la hoja */
.hueco {
  position: absolute; inset: 0;
  border-radius: 6px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #e0688a, var(--baya) 55%, #8e2c4b);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), inset 0 10px 24px rgba(0,0,0,.35);
  display: grid; place-items: center;
}
.hueco img { width: 100%; height: 100%; object-fit: cover; }
/* mientras está cerrada, el interior es solo un hueco oscuro (si no, se transparenta por el vidrio) */
.hueco > * { transition: opacity .6s .25s var(--ease); }
.puerta:not(.abierta) .hueco { background: var(--noche-hondo); }
.puerta:not(.abierta) .hueco > * { opacity: 0; transition: none; }
.hueco svg { width: 30%; max-width: 44px; color: #ffe7ee; opacity: .9; }

/* la hoja de vidrio helado */
.hoja {
  position: absolute; inset: 0;
  border-radius: 6px;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 1s var(--ease), box-shadow .4s var(--ease);
  background:
    linear-gradient(150deg, rgba(255,255,255,.16), rgba(255,255,255,.04) 55%, rgba(255,255,255,.08)),
    rgba(30, 62, 86, .55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 0 8px 24px rgba(4, 14, 24, .35);
  display: flex;
  align-items: flex-end;
  padding: .7rem .85rem;
}
.hoja::after { /* tirador */
  content: "";
  position: absolute; right: 10px; top: 50%;
  width: 4px; height: 18px; margin-top: -9px;
  border-radius: 2px;
  background: rgba(255,255,255,.22);
}

.num {
  font: 400 clamp(1.6rem, 3.4vw, 2.4rem)/1 var(--display);
  color: var(--escarcha);
}
.grande .num { font-size: clamp(3rem, 7vw, 5.5rem); }

/* bloqueada */
.puerta.bloqueada .num { opacity: .55; }
.puerta.bloqueada .hoja::after { background: rgba(255,255,255,.12); }

/* hoy: brilla como una vela detrás del vidrio */
.puerta.hoy .hoja {
  box-shadow: inset 0 0 0 1.5px var(--vela), 0 0 0 0 rgba(243,198,111,.5), 0 10px 30px rgba(243,198,111,.18);
  animation: latido 2.8s ease-in-out infinite;
}
.puerta.hoy .num { color: var(--vela); }
@keyframes latido {
  50% { box-shadow: inset 0 0 0 1.5px var(--vela), 0 0 0 6px rgba(243,198,111,0), 0 10px 40px rgba(243,198,111,.32); }
}

.puerta.disponible:hover .hoja { transform: rotateY(-14deg); }

/* abierta: la hoja queda entornada */
.puerta.abierta .hoja { transform: rotateY(-78deg); box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 12px 0 24px rgba(4,14,24,.4); animation: none; }
.puerta.abierta:hover .hoja { transform: rotateY(-70deg); }

/* puerta bloqueada que no se deja abrir */
.puerta.temblar .hoja { animation: temblar .45s var(--ease); }
@keyframes temblar {
  20% { transform: rotateY(-6deg); }
  45% { transform: rotateY(3deg); }
  70% { transform: rotateY(-2deg); }
}

/* ---------- Carta (modal) ---------- */
.carta {
  width: min(520px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--escarcha);
  color: var(--noche);
  box-shadow: 0 30px 80px rgba(2, 10, 18, .55);
  overflow: auto;
}
.carta::backdrop { background: rgba(9, 22, 34, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.carta[open] { animation: abrirCarta .6s var(--ease); }
.carta[open]::backdrop { animation: fundido .5s ease; }
.carta.cerrando { animation: cerrarCarta .3s ease forwards; }
.carta.cerrando::backdrop { animation: fundido .3s ease reverse forwards; }
@keyframes abrirCarta { from { opacity: 0; transform: translateY(24px) scale(.96); } }
@keyframes cerrarCarta { to { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes fundido { from { opacity: 0; } }

.carta-cuerpo { padding: 2.25rem clamp(1.5rem, 5vw, 2.5rem) 2.25rem; }
.carta-cuerpo > * { animation: aparecer .8s var(--ease) both; }
.carta-cuerpo > :nth-child(2) { animation-delay: .1s; }
.carta-cuerpo > :nth-child(3) { animation-delay: .2s; }
.carta-cuerpo > :nth-child(4) { animation-delay: .3s; }
.carta-cuerpo > :nth-child(5) { animation-delay: .35s; }

.cerrar {
  position: sticky; top: .75rem; float: right; margin: .75rem .75rem 0 0; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgba(19, 41, 61, .07); color: var(--noche);
  display: grid; place-items: center; cursor: pointer;
  transition: background .2s;
}
.cerrar:hover { background: rgba(19, 41, 61, .14); }
.cerrar:focus-visible { outline: 2px solid var(--baya); outline-offset: 2px; }

.carta-dia { margin: 0 0 1.25rem; font: 400 1rem/1 var(--texto); color: #5c7587; }
.carta-dia b { font: 400 2.75rem/1 var(--display); color: var(--baya); margin-right: .35rem; vertical-align: -.2em; }

.carta-foto { margin: 0 0 1.5rem; border-radius: 8px; overflow: hidden; background: #d6e2e6; }
.carta-foto img { display: block; width: 100%; max-height: 56vh; object-fit: cover; }

.carta-frase {
  margin: 0;
  font: 400 clamp(1.4rem, 4.2vw, 1.75rem)/1.35 var(--display);
  color: var(--noche);
  text-wrap: pretty;
}

.carta-cancion { margin-top: 1.5rem; }
.carta-cancion iframe { display: block; width: 100%; border: 0; border-radius: 12px; }
.carta-cancion audio { width: 100%; }

.carta-nota { margin: .75rem 0 0; color: #5c7587; font-size: .95rem; }

/* ---------- Aviso ---------- */
.aviso {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 10;
  transform: translate(-50%, 20px);
  padding: .75rem 1.15rem;
  border-radius: 999px;
  background: rgba(233, 241, 243, .95);
  color: var(--noche);
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(2, 10, 18, .4);
  opacity: 0; pointer-events: none;
  transition: opacity .35s var(--ease), transform .35s var(--ease);
  white-space: nowrap;
}
.aviso.visible { opacity: 1; transform: translate(-50%, 0); }

.pie { text-align: center; color: var(--bruma); opacity: .7; font-size: .9rem; padding: 0 1rem 3rem; }

/* ---------- Móvil ---------- */
@media (max-width: 640px) {
  .calendario { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 26vw; }
  .aviso { white-space: normal; width: max-content; max-width: calc(100vw - 2rem); text-align: center; border-radius: 16px; }
}

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