/* ¿Qué me pongo? — una pregunta, una respuesta y un sol de pie en su colina */

:root {
  --ink: #4b2a20;          /* chocolate, como los ojos del sol */
  --ink-soft: #7a5546;
  --card: #fffaf6;
  --field: #fff1ec;

  /* Una prenda por color: relleno pastel y tinta fuerte */
  --l0: #ffcf4d; --l0-deep: #a36200;
  --l1: #ff9ec0; --l1-deep: #c7336b;
  --l2: #b6a2ff; --l2-deep: #5a40d1;
  --l3: #8cc4ff; --l3-deep: #2a69b8;
  --level: var(--l1);
  --level-deep: var(--l1-deep);

  /* Cielo (lo cambia app.js con la hora y el sol) */
  --sky-1: #95cfff;
  --sky-2: #cfe9ff;
  --sky-3: #fff0e2;
  --on-sky: var(--ink);
  --cloud: #ffffff;

  /* Escena */
  --ground-h: clamp(120px, 24vh, 230px);
  --ground-air: 80px;              /* aire por encima de la colina para que asomen las matas */
  --sw: min(40vw, 500px, 62vh);    /* ancho del sol (que quepa también en ventanas bajitas) */
  /* Cuánto se meten los pies en el prado. A los pies se les ve el empeine (los miramos algo
     desde arriba), así que el horizonte tiene que quedar a media pierna, no a la altura de
     los dedos: si no, el sol parece flotar delante de un decorado. */
  --sink: calc(var(--sw) * .135);
  --sun-x: calc(50% + min(25vw - 20px, 290px));   /* centro exacto de la columna del sol: ahí va la cima de la colina */

  --shadow: 0 2px 4px rgb(75 42 32 / .05), 0 18px 40px -20px rgb(75 42 32 / .35);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --display: "Baloo 2", "Nunito", ui-rounded, system-ui, sans-serif;
  --font: "Nunito", ui-rounded, system-ui, sans-serif;
  --hand: "Shantell Sans", "Nunito", cursive;
}

body[data-level="0"] { --level: var(--l0); --level-deep: var(--l0-deep); }
body[data-level="1"] { --level: var(--l1); --level-deep: var(--l1-deep); }
body[data-level="2"] { --level: var(--l2); --level-deep: var(--l2-deep); }
body[data-level="3"] { --level: var(--l3); --level-deep: var(--l3-deep); }
/* Con lluvia manda el chubasquero: verde agua */
body[data-rainy="true"] { --level: #8fe3cf; --level-deep: #12806c; }

/* Contraste medido contra cada cielo (WCAG): el color de la prenda se oscurece lo justo
   para que el veredicto llegue a 3:1 y las cifras pequeñas a 4,5:1. De noche van en blanco. */
body { --answer-c: color-mix(in srgb, var(--level-deep) 95%, #3a1c12); --num-c: color-mix(in srgb, var(--level-deep) 60%, #3a1c12); }
body:is([data-cloudy="true"], [data-sky="rain"]) { --answer-c: color-mix(in srgb, var(--level-deep) 80%, #3a1c12); --num-c: color-mix(in srgb, var(--level-deep) 45%, #3a1c12); }
body:is([data-phase="dusk"], [data-sky="storm"]) { --answer-c: color-mix(in srgb, var(--level-deep) 50%, #3a1c12); --num-c: color-mix(in srgb, var(--level-deep) 20%, #3a1c12); }

body[data-phase="dawn"]  { --sky-1: #ffbfae; --sky-2: #ffdcc6; --sky-3: #ffeede; }
body[data-phase="day"]   { --sky-1: #95cfff; --sky-2: #cfe9ff; --sky-3: #fff0e2; }
body[data-phase="dusk"]  { --sky-1: #9a97f2; --sky-2: #f5b0cc; --sky-3: #ffd9b0; }
body[data-phase="night"] { --sky-1: #1c2257; --sky-2: #343a8c; --sky-3: #6c5fae; --on-sky: #ffffff; --cloud: #5b60ae; }
body[data-cloudy="true"][data-phase="day"] { --sky-1: #a9c2de; --sky-2: #d3dfec; --sky-3: #f6efe9; }

/* El cielo también va con el tiempo (de noche manda la noche, pero más tapada) */
body[data-sky="warm"][data-phase="day"]   { --sky-1: #86ccff; --sky-2: #d4eeff; --sky-3: #ffe0b5; }
body[data-sky="fog"]:not([data-phase="night"])   { --sky-1: #c3cad3; --sky-2: #dde2e7; --sky-3: #eef0f2; --cloud: #f6f7f9; }
body[data-sky="rain"]:not([data-phase="night"])  { --sky-1: #a3b6cb; --sky-2: #c8d3df; --sky-3: #e8ecf0; --cloud: #e4e9f0; }
body[data-sky="storm"]:not([data-phase="night"]) { --sky-1: #8a9ab2; --sky-2: #afbbca; --sky-3: #d8dde5; --cloud: #cfd5df; }
body[data-sky="snow"]:not([data-phase="night"])  { --sky-1: #c8d6e7; --sky-2: #e4ebf4; --sky-3: #f7f9fc; --cloud: #ffffff; }
body[data-phase="night"]:is([data-sky="rain"], [data-sky="storm"], [data-sky="fog"]) { --sky-1: #151b3c; --sky-2: #283060; --sky-3: #474b80; --cloud: #41467e; }
body[data-phase="night"][data-sky="snow"] { --sky-1: #27315f; --sky-2: #4b568f; --sky-3: #8b93c4; --cloud: #7c83c0; }

*, *::before, *::after { box-sizing: border-box; }
@property --sky-1 { syntax: "<color>"; inherits: true; initial-value: #95cfff; }
@property --sky-2 { syntax: "<color>"; inherits: true; initial-value: #cfe9ff; }
@property --sky-3 { syntax: "<color>"; inherits: true; initial-value: #fff0e2; }
@property --cloud { syntax: "<color>"; inherits: true; initial-value: #ffffff; }
/* Cuánto movimiento pone el código (respirar, saltitos, tiritar): 1 con imagen
   fija, 0 cuando el vídeo ya trae su propio movimiento. Al ser una propiedad
   registrada se funde poco a poco: el sol nunca se queda congelado a medias. */
@property --life { syntax: "<number>"; inherits: true; initial-value: 1; }
@property --scan { syntax: "<number>"; inherits: true; initial-value: 0; }
/* Cuánto sube el bocadillo siguiendo al sol cuando salta */
@property --hop { syntax: "<length>"; inherits: true; initial-value: 0px; }

html { -webkit-text-size-adjust: 100%; }

body {
  position: relative;   /* el suelo va pegado al final de la página, como el sol: si la página se desplaza, van juntos */
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-weight: 700;
  color: var(--on-sky);
  background: var(--sky-3);
  background-image: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 50%, var(--sky-3) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  transition: --sky-1 1.6s ease, --sky-2 1.6s ease, --sky-3 1.6s ease, --cloud 1.6s ease;
}
body.slow-sky { transition-duration: 8s; }
body.slow-sky .stars { transition-duration: 8s; }

[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
button, input, output { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
p, h1 { margin: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 14px; }
.ico { width: 1.2em; height: 1.2em; flex: none; }

/* ---------- Cielo ---------- */

.sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
/* Nubes opacas: si se cruzan se ven como un solo cúmulo, sin costuras de
   transparencia. La lejanía va en el color (más cerca del cielo), y la entrada
   y salida las funde una máscara de todo el grupo. */
.clouds {
  position: absolute; inset: 0;
  --m0: 48vw; --m1: 60vw; --m2: 94vw; --m3: 100vw;
  -webkit-mask-image: linear-gradient(90deg, transparent var(--m0), #000 var(--m1), #000 var(--m2), transparent var(--m3));
          mask-image: linear-gradient(90deg, transparent var(--m0), #000 var(--m1), #000 var(--m2), transparent var(--m3));
}
.cloud {
  position: absolute; left: 0; color: var(--cloud);
  --from: 46vw; --to: 102vw;
  animation: drift linear infinite;
}
.c1 { width: 300px; top: 7%;  animation-duration: 70s;  animation-delay: -10s; }
.c2 { width: 180px; top: 21%; animation-duration: 90s;  animation-delay: -55s; color: color-mix(in srgb, var(--cloud) 72%, var(--sky-2)); }
.c3 { width: 380px; top: 33%; animation-duration: 80s;  animation-delay: -32s; color: color-mix(in srgb, var(--cloud) 84%, var(--sky-2)); }
.c4 { width: 150px; top: 13%; animation-duration: 100s; animation-delay: -80s; color: color-mix(in srgb, var(--cloud) 60%, var(--sky-2)); }
.c2, .c4 { z-index: -1; }
@keyframes drift {
  from { transform: translateX(var(--from)); }
  to   { transform: translateX(var(--to)); }
}

.stars {
  position: absolute; inset: 0; opacity: 0; transition: opacity 1.5s ease;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 8%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 44% 22%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 61% 12%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 77% 28%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 9%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 8% 46%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 36% 38%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 93% 52%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 69% 44%, #fff 50%, transparent 51%);
  animation: twinkle 4s ease-in-out infinite alternate;
}
body[data-phase="night"] .stars { opacity: 1; }
@keyframes twinkle { to { filter: brightness(.55); } }

/* ---------- El suelo: va con el tiempo que hace ---------- */

/* Hierba de verano por defecto; cada estación y cada tiempo cambia los tonos */
body {
  --contact: rgb(38 82 28 / .3); --contact-deep: rgb(30 66 20 / .55);
  --grass-back: #c4e8a4; --grass-1: #a3dc84; --grass-2: #7fc56b; --tuft: #6db45a; --tuft-tip: #8fd174;
}
body[data-season="spring"] { --grass-back: #c9ecae; --grass-1: #a8e08c; --grass-2: #84c972; --tuft: #70b95e; --tuft-tip: #98d67e; }
body[data-season="autumn"] { --grass-back: #d6e2a2; --grass-1: #bcd581; --grass-2: #9bbf68; --tuft: #8aad57; --tuft-tip: #b6c96f; }
body[data-season="winter"] { --grass-back: #cddcb8; --grass-1: #b0cc96; --grass-2: #91b47d; --tuft: #7fa36e; --tuft-tip: #a4c08f; }
body[data-ground="wet"]   { --grass-back: #b3d89f; --grass-1: #8ec678; --grass-2: #69a95b; --tuft: #5b9b4f; --tuft-tip: #7dbb69; }
body[data-ground="frost"] { --grass-back: #e1edea; --grass-1: #cfe3dc; --grass-2: #b0cec5; --tuft: #9ec2b8; --tuft-tip: #ffffff; }
body[data-ground="snow"]  { --contact: rgb(80 110 170 / .28); --contact-deep: rgb(70 100 160 / .5); }
body[data-ground="frost"] { --contact: rgb(60 100 110 / .28); --contact-deep: rgb(50 90 100 / .5); }
body[data-ground="snow"]  { --grass-back: #eef4fb; --grass-1: #ffffff; --grass-2: #e2ecf8; --tuft: #d7e4f3; --tuft-tip: #ffffff; }

/* El suelo NO va fijo a la ventana: iba así y, al desplazarse la página, el sol
   (que sí se mueve con ella) se quedaba flotando en el cielo. */
.ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--ground-h) + var(--ground-air));
  overflow: hidden; overflow: clip;   /* las colinas son elipses enormes: que no alarguen la página */
  z-index: 1; pointer-events: none;
}
.hill { position: absolute; border-radius: 50%; transition: background .8s ease; }
.hill--back {
  left: -30vw; width: 95vw; top: calc(var(--ground-air) - var(--ground-h) * .26); height: calc(var(--ground-h) * 2.6);
  /* La colina del fondo, más clara arriba y un pelín teñida de cielo: está más lejos */
  background: linear-gradient(180deg, color-mix(in srgb, var(--grass-back) 80%, #fff), color-mix(in srgb, var(--grass-back) 90%, var(--sky-2)) 22%);
}
.hill--front {
  left: calc(var(--sun-x) - 75vw); width: 150vw; top: var(--ground-air); height: calc(var(--ground-h) * 2.4);
  /* Pintada, no plana: luz en la cima, manchas suaves de claro y de sombra, y más oscura hacia abajo */
  background:
    radial-gradient(55% 26% at 50% 0%, rgb(255 255 255 / .4), transparent 70%),
    radial-gradient(22% 10% at 27% 5%, rgb(255 255 255 / .2), transparent 72%),
    radial-gradient(18% 9% at 74% 7%, rgb(20 80 30 / .1), transparent 72%),
    radial-gradient(26% 12% at 44% 13%, rgb(20 80 30 / .08), transparent 72%),
    linear-gradient(180deg, var(--grass-1), var(--grass-2) 45%);
  box-shadow: inset 0 10px 14px -8px rgb(255 255 255 / .45);
}
body[data-ground="snow"] .hill--front { box-shadow: inset 0 12px 14px -6px #fff, inset 0 -40px 60px -30px rgb(120 150 200 / .25); }
body[data-phase="night"] :is(.ground, .near) { filter: brightness(.8) saturate(.85); }

/* Lo que hay encima: matas, flores, hojas, charcos, nieve y brillos */
.deco { position: absolute; inset: 0; overflow-x: clip; overflow-y: visible; }   /* las matas del filo asoman enteras por encima */
.d { position: absolute; display: block; transform: translate(-50%, -100%) rotate(var(--r)) scale(var(--s, 1)); transform-origin: 50% 100%; }
.d svg { display: block; width: 100%; height: 100%; }
.d-tuft { width: 32px; height: 24px; }
/* Las briznas llevan degradado (definido en index.html): base oscura, punta clara */
.g-dark { stop-color: color-mix(in srgb, var(--tuft) 78%, #1f4a1a); }
.g-mid  { stop-color: var(--tuft); }
.g-tip  { stop-color: var(--tuft-tip); }
body[data-ground="frost"] .d-tuft path { fill: var(--tuft); stroke: #fff; stroke-width: 1.2; }
.d-tuft { animation: sway var(--sway, 3.4s) ease-in-out var(--dl, 0s) infinite alternate; }
@keyframes sway {
  from { transform: translate(-50%, -100%) rotate(calc(var(--r) - var(--amp, 5deg) * .35)) scale(var(--s, 1)); }
  to   { transform: translate(-50%, -100%) rotate(calc(var(--r) + var(--amp, 5deg))) scale(var(--s, 1)); }
}
.d-tuft.thump { animation: thump .75s ease-out; }
@keyframes thump {
  25% { transform: translate(-50%, -100%) rotate(calc(var(--r) + var(--bend))) scale(calc(var(--s) * 1.05), calc(var(--s) * .85)); }
  50% { transform: translate(-50%, -100%) rotate(calc(var(--r) - var(--bend) * .45)) scale(var(--s)); }
  75% { transform: translate(-50%, -100%) rotate(calc(var(--r) + var(--bend) * .15)) scale(var(--s)); }
}
.d-flower.thump { animation: flower-hop .6s ease-out; }
@keyframes flower-hop { 35% { transform: translate(-50%, -90%) scale(calc(var(--s) * 1.15)) rotate(calc(var(--bend) * .6)); } }
.d-lump.thump { animation: lump-puff .6s ease-out; }
@keyframes lump-puff { 30% { transform: translate(-50%, -78%) rotate(var(--r)) scale(calc(var(--s) * 1.12), calc(var(--s) * .8)); } }
.d-splash {
  width: 22px; height: 8px; border-radius: 50%; border: 2px solid rgb(255 255 255 / .85);
  transform: translate(-50%, -50%) scale(.1); opacity: 0;
  animation: splash 1.5s ease-out var(--dl, 0s) infinite;
}
@keyframes splash {
  0%  { transform: translate(-50%, -50%) scale(.1); opacity: 0; }
  8%  { opacity: 1; }
  55% { transform: translate(-50%, -50%) scale(var(--s, 1)); opacity: 0; }
  100% { opacity: 0; }
}
.d-flower { width: 16px; height: 16px; transform: translate(-50%, -50%) scale(var(--s, 1)); }
.d-flower .petals { fill: var(--c); }
.d-leaf { width: 18px; height: 11px; transform: translate(-50%, -50%) rotate(var(--r)) scale(var(--s, 1)); }
.d-leaf path:first-child { fill: var(--c); }
.d-puddle {
  width: 64px; height: 14px; border-radius: 50%; transform: translate(-50%, -50%) scale(var(--s, 1));
  background: radial-gradient(60% 50% at 40% 40%, rgb(255 255 255 / .75), transparent 60%), #9fd0f5;
  box-shadow: inset 0 -2px 0 rgb(40 100 160 / .18);
}
.d-lump {
  width: 46px; height: 18px; border-radius: 50% 50% 45% 45% / 90% 90% 20% 20%;
  background: radial-gradient(120% 100% at 50% 18%, #fff 58%, #e4ecf8);
  box-shadow: 0 5px 7px -4px rgb(130 160 210 / .45);
  transform: translate(-50%, -78%) rotate(var(--r)) scale(var(--s, 1));
}
.d-spark { width: 14px; height: 14px; transform: translate(-50%, -50%) scale(var(--s, 1)); animation: glint 2.6s ease-in-out infinite alternate; animation-delay: calc(var(--s) * -4s); }
.d-spark path { fill: #fff; }
@keyframes glint { from { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .d-tuft, .d-spark { animation: none; } }

/* ---------- Escena ---------- */

.scene {
  position: relative; z-index: 2;
  max-width: 1240px; min-height: 100dvh; margin: 0 auto;
  padding: 0 40px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.talk {
  /* Por encima del sol: su entrada deja un transform que encierra el desplegable
     de ciudad en esta capa, y sin esto el bocadillo le pasaba por encima */
  position: relative; z-index: 4;
  align-self: center;
  padding: 40px 0 calc(var(--ground-h) + 24px);
  animation: rise-in .9s var(--ease-out) both;
}
@keyframes rise-in { from { transform: translateY(18px); } }

.question {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(1.7rem, 2.8vw, 2.5rem); line-height: 1.1;
}

/* Veredicto: macizo, en la tinta fuerte del color del veredicto, para que se lea de un vistazo */
.answer {
  margin: 8px 0 14px -.04em;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(5rem, 12vw, 10rem); line-height: .92; letter-spacing: -.02em;
  font-size: min(clamp(5rem, 12vw, 10rem), 24dvh);
  color: var(--answer-c);
  text-wrap: balance;
  text-shadow: 0 .05em 0 rgb(255 255 255 / .55);
  transition: color .6s ease;
}
body[data-phase="night"] .answer { color: #fff; text-shadow: 0 .05em 0 var(--level-deep); }
.answer[data-len="long"] { font-size: clamp(3.6rem, 7.6vw, 6.4rem); font-size: min(clamp(3.6rem, 7.6vw, 6.4rem), 15dvh); }
.answer[data-len="xl"] { font-size: clamp(3rem, 6vw, 5.2rem); font-size: min(clamp(3rem, 6vw, 5.2rem), 12dvh); }
.answer .w { display: inline-block; white-space: nowrap; }
.answer .ch { display: inline-block; transform-origin: 50% 100%; animation: drop .8s linear both; animation-delay: calc(var(--i) * 50ms); }
@keyframes drop {
  0%   { transform: translateY(-110%) scale(.85, 1.25); opacity: 0; animation-timing-function: cubic-bezier(.5, 0, 1, .6); }
  38%  { transform: translateY(0) scale(1.22, .76); opacity: 1; animation-timing-function: cubic-bezier(0, .5, .5, 1); }
  58%  { transform: translateY(-14%) scale(.94, 1.08); animation-timing-function: cubic-bezier(.5, 0, 1, .6); }
  74%  { transform: translateY(0) scale(1.07, .93); animation-timing-function: ease-out; }
  88%  { transform: translateY(-3%) scale(.99, 1.01); }
  100% { transform: none; }
}
.answer-wait { display: inline-block; font-size: .3em; rotate: 3deg; color: var(--on-sky); text-shadow: none; }
.dots i { display: inline-block; font-style: normal; animation: dot 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 40% { transform: translateY(-.25em); } }

.brief {
  min-height: 1.6em;
  font-size: clamp(1.1rem, 1.5vw, 1.3rem); font-weight: 800;
}
.brief strong { display: inline-block; color: var(--num-c); font-weight: 900; }
.brief.flash strong { animation: bump .45s var(--ease-spring); }
body[data-phase="night"] .brief strong { color: #fff; }

/* «Vuelvo a casa a las 21:00 en Madrid»: la frase es el control */
.when {
  /* Aire entre las dos líneas: cada una lleva una píldora blanca con sombra, y pegadas se pisaban */
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 12px;
  margin-top: 26px;
  font-size: clamp(1.1rem, 1.5vw, 1.3rem); font-weight: 800;
}
/* «en [ciudad]» va SIEMPRE en su propia línea: antes cabía o no según lo largo del
   nombre (Tamaulipas sí, Nuevo Laredo no) y quedaba distinto en cada ciudad */
.when-place { display: flex; flex-basis: 100%; min-width: 0; max-width: 100%; align-items: center; gap: 12px; }
.stepper {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 4px; border-radius: 999px; background: #fff; color: var(--ink);
  box-shadow: var(--shadow);
}
.step {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--level) 25%, #fff); color: var(--level-deep);
  font-family: var(--display); font-weight: 800; font-size: 1.4rem; line-height: 1;
  display: grid; place-items: center; padding-bottom: 2px;
  transition: transform .25s var(--ease-spring), opacity .2s ease, background-color .4s ease;
}
.step:active { transform: scale(.86); }
.step:disabled { opacity: .35; cursor: not-allowed; }
.back-out {
  display: inline-block; min-width: 4.2ch; text-align: center;
  font-family: var(--display); font-weight: 800; font-size: 1.3rem; font-variant-numeric: tabular-nums;
}
.back-out.bump { animation: bump .35s var(--ease-spring); }
.back-out.roll[data-dir="up"]   { animation: roll-up .45s var(--ease-spring); }
.back-out.roll[data-dir="down"] { animation: roll-down .45s var(--ease-spring); }
@keyframes roll-up   { from { transform: translateY(70%) scale(.8, 1.15); opacity: 0; } }
@keyframes roll-down { from { transform: translateY(-70%) scale(.8, 1.15); opacity: 0; } }
@keyframes bump { 40% { transform: scale(1.22); } }

.place { position: relative; min-width: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 0 16px 0 14px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: #fff; color: var(--ink); font-weight: 800; font-size: 1.15rem;
  box-shadow: var(--shadow);
  transition: transform .25s var(--ease-spring);
}
.pill:active { transform: scale(.96); }
/* El nombre, siempre en una línea: si es muy largo se corta con puntos suspensivos */
.place-name { text-align: start; line-height: 1.15; padding: 6px 0; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pill { max-width: 100%; }
.pill .ico { flex: none; }
.when-text { white-space: nowrap; flex: none; }
.ico--pin { color: var(--level-deep); width: 1.25em; height: 1.25em; }
.ico--caret { width: 1em; height: 1em; transition: rotate .3s var(--ease-out); }
.pill[aria-expanded="true"] .ico--caret { rotate: 180deg; }

.pop {
  position: absolute; inset-inline-start: 0; top: calc(100% + 10px); z-index: 20;
  width: min(340px, calc(100vw - 32px));
  padding: 14px; border-radius: 24px;
  background: var(--card); color: var(--ink); box-shadow: 0 24px 60px -18px rgb(75 42 32 / .4);
  display: flex; flex-direction: column; gap: 10px;
  max-height: var(--pop-max, none); overscroll-behavior: contain;
  animation: pop .3s var(--ease-spring);
}
/* Si no cabe, lo único que encoge es la lista de ciudades (con su propio desplazamiento) */
.pop > * { flex: none; }
.pop > .search { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.pop .results { flex: 0 1 auto; min-height: 0; }
.pop--up { top: auto; bottom: calc(100% + 10px); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
.pop-region { font-size: .9rem; color: var(--ink-soft); padding: 0 4px; }
.pop-region:empty { display: none; }
.search { position: relative; display: block; }
.field {
  display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 16px;
  background: var(--field); border-radius: 999px; border: 2.5px solid transparent;
}
.field:focus-within { border-color: var(--level-deep); background: #fff; }
.field .ico { color: var(--ink-soft); }
.field input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font-size: 1rem; font-weight: 700; }
.field input::placeholder { color: #9a7b6e; }
.field input::-webkit-search-cancel-button { display: none; }
.results { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 2px; max-height: 260px; max-height: min(260px, 30dvh); overflow-y: auto; }
.results li { padding: 10px 14px; border-radius: 16px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.results li b { font-weight: 800; }
.results li span { font-size: .85rem; color: var(--ink-soft); }
.results li[aria-selected="true"], .results li:hover { background: color-mix(in srgb, var(--level) 22%, #fff); }
.results .empty { cursor: default; color: var(--ink-soft); }
.btn-geo {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--ink); color: #fff; font-weight: 800;
}
.btn-geo[aria-busy="true"] { opacity: .7; cursor: progress; }

/* ---------- El sol en su colina ---------- */

.stage { position: relative; min-height: calc(var(--sw) * 1.2 + var(--ground-h)); }
.sun {
  position: absolute; left: 50%; bottom: calc(var(--ground-h) - var(--sink));
  width: var(--sw); translate: -50% 0;
  padding: 0; border: 0; background: none; cursor: pointer;
}
/* Foco con teclado: nada de recuadro; un aro del color del veredicto a sus pies,
   como al elegir personaje en un juego */
.sun:focus-visible { outline: none; }
.sun:focus-visible .sun-shadow { outline: 3px solid var(--level-deep); outline-offset: 5px; }
.sun-body {
  position: relative; display: block; aspect-ratio: 1120 / 1320;
  transform-origin: 50% 100%;
  animation: breathe 3.6s ease-in-out infinite;
}
/* Sombra sobre el suelo, que se ve desde arriba: un óvalo alrededor de los pies (la
   parte de atrás la tapa el propio sol) y un punto más oscuro bajo cada pie, donde apoya.
   La línea de los pies está al 1,5 % del alto; una tira fina por debajo no asienta. */
.sun-shadow {
  position: absolute; left: 50%; bottom: 2.4%; width: 64%; height: 8.5%; translate: -50% 50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--contact) 0%, color-mix(in srgb, var(--contact) 70%, transparent) 45%, color-mix(in srgb, var(--contact) 28%, transparent) 75%, transparent 100%);
}
.sun-shadow::before, .sun-shadow::after {
  content: ""; position: absolute; top: 36%; height: 50%; width: 34%; border-radius: 50%;
  background: radial-gradient(closest-side, var(--contact-deep) 0%, color-mix(in srgb, var(--contact-deep) 55%, transparent) 60%, transparent 100%);
}
.sun-shadow::before { left: 18.5%; }    /* pie izquierdo */
.sun-shadow::after  { right: 18.5%; }   /* pie derecho */
@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50%      { transform: scale(calc(1 + .015 * var(--life)), calc(1 - .015 * var(--life))); }
}

/* Bocadillo: lo que te dice el solito */
.bubble {
  position: absolute; z-index: 3; left: 50%;
  bottom: calc(var(--ground-h) - var(--sink) + var(--sw) * (.9 + var(--rise, 0)));
  translate: -50% calc(-1 * var(--hop));   /* sigue a la cabeza del sol (sin transición: va pegado) */
  width: max-content; max-width: min(92%, 340px);
  padding: 12px 20px 13px;
  background: #fff; color: var(--ink); border-radius: 24px;
  font-family: var(--hand); font-weight: 600; font-size: 1.12rem; line-height: 1.3; text-align: center;
  box-shadow: var(--shadow);
  transform-origin: 50% 120%;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -9px; width: 18px; height: 18px;
  background: #fff; border-radius: 0 0 6px 0; transform: translateX(-50%) rotate(45deg);
}
.bubble { transition: bottom .5s var(--ease-out), opacity .35s ease, visibility 0s; }
/* Callado (lo normal): el bocadillo solo sale cuando el sol dice algo, y se retira solo */
.bubble.quiet { opacity: 0; visibility: hidden; pointer-events: none; transition: bottom .5s var(--ease-out), opacity .35s ease, visibility 0s .35s; }
/* Con lluvia lleva el paraguas abierto sobre la cabeza: el bocadillo va por encima de la tela */
.window[data-rain="true"] .bubble { bottom: min(calc(var(--ground-h) - var(--sink) + var(--sw) * (1.01 + var(--rise, 0))), calc(100% - 84px)); }
/* El bocadillo sigue a la cabeza del sol en cada fotograma (app.js, followTick) */
.head-mark { position: absolute; left: 50%; top: 29%; width: 0; height: 0; pointer-events: none; }
.bubble.say { animation: say .6s linear; }
@keyframes say {
  0%   { transform: translateY(14px) scale(.3); opacity: 0; animation-timing-function: cubic-bezier(.2, .7, .4, 1); }
  45%  { transform: translateY(-4px) scale(1.08, .94); opacity: 1; animation-timing-function: ease-in-out; }
  70%  { transform: scale(.97, 1.03); }
  100% { transform: none; }
}

/* Poses: una imagen por pose; se cambian de golpe, como fotogramas */
.pose { position: absolute; inset: 0; opacity: 0; }
.pose.is-on { opacity: 1; }
.pose img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.ly-blink { opacity: 0; }
/* Parpadeo de verdad: el párpado baja rápido de arriba abajo, aguanta un instante
   y sube algo más despacio (antes los ojos cerrados aparecían y desaparecían de golpe).
   Los párpados de todas las poses caen entre el 48,9 % y el 57,7 % del alto. */
.sun.blink .is-on .ly-blink { animation: blink .25s linear; }
@keyframes blink {
  0%   { opacity: 1; clip-path: inset(0 0 51.5% 0); animation-timing-function: ease-in; }
  28%  { opacity: 1; clip-path: inset(0 0 41.8% 0); }
  54%  { opacity: 1; clip-path: inset(0 0 41.8% 0); animation-timing-function: ease-out; }
  100% { opacity: 1; clip-path: inset(0 0 51.5% 0); }
}
.sun.jump .is-on .ly-blink { opacity: 1; animation: none; }
/* Prendas animadas (vídeo convertido): sustituyen a la imagen fija y traen su propio movimiento */
/* El vídeo entra fundiéndose POR ENCIMA de la imagen fija, que no se quita hasta
   que el vídeo ya tapa del todo: así el sol nunca se vuelve medio transparente. */
.ly-anim { opacity: 0; transition: opacity .45s ease; }
.pose.anim-ready .ly-anim { opacity: 1; }
.pose.anim-ready .ly-full { opacity: 0 !important; transition: opacity 0s .45s; }
.pose.anim-ready .ly-blink { opacity: 0 !important; }
/* Luz de la escena: el sol coge el color del cielo (filtros en index.html) */
body[data-phase="dawn"]  .sun-body { filter: url(#lt-dawn); }
body[data-phase="dusk"]  .sun-body { filter: url(#lt-dusk); }
body[data-phase="night"] .sun-body { filter: url(#lt-night); }
body[data-phase="day"]:is([data-cloudy="true"], [data-sky="rain"], [data-sky="storm"], [data-sky="fog"]) .sun-body { filter: url(#lt-grey); }

/* Con vídeo, el movimiento en código se apaga suave (sin congelarse ni saltar) */
.sun-body { transition: --life .9s ease; }
.window .sun:has(.pose.is-on.anim-ready) .sun-body { --life: 0; }
/* Cada pose nueva se asienta: aplasta un poco y rebota (seguimiento, no un corte seco) */
.pose.is-on { z-index: 2; animation: pose-in .36s cubic-bezier(.3, 1.4, .5, 1); transform-origin: 50% 98%; }
@keyframes pose-in { from { transform: scale(1.02, .975); } }
/* En los bucles lentos (prismáticos, lupa) el dibujo nuevo se funde encima del anterior */
.pose.was-on { opacity: 1; z-index: 1; }
.pose.is-on.fade-in { animation: pose-fade .2s ease both, pose-in .36s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes pose-fade { from { opacity: 0; } }

/* ---------- Gestos sueltos (capa interior: no choca con respirar ni saltar) ---------- */
.sun-act {
  position: absolute; inset: 0; display: block; transform-origin: 50% 98%;
  transition: --scan .6s ease;
  animation: scan 2.08s ease-in-out infinite;
}
/* Con los prismáticos se balancea hacia donde mira (va a la par que los dibujos) */
.sun.looking .sun-act { --scan: 1; }
@keyframes scan {
  0%, 50%, 100% { rotate: 0deg; translate: 0 0; }
  25% { rotate: calc(var(--scan) * -2.5deg); translate: calc(var(--scan) * -1%) 0; }
  75% { rotate: calc(var(--scan) * 2.5deg); translate: calc(var(--scan) * 1%) 0; }
}
.sun.g-look    .sun-act { animation: scan 2.08s ease-in-out infinite, g-look 2s linear; }
.sun.g-stretch .sun-act { animation: scan 2.08s ease-in-out infinite, g-stretch 2.4s linear; }
.sun.g-gust    .sun-act { animation: scan 2.08s ease-in-out infinite, g-gust 1.5s linear; }
.sun.g-brr     .sun-act { animation: scan 2.08s ease-in-out infinite, g-brr .85s linear; }
.sun.g-yay     .sun-act { animation: scan 2.08s ease-in-out infinite, g-yay .75s linear; }
.sun.g-nod     .sun-act { animation: scan 2.08s ease-in-out infinite, g-nod .5s linear; }
.sun.g-inhale  .sun-act { animation: scan 2.08s ease-in-out infinite, g-inhale .9s linear both; }
.sun.g-sneeze  .sun-act { animation: scan 2.08s ease-in-out infinite, g-sneeze .7s linear; }
/* ¡Achís!: de echado hacia atrás se lanza hacia delante, rebota y se asienta */
@keyframes g-sneeze {
  0%   { transform: rotate(-3.5deg) translateY(-1.5%) scale(.95, 1.07); animation-timing-function: cubic-bezier(.5, 0, .9, .4); }
  16%  { transform: rotate(4.5deg) translateY(1.2%) scale(1.07, .93); animation-timing-function: ease-out; }
  42%  { transform: rotate(-1.4deg) scale(.98, 1.02); animation-timing-function: ease-in-out; }
  68%  { transform: rotate(.7deg); animation-timing-function: ease-in-out; }
  100% { transform: none; }
}
/* Coge aire para estornudar: se echa hacia atrás y se estira, cada vez más */
@keyframes g-inhale {
  0%   { transform: none; animation-timing-function: ease-in-out; }
  45%  { transform: rotate(-2deg) translateY(-.8%) scale(.97, 1.04); animation-timing-function: ease-in; }
  100% { transform: rotate(-3.5deg) translateY(-1.5%) scale(.95, 1.07); }
}
/* Mira hacia arriba lo que cae: se agacha un pelín, se estira hacia atrás, aguanta y vuelve pasándose */
@keyframes g-look {
  0%   { transform: none; animation-timing-function: ease-out; }
  15%  { transform: translateY(.6%) scale(1.025, .975); animation-timing-function: cubic-bezier(.3, .7, .4, 1); }
  38%  { transform: rotate(-2.4deg) translateY(-1.2%) scale(.985, 1.025); animation-timing-function: ease-in-out; }
  70%  { transform: rotate(-2.8deg) translateY(-1.3%) scale(.985, 1.025); animation-timing-function: ease-in; }
  86%  { transform: rotate(.7deg) scale(1.015, .985); animation-timing-function: ease-out; }
  100% { transform: none; }
}
/* Se despereza (de noche): se encoge, se estira hacia arriba despacio y rebota al soltar */
@keyframes g-stretch {
  0%   { transform: none; animation-timing-function: ease-out; }
  18%  { transform: scale(1.045, .95); animation-timing-function: cubic-bezier(.3, .6, .3, 1); }
  52%  { transform: translateY(-1%) scale(.95, 1.07); animation-timing-function: ease-in-out; }
  70%  { transform: translateY(-1%) scale(.955, 1.065); animation-timing-function: ease-in; }
  84%  { transform: scale(1.035, .965); animation-timing-function: ease-out; }
  100% { transform: none; }
}
/* Ráfaga de viento: se inclina, recupera y oscila hasta pararse */
@keyframes g-gust {
  0%   { transform: none; animation-timing-function: ease-out; }
  14%  { transform: rotate(3.2deg) skewX(-2deg) scale(.99, 1.01); animation-timing-function: ease-in-out; }
  32%  { transform: rotate(-1.6deg); animation-timing-function: ease-in-out; }
  50%  { transform: rotate(1.1deg); animation-timing-function: ease-in-out; }
  68%  { transform: rotate(-.5deg); animation-timing-function: ease-in-out; }
  100% { transform: none; }
}
/* Más frío a esa hora: se encoge y tirita */
@keyframes g-brr {
  0%   { transform: none; animation-timing-function: ease-out; }
  14%  { transform: scale(1.05, .93); }
  24%  { transform: translateX(-1.4%) scale(1.045, .94); }
  34%  { transform: translateX(1.4%) scale(1.04, .945); }
  44%  { transform: translateX(-1.1%) scale(1.035, .95); }
  54%  { transform: translateX(.9%) scale(1.03, .96); }
  64%  { transform: translateX(-.5%) scale(1.02, .975); animation-timing-function: ease-out; }
  82%  { transform: scale(.99, 1.01); }
  100% { transform: none; }
}
/* Más calor a esa hora: saltito contento */
@keyframes g-yay {
  0%   { transform: none; animation-timing-function: ease-out; }
  18%  { transform: scale(1.08, .9); animation-timing-function: cubic-bezier(.2, .8, .4, 1); }
  45%  { transform: translateY(-7%) scale(.94, 1.08); animation-timing-function: ease-in; }
  68%  { transform: scale(1.07, .93); animation-timing-function: ease-out; }
  84%  { transform: scale(.98, 1.02); }
  100% { transform: none; }
}
/* Misma temperatura: asiente, «apuntado» */
@keyframes g-nod {
  0%   { transform: none; animation-timing-function: ease-out; }
  35%  { transform: translateY(1%) rotate(1deg) scale(1.025, .975); animation-timing-function: ease-in-out; }
  70%  { transform: translateY(-.4%) scale(.99, 1.01); }
  100% { transform: none; }
}


/* Trocitos que saltan del suelo al caer y brillitos al cambiarse */
/* Matas delante de los pies (van por delante del sol) */
.near { position: absolute; left: 50%; bottom: calc(var(--ground-h) - var(--sink) + 2px); width: 0; height: 0; z-index: 3; pointer-events: none; }
.puff { position: absolute; left: 50%; bottom: calc(var(--ground-h) - var(--sink) + 8px); width: 0; height: 0; z-index: 3; pointer-events: none; }
.bit { position: absolute; left: var(--x0); top: var(--y0, 0); display: block; animation: bit .8s linear forwards; }
@keyframes bit {
  0%   { transform: translate(0, 0) rotate(0); animation-timing-function: cubic-bezier(.2, .7, .4, 1); }
  45%  { transform: translate(calc(var(--dx) * .6), var(--dy)) rotate(calc(var(--rot) * .5)); opacity: 1; animation-timing-function: cubic-bezier(.6, 0, 1, .7); }
  100% { transform: translate(var(--dx), 14px) rotate(var(--rot)); opacity: 0; }
}
.bit-leaf  { width: 11px; height: 7px; background: var(--c); border-radius: 0 100% 0 100%; }
.bit-snow  { width: 7px; height: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 4px rgb(160 190 230 / .8); }
.bit-drop  { width: 5px; height: 7px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #8cc4f0; }
.bit-grass { width: 3px; height: 9px; border-radius: 3px; background: var(--tuft); }
.bit-spark {
  width: 16px; height: 16px; margin: -8px; background: #fff3a8;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: spark .7s ease-out forwards;
}
@keyframes spark {
  0%   { transform: translate(0, 0) scale(0); }
  35%  { transform: translate(calc(var(--dx) * .7), calc(var(--dy) * .7)) scale(1.3) rotate(calc(var(--rot) * .5)); }
  100% { transform: translate(var(--dx), var(--dy)) scale(0) rotate(var(--rot)); }
}

/* Ánimos según el tiempo (solo con imagen fija) */
.window[data-mood="hot"] .sun-body { animation: breathe 3.6s ease-in-out infinite, happy 2.4s 1s var(--ease-spring) infinite; }
@keyframes happy { 0%, 70%, 100% { translate: 0 0; } 78% { translate: 0 calc(-14px * var(--life)); } 86% { translate: 0 0; } 91% { translate: 0 calc(-5px * var(--life)); } }
.window[data-mood="cold"] .sun-body,
.window[data-mood="freezing"] .sun-body { animation: breathe 3.6s ease-in-out infinite, shiver 2.8s linear infinite; }
@keyframes shiver {
  0%, 55%, 100% { translate: 0 0; }
  58% { translate: calc(-2px * var(--life)) 0; } 61% { translate: calc(2px * var(--life)) 0; } 64% { translate: calc(-2px * var(--life)) 0; }
  67% { translate: calc(2px * var(--life)) 0; } 70% { translate: calc(-1px * var(--life)) 0; } 73% { translate: calc(1px * var(--life)) 0; }
}

/* Al abrir: asoma por detrás de la colina, como un amanecer */
.sun.rise { animation: sunrise 1.5s linear both; }
@keyframes sunrise {
  0%   { transform: translateY(78%); clip-path: inset(-60% -30% calc(78% + var(--sink)) -30%); animation-timing-function: cubic-bezier(.3, .6, .4, 1); }
  58%  { transform: translateY(-6%); clip-path: inset(-60% -30% calc(-6% + var(--sink)) -30%); animation-timing-function: ease-in-out; }
  76%  { transform: translateY(1.5%); clip-path: inset(-60% -30% -40% -30%); animation-timing-function: ease-out; }
  100% { transform: none; clip-path: inset(-60% -30% -40% -30%); }
}

/* Salto: se agacha (anticipación), estira al subir, flota arriba, estira al caer, se aplasta y se asienta */
.window .sun.jump .sun-body { animation: jump .8s linear; }
@keyframes jump {
  0%   { transform: none; animation-timing-function: ease-out; }
  16%  { transform: translateY(1%) scale(1.13, .84); animation-timing-function: cubic-bezier(.2, .8, .4, 1); }
  30%  { transform: translateY(-9%) scale(.9, 1.13); animation-timing-function: ease-out; }
  48%  { transform: translateY(-15%) scale(.98, 1.03); animation-timing-function: ease-in; }
  68%  { transform: translateY(-3%) scale(.92, 1.1); animation-timing-function: cubic-bezier(.6, 0, 1, .6); }
  76%  { transform: translateY(0) scale(1.17, .8); animation-timing-function: ease-out; }
  88%  { transform: scale(.97, 1.04); animation-timing-function: ease-in-out; }
  100% { transform: none; }
}
/* La sombra se encoge cuando está en el aire */
.window .sun.jump .sun-shadow { animation: shadow-jump .8s linear; }
@keyframes shadow-jump {
  16% { transform: scale(1.12, 1); opacity: 1; }
  48% { transform: scale(.55); opacity: .45; }
  76% { transform: scale(1.18, 1.1); opacity: 1; }
}
/* Cambio de ropa de dibujo animado: se agacha, salta dentro de una nube mágica
   (ahí, sin que se vea, cambia de ropa) y cae ya vestido. Nada de girar de canto:
   eso delataba que es un dibujo plano. */
.window .sun.change .sun-body { animation: change .9s linear; }
@keyframes change {
  0%   { transform: none; animation-timing-function: ease-out; }
  18%  { transform: translateY(1.5%) scale(1.12, .86); animation-timing-function: cubic-bezier(.2, .8, .4, 1); }
  34%  { transform: translateY(-5%) scale(.9, 1.12); animation-timing-function: ease-in-out; }
  48%  { transform: translateY(-4%) scale(.94, 1.06); animation-timing-function: cubic-bezier(.6, 0, 1, .6); }
  62%  { transform: translateY(0) scale(1.12, .9); animation-timing-function: ease-out; }
  78%  { transform: scale(.97, 1.03); animation-timing-function: ease-in-out; }
  100% { transform: none; }
}
/* La nube: bolitas de algodón que brotan con muelle, tapan al sol y se deshacen hacia fuera */
.dress-cloud { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.dress-cloud i {
  position: absolute; left: var(--x); top: var(--y); width: var(--r); height: var(--r); margin: calc(var(--r) / -2);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff 52%, color-mix(in srgb, var(--cloud, #fff) 35%, #ece6f6));
  box-shadow: 0 6px 14px -8px rgb(90 70 120 / .35);
  animation: dress-cloud .9s linear both; animation-delay: var(--d);
}
@keyframes dress-cloud {
  0%   { transform: scale(0); opacity: 1; animation-timing-function: cubic-bezier(.2, .9, .3, 1.3); }
  26%  { transform: scale(1.12); }
  36%  { transform: scale(1); animation-timing-function: ease-in-out; }
  58%  { transform: scale(1.05); opacity: 1; animation-timing-function: cubic-bezier(.3, 0, .8, .5); }
  100% { transform: translate(var(--dx), var(--dy)) scale(.35); opacity: 0; }
}
.window .sun.squash .sun-body { animation: squash .5s var(--ease-out); }
@keyframes squash {
  0% { transform: scale(1, 1); }
  28% { transform: translateY(4%) scale(1.14, .76); }
  60% { transform: translateY(-3%) scale(.94, 1.08); }
  100% { transform: scale(1, 1); }
}
.window .sun.achoo .sun-body { animation: achoo .8s ease-in; }
@keyframes achoo {
  20%, 40%, 60% { transform: translateX(-1.5px) rotate(-1deg); }
  30%, 50%, 70% { transform: translateX(1.5px) rotate(1deg); }
}
.pose[data-pose="estornudo"].is-on { animation: sneeze .55s var(--ease-spring); transform-origin: 50% 98%; }
@keyframes sneeze { 0% { transform: rotate(-6deg); } 35% { transform: rotate(5deg) translateY(4px) scale(1.04, .95); } }

/* ---------- Lluvia, nieve y hojas por toda la escena ---------- */

.particles { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.p { position: absolute; top: -24px; left: var(--x); animation: fall var(--d) linear var(--delay) infinite; will-change: transform; }
@keyframes fall { to { transform: translate3d(var(--drift), 110vh, 0) rotate(var(--spin)); } }
@keyframes fall-straight { to { transform: translate3d(var(--drift), 110vh, 0); } }
.p-snow, .p-leaf { animation-name: fall-straight; }
.p > i { display: block; animation: flutter var(--fd, 2s) ease-in-out infinite alternate; }
@keyframes flutter {
  from { transform: translateX(calc(var(--amp, 20px) * -1)) rotate(-35deg) rotateX(0deg); }
  50%  { transform: translateX(0) rotate(0deg) rotateX(70deg); }
  to   { transform: translateX(var(--amp, 20px)) rotate(35deg) rotateX(0deg); }
}
.p-snow > i { width: var(--s); height: var(--s); border-radius: 50%; background: #fff; box-shadow: 0 0 6px rgb(255 255 255 / .9); animation-name: snow-sway; }
@keyframes snow-sway { from { transform: translateX(calc(var(--amp, 20px) * -.5)); } to { transform: translateX(calc(var(--amp, 20px) * .5)); } }
.p-leaf > i { width: calc(var(--s) * 1.6); height: var(--s); background: var(--leaf); border-radius: 0 100% 0 100%; }
.p-petal > i { width: var(--s); border-radius: 50% 0 50% 50%; }
.p-rain { width: 3px; height: 18px; border-radius: 3px; background: linear-gradient(transparent, #6c9fe0); animation-name: rain; opacity: .7; }
@keyframes rain { from { transform: rotate(12deg); } to { transform: translate3d(-90px, 110vh, 0) rotate(12deg); } }
.p-spark {
  top: auto; bottom: 30%;
  width: var(--s); height: var(--s); background: #fff3b8;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation-name: rise-spark;
}
@keyframes rise-spark { 0% { transform: translateY(0) scale(.4); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-260px) scale(1); opacity: 0; } }

/* ---------- Estados ---------- */

.talk[aria-busy="true"] .brief { opacity: .6; }
.is-error .answer { font-size: clamp(3.4rem, 7vw, 5rem); }
.retry { margin-top: 14px; min-height: 46px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 800; cursor: pointer; }

/* ---------- Móvil ---------- */

@media (max-width: 820px) {
  /* El sol cabe en el alto que deja libre el texto (--talk-h lo mide app.js): en móviles
     bajitos se encoge antes que obligar a hacer scroll para verle los pies */
  :root {
    --sw: min(76vw, 360px, 42vh, max(190px, calc((100dvh - var(--talk-h, 300px) - var(--ground-h)) / 1.25)));
    --sun-x: 50%; --ground-h: clamp(90px, 16vh, 150px);
  }
  .scene { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; padding: 0 20px; }
  .talk { align-self: start; padding: 28px 0 0; text-align: start; }
  .answer { font-size: clamp(4.4rem, 23vw, 6rem); }
  .answer[data-len="long"] { font-size: clamp(3rem, 14vw, 4.4rem); }
  .answer[data-len="xl"] { font-size: clamp(2.6rem, 12vw, 3.6rem); }
  /* El desplegable sale desde la píldora (a ~50 px del borde): que no se salga por la derecha */
  .pop { width: min(340px, calc(100vw - 40px)); }
  .when { margin-top: 20px; row-gap: 12px; }
  .stage { min-height: calc(var(--sw) * 1.25 + var(--ground-h)); }
  .bubble { font-size: 1rem; }
  /* (el @media de abajo baja el texto en pantallas muy estrechas) */
  /* En móvil las nubes van por la franja entre la frase y el sol */
  .clouds { --m0: 0vw; --m1: 8vw; --m2: 92vw; --m3: 100vw; }
  .cloud { --from: -45vw; --to: 105vw; }
  .c1 { top: 44%; } .c2 { top: 52%; } .c3 { top: 47%; width: 300px; } .c4 { top: 56%; }
}

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

/* Mientras eliges ciudad, el sol calla */
.window.picking .bubble { opacity: 0 !important; transition: opacity .2s ease; }

/* ---------- Esquina: sonido, grados, idioma y «cómo funciona» ---------- */
.corner { position: absolute; top: 14px; inset-inline-end: 16px; z-index: 6; }
.corner-items { display: flex; gap: 8px; }
.corner-btn {
  position: relative; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: rgb(255 255 255 / .82); color: var(--ink); box-shadow: var(--shadow);
  font: inherit;
  transition: transform .25s var(--ease-spring), background-color .3s ease;
}
.corner .menu-btn { display: none; }   /* solo en móvil */
.corner-btn:hover { background: #fff; }
.corner-btn:active { transform: scale(.9); }
.corner-btn .ico { width: 20px; height: 20px; flex: none; }
.corner-unit { font-family: var(--display); font-weight: 800; font-size: .92rem; letter-spacing: -.01em; direction: ltr; }
/* En escritorio los nombres solo los lee el lector de pantalla; en el menú del móvil se ven */
.corner-label, .corner-value, .switch { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* El selector de idioma es un <select> de verdad (accesible y con la lista del sistema en el
   móvil), invisible encima; a 16 px para que el iPhone no haga zoom al abrirlo */
.corner-btn select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.corner-btn:focus-within, .corner-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
#sound .snd-on { display: none; }
#sound[aria-pressed="true"] .snd-on { display: inline; }
#sound[aria-pressed="true"] .snd-off { display: none; }
#sound[aria-pressed="false"] .ico { color: color-mix(in srgb, var(--ink) 60%, transparent); }

/* Velo detrás de los paneles del móvil */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgb(60 36 60 / .4); opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility 0s .25s; }
body.sheet-open .scrim { opacity: 1; visibility: visible; transition: opacity .25s ease; }
@keyframes sheet-in { from { transform: translateY(100%); } }

/* En móvil: un solo botón que abre un panel desde abajo, con cada ajuste en su fila */
@media (max-width: 820px) {
  .corner .menu-btn { display: grid; width: 42px; height: 42px; }
  .corner.open { z-index: 40; }
  .corner.open .menu-btn { visibility: hidden; }
  .corner-items, .pop.pop--sheet {
    position: fixed; inset: auto 0 0 0; top: auto; z-index: 40;
    width: auto; max-width: none; min-width: 0; margin: 0;
    padding: 10px 16px calc(18px + env(safe-area-inset-bottom) + var(--badge-h, 0px));
    border-radius: 30px 30px 0 0;
    background: var(--card); color: var(--ink); box-shadow: 0 -18px 60px -20px rgb(60 36 60 / .5);
    max-height: calc(var(--vvh, 100dvh) - 24px); overflow-y: auto; overscroll-behavior: contain;
  }
  /* El tirador de arriba */
  .corner-items::before, .pop.pop--sheet::before {
    content: ""; flex: none; align-self: center; width: 46px; height: 5px; margin: 2px 0 10px; border-radius: 99px;
    background: color-mix(in srgb, var(--ink) 20%, transparent);
  }
  .corner-items { display: none; flex-direction: column; gap: 4px; }
  .corner.open .corner-items { display: flex; animation: sheet-in .38s var(--ease-out); }
  .corner-items .corner-btn {
    width: 100%; height: 62px; padding: 0 12px; border-radius: 18px;
    display: flex; align-items: center; justify-content: flex-start; gap: 16px;
    background: none; box-shadow: none; text-align: start;
    font-weight: 800; font-size: 1.1rem;
  }
  .corner-items .corner-btn:hover { background: none; }
  .corner-items .corner-btn:active { background: var(--field); transform: none; }   /* (sin :hover: en táctil se queda pegado) */
  .corner-items .corner-btn:focus-within, .corner-items .corner-btn:focus-visible { outline-offset: -3px; }
  .corner-items .ico { width: 24px; height: 24px; }
  .corner-unit { width: 24px; text-align: center; font-size: 1.05rem; }
  .corner-label { position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; flex: 1; }
  .corner-value { position: static; width: auto; height: auto; overflow: visible; clip-path: none; color: var(--ink-soft); font-size: 1rem; }
  /* Interruptor del sonido */
  .switch {
    position: relative; flex: none; width: 46px; height: 28px; overflow: visible; clip-path: none; border-radius: 999px;
    background: color-mix(in srgb, var(--ink) 22%, transparent); transition: background-color .25s ease;
  }
  .switch::after {
    content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: inset-inline-start .25s var(--ease-spring);
  }
  #sound[aria-pressed="true"] .switch { background: var(--level-deep); }
  #sound[aria-pressed="true"] .switch::after { inset-inline-start: 21px; }

  /* El buscador de ciudad, también como panel inferior */
  .pop.pop--sheet { gap: 12px; animation: sheet-in .38s var(--ease-out); }
  .pop.pop--sheet .pop-region { font-size: 1rem; padding: 0 6px; }
  .pop.pop--sheet .field { height: 56px; }
  .pop.pop--sheet .field input { font-size: 1.05rem; }   /* ≥16 px: el iPhone no hace zoom al escribir */
  .pop.pop--sheet .btn-geo { min-height: 54px; }
  /* Al escribir ocupa la pantalla visible: el campo queda arriba, a salvo del teclado, y la lista llena el resto */
  .pop.pop--sheet.typing {
    top: calc(var(--vvt, 0px) + 12px); bottom: auto; height: calc(var(--vvh, 100dvh) - 12px); max-height: none;
    padding-bottom: calc(14px + var(--badge-h, 0px)); animation: none;
  }
  .pop.pop--sheet.typing > .search { flex: 1 1 auto; }
  /* Escribiendo, todo el sitio es para el campo y los resultados: fuera la región y, en cuanto
     hay texto, el botón de ubicación (con el teclado abierto en un móvil pequeño no cabía la lista) */
  .pop.pop--sheet.typing .pop-region { display: none; }
  .pop.pop--sheet.typing:has(#q:not(:placeholder-shown)) .btn-geo { display: none; }
  .pop.pop--sheet.typing .results { flex: 1 1 auto; max-height: none; align-content: start; }
  .pop.pop--sheet .results li { padding: 12px 14px; }
}

/* ---------- Cómo funciona ---------- */
.intro {
  width: min(400px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  margin: auto; padding: 26px 24px 22px; border: 0; border-radius: 30px;
  background: var(--card); color: var(--ink); text-align: center;
  box-shadow: 0 30px 80px -20px rgb(75 42 32 / .55);
}
.intro[open] { animation: intro-in .45s var(--ease-spring); }
.intro::backdrop { background: rgb(60 36 60 / .38); backdrop-filter: blur(3px); animation: fade-in .3s ease; }
/* Entra solo con movimiento (nunca transparente): es modal, y si la animación no llegara a correr
   tiene que verse igual */
@keyframes intro-in { from { transform: translateY(18px) scale(.93); } }
@keyframes fade-in { from { opacity: 0; } }
.intro-sun { width: 84px; height: 84px; border-radius: 26px; box-shadow: var(--shadow); }
.intro h2 { margin: 12px 0 14px; font-family: var(--display); font-weight: 800; font-size: 1.7rem; line-height: 1.1; }
.intro-steps { margin: 0 0 20px; padding: 0; list-style: none; counter-reset: paso; display: grid; gap: 12px; text-align: start; }
.intro-steps li { counter-increment: paso; display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; font-weight: 700; font-size: 1.02rem; line-height: 1.35; }
.intro-steps li::before {
  content: counter(paso); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--level) 32%, #fff); color: var(--level-deep);
  font-family: "Baloo 2", "Nunito", sans-serif; font-weight: 800; font-size: 1.15rem;
}
.intro-ok {
  width: 100%; min-height: 52px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--ink); color: #fff; font: inherit; font-weight: 800; font-size: 1.1rem;
  transition: transform .25s var(--ease-spring);
}
.intro-ok:active { transform: scale(.97); }
.intro-ok:focus-visible { outline: 3px solid var(--level-deep); outline-offset: 3px; }
html[lang="ru"] .intro h2 { font-weight: 900; }
@media (prefers-reduced-motion: reduce) { .intro[open], .intro::backdrop, .corner.open .corner-items, .pop.pop--sheet { animation: none; } }

/* ---------- Árabe: de derecha a izquierda ---------- */
/* La cuadrícula se da la vuelta sola (texto a la derecha, sol a la izquierda); la colina,
   su compañera de fondo y las nubes se van con el sol. Las horas siguen leyéndose 21:00. */
html[dir="rtl"] { --sun-x: calc(50% - min(25vw - 20px, 290px)); }
html[dir="rtl"] .hill--back { left: auto; right: -30vw; }
html[dir="rtl"] .clouds { transform: scaleX(-1); }
html[dir="rtl"] :is(.stepper, .back-out) { direction: ltr; }
/* Las cifras con su «°» se leen siempre de izquierda a derecha (si no, sale «°11») */
html[dir="rtl"] .brief strong { direction: ltr; unicode-bidi: isolate; }
@media (max-width: 820px) { html[dir="rtl"] { --sun-x: 50%; } }

/* Letra redonda propia para los idiomas que la letra de la app no cubre */
html[lang="ar"] {
  --display: "Baloo Bhaijaan 2", "Baloo 2", system-ui, sans-serif;
  --font: "Baloo Bhaijaan 2", "Nunito", system-ui, sans-serif;
  --hand: "Baloo Bhaijaan 2", "Nunito", system-ui, sans-serif;
}
html[lang="ar"] .answer { letter-spacing: 0; line-height: 1.1; margin-bottom: 8px; }
html[lang="zh"] {
  --display: "ZCOOL KuaiLe", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --hand: "ZCOOL KuaiLe", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Nunito", sans-serif;
}
/* Esa letra china solo tiene un grosor: sin negrita falsa, que la emborrona */
html[lang="zh"] :is(.answer, .question, .bubble) { font-weight: 400; letter-spacing: 0; }
html[lang="zh"] .answer { line-height: 1.1; }
html[lang="ja"] {
  --display: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Meiryo", sans-serif;
  --hand: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Meiryo", sans-serif;
  --font: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Meiryo", "Nunito", sans-serif;
}
html[lang="ja"] :is(.answer, .question, .bubble) { letter-spacing: 0; }
html[lang="ja"] .answer { line-height: 1.12; }
/* Las cifras y el ° de la frase, en la letra latina: en la japonesa el ° sale ancho y descoloca los espacios */
html[lang="ja"] .brief strong { font-family: "Nunito", sans-serif; }
/* Ruso: la letra del título no tiene cirílico; Nunito (ya cargada) sí, y bien gordita se le parece */
html[lang="ru"] { --display: "Nunito", ui-rounded, system-ui, sans-serif; }
html[lang="ru"] :is(.answer, .question, .back-out, .step) { font-weight: 900; }
html[lang="ru"] .answer { letter-spacing: -.015em; }

/* ---------- Grano de papel y viñeta ---------- */
.grain {
  position: fixed; inset: 0; z-index: 8; pointer-events: none;
  background:
    radial-gradient(125% 95% at 50% 42%, transparent 62%, rgb(46 30 70 / .11)),
    url("assets/icon/grano.png?v=2") 0 0 / 160px 160px;
  opacity: .5;
}

/* ---------- Clima vivo ---------- */
/* Lo que cae se inclina con el viento de verdad */
.particles { transform: skewX(var(--slant, 0deg)); }

/* Luna con la fase real; solo de noche, y más tenue si está nublado */
.moon {
  position: absolute; top: 15vh; inset-inline-end: 7vw; width: clamp(46px, 5.5vw, 76px); aspect-ratio: 1;
  opacity: 0; transition: opacity 2s ease; filter: drop-shadow(0 0 14px rgb(255 244 200 / .55));
}
.moon-dark { fill: rgb(255 255 255 / .1); }
.moon-lit { fill: #fff6d8; }
body[data-phase="night"] .moon { opacity: 1; }
body[data-phase="night"][data-cloudy="true"] .moon { opacity: .45; }
body[data-phase="night"]:is([data-sky="rain"], [data-sky="storm"], [data-sky="fog"], [data-sky="snow"]) .moon { opacity: 0; }

/* Estrella fugaz: una raya de luz que cruza y se apaga */
.shoot {
  position: absolute; left: var(--x, 50%); top: var(--y, 12%); width: 110px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / .95));
  rotate: 158deg; opacity: 0; pointer-events: none;
}
.shoot.go { animation: shoot .95s ease-out; }
@keyframes shoot {
  0%   { opacity: 0; translate: 0 0; }
  12%  { opacity: 1; }
  100% { opacity: 0; translate: -260px 105px; }
}

/* Relámpago: dos destellos suaves (nada de fogonazos fuertes) */
/* (se llama .lightning y no .flash: «flash» ya es la clase que resalta las cifras de la frase) */
.lightning { position: fixed; inset: 0; z-index: 7; pointer-events: none; background: #f3f6ff; opacity: 0; }
.lightning.go { animation: flash .7s linear; }
@keyframes flash {
  0% { opacity: 0; } 6% { opacity: .3; } 16% { opacity: .05; } 26% { opacity: .22; } 100% { opacity: 0; }
}

@media (max-width: 820px) {
  .moon { top: 39%; inset-inline-end: 8%; width: 44px; }
}
@media (prefers-reduced-motion: reduce) { .shoot, .lightning { display: none; } }

/* Móviles bajitos (hasta 700 px de alto): todo un punto más apretado y el sol puede encogerse
   un poco más, para que quepa sin scroll también con frases de tres líneas (árabe, alemán) */
@media (max-width: 820px) and (max-height: 700px) {
  :root { --sw: min(76vw, 360px, 42vh, max(176px, calc((100dvh - var(--talk-h, 300px) - var(--ground-h)) / 1.25))); }
  .talk { padding-top: 18px; }
  .answer { margin: 4px 0 10px -.04em; }
  .when { margin-top: 14px; row-gap: 10px; }
}

/* Móviles estrechos: la pregunta un punto más pequeña para que no roce los tres botones de arriba */
@media (max-width: 420px) {
  .question { font-size: min(1.7rem, 6.3vw); }
}

/* Pantallas muy estrechas (menos de 350 px): la pregunta baja para no quedar debajo de los botones */
@media (max-width: 349px) {
  .talk { padding-top: 60px; }
  /* …y la frase de la hora y la ciudad, un punto más pequeña para que cada control siga en su línea */
  .when { font-size: 1rem; gap: 10px 8px; margin-top: 12px; }
  .when-place { gap: 8px; }
  .step { width: 32px; height: 32px; font-size: 1.2rem; }
  .back-out { font-size: 1.12rem; min-width: 3.9ch; }
  .pill { min-height: 40px; font-size: 1.05rem; padding: 0 12px 0 10px; }
  .answer[data-len="long"] { font-size: clamp(2.6rem, 13vw, 4.4rem); }
}
