:root {
  --bg: #eef6f1;
  --bg-2: #f2edda;
  --surface: rgba(255, 255, 255, .42);
  --surface-2: rgba(255, 255, 255, .55);
  --surface-solid: #ffffff;
  --glass-edge: rgba(255, 255, 255, .65);
  --glass-shine: rgba(255, 255, 255, .8);
  --text: #14231c;
  --text-soft: #56685e;
  --border: rgba(20, 60, 40, .12);
  --accent: #0a7d4f;
  --accent-2: #10b56b;
  --accent-soft: rgba(16, 181, 107, .12);
  --now: #0a9e53;
  --now-glow: rgba(16, 181, 107, .35);
  --night: #8f6b06;
  --night-soft: rgba(222, 178, 55, .16);
  --night-edge: #d9a514;
  --danger: #c0392b;
  --radius: 18px;
  --shadow: 0 2px 6px rgba(10, 40, 25, .06), 0 12px 32px rgba(10, 40, 25, .08);
  --glow-a: rgba(16, 181, 107, .22);
  --glow-b: rgba(222, 178, 55, .16);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1310;
    --bg-2: #0b1a22;
    --surface: rgba(23, 33, 28, .38);
    --surface-2: rgba(28, 40, 34, .5);
    --surface-solid: #17211c;
    --glass-edge: rgba(255, 255, 255, .14);
    --glass-shine: rgba(255, 255, 255, .22);
    --text: #eaf4ee;
    --text-soft: #93a89c;
    --border: rgba(160, 220, 190, .14);
    --accent: #35c98a;
    --accent-2: #2ee59a;
    --accent-soft: rgba(53, 201, 138, .14);
    --now: #21c877;
    --now-glow: rgba(33, 200, 119, .35);
    --night: #f0c75e;
    --night-soft: rgba(240, 199, 94, .13);
    --night-edge: #c9a03e;
    --shadow: 0 2px 8px rgba(0, 0, 0, .45), 0 14px 40px rgba(0, 0, 0, .35);
    --glow-a: rgba(33, 200, 119, .17);
    --glow-b: rgba(240, 199, 94, .14);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%) fixed;
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* Halos decorativos de fondo */
.glow {
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
}
.glow--a { top: -140px; right: -120px; background: var(--glow-a); }
.glow--b { bottom: -160px; left: -140px; background: var(--glow-b); }

/* Cielo tras la cabecera, con parallax inverso muy sutil */
.sky {
  position: fixed;
  left: 0; right: 0; top: 0;
  height: 34vh;
  z-index: -1;
  pointer-events: none;
  will-change: transform;
}
.sky img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.sky::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, var(--bg) 0%, transparent 78%);
}

/* Nubes a la deriva y estrellas que parpadean */
.clouds {
  position: fixed;
  left: 0; right: 0; top: 0;
  height: 34vh;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  will-change: transform;
}
.cloud {
  position: absolute;
  left: -240px;
  background: no-repeat center / contain;
  animation: drift linear infinite;
}
.cloud--1 { width: 190px; height: 132px; top: 4%; animation-duration: 110s; animation-delay: -30s; opacity: .95; }
.cloud--2 { width: 120px; height: 83px; top: 40%; animation-duration: 75s; animation-delay: -58s; opacity: .8; }
.cloud--3 { width: 74px; height: 51px; top: 62%; animation-duration: 55s; animation-delay: -12s; opacity: .6; }
@keyframes drift {
  to { transform: translateX(calc(100vw + 480px)); }
}

@media (prefers-color-scheme: light) {
  .cloud { background-image: url(assets/nube-dia.webp); }
}
@media (prefers-color-scheme: dark) {
  .cloud { background-image: url(assets/nube-noche.webp); }
  /* Estrellas extra que parpadean sobre las del cielo */
  .clouds::before, .clouds::after {
    content: "";
    position: absolute;
    width: 3px; height: 3px;
    border-radius: 50%;
    background: #f5e9b8;
    box-shadow:
      11vw 22vh 0 0 #f5e9b8,
      27vw 9vh 0 1px #fff3c4,
      46vw 30vh 0 0 #f5e9b8,
      63vw 12vh 0 1px #fff3c4,
      82vw 26vh 0 0 #f5e9b8,
      93vw 7vh 0 0 #f5e9b8;
    animation: twinkle 3.6s ease-in-out infinite;
  }
  .clouds::after {
    box-shadow:
      6vw 8vh 0 0 #fff3c4,
      19vw 31vh 0 0 #f5e9b8,
      38vw 5vh 0 1px #f5e9b8,
      54vw 21vh 0 0 #fff3c4,
      74vw 33vh 0 0 #f5e9b8,
      88vw 17vh 0 1px #fff3c4;
    animation-duration: 5.2s;
    animation-delay: 1.4s;
  }
}
@keyframes twinkle {
  0%, 100% { opacity: .2; }
  50% { opacity: 1; }
}

/* Paisaje manchego al fondo, con parallax suave al hacer scroll */
.scene {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 58vh;
  z-index: -1;
  pointer-events: none;
  will-change: transform;
}
.scene picture, .scene img, .scene video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  display: block;
}
/* El vídeo (aspas girando) aparece en fundido sobre el póster JPEG */
.scene video { opacity: 0; transition: opacity 1.2s ease; z-index: 1; }
.scene video.on { opacity: 1; }
/* Funde el cielo de la imagen con el fondo de la página */
.scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, var(--bg) 0%, transparent 55%);
}

/* ---------- Cabecera ---------- */
.header {
  padding: 34px 16px 6px;
  text-align: center;
  text-shadow: 0 1px 12px var(--bg);
}
.logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  filter: drop-shadow(0 14px 26px var(--now-glow)) drop-shadow(0 2px 6px rgba(0, 0, 0, .18));
  animation: float 5s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}
.header h1 {
  margin: 10px 0 2px;
  font-size: 1.55rem;
  letter-spacing: -.02em;
}
.header .hl {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.tagline {
  margin: 0;
  color: var(--text-soft);
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

/* ---------- Tarjetas base (liquid glass) ---------- */
.card {
  background: var(--surface);
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  backdrop-filter: blur(26px) saturate(1.6);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-shine), inset 0 -1px 0 rgba(255, 255, 255, .06);
}

/* ---------- Dónde estás ---------- */
.where {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  padding: 12px;
}
.search-wrap { position: relative; flex: 1 1 220px; }

#search {
  width: 100%;
  font-size: 1.05rem;
  padding: 13px 15px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 0 0 1px var(--glass-edge);
  transition: box-shadow .15s, border-color .15s;
}
#search::placeholder { color: var(--text-soft); }
#search:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.btn-geo {
  font-size: .95rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid var(--glass-edge);
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
  transition: transform .1s, box-shadow .15s;
  box-shadow: inset 0 1px 0 var(--glass-shine);
}
.btn-geo:hover { box-shadow: 0 0 0 4px var(--accent-soft); }
.btn-geo:active { transform: scale(.97); }

#suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0; right: 0;
  margin: 0; padding: 6px;
  list-style: none;
  background: var(--surface-2);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  backdrop-filter: blur(30px) saturate(1.6);
  border: 1px solid var(--glass-edge);
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
}
#suggestions li {
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
#suggestions li .prov { color: var(--text-soft); font-size: .8rem; flex-shrink: 0; }
#suggestions li:hover, #suggestions li[aria-selected="true"] { background: var(--accent-soft); }

.geo-status { flex-basis: 100%; margin: 0 4px 2px; font-size: .85rem; color: var(--text-soft); }

/* ---------- Estados ---------- */
.welcome {
  text-align: center;
  color: var(--text-soft);
  padding: 26px 14px;
  font-size: 1.08rem;
}
.welcome strong { color: var(--text); }

.status {
  text-align: center;
  color: var(--text-soft);
  padding: 26px 0;
  font-size: 1.05rem;
}
.status .spinner {
  display: inline-block;
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: middle;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty, .error {
  text-align: center;
  padding: 30px 20px;
  margin-top: 8px;
}
.state-img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  margin-bottom: 4px;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .15));
}
.error { border-color: var(--danger); }

.btn-primary {
  font-size: 1rem;
  padding: 11px 20px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 700;
  box-shadow: 0 6px 18px var(--now-glow);
}

/* ---------- La respuesta ---------- */
.intro {
  font-size: 1.18rem;
  margin: 6px 4px 14px;
}
.intro strong { color: var(--accent); }

#rows { display: flex; flex-direction: column; gap: 12px; }

.row {
  background: var(--surface);
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  backdrop-filter: blur(26px) saturate(1.6);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-shine);
  padding: 15px 17px;
}
.row--now {
  border: 1.5px solid var(--now);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 10px 30px var(--now-glow), inset 0 1px 0 var(--glass-shine);
}
.row--night { border-left: 5px solid var(--night-edge); }
.row--closed { opacity: .75; }

/* Puntos de estado con pulso */
.dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  margin-right: 2px;
  vertical-align: baseline;
}
.dot--now {
  background: var(--now);
  box-shadow: 0 0 0 0 var(--now-glow);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--now-glow); }
  70% { box-shadow: 0 0 0 9px rgba(0, 0, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); }
}
.dot--night { background: var(--night-edge); }
.dot--next { background: #2aa8a0; }

.row-head { font-size: 1rem; margin-bottom: 4px; }
.row--now .row-head strong { color: var(--now); }
.row--night .row-head strong { color: var(--night); }

.row-name { font-size: 1.18rem; font-weight: 700; margin: 2px 0; letter-spacing: -.01em; }
.row-meta { color: var(--text-soft); font-size: .92rem; }

.row-actions { display: flex; gap: 10px; margin-top: 12px; }
.row-actions a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  padding: 12px 8px;
  border-radius: 12px;
  font-size: 1rem;
  transition: transform .1s;
}
.row-actions a:active { transform: scale(.97); }
.call-btn {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  box-shadow: 0 6px 16px var(--now-glow);
}
.map-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--glass-edge);
  box-shadow: inset 0 1px 0 var(--glass-shine);
}

.none-open {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--night-soft);
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  backdrop-filter: blur(26px) saturate(1.6);
  border: 1px solid var(--night-edge);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 1.05rem;
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-shine);
}
.none-img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .2));
}

/* ---------- Próximos días ---------- */
.later {
  margin-top: 18px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  backdrop-filter: blur(26px) saturate(1.6);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  padding: 4px 16px;
  box-shadow: var(--shadow), inset 0 1px 0 var(--glass-shine);
}
.later summary {
  cursor: pointer;
  padding: 11px 0;
  font-weight: 600;
  color: var(--text-soft);
}
.later h4 {
  margin: 10px 0 4px;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-soft);
}
.later p { margin: 4px 0 10px; font-size: .95rem; }
.later p .sep { color: var(--text-soft); }

.footer {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 34px;
  text-align: center;
  color: var(--text-soft);
  font-size: .82rem;
  text-shadow: 0 1px 10px var(--bg), 0 0 4px var(--bg);
}
.footer a { color: inherit; }

@media (min-width: 520px) {
  .row-actions a { flex: 0 0 auto; padding: 12px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .logo { animation: none; }
  .dot--now { animation: none; }
  .cloud { display: none; }
  .clouds::before, .clouds::after { animation: none; opacity: .6; }
  html { scroll-behavior: auto; }
}
