/* ==========================================================
   Diseño "Osito" · Infantil ("Abrazo de osito")
   Osito de peluche propio sobre una mantita de cuadros: mantener presionado para abrazarlo →
   el corazón late → se abre como relicario con la foto → nombre bordado y etiqueta para el invitado.
   Paleta: beige, miel, rosa palo, crema y café suave. Textura de fieltro y peluche.
   ========================================================== */

:root {
  --cafe: #7c5236;
  --cafe-osc: #5a3d2b;
  --miel: #e2b06e;
  --rosa: #e8a5a6;
  --rosa-osc: #c46f7c;
  --crema: #fbf4ea;
  --beige: #f3e6d6;
  --alto: 100vh;

  --s-fondo: var(--crema);
  --s-tinta: var(--cafe-osc);
  --s-suave: #8b6b55;
  --s-acento: var(--rosa-osc);
  --s-acento-tinta: #fff9f2;
  --s-tarjeta: #fffaf3;
  --s-borde: rgba(160, 110, 70, .2);
  --s-radio: 26px;
  --s-sombra: 0 16px 28px -18px rgba(110, 70, 40, .5);
  --s-fuente: "Fredoka", system-ui, sans-serif;
  --s-titulo: "Pacifico", "Fredoka", cursive;
  --s-titulo-tam: clamp(1.9rem, 8.4vw, 2.5rem);
  --s-titulo-color: var(--cafe);
  --s-etiqueta: "Fredoka", system-ui, sans-serif;
  --s-num: "Fredoka", system-ui, sans-serif;
  --s-num-color: var(--rosa-osc);
  --s-btn-linea-color: var(--cafe);
}
@supports (height: 100svh) { :root { --alto: 100svh; } }

body {
  background:
    radial-gradient(circle, rgba(232, 165, 166, .2) 2.2px, transparent 2.8px) 0 0 / 30px 30px,
    radial-gradient(circle, rgba(226, 176, 110, .16) 2.2px, transparent 2.8px) 15px 15px / 30px 30px,
    var(--grano),
    var(--crema);
  color: var(--s-tinta);
  font-family: var(--s-fuente);
}

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

/* ==========================================================
   HERO · el cuarto del osito
   ========================================================== */
.cuarto {
  position: relative;
  min-height: var(--alto);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 12px);
  overflow: hidden;
  background:
    radial-gradient(70% 45% at 50% 18%, rgba(255, 238, 205, .9), transparent 70%),
    radial-gradient(circle, rgba(232, 165, 166, .28) 1.6px, transparent 2.2px) 11px 11px / 44px 44px,
    repeating-linear-gradient(90deg, #f6eadb 0 22px, #f2e2cf 22px 44px);
}

/* Capa de piezas de fieltro que brotan del abrazo */
.fieltros { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.fieltro { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; will-change: transform, opacity; }
.fieltro .f { fill: var(--c, #e8a5a6); stroke: rgba(122, 78, 51, .28); stroke-width: .8; stroke-linejoin: round; }
.fieltro .p { fill: none; stroke: #ffffff; stroke-width: 1.1; stroke-dasharray: 2.2 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }

/* ---------- Cabecera (instrucción ↔ nombre bordado) ---------- */
.cab {
  position: relative;
  z-index: 3;
  display: grid;
  width: min(100%, 420px);
  min-height: 132px;
  align-items: end;
  text-align: center;
}
.cab > * { grid-area: 1 / 1; }
.cab__intro { transition: opacity .5s ease, transform .5s ease, visibility 0s; }
.cab__eyebrow { margin: 0; font-weight: 600; font-size: .76rem; letter-spacing: .2em; text-transform: uppercase; color: #b07a5a; }
.cab__titulo {
  margin: 6px auto 4px;
  max-width: 15em;
  font-family: "Pacifico", "Fredoka", cursive;
  font-size: clamp(1.32rem, 6.2vw, 1.85rem);
  line-height: 1.32;
  color: var(--cafe);
  text-shadow: 0 2px 0 #fff9f1;
}
.cab__final { visibility: hidden; display: flex; flex-direction: column; align-items: center; }
.cab__cumplo {
  position: relative;
  margin: 0;
  padding-bottom: 4px;
  font-weight: 700;
  font-size: clamp(1.2rem, 5.6vw, 1.5rem);
  letter-spacing: .02em;
  color: var(--rosa-osc);
  opacity: 0;
}
.cab__cumplo::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 0;
  border-bottom: 2px dashed rgba(196, 111, 124, .55);
}
.bordado { position: relative; width: min(84vw, 300px); margin: 0; line-height: 0; }
.bordado:focus { outline: none; }
.bordado__svg { display: block; width: 100%; height: auto; overflow: visible; clip-path: inset(0 100% 0 0); }
.bordado__svg text { font-family: "Pacifico", "Fredoka", cursive; }
.bordado__carril { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; }
.bordado__aguja { position: absolute; left: -12px; top: 20%; width: 26px; height: 26px; overflow: visible; }
.cab__fecha { margin: 2px 0 0; font-weight: 500; font-size: .98rem; letter-spacing: .03em; color: var(--s-suave); opacity: 0; }

.final .cab__intro { opacity: 0; transform: translateY(-10px); visibility: hidden; transition: opacity .45s ease, transform .45s ease, visibility 0s .45s; }
.final .cab__final { visibility: visible; }
.final .cab__cumplo { animation: osito-pop .7s cubic-bezier(.3, 1.6, .5, 1) both; }
.nombre .bordado__svg { animation: osito-coser 1.7s linear .1s both; }
.nombre .bordado__carril { animation: osito-carril 1.7s linear .1s both, osito-desvanecer .4s ease 1.8s forwards; }
.nombre .bordado__aguja { animation: osito-puntada .17s ease-in-out .1s 10; }
.nombre .cab__fecha { animation: osito-subir .6s ease 1.4s both; }

@keyframes osito-pop { 0% { opacity: 0; transform: scale(.4); } 60% { opacity: 1; transform: scale(1.12); } 100% { opacity: 1; transform: scale(1); } }
@keyframes osito-coser { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes osito-carril { from { opacity: 1; transform: translateX(0); } to { opacity: 1; transform: translateX(100%); } }
@keyframes osito-desvanecer { from { opacity: 1; } to { opacity: 0; } }
@keyframes osito-puntada { 0% { transform: translateY(0); } 50% { transform: translateY(9px); } 100% { transform: translateY(0); } }
@keyframes osito-subir { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Escenario: piso, guirnalda, mantita y osito ---------- */
.escenario {
  --esc: clamp(196px, min(88vw, calc((var(--alto) - 290px) * .889)), 340px);
  position: relative;
  z-index: 2;
  width: var(--esc);
  aspect-ratio: 320 / 360;
  flex: none;
}
.escenario::before {                       /* piso de madera clara con zoclo */
  content: "";
  position: absolute;
  z-index: -1;
  left: -100vw;
  right: -100vw;
  top: 60%;
  height: 100vh;
  border-top: 9px solid #fbf3e8;
  box-shadow: 0 -2px 0 #e6d2b9, inset 0 10px 14px -10px rgba(110, 70, 40, .35);
  background:
    repeating-linear-gradient(180deg, transparent 0 30px, rgba(150, 105, 65, .14) 30px 32px),
    linear-gradient(#ecd9bf, #e3c9a6 60%);
}
.guirnalda {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: -7%;
  width: 165%;
  transform: translateX(-50%);
  overflow: visible;
  pointer-events: none;
}
.guir__colg { transform-box: fill-box; transform-origin: 50% 0; animation: osito-mecer 3.4s ease-in-out infinite; }
.guirnalda g:nth-of-type(2n) .guir__colg { animation-delay: -1.1s; animation-duration: 3.9s; }
.guirnalda g:nth-of-type(3n) .guir__colg { animation-delay: -2.2s; }
@keyframes osito-mecer { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }

.mantita {
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: -7%;
  width: 124%;
  height: 50%;
  border-radius: 22px;
  transform: translateX(-50%) perspective(600px) rotateX(58deg);
  transform-origin: 50% 100%;
  background-color: #fdf6ee;
  background-image:
    linear-gradient(90deg, rgba(232, 160, 158, .5) 50%, transparent 0),
    linear-gradient(rgba(232, 160, 158, .5) 50%, transparent 0);
  background-size: 34px 34px;
  background-position: center;
  border: 7px solid #efbdb7;
  outline: 2px dashed rgba(255, 255, 255, .9);
  outline-offset: -14px;
  box-shadow: 0 26px 26px -14px rgba(110, 70, 40, .38);
}

/* El osito es un <button>: se mantiene presionado (pointer o Espacio/Enter) */
.osito {
  all: unset;
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  border-radius: 40%;
}
.osito:active { cursor: grabbing; }
.osito:focus-visible { outline: 3px dashed var(--rosa-osc); outline-offset: 2px; }
.osito:disabled { cursor: default; }
.osito__cuerpo { position: absolute; inset: 0; display: block; transform-origin: 50% 94%; will-change: transform; }
.osito__svg, .osito__brazos { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.osito__cabeza { transform-box: view-box; transform-origin: 160px 192px; }
.brazo { transform-box: view-box; }
.brazo--izq { transform-origin: 104px 206px; transform: rotate(118deg); }
.brazo--der { transform-origin: 216px 206px; transform: rotate(-118deg); }
.oreja { transform-box: view-box; transition: transform .45s cubic-bezier(.3, 1.5, .5, 1); }
.oreja--izq { transform-origin: 104px 72px; }
.oreja--der { transform-origin: 216px 72px; }
.mejilla { opacity: var(--rubor, .32); }
.ojo { transform-box: fill-box; transform-origin: 50% 50%; transition: transform .07s ease, opacity .15s ease; }
.ojo-feliz, .ceja, .boca--feliz, .boca--triste, .lagrima { opacity: 0; transition: opacity .18s ease; }
.boca--normal { transition: opacity .18s ease; }
.lagrima { transform-box: fill-box; }

.parpadea .ojo { transform: scaleY(.1); }
.es-abrazo .ojo { opacity: 0; }
.es-abrazo .ojo-feliz { opacity: 1; }
.es-abrazo .boca--normal, .es-feliz .boca--normal, .es-triste .boca--normal { opacity: 0; }
.es-abrazo .boca--feliz, .es-feliz .boca--feliz { opacity: 1; }
.es-abrazo .oreja--izq { transform: rotate(7deg); }
.es-abrazo .oreja--der { transform: rotate(-7deg); }
.es-triste .boca--triste, .es-triste .ceja { opacity: 1; }
.es-triste .oreja--izq { transform: rotate(-16deg); }
.es-triste .oreja--der { transform: rotate(16deg); }
.es-triste .lagrima { animation: osito-lagrima 1.5s ease-in .2s both; }
@keyframes osito-lagrima { 0% { opacity: 0; transform: translateY(-2px); } 25% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(16px); } }

/* ---------- Relicario (parche de corazón) ---------- */
.relicario {
  position: absolute;
  left: 50%;
  top: 73.89%;
  width: 46%;
  aspect-ratio: 100 / 90;
  display: block;
  z-index: 2;
  pointer-events: none;
  transform: translate(-50%, -50%) translateY(12.1%) scale(.34);
  will-change: transform;
}
.relicario__brillo {
  position: absolute;
  inset: -40%;
  display: block;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 240, 214, .95), rgba(255, 184, 192, .55) 45%, rgba(255, 184, 192, 0));
  opacity: var(--brillo, 0);
  transform: scale(calc(.75 + var(--brillo, 0) * .35));
}
.relicario__interior, .relicario__tapa { position: absolute; inset: 0; display: block; }
.relicario__interior svg { display: block; width: 100%; height: 100%; overflow: visible; }
.relicario__tapa { perspective: 520px; }
.relicario__puerta {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  display: block;
  transform-style: preserve-3d;
  transition: transform 1.15s cubic-bezier(.25, 1.35, .45, 1);
}
.relicario__puerta--izq { left: 0; transform-origin: 0 50%; }
.relicario__puerta--der { right: 0; transform-origin: 100% 50%; }
.cara { position: absolute; inset: 0; display: block; overflow: hidden; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.cara svg { position: absolute; top: 0; width: 200%; height: 100%; display: block; }
.cara--dorso { transform: rotateY(180deg); }
.relicario__puerta--izq .cara--frente svg, .relicario__puerta--der .cara--dorso svg { left: 0; }
.relicario__puerta--izq .cara--dorso svg, .relicario__puerta--der .cara--frente svg { left: -100%; }
.tapa__luz { opacity: var(--luz, 0); }
.abierto .relicario__puerta--izq { transform: rotateY(-122deg); }
.abierto .relicario__puerta--der { transform: rotateY(122deg); }

/* ---------- Etiqueta de cartón colgada de la patita ---------- */
.etiqueta {
  position: absolute;
  z-index: 3;
  left: 79.4%;
  top: 74.6%;
  width: 36%;
  min-width: 100px;
  max-width: 134px;
  transform: translateX(-50%);
  transform-origin: 50% 0;
  visibility: hidden;
  pointer-events: none;
  filter: drop-shadow(0 8px 8px rgba(110, 70, 40, .28));
}
.etiqueta.ver { visibility: visible; animation: osito-etiqueta 1.6s cubic-bezier(.3, .7, .4, 1) both, osito-mece 4.2s ease-in-out 1.6s infinite; }
.etiqueta__hilo {
  position: relative;
  z-index: 1;
  display: block;
  width: 2px;
  height: 26px;
  margin: 0 auto -10px;
  border-radius: 1px;
  background: repeating-linear-gradient(180deg, #a77d52 0 3px, #d9b98c 3px 6px);
}
.etiqueta__carton {
  position: relative;
  padding: 19px 10px 11px;
  text-align: center;
  color: var(--cafe-osc);
  background: var(--grano), linear-gradient(165deg, #e6caa0, #d6b386 70%, #cfaa7b);
  clip-path: polygon(24% 0, 76% 0, 100% 15%, 100% 100%, 0 100%, 0 15%);
}
.etiqueta__carton::after {
  content: "";
  position: absolute;
  inset: 15px 6px 6px;
  border: 1.5px dashed rgba(90, 61, 43, .32);
  border-radius: 4px;
  pointer-events: none;
}
.etiqueta__ojal {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: #f6eadb;
  box-shadow: 0 0 0 2.5px #c39a69, inset 0 1px 2px rgba(0, 0, 0, .25);
}
.etiqueta__t { margin: 0; font-family: "Caveat", cursive; font-weight: 600; font-size: 1rem; line-height: 1; }
.etiqueta__n { margin: 2px 0 0; font-family: "Caveat", cursive; font-weight: 700; font-size: 1.36rem; line-height: 1.02; color: #8e3f50; overflow-wrap: anywhere; }
.etiqueta__pases { margin: 4px 0 0; font-weight: 600; font-size: .6rem; letter-spacing: .06em; text-transform: uppercase; color: var(--cafe); }
@keyframes osito-etiqueta {
  0% { opacity: 0; transform: translateX(-50%) translateY(-26px) rotate(-30deg); }
  30% { opacity: 1; transform: translateX(-50%) translateY(0) rotate(16deg); }
  50% { opacity: 1; transform: translateX(-50%) rotate(-9deg); }
  68% { opacity: 1; transform: translateX(-50%) rotate(5deg); }
  84% { opacity: 1; transform: translateX(-50%) rotate(-2deg); }
  100% { opacity: 1; transform: translateX(-50%) rotate(0deg); }
}
@keyframes osito-mece { 0%, 100% { transform: translateX(-50%) rotate(0deg); } 25% { transform: translateX(-50%) rotate(-2.5deg); } 75% { transform: translateX(-50%) rotate(2.5deg); } }

.personaje { position: absolute; z-index: 2; left: -8%; bottom: 0; width: 34%; height: auto; pointer-events: none; }

/* ---------- Controles: hilo de progreso + botón alterno ---------- */
.controles {
  position: relative;
  z-index: 3;
  width: min(100%, 320px);
  display: grid;
  justify-items: center;
  gap: 4px;
  margin-top: 4px;
  transition: opacity .45s ease, visibility 0s;
}
.final .controles { opacity: 0; visibility: hidden; transition: opacity .45s ease, visibility 0s .45s; }
.hilo { width: min(100%, 290px); }
.hilo__svg { display: block; width: 100%; height: auto; overflow: visible; }
.hilo__cor { transition: fill .3s ease; }
.hilo--lleno .hilo__cor { fill: #e07f8c; }
.pista { margin: 0; min-height: 1.4em; font-weight: 500; font-size: .92rem; color: var(--s-suave); }
.btn-osito {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  margin-top: 4px;
  padding: 0 22px;
  border-radius: 999px;
  background: #fffaf3;
  color: var(--cafe);
  font-family: "Fredoka", system-ui, sans-serif;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  outline: 1.5px dashed rgba(196, 111, 124, .55);
  outline-offset: -6px;
  box-shadow: 0 5px 0 #e3c9ab, 0 12px 20px -12px rgba(110, 70, 40, .55);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-osito svg { color: var(--rosa-osc); flex: none; }
.btn-osito:active { transform: translateY(3px); box-shadow: 0 2px 0 #e3c9ab, 0 8px 14px -10px rgba(110, 70, 40, .55); }
.btn-osito:focus-visible { box-shadow: 0 5px 0 #e3c9ab, 0 0 0 3px var(--rosa-osc); }
.btn-osito:disabled { opacity: .6; cursor: default; }

.cuarto .desliza-c { z-index: 4; color: var(--cafe); }

/* ==========================================================
   INVITACIÓN
   ========================================================== */
.costura { display: block; width: min(62%, 220px); height: auto; margin: 0 auto; }

.carta { padding-top: 64px; }
.carta__foto {
  margin: 0 0 26px;
  padding: 12px 12px 10px;
  width: min(74%, 280px);
  background: #fffaf3;
  border-radius: 18px;
  outline: 2px dashed rgba(196, 111, 124, .45);
  outline-offset: -6px;
  box-shadow: var(--s-sombra);
  transform: rotate(-2.5deg);
}
.carta__foto img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.carta__foto figcaption { margin-top: 8px; font-family: "Caveat", cursive; font-weight: 700; font-size: 1.3rem; color: var(--cafe); }
.carta__eyebrow { margin: 0; font-weight: 600; font-size: .76rem; letter-spacing: .22em; text-transform: uppercase; color: #b07a5a; }
.carta__titulo { margin: 6px 0 12px; font-family: "Pacifico", "Fredoka", cursive; font-weight: 400; font-size: clamp(2rem, 9vw, 2.6rem); line-height: 1.2; color: var(--rosa-osc); }
.carta__texto { margin: 0; max-width: 23em; font-size: 1.06rem; line-height: 1.65; }
.carta__firma { margin: 18px 0 0; font-family: "Caveat", cursive; font-weight: 700; font-size: 1.6rem; color: var(--cafe); }

/* Tarjetas de fieltro con costura */
.s-cuenta__caja, .s-evento {
  background: var(--grano), #fffaf3;
  outline: 1.5px dashed rgba(196, 111, 124, .42);
  outline-offset: -7px;
}
.s-cuenta__caja { border-radius: 22px; }
.s-cuenta__num { font-weight: 600; }
.s-evento__icono { background: #fdf0ea; border-style: dashed; }
.s-evento__hora { font-weight: 600; }
.s-btn--lleno {
  background: var(--cafe);
  color: #fff7ec;
  outline: 1.5px dashed rgba(255, 247, 236, .55);
  outline-offset: -6px;
}
.s-btn--lleno svg { color: #f4b9b2; }
.s-btn--lleno:focus-visible { outline: 2px solid var(--rosa-osc); outline-offset: 3px; }
.s-btn--linea, .s-btn--mini { border-style: dashed; background: rgba(255, 250, 243, .7); }
.s-foto { padding: 7px; background: #fffaf3; outline: 1.5px dashed rgba(196, 111, 124, .4); outline-offset: -4px; }
.s-foto img { border-radius: calc(var(--s-radio) - 8px); }
.s-galeria__rejilla .s-foto:nth-child(2) { transform: rotate(-1.5deg); }
.s-galeria__rejilla .s-foto:nth-child(3) { transform: rotate(1.5deg); }
.s-paleta li { border-style: dashed; border-color: rgba(160, 110, 70, .35); }
.s-vestimenta__tipo { font-family: "Fredoka", system-ui, sans-serif; font-weight: 600; font-size: 1.45rem; }
.s-rsvp__saludo { font-family: "Caveat", cursive; font-weight: 700; font-size: 1.65rem; }
.s-pie__n { color: var(--rosa-osc); }

/* ==========================================================
   Pantallas bajas o muy angostas
   ========================================================== */
@media (max-height: 600px) {
  .cab { min-height: 118px; }
  .cab__titulo { font-size: 1.25rem; }
  .bordado { width: min(76vw, 260px); }
  .btn-osito { min-height: 44px; }
}
@media (max-height: 520px) {
  .escenario { --esc: clamp(140px, calc((var(--alto) - 250px) * .889), 340px); }
  .cab { min-height: 100px; }
  .cab__eyebrow { display: none; }
  .pista { position: absolute; width: 1px; height: 1px; min-height: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }  /* sigue anunciándose */
  .bordado { width: min(60vw, 220px); }
}
@media (max-width: 370px) {
  .etiqueta__n { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .guir__colg, .es-triste .lagrima { animation: none; }
  .etiqueta.ver { animation: none; opacity: 1; }
  .final .cab__cumplo, .nombre .bordado__svg, .nombre .cab__fecha { animation-duration: .01s; animation-delay: 0s; }
  .bordado__carril { display: none; }
  .relicario__puerta { transition-duration: .25s; transition-timing-function: ease-out; }
  .oreja { transition-duration: .15s; }
}
