:root {
  --bg: #07130e;
  --bg-2: #0c1f17;
  --ink: #e9f3ec;
  --muted: #8fa89a;
  --line: rgba(160, 230, 190, 0.14);
  --neon: #19e07a;
  --neon-soft: rgba(25, 224, 122, 0.18);
  --warn: #ffb547;
  --card: rgba(16, 38, 28, 0.72);
  --shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  --radius: 20px;
  --display: "Bricolage Grotesque", "Atkinson Hyperlegible", sans-serif;
  --body: "Atkinson Hyperlegible", sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4efe4;
    --bg-2: #ebe3d2;
    --ink: #10221a;
    --muted: #5c6f64;
    --line: rgba(16, 34, 26, 0.12);
    --neon: #0a9a4f;
    --neon-soft: rgba(10, 154, 79, 0.12);
    --warn: #b4630a;
    --card: rgba(255, 252, 245, 0.8);
    --shadow: 0 24px 50px -30px rgba(40, 30, 10, 0.35);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(900px 520px at 85% -10%, var(--neon-soft), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, var(--neon-soft), transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.5 var(--body);
  padding: 0 16px env(safe-area-inset-bottom);
}

.grain {
  position: fixed; inset: 0; pointer-events: none; opacity: 0.07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Hero: the cross is the brand. */
.hero {
  max-width: 720px; margin: 0 auto; padding: 56px 0 28px;
  display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center;
}
.cross-wrap { position: relative; width: 112px; height: 112px; }
.cross { width: 100%; height: 100%; fill: var(--neon); filter: drop-shadow(0 0 18px var(--neon)) drop-shadow(0 0 42px var(--neon-soft)); animation: flicker 6s infinite, rise .8s cubic-bezier(.2,.8,.2,1) both; }
@keyframes flicker { 0%, 92%, 100% { opacity: 1 } 93% { opacity: .55 } 94% { opacity: 1 } 96% { opacity: .7 } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.92) } }

.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: .9rem; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--neon); box-shadow: 0 0 10px var(--neon); animation: pulse 2s infinite; }
@keyframes pulse { 50% { transform: scale(1.5); opacity: .5 } }
h1 { font: 800 clamp(2.6rem, 9vw, 4.4rem)/.92 var(--display); letter-spacing: -.035em; margin: 0; animation: rise .8s .08s cubic-bezier(.2,.8,.2,1) both; }
.lede { margin: 12px 0 0; color: var(--muted); font-size: 1.1rem; animation: rise .8s .16s cubic-bezier(.2,.8,.2,1) both; }

main, footer { max-width: 720px; margin: 0 auto; }

/* Finder */
.finder { display: grid; gap: 12px; animation: rise .8s .24s cubic-bezier(.2,.8,.2,1) both; }
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%;
  padding: 20px 24px; border: 0; border-radius: var(--radius); cursor: pointer;
  background: var(--neon); color: #03140b; font: 800 1.2rem var(--display); letter-spacing: -.01em;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset, 0 18px 40px -16px var(--neon);
  transition: transform .15s, box-shadow .15s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255,255,255,.1) inset, 0 22px 50px -14px var(--neon); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.btn-primary svg .fill { fill: currentColor; }
.btn-primary[aria-busy="true"] svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

.town { display: flex; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); backdrop-filter: blur(8px); overflow: hidden; }
.town input { flex: 1; min-width: 0; padding: 16px 20px; border: 0; background: transparent; color: var(--ink); font: inherit; }
.town input::placeholder { color: var(--muted); }
.town input:focus { outline: none; }
.town:focus-within { border-color: var(--neon); box-shadow: 0 0 0 3px var(--neon-soft); }
.town button { padding: 0 22px; border: 0; background: transparent; color: var(--neon); font: 800 1.4rem var(--display); cursor: pointer; }

/* States */
.state { margin: 28px 0 8px; color: var(--muted); }
.state:empty { display: none; }
.state h2 { font: 800 1.5rem/1.15 var(--display); color: var(--ink); margin: 0 0 4px; letter-spacing: -.02em; }
.state p { margin: 0; }
.state .warn { color: var(--warn); }
.state a, .sources a, footer a { color: var(--neon); }

/* Results */
.results { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.card {
  position: relative; padding: 22px 22px 18px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(8px);
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 55ms);
}
.card:first-child { border-color: color-mix(in srgb, var(--neon) 55%, transparent); }
.card:first-child::before {
  content: "La más cercana"; position: absolute; top: -11px; left: 20px; padding: 2px 10px; border-radius: 99px;
  background: var(--neon); color: #03140b; font: 700 .75rem var(--body); letter-spacing: .03em;
}
.results.by-town .card:first-child::before { content: none; }
.card.unconfirmed .hours .open { color: var(--warn); }
.card.unconfirmed:first-child::before { content: "Horario sin confirmar"; background: var(--warn); }
.results.by-town .card:first-child { border-color: var(--line); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.dist { font: 800 1.9rem/1 var(--display); letter-spacing: -.03em; color: var(--neon); }
.dist small { font-size: .9rem; font-weight: 500; color: var(--muted); margin-left: 2px; }
.badge { font-size: .8rem; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; white-space: nowrap; }
.name { font: 800 1.2rem/1.2 var(--display); margin: 10px 0 2px; letter-spacing: -.01em; text-transform: capitalize; }
.addr { margin: 0; color: var(--muted); text-transform: capitalize; }
.hours { margin: 10px 0 0; font-weight: 700; }
.hours .open { color: var(--neon); }
.note { margin: 6px 0 0; font-size: .92rem; color: var(--warn); }
.note:empty { display: none; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.btn {
  display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 14px;
  text-decoration: none; font-weight: 700; color: var(--ink); border: 1px solid var(--line); background: var(--bg-2);
  transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--neon); }
.btn.call { background: var(--neon-soft); color: var(--neon); border-color: transparent; }
.btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }

.sources { margin: 24px 0 0; font-size: .92rem; color: var(--muted); }
.sources:empty { display: none; }
.sources p { margin: 4px 0; }
.sources .stale { color: var(--warn); }

footer { padding: 40px 0 48px; color: var(--muted); font-size: .92rem; }
.emergency { padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.emergency a { font-weight: 700; }
.fine { margin-top: 14px; }

@media (max-width: 480px) {
  .hero { grid-template-columns: auto 1fr; gap: 16px; padding: 28px 0 20px; align-items: end; }
  .cross-wrap { width: 56px; height: 56px; margin-bottom: 6px; }
  h1 { font-size: 2.5rem; }
  .lede { display: none; }
  .eyebrow { font-size: .8rem; }
}

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

/* Server-rendered pages: breadcrumbs and town/province link lists. */
a.cross-wrap { display: block; }
.crumbs { margin: 0 0 18px; font-size: .92rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--neon); }
.links { margin: 36px 0 0; }
.links h2 { font: 800 1.25rem/1.2 var(--display); letter-spacing: -.01em; margin: 0 0 12px; }
.link-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px 16px; }
.link-grid a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.link-grid a:hover { color: var(--neon); border-color: var(--neon); }
.link-grid a.dim { color: var(--muted); }
.link-grid .count { font-size: .8rem; color: var(--neon); }
