/* ==========================================================
   Calendario de Adviento · Preciosas Bisutería
   Mobile first: todo se diseña para celular y se amplía en pantallas grandes.
   ========================================================== */

:root {
  /* Paleta del cascanueces (Cascanueces.jpg): el rosa manda, rojo y verde acompañan */
  --rosa-fondo: #FADCE6;   /* fondo de la página */
  --rosa-claro: #F8C8D8;   /* rosa pálido del contorno del cascanueces */
  --rosa: #F26495;         /* rosa de la casaca: cajas, cintas, confeti */
  --rosa-fuerte: #D62872;  /* títulos y botones (texto blanco encima) */
  --rosa-noche: #A3134F;   /* sombras y fondo de la escena */
  --rojo: #E3211F;
  --verde: #0A7D4F;
  --oro: #F1C63B;          /* brillos dorados */
  --oro-osc: #D9A520;      /* dorado que se lee sobre el rosa */
  --blanco: #FFF8F4;
  --tinta: #4E0F2E;        /* texto: vino oscuro */
  --sombra: rgba(140, 12, 66, .24);
  --fuente: "Life Savers", Georgia, serif;          /* cuerpo */
  --fuente-titulos: "Cinzel", "Times New Roman", serif; /* encabezados */
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html.bloqueado { overflow: hidden; }

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--rosa-fondo);
  /* escarcha dorada y destellos blancos, como el papel del cascanueces */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='170' height='170' viewBox='0 0 170 170'%3E%3Cg stroke='%23FFFFFF' stroke-width='1.4' stroke-linecap='round' opacity='.75'%3E%3Cpath d='M32 20v20M22 30h20M25 23l14 14M39 23L25 37'/%3E%3Cpath d='M126 104v12M120 110h12'/%3E%3C/g%3E%3Cpath d='M70 138v12M64 144h12' stroke='%23E2B12E' stroke-width='1.4' stroke-linecap='round' opacity='.7'/%3E%3Cg fill='%23E2B12E' opacity='.55'%3E%3Ccircle cx='98' cy='38' r='1.8'/%3E%3Ccircle cx='150' cy='58' r='1.2'/%3E%3Ccircle cx='20' cy='112' r='1.5'/%3E%3Ccircle cx='62' cy='74' r='1'/%3E%3Ccircle cx='110' cy='150' r='1.4'/%3E%3Ccircle cx='146' cy='16' r='.9'/%3E%3Ccircle cx='86' cy='102' r='.8'/%3E%3Ccircle cx='8' cy='160' r='1.1'/%3E%3Ccircle cx='158' cy='132' r='.8'/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(120% 60% at 50% -10%, #FFF2F6 0%, transparent 60%);
  background-size: 170px 170px, 100% 100%;
  color: var(--tinta);
  font-family: var(--fuente);
  font-weight: 700; /* Life Savers normal es muy delgada para leerse en celular */
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; }

/* ---------- Nieve de fondo ---------- */
.nieve { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.nieve i {
  position: absolute; top: -12px; display: block;
  border-radius: 50%; background: #fff;
}

/* ---------- Cabecera ---------- */
.cabecera {
  position: relative; z-index: 1;
  text-align: center;
  padding: calc(28px + env(safe-area-inset-top)) 16px 4px;
}
.cabecera__logo {
  display: block;
  width: min(56vw, 230px); height: auto;
  margin: 0 auto 14px;
}
.cabecera__titulo {
  margin: 8px 0 10px;
  font-family: var(--fuente-titulos);
  font-size: clamp(34px, 10.5vw, 64px);
  font-weight: 700; line-height: 1;
  letter-spacing: .01em;
  color: var(--rosa-fuerte);
}
.cabecera__titulo span { display: block; color: var(--rojo); }
.cabecera__sub { margin: 0 auto; max-width: 26ch; font-size: clamp(21px, 5.8vw, 26px); line-height: 1.3; opacity: .9; text-wrap: balance; }

/* ---------- Estado (cuenta regresiva / botón de hoy) ---------- */
.estado { margin: 20px auto 0; max-width: 380px; min-height: 48px; }
.estado__texto { margin: 0 0 14px; font-size: 19px; line-height: 1.3; text-wrap: balance; }
.estado__texto b { white-space: nowrap; }

/* Cifras en Cinzel: en Life Savers el 1 se confunde con la l */
.cifra { font-family: var(--fuente-titulos); font-weight: 700; }

/* Collar de 21 cuentas */
.collar { display: block; width: min(100%, 340px); height: auto; margin: 0 auto 6px; overflow: visible; }
.collar__hilo { fill: none; stroke: rgba(78, 15, 46, .3); stroke-width: 1.4; }
.collar__broche { fill: none; stroke: var(--oro-osc); stroke-width: 2; }
.collar__vacia { fill: rgba(255, 255, 255, .6); stroke: rgba(214, 40, 114, .45); stroke-width: 1.2; }
.collar__oro { fill: var(--oro-osc); }
.collar__argolla { fill: none; stroke: var(--oro-osc); stroke-width: 1.8; stroke-linecap: round; }
.collar__brillo { fill: #fff; opacity: .7; }
.collar__dije-fondo { stroke: #fff; stroke-width: 2.5; }
.collar__dije text { font: 700 18px var(--fuente-titulos); text-anchor: middle; dominant-baseline: central; }
.estado__texto b { color: var(--rosa-fuerte); }

.contador { display: flex; justify-content: center; gap: 8px; }
.contador div {
  flex: 0 1 76px; min-width: 0; /* 4 × 76 px; en 320 px se encogen parejo */
  padding: 10px 0 9px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .6);
  border: 1.5px solid rgba(214, 40, 114, .18);
}
.contador b { display: block; color: var(--rosa-fuerte); font-family: var(--fuente-titulos); font-size: 32px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.contador small { font-size: 15px; opacity: .8; }

.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 28px;
  border: 0; border-radius: 999px;
  background: var(--rosa-fuerte); color: #fff;
  font-size: 18px; font-weight: 800;
  box-shadow: 0 4px 0 var(--rosa-noche);
  cursor: pointer;
  transition: transform .08s, box-shadow .08s;
}
.boton:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--rosa-noche); }
.boton:focus-visible, .celda:focus-visible, .escena__cerrar:focus-visible {
  outline: 3px solid var(--tinta); outline-offset: 4px;
}

/* ---------- Cuadrícula del calendario ---------- */
.calendario {
  position: relative; z-index: 1;
  list-style: none;
  max-width: 560px;
  margin: 8px auto 0;
  /* 14 px: las cajas ganan ancho y el candado (sobresale 7%) no queda pegado a la orilla */
  padding: 0 14px 48px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 16px;
}
.calendario li { padding-top: 36%; } /* espacio para la tapa y el lazo */

.celda {
  display: block; width: 100%;
  padding: 0; border: 0; background: none;
  cursor: pointer;
  border-radius: 6px;
}

@media (min-width: 760px) {
  .calendario { grid-template-columns: repeat(7, minmax(0, 1fr)); max-width: 1120px; padding-inline: 16px; gap: 12px 24px; }
}

/* ---------- La caja (se usa en la cuadrícula y en la escena) ---------- */
.caja {
  position: relative;
  aspect-ratio: 1;
  container-type: inline-size; /* las medidas internas usan cqw = % del ancho de la caja */
}
.caja__frente {
  position: absolute; inset: 0;
  overflow: hidden;
  border-radius: 2.5cqw;
  background: var(--fondo);
  box-shadow: 0 3cqw 0 var(--sombra);
}
.caja__frente img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Tapa provisional hecha con CSS. Cuando tengas tus tapas, usa imágenes (ver app.js). */
.caja__tapa {
  position: absolute; z-index: 2;
  left: -6%; width: 112%;
  bottom: 95%;
  height: 20cqw;
}
.caja__tapa-cuerpo {
  position: absolute; inset: 0;
  overflow: hidden;
  border-radius: 3cqw 3cqw 2cqw 2cqw;
  background: var(--tapa);
  box-shadow: inset 0 1.8cqw 0 rgba(255, 255, 255, .22), 0 1.8cqw 0 var(--sombra);
}
.caja__tapa-cuerpo::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  width: 15cqw; translate: -50% 0;
  background: var(--cinta);
}
.caja__lazo {
  position: absolute; left: 50%;
  bottom: calc(100% - 7cqw);
  width: 42cqw; translate: -50% 0;
  overflow: visible;
}
.caja__lazo .l { fill: var(--cinta); }
.caja__lazo .d { fill: none; stroke: rgba(78, 15, 46, .22); stroke-width: 3; stroke-linecap: round; }

/* Tapa con imagen (cuando USAR_TAPAS_IMAGEN = true) */
.caja__tapa--img { height: auto; }
.caja__tapa--img img { display: block; width: 100%; height: auto; }

/* Etiquetas: en cqw para crecer con la caja, con un mínimo en px para que se lean en celular */
.caja__candado {
  position: absolute; z-index: 3;
  right: -7cqw; bottom: -7cqw;
  width: max(32px, 30cqw); height: max(32px, 30cqw);
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--blanco); color: var(--tinta);
  box-shadow: 0 1.6cqw 0 var(--sombra);
}
.caja__candado svg { width: 52%; }

.caja__sello { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; }
.caja__sello span {
  rotate: -14deg;
  padding: 1.5cqw 5cqw;
  border: 1.6cqw solid currentColor; border-radius: 4cqw;
  background: rgba(78, 15, 46, .6);
  color: #fff;
  font-size: max(15px, 13cqw); font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
}

.caja__hoy {
  position: absolute; z-index: 3;
  left: 50%; bottom: -9cqw; translate: -50% 0;
  padding: 1.5cqw 7cqw;
  border-radius: 999px;
  background: var(--rojo); color: #fff;
  font-size: max(15px, 13cqw); font-weight: 800; white-space: nowrap;
  box-shadow: 0 1.6cqw 0 var(--sombra);
}

/* Estados */
.caja--pasado .caja__frente { background: #EDC9D5; box-shadow: 0 3cqw 0 rgba(140, 12, 66, .12); }
.caja--pasado .caja__frente img { filter: grayscale(1) brightness(1.05); opacity: .5; mix-blend-mode: multiply; } /* gris teñido de rosa */
.caja--hoy .caja__frente,
.caja--abierta .caja__frente {
  /* doble contorno blanco y rosa, como el sticker del cascanueces */
  box-shadow: 0 0 0 2cqw #fff, 0 0 0 4cqw var(--rosa-fuerte), 0 3cqw 0 4cqw var(--sombra);
}

/* ---------- Escena (caja de hoy abriéndose) ---------- */
.escena {
  position: fixed; inset: 0; z-index: 50;
  overflow: hidden;
  overscroll-behavior: contain;
  visibility: hidden; opacity: 0;
}
.escena.lista { overflow-y: auto; }

.escena__fondo {
  position: fixed; inset: 0;
  background: rgba(163, 19, 79, .94); /* sin backdrop-filter: es muy pesado en celulares de gama baja */
}
.escena__rayos {
  position: fixed; left: 50%; top: 50%;
  width: 130vmax; height: 130vmax;
  pointer-events: none;
  will-change: transform; /* se dibuja una vez y la GPU solo la rota */
  background: repeating-conic-gradient(rgba(255, 255, 255, .11) 0deg 8deg, transparent 8deg 16deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, transparent 52%);
  mask-image: radial-gradient(circle, #000 0%, transparent 52%);
}
.escena__contenido {
  position: relative;
  min-height: 100%;
  display: grid;
  padding: calc(64px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}
.escena__caja {
  grid-area: 1 / 1;
  margin: auto;
  position: relative; top: 5vh; z-index: 2;
  width: min(56vw, 240px);
}
.escena__confeti { position: fixed; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.escena__confeti i { position: absolute; left: 0; top: 0; display: block; }

/* Confeti de bisutería */
.b--perla {
  width: var(--t); height: var(--t); border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff 0 14%, #F6EEDF 38%, #D8C8AE 78%, #BFAE93 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.b--chaquira {
  width: var(--t); height: calc(var(--t) * .8); border-radius: 45%;
  background:
    radial-gradient(circle at 28% 26%, rgba(255, 255, 255, .75) 0 11%, transparent 15%),
    radial-gradient(ellipse, transparent 0 25%, var(--c) 29%);
}
.b--cristal {
  width: var(--t); height: calc(var(--t) * 1.3);
  clip-path: polygon(50% 0, 100% 38%, 50% 100%, 0 38%);
  background: linear-gradient(100deg,
    color-mix(in srgb, var(--c), #fff 55%) 0 46%,
    var(--c) 46% 68%,
    color-mix(in srgb, var(--c), #000 22%) 68%);
}
.b--argolla {
  width: var(--t); height: var(--t); border-radius: 50%;
  border: 2px solid var(--oro);
}
.b--estrella {
  width: var(--t); height: var(--t);
  background: var(--oro);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
}

.escena__cerrar {
  position: fixed; z-index: 5;
  top: calc(12px + env(safe-area-inset-top)); right: 12px;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  cursor: pointer;
}
.escena__cerrar svg { width: 20px; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; }

/* ---------- Tarjeta de la promo ----------
   Una carta: marco rosa a rayas → papel con bordes festoneados y esquinas recortadas
   → estampilla con la caja del día en la esquina. El botón queda debajo de la carta. */
.tarjeta {
  grid-area: 1 / 1;
  margin: auto;
  position: relative; z-index: 1;
  width: min(100%, 380px);
  color: var(--tinta);
  text-align: center;
  visibility: hidden;
}
.tarjeta__marco {
  position: relative;
  display: flex; flex-direction: column;
  min-height: 480px;
  padding: 36px 12px;
  overflow: hidden; /* recorta los copos que se salen del borde */
  border-radius: 6px;
  background: repeating-linear-gradient(60deg, #F57CA7 0 15px, #F88FB5 15px 30px);
  box-shadow: 0 12px 0 rgba(78, 15, 46, .35), 0 30px 60px rgba(60, 5, 30, .35);
}

/* Papel: los mordiscos de los bordes son huecos (mask) por los que se ven las rayas del marco.
   Cada borde es una capa; las cuatro se intersectan y luego se rellenan las esquinas,
   así el primer y el último mordisco de cada lado no chocan con el corte diagonal. */
.tarjeta__papel {
  --r: 11px;   /* radio de cada mordisco */
  --g: 48px;   /* separación aproximada entre mordiscos (se ajusta para que quepan enteros) */
  --e: 44px;   /* esquinas sin mordiscos */
  --c: 14px;   /* corte diagonal de las esquinas */
  --lleno: linear-gradient(#000 0 0);
  --hueco: #0000 var(--r), #000 calc(var(--r) + .5px);
  --mascara:
    var(--lleno) 0 0 / var(--e) var(--e) no-repeat,
    var(--lleno) 100% 0 / var(--e) var(--e) no-repeat,
    var(--lleno) 0 100% / var(--e) var(--e) no-repeat,
    var(--lleno) 100% 100% / var(--e) var(--e) no-repeat,
    radial-gradient(circle at 50% 0, var(--hueco)) 0 0 / var(--g) 100% round no-repeat,
    radial-gradient(circle at 50% 100%, var(--hueco)) 0 0 / var(--g) 100% round no-repeat,
    radial-gradient(circle at 0 50%, var(--hueco)) 0 0 / 100% var(--g) no-repeat round,
    radial-gradient(circle at 100% 50%, var(--hueco)) 0 0 / 100% var(--g) no-repeat round;
  position: relative; z-index: 1;
  flex: 1;
  display: flex; flex-direction: column;
  padding: 42px 18px 22px;
  background: var(--blanco);
  clip-path: polygon(var(--c) 0, calc(100% - var(--c)) 0, 100% var(--c), 100% calc(100% - var(--c)),
    calc(100% - var(--c)) 100%, var(--c) 100%, 0 calc(100% - var(--c)), 0 var(--c));
  -webkit-mask: var(--mascara);
  -webkit-mask-composite: source-over, source-over, source-over, source-over, source-in, source-in, source-in, source-over;
  mask: var(--mascara);
  mask-composite: add, add, add, add, intersect, intersect, intersect, add;
}

.tarjeta__cabeza {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 6px 10px; margin-bottom: 14px;
}
.tarjeta__etiqueta {
  font-family: var(--fuente-titulos); font-size: 15px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--rosa-fuerte);
}
.tarjeta__dia {
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--rosa-fuerte); color: #fff;
  font-size: 16px; font-weight: 800; white-space: nowrap;
}
.tarjeta__titulo {
  margin: 0;
  font-family: var(--fuente-titulos); font-size: clamp(26px, 7.8vw, 31px); font-weight: 700; line-height: 1.1;
  text-wrap: balance;
}
.tarjeta__promo { margin: 12px 0 18px; font-size: clamp(19px, 5.6vw, 21px); line-height: 1.36; }
.tarjeta__promo mark { background: none; color: var(--rosa-fuerte); font-family: var(--fuente-titulos); font-weight: 700; }

.tarjeta__corte { margin-top: auto; border-top: 2.5px dashed rgba(78, 15, 46, .22); }

/* El sello tiene todo el ancho para que la fecha quepa en una línea; la nota va abajo, junto a la estampilla */
.tarjeta__pie { padding-top: 14px; text-align: left; }
.tarjeta__sello {
  display: inline-flex; flex-direction: column; gap: 2px;
  margin: 2px 0 0 2px;
  padding: 7px 12px;
  border: 3px solid var(--rojo); border-radius: 14px;
  color: var(--rojo);
  rotate: -3deg;
  text-wrap: balance;
}
.tarjeta__sello > span { font-size: 15px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.tarjeta__sello strong { font-size: clamp(17px, 5.3vw, 20px); font-weight: 800; line-height: 1.15; }
/* el lado derecho queda libre para la estampilla */
.tarjeta__nota { margin: 12px 0 0; padding-right: 82px; font-size: 17px; line-height: 1.35; opacity: .85; }

/* Estampilla: borde verde con perforaciones (círculos sobre las orillas) y la caja del día dentro */
.tarjeta__estampilla {
  --mascara-estampilla:
    radial-gradient(circle, #0000 3.6px, #000 4.1px) -6px -6px / 12px 12px,
    linear-gradient(#000 0 0) 50% 50% / calc(100% - 8px) calc(100% - 8px) no-repeat;
  position: absolute; z-index: 2;
  right: 8px; bottom: 12px;
  width: 96px; height: 96px; /* múltiplo de 12 para que las perforaciones cierren parejo */
  padding: 9px;
  background: #0B4D31;
  -webkit-mask: var(--mascara-estampilla);
  mask: var(--mascara-estampilla);
}
.tarjeta__estampilla img { display: block; width: 100%; height: 100%; object-fit: cover; }

.tarjeta__adornos { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.adorno { position: absolute; width: var(--t); height: var(--t); overflow: visible; }

/* botón sobre el fondo frambuesa de la escena */
.tarjeta > .boton {
  width: 100%; min-height: 54px; margin-top: 22px;
  background: #fff; color: var(--rosa-fuerte);
  font-size: 19px;
  box-shadow: 0 4px 0 rgba(78, 15, 46, .45);
}
.tarjeta > .boton:active { box-shadow: 0 1px 0 rgba(78, 15, 46, .45); }
.tarjeta > .boton:focus-visible { outline-color: #fff; }

/* Celulares angostos (320 px): menos margen y estampilla más chica para que el texto respire */
@media (max-width: 359px) {
  .escena__contenido { padding-left: 12px; padding-right: 12px; }
  .tarjeta__marco { min-height: 460px; padding: 32px 10px; }
  .tarjeta__papel { padding: 38px 16px 18px; }
  .tarjeta__etiqueta { font-size: 14px; letter-spacing: .06em; }
  .tarjeta__dia { padding: 2px 10px; font-size: 15px; }
  .tarjeta__sello > span { font-size: 14px; letter-spacing: .08em; }
  .tarjeta__nota { padding-right: 70px; font-size: 16px; }
  .tarjeta__estampilla { right: 4px; width: 84px; height: 84px; padding: 8px; }
}

/* ---------- Aviso flotante ---------- */
.aviso {
  position: fixed; z-index: 60;
  left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  /* max-content: con left: 50% el ancho automático se quedaba en media pantalla y partía el texto */
  width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 22px;
  border-radius: 26px;
  background: var(--blanco); color: var(--tinta);
  font-weight: 700; font-size: 17px; line-height: 1.3; text-align: center;
  box-shadow: 0 6px 0 var(--sombra);
  visibility: hidden; opacity: 0;
}

/* ---------- Pie ---------- */
.pie {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  padding: 0 24px calc(32px + env(safe-area-inset-bottom));
  font-size: 17px; line-height: 1.45; opacity: .88;
}
.pie h2 { margin: 0 0 8px; color: var(--rosa-fuerte); font-family: var(--fuente-titulos); font-size: 20px; font-weight: 700; }
.pie ul { margin: 0; padding-left: 20px; }
.pie li + li { margin-top: 6px; }

/* ---------- Error ---------- */
.error { margin: 0 0 12px; }
