/* Códigos Postales – estilos (mobile-first, sin dependencias) */
/* Paleta de la web original: fondo amarillo oscuro #ffcc00, azul marino #003366, enlaces #333366, dorado #ffd700 */
:root {
  color-scheme: light;
  --bg: #ffcc00; --surface: #ffffff; --text: #17172e; --muted: #4a4a5e;
  --brand: #003366; --brand-ink: #ffffff; --link: #333366; --accent: #fff3b0; --line: #d9ad00;
  --radius: 14px; --shadow: 0 1px 2px rgba(51,41,0,.12), 0 4px 14px rgba(51,41,0,.12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1rem/1.5 var(--font);
       padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
a { color: var(--link); }
a:hover { text-decoration: none; }
main, .top, footer { max-width: 62rem; margin: 0 auto; padding: 0 1rem; }
main { padding-bottom: 2rem; min-height: 70vh; }

.top { display: flex; align-items: center; justify-content: space-between; height: 3.5rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.logo { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9px; background: var(--brand); color: #ffcc00; }
.top nav a { color: var(--muted); text-decoration: none; padding: .5rem; }

h1 { font-size: clamp(1.6rem, 6vw, 2.4rem); line-height: 1.15; margin: .6rem 0 .4rem; letter-spacing: -.02em; color: var(--brand); }
h2 { font-size: 1.15rem; margin: 2rem 0 .8rem; }
.lead { color: var(--muted); margin: 0 0 1rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .75rem; color: var(--muted); margin: .5rem 0 0; }
.crumbs { font-size: .9rem; color: var(--muted); margin-top: .5rem; }
.crumbs a { color: var(--muted); }
.count { font-weight: 400; color: var(--muted); font-size: .9em; }
.status { color: var(--muted); min-height: 1.5em; margin: .6rem 0; }

/* buscador */
.hero { padding: 1.5rem 0 .5rem; }
.search input { width: 100%; font: inherit; font-size: 1.15rem; padding: .95rem 1.1rem; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface); color: var(--text); box-shadow: var(--shadow); outline: none; }
.search input:focus { border-color: var(--brand); }
.btn { display: inline-block; font: inherit; font-weight: 600; padding: .7rem 1.2rem; border-radius: 999px; border: 0;
  background: var(--brand); color: var(--brand-ink); text-decoration: none; cursor: pointer; min-height: 44px; }
.btn.ghost { background: var(--accent); color: var(--brand); margin-top: .8rem; border: 1px solid var(--brand); }
.btn[hidden] { display: none; }

/* provincias, chips y tarjetas */
.provs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; }
.prov { display: flex; align-items: center; gap: .6rem; padding: .75rem .9rem; min-height: 48px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.prov:hover, .prov:focus-visible { border-color: var(--brand); }
.prov.long { font-size: .78rem; line-height: 1.12; padding-top: .35rem; padding-bottom: .35rem; }
.prov .num { font-variant-numeric: tabular-nums; color: var(--brand); font-weight: 700; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .5rem; }
.chip { display: flex; flex-direction: column; padding: .55rem .8rem; min-height: 44px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; text-decoration: none; color: var(--text); }
.chip b { color: var(--brand); font-variant-numeric: tabular-nums; }
.chip small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip:hover { border-color: var(--brand); }
.cards { margin-top: 2rem; display: grid; gap: .8rem; }
.card { display: block; padding: 1rem 1.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--text); }
.card b { display: block; color: var(--brand); }
.card span { color: var(--muted); font-size: .95rem; }

/* zonas (provincia) */
.zones { display: flex; gap: .5rem; overflow-x: auto; padding: .8rem 0; scrollbar-width: thin; }
.zone { flex: 0 0 auto; }
.zone input { position: absolute; opacity: 0; pointer-events: none; }
.zone span { display: block; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; white-space: nowrap; }
.zone input:checked + span { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.zone input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* resultados */
.results { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; }
.results a { display: flex; gap: .9rem; align-items: center; padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; text-decoration: none; color: var(--text); }
.results a:hover, .results a:focus-visible { border-color: var(--brand); }
.results .cp { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; min-width: 3.6rem; }
.results small, .cols small { display: block; color: var(--muted); }
mark { background: var(--accent); color: inherit; border-radius: 3px; }

/* página de código */
.cphead { position: relative; margin: .8rem 0; padding: .8rem 3.4rem .9rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cphead .eyebrow { margin: 0; }
.cphead .bigcp { line-height: 1.05; }
.town { margin: .15rem 0 0; font-size: clamp(1.25rem, 5vw, 1.7rem); font-weight: 600; line-height: 1.25; color: var(--text); }
.copybtn { position: absolute; top: .6rem; right: .6rem; display: grid; place-items: center; width: 2.4rem; height: 2.4rem;
           border: 1px solid var(--line); border-radius: 10px; background: var(--accent); color: var(--brand); cursor: pointer; padding: 0; }
.copybtn:hover { border-color: var(--brand); }
.copybtn .i-ok, .copybtn.ok .i-copy { display: none; }
.copybtn.ok .i-ok { display: block; }
.bigcp { font-size: clamp(2.6rem, 16vw, 4.5rem); margin: 0; letter-spacing: .04em; font-variant-numeric: tabular-nums; color: var(--brand); }
.muni { color: var(--muted); }
.facts { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; }
.facts div { flex: 1 1 8rem; padding: .6rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-size: 1.15rem; font-weight: 600; }
.maptools { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .8rem 0; }
.maptools select { font: inherit; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.map.tall { height: 70vh; }
.hovertip { pointer-events: none; }
.hovertip .maplibregl-popup-content { padding: .2rem .55rem; font-weight: 700; font-size: .85rem; color: #003366; pointer-events: none; }
.map { height: 55vh; min-height: 280px; border-radius: var(--radius); overflow: hidden; background: var(--accent); border: 1px solid var(--line); }
.cols { list-style: none; padding: 0; margin: 0; columns: 16rem; column-gap: 1.5rem; }
.cols li { break-inside: avoid; padding: .3rem 0; border-bottom: 1px solid var(--line); }
.answer { font-size: clamp(1.3rem, 5vw, 1.9rem); line-height: 1.3; margin: 1rem 0; }
.answer a { font-weight: 800; }
.answer strong { color: var(--brand); }

footer { color: var(--muted); font-size: .9rem; padding-top: 1rem; padding-bottom: 2rem; border-top: 1px solid var(--line); }
.fine { font-size: .8rem; }

@media (min-width: 40rem) {
  .results { grid-template-columns: 1fr 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
