@font-face { font-family: 'Fraunces'; src: url('fuentes/fraunces.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Figtree'; src: url('fuentes/figtree.woff2') format('woff2'); font-weight: 300 900; font-display: swap; }

/* A very Christmassy night: fir green, falling snow, baubles above and reindeer below */
:root, [data-tema='pino'] { --fondo: #0f3b2c; --panel: #19533e; }
[data-tema='noche'] { --fondo: #132648; --panel: #213b6a; }
[data-tema='acebo'] { --fondo: #5c1426; --panel: #7c2139; }
:root {
  --tinta: #fbf3e4; --tinta-suave: #dce7df; --luz: #f6d370; --sobre-luz: #2a1f08; --papel: #fff; --sobre-papel: #17231f;
  --rojo: #c8302b; --fondo-abierto: #7d1f1b; --crema: #fbf3e4; --sobre-crema: #3a2a14;
  --radio: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { background: var(--fondo); -webkit-text-size-adjust: 100%; }
body { color: var(--tinta); font: 400 1.0625rem/1.5 'Figtree', system-ui, sans-serif; min-height: 100dvh; overflow-wrap: anywhere; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 650; line-height: 1.08; text-wrap: balance; }
h1 { font-size: clamp(2.25rem, 10vw, 3.75rem); letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.75rem; }
a { color: var(--luz); text-underline-offset: 3px; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--luz); outline-offset: 3px; }

.columna { width: 100%; max-width: 34rem; margin: 0 auto; padding: 1.5rem max(1.25rem, env(safe-area-inset-right)) 3rem max(1.25rem, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 1.5rem; }
.columna, .volver { position: relative; z-index: 1; }
.centrada { text-align: center; }
.entradilla { font-size: 1.25rem; line-height: 1.4; }
.nota { color: var(--tinta-suave); font-size: 1rem; }
.texto h2 { margin-top: 1rem; }
.dibujo { width: 100%; height: auto; border-radius: var(--radio); }
.volver { width: 100%; max-width: 34rem; margin: 0 auto; padding: 0 1.25rem; }
.volver a { display: inline-block; padding: 0.6rem 0; font-weight: 600; }
.volver a::before { content: '← '; }

/* ---------- Decorations. They never get in the way of a finger */
.definiciones { position: absolute; width: 0; height: 0; overflow: hidden; }
.nieve { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.nieve i { position: absolute; left: 0; right: 0; top: -400px; bottom: 0; background: url('dibujos/copos-lejos.svg'); animation: nevar 26s linear infinite; }
.nieve i + i { background-image: url('dibujos/copos-cerca.svg'); background-position: 130px 0; animation-duration: 15s; }
@keyframes nevar { to { transform: translateY(400px); } }
.guirnalda { flex: none; height: 84px; background: url('dibujos/guirnalda.svg') top center / 390px 84px repeat-x; pointer-events: none; }
@media (min-width: 30rem) { .guirnalda { height: 108px; background-size: 500px 108px; } }
.suelo { position: relative; z-index: 1; margin-top: auto; }
.suelo img { width: 100%; max-width: none; height: clamp(150px, 38vw, 200px); object-fit: cover; object-position: top center; }
.suelo .pie { background: #e3eaf4; text-align: center; padding: 0.5rem 1rem calc(0.75rem + env(safe-area-inset-bottom)); margin-top: -1px; }
.pie a { display: inline-block; padding: 0.5rem 1rem; color: #24425c; }

/* ---------- Forms and buttons */
form { display: flex; flex-direction: column; gap: 1.25rem; }
label, fieldset { display: flex; flex-direction: column; gap: 0.4rem; font-weight: 600; border: 0; min-width: 0; }
legend { margin-bottom: 0.4rem; }
input:not([type=radio], [type=checkbox]), textarea {
  width: 100%; min-height: 3.25rem; padding: 0.75rem 0.9rem; font: inherit; font-weight: 400;
  color: var(--sobre-papel); background: var(--papel); border: 0; border-radius: var(--radio); color-scheme: light;
}
textarea { resize: vertical; }
input[type=file] { padding: 0.65rem; }
input::file-selector-button { font: inherit; font-weight: 600; margin-right: 0.75rem; padding: 0.35rem 0.75rem; border: 0; border-radius: 6px; background: #e4ece9; color: var(--sobre-papel); }
.casilla { flex-direction: row; align-items: center; gap: 0.75rem; }
.casilla input { width: 1.5rem; height: 1.5rem; accent-color: var(--luz); }

.temas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.tema { position: relative; align-items: center; justify-content: center; min-height: 4rem; padding: 0.6rem; background: var(--fondo); border: 2px solid var(--crema); border-radius: var(--radio); cursor: pointer; }
.tema input { position: absolute; opacity: 0; }
.tema:has(input:checked) { outline: 4px solid var(--luz); }
.tema:has(input:focus-visible) { outline: 4px dashed var(--luz); }

.boton {
  display: inline-flex; align-items: center; justify-content: center; min-height: 3.25rem; padding: 0.6rem 1.4rem;
  font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer;
  color: var(--sobre-luz); background: var(--luz); border: 0; border-radius: 99px;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.boton:hover { filter: brightness(1.06); }
.boton:active { transform: scale(0.97); }
.boton:disabled { opacity: 0.6; cursor: progress; }
.boton.secundario { background: var(--panel); color: var(--tinta); }
.bloque .boton.secundario, .añadir .boton.secundario { background: var(--fondo); }
.boton.peligro { background: var(--papel); color: #9d1c1c; }
.boton.grabando { background: var(--papel); color: #9d1c1c; }
.estado:empty { display: none; }
.estado { font-weight: 600; }
.estado.error { background: var(--papel); color: #9d1c1c; padding: 0.75rem 1rem; border-radius: var(--radio); }

.bloque { background: var(--panel); border-radius: var(--radio); padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.enlace { font-size: 0.95rem !important; text-overflow: ellipsis; }
.acciones, .vecinas { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.aviso { background: var(--luz); color: var(--sobre-luz); border-radius: var(--radio); padding: 1.1rem 1.25rem; }
.aviso a { color: inherit; font-weight: 700; display: inline-block; padding: 0.5rem 0.9rem 0.25rem 0; }

/* ---------- The presents */
.cartel { position: relative; z-index: 1; text-align: center; padding: 0.5rem 1.25rem 0; }
.cartel h1 { font-weight: 500; }
.cartel .año { color: var(--luz); font-weight: 600; margin-bottom: 0.25rem; }
.cartel .de { color: var(--tinta-suave); margin-top: 0.35rem; }
.columna.calendario { max-width: 32rem; padding: 1rem 0.9rem 1rem; gap: 1rem; }
.mosaico { container-type: inline-size; }
.rejilla { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 17.6cqw; gap: 2.4cqw; }
.rejilla li { min-width: 0; min-height: 0; }
.r1 { grid-area: 1 / 1 / span 1 / span 1; }
.r2 { grid-area: 1 / 2 / span 1 / span 1; }
.r3 { grid-area: 4 / 1 / span 1 / span 1; }
.r4 { grid-area: 6 / 2 / span 1 / span 1; }
.r5 { grid-area: 2 / 4 / span 1 / span 1; }
.r6 { grid-area: 7 / 3 / span 1 / span 1; }
.r7 { grid-area: 5 / 3 / span 1 / span 2; }
.r8 { grid-area: 6 / 4 / span 1 / span 1; }
.r9 { grid-area: 2 / 3 / span 2 / span 1; }
.r10 { grid-area: 6 / 1 / span 2 / span 1; }
.r11 { grid-area: 8 / 1 / span 1 / span 1; }
.r12 { grid-area: 3 / 4 / span 1 / span 1; }
.r13 { grid-area: 8 / 4 / span 1 / span 1; }
.r14 { grid-area: 4 / 3 / span 1 / span 1; }
.r15 { grid-area: 7 / 2 / span 1 / span 1; }
.r16 { grid-area: 8 / 3 / span 1 / span 1; }
.r17 { grid-area: 1 / 3 / span 1 / span 2; }
.r18 { grid-area: 5 / 1 / span 1 / span 1; }
.r19 { grid-area: 7 / 4 / span 1 / span 1; }
.r20 { grid-area: 4 / 2 / span 2 / span 1; }
.r21 { grid-area: 6 / 3 / span 1 / span 1; }
.r22 { grid-area: 4 / 4 / span 1 / span 1; }
.r23 { grid-area: 8 / 2 / span 1 / span 1; }
.r24 { grid-area: 2 / 1 / span 2 / span 2; }
.paquete { position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; border-radius: 14px; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform 0.12s ease; }
.paquete:active { transform: scale(0.94); }
.paquete.marcado { outline: 3px dashed var(--luz); outline-offset: 2px; }
.paquete:focus-visible { outline: 3px solid var(--papel); outline-offset: 3px; }
.regalo { display: block; width: 100%; height: 100%; overflow: visible; }
.regalo text { font-family: 'Fraunces', Georgia, serif; font-weight: 650; }
.regalo .tapa, .regalo .lazo, .regalo .destellos .destello { transform-box: fill-box; }
.regalo .tapa { transform-origin: 85% 100%; }
.regalo .lazo { transform-origin: center bottom; }
.regalo .destellos, .regalo .visto { display: none; }

/* Available and not opened yet: it wiggles now and then */
.paquete.listo .regalo { animation: llamar 4s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes llamar { 0%, 82%, 100% { transform: none; } 86% { transform: rotate(-4deg) scale(1.04); } 90% { transform: rotate(3deg) scale(1.04); } 94% { transform: rotate(-2deg); } }
/* Opened: lid off, a tick and a sparkle */
.abierto .regalo .tapa, .caja .regalo .tapa { transform: translate(7%, -75%) rotate(-19deg); }
.abierto .regalo .destellos, .abierto .regalo .visto, .abriendo .regalo .destellos, .caja .regalo .destellos { display: inline; }
.abierto .regalo .destellos .destello:nth-child(n + 2) { display: none; }
.paquete.abierto .regalo { opacity: 0.62; }
/* Empty, only seen by the giver */
.paquete.vacio .cuerpo > rect, .paquete.vacio .tapa { opacity: 0.4; }
.paquete.vacio .lazo { display: none; }

/* Opening: the bow flies away, the lid lifts, sparkles */
.paquete.abriendo { z-index: 3; }
.paquete.abriendo .regalo { animation: sacudir 0.35s ease 2; }
.abriendo .lazo { animation: desatar 0.5s ease-in 0.1s forwards; }
.abriendo .tapa { animation: destapar 0.55s cubic-bezier(0.3, 1.5, 0.6, 1) 0.45s forwards; }
.abriendo .destello, .caja .destello { transform-origin: center; animation: brillar 0.7s ease-out 0.55s backwards; }
.caja .destello { animation-delay: 0.25s; }
.caja .destello:nth-child(2) { animation-delay: 0.4s; }
.caja .destello:nth-child(3) { animation-delay: 0.55s; }
.caja .tapa { animation: destapar 0.6s cubic-bezier(0.3, 1.5, 0.6, 1) backwards; }
@keyframes sacudir { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes desatar { to { transform: translateY(-160%) rotate(35deg) scale(0.5); opacity: 0; } }
@keyframes destapar { from { transform: none; } to { transform: translate(7%, -75%) rotate(-19deg); } }
@keyframes brillar { from { transform: scale(0) rotate(-90deg); opacity: 0; } 60% { transform: scale(1.5); opacity: 1; } }
.paquete.temblor { animation: temblor 0.4s ease; }
@keyframes temblor { 25% { transform: translateX(-5px) rotate(-3deg); } 75% { transform: translateX(5px) rotate(3deg); } }

.anuncio { align-self: center; margin-bottom: -2.5rem; position: relative; z-index: 2; background: var(--rojo); color: var(--crema); font: 700 1.1rem/1.3 'Figtree', system-ui, sans-serif; text-align: center; border: 0; border-radius: 99px; padding: 0.85rem 1.6rem; }
button.anuncio { cursor: pointer; }
.flotante { position: fixed; left: 1rem; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); max-width: 30rem; margin: 0 auto; background: var(--papel); color: var(--sobre-papel); padding: 0.9rem 1.1rem; border-radius: var(--radio); box-shadow: 0 8px 24px rgb(0 0 0 / 0.35); text-align: center; z-index: 2; }

/* ---------- The open present */
dialog { width: 100%; height: 100%; max-width: none; max-height: none; border: 0; background: var(--fondo-abierto); color: var(--crema); overscroll-behavior: contain; }
dialog[open] { display: flex; flex-direction: column; animation: aparecer 0.35s ease; }
dialog > .guirnalda { flex: none; }
@keyframes aparecer { from { opacity: 0; transform: translateY(24px) scale(0.97); } }
.visor-contenido { position: relative; z-index: 1; width: 100%; max-width: 32rem; margin: 0 auto; padding: 0.5rem 1.25rem 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 1.25rem; text-align: center; }
.visor-contenido h2 { font: 600 1.25rem/1.3 'Figtree', system-ui, sans-serif; color: var(--luz); }
.caja { width: 11rem; height: 7.5rem; margin-top: 2rem; }
.sorpresa { width: 100%; animation: aparecer 0.5s ease 0.45s backwards; }
.despues:empty { display: none; }
.visor-suelo { position: relative; z-index: 1; flex: none; margin-top: auto; width: 100%; max-width: none; height: clamp(150px, 38vw, 200px); object-fit: cover; object-position: top center; background: var(--fondo-abierto); }

/* The surprise, on a big card */
.tarjeta { background: var(--crema); color: var(--sobre-crema); border: 4px solid var(--luz); border-radius: 24px; padding: 1.5rem 1.25rem; display: flex; flex-direction: column; gap: 1rem; text-align: center; color-scheme: light; }
.tarjeta h3 { font-weight: 500; }
.firma { color: #75592c; }
.mensaje { white-space: pre-wrap; font: 400 1.5rem/1.45 'Fraunces', Georgia, serif; }
.foto, .tarjeta video { width: 100%; height: auto; max-height: 70dvh; object-fit: contain; border-radius: 12px; }
.tarjeta video { background: #000; }
.reproductor { display: flex; align-items: center; gap: 0.9rem; }
.reproductor audio { width: 100%; }
.reproductor .onda, .reproductor.listo audio { display: none; }
.reproductor.listo .onda { display: block; flex: 1; min-width: 0; height: 3.5rem; fill: var(--rojo); }
.onda rect { opacity: 0.4; }
.onda rect.sonado { opacity: 1; }
.tocar { flex: none; width: 4.5rem; height: 4.5rem; border: 0; border-radius: 50%; background: var(--rojo); cursor: pointer; transition: transform 0.12s ease; }
.tocar:active { transform: scale(0.93); }
.tocar::before { content: ''; display: block; width: 1.4rem; height: 1.7rem; margin: 0 auto; translate: 0.2rem 0; background: var(--crema); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.tocar[aria-pressed='true']::before { translate: 0; clip-path: polygon(0 0, 35% 0, 35% 100%, 0 100%, 0 0, 65% 0, 100% 0, 100% 100%, 65% 100%, 65% 0); }
.tarjeta :focus-visible { outline-color: var(--rojo); }
.de-vale { border-style: dashed; border-color: var(--rojo); outline: 4px solid var(--luz); outline-offset: 4px; margin: 4px; }
.de-vale h3 { font-size: 2.1rem; font-weight: 650; color: #8f221e; }
.de-vale .detalle { white-space: pre-wrap; }
.de-vale .para { align-self: center; font-weight: 700; background: var(--rojo); color: var(--crema); padding: 0.4rem 1.2rem; border-radius: 99px; }

/* ---------- Door editor */
.piezas { list-style: none; display: flex; flex-direction: column; gap: 2rem; }
.pieza { display: flex; flex-direction: column; gap: 0.75rem; }
.herramientas { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: start; justify-content: end; }
.herramientas details { margin-right: auto; }
.herramientas details[open] { flex-basis: 100%; }
.herramientas summary { display: inline-flex; align-items: center; min-height: 3.25rem; padding: 0 1.4rem; border-radius: 99px; background: var(--panel); font-weight: 700; cursor: pointer; list-style: none; }
.herramientas details form { margin-top: 1rem; }
.opciones { display: flex; flex-direction: column; gap: 0.75rem; }
.añadir { background: var(--panel); border-radius: var(--radio); }
.añadir summary { display: flex; justify-content: space-between; align-items: center; min-height: 3.5rem; padding: 0 1.25rem; font-weight: 700; cursor: pointer; list-style: none; }
.añadir summary::-webkit-details-marker, .herramientas summary::-webkit-details-marker { display: none; }
.añadir summary::after { content: '+'; font-size: 1.75rem; color: var(--luz); }
.añadir[open] summary::after { content: '−'; }
.añadir > form, .añadir > .dentro, .grabadora { padding: 0.25rem 1.25rem 1.25rem; }
.añadir > .dentro { display: flex; flex-direction: column; gap: 1rem; }
.grabadora { display: flex; flex-direction: column; gap: 0.75rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
