/* Mapa de España por circunscripciones y páginas de provincias/diputados.
   Se carga en la portada (con citizen.css) y en las páginas generadas (con seo.css): todas las variables
   de la web llevan valor de reserva. Escala secuencial de pizarra; el ámbar solo marca resaltado y foco,
   nunca colores de partido ni el verde/rojo del voto. */

/* ---------- Mapa ---------- */
.smap {
  --sm-0: #e2e8f0; --sm-1: #cbd5e1; --sm-2: #94a3b8; --sm-3: #64748b; --sm-4: #334155;
  --sm-t0: #1e293b; --sm-t1: #1e293b; --sm-t2: #0f172a; --sm-t3: #ffffff; --sm-t4: #ffffff;
  --sm-edge: var(--paper, #ffffff); --sm-hover: #fbbf24; --sm-on-hover: #0f172a;
  --sm-ink: #0f172a; --sm-hl-edge: #0f172a; --sm-inset: var(--line-strong, #cbd5e1);
  position: relative; margin: 0; container-type: inline-size; color: var(--ink, #0f172a);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .smap {
    --sm-0: #334155; --sm-1: #475569; --sm-2: #64748b; --sm-3: #94a3b8; --sm-4: #cbd5e1;
    --sm-t0: #e2e8f0; --sm-t1: #f1f5f9; --sm-t2: #ffffff; --sm-t3: #0f172a; --sm-t4: #0f172a;
    --sm-edge: var(--paper, #1e293b); --sm-ink: #ffffff; --sm-hl-edge: #ffffff; --sm-inset: var(--line-strong, #475569);
  }
}
:root[data-theme="dark"] .smap {
  --sm-0: #334155; --sm-1: #475569; --sm-2: #64748b; --sm-3: #94a3b8; --sm-4: #cbd5e1;
  --sm-t0: #e2e8f0; --sm-t1: #f1f5f9; --sm-t2: #ffffff; --sm-t3: #0f172a; --sm-t4: #0f172a;
  --sm-edge: var(--paper, #1e293b); --sm-ink: #ffffff; --sm-hl-edge: #ffffff; --sm-inset: var(--line-strong, #475569);
}

[data-spain-map] { display: block; min-width: 0; }
[data-spain-map]:empty { aspect-ratio: 604 / 436; border-radius: 14px; background: radial-gradient(var(--line, #e2e8f0) 1.4px, transparent 1.6px) 0 0 / 16px 16px; }
.smap-error { margin: 0; padding: 20px 0; color: var(--muted, #475569); }

.smap-stage { position: relative; display: flex; flex-direction: column; }
.smap svg { display: block; width: 100%; height: auto; overflow: visible; }
.smap-p { stroke: var(--sm-edge); stroke-width: 1.2px; stroke-linejoin: round; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill .12s; }
.smap-b0 { fill: var(--sm-0); } .smap-b1 { fill: var(--sm-1); } .smap-b2 { fill: var(--sm-2); } .smap-b3 { fill: var(--sm-3); } .smap-b4 { fill: var(--sm-4); }
.smap a { outline: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.smap a:hover .smap-p, .smap a:focus-visible .smap-p, .smap-p.is-hl { fill: var(--sm-hover); }
.smap a:focus-visible .smap-p { stroke: var(--sm-ink); stroke-width: 3px; }
.smap-inset { fill: none; stroke: var(--sm-inset); stroke-width: 1px; vector-effect: non-scaling-stroke; }

/* Capa superior: borde de la provincia activa y de la resaltada, para que no lo tape ninguna vecina. */
.smap-over { pointer-events: none; }
.smap-ring, .smap-hl { fill: none; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.smap-ring { stroke: var(--sm-ink); stroke-width: 1.8px; opacity: 0; }
.smap-ring.is-on { opacity: 1; }
.smap-ring.is-focus { stroke-width: 3px; }
.smap-hl { stroke: var(--sm-hl-edge); stroke-width: 2.4px; }

/* Cifras y etiquetas: tamaño constante en pantalla (--sm-k = unidades del SVG por píxel, lo fija mapa.js). */
.smap-labels { pointer-events: none; }
.smap-n { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-weight: 700; font-size: calc(var(--sm-k, 1) * var(--sm-px, 11px)); text-anchor: middle; dominant-baseline: central; font-variant-numeric: tabular-nums; }
.smap-t0 { fill: var(--sm-t0); } .smap-t1 { fill: var(--sm-t1); } .smap-t2 { fill: var(--sm-t2); } .smap-t3 { fill: var(--sm-t3); } .smap-t4 { fill: var(--sm-t4); }
.smap-n.is-on, .smap-n.is-hl { fill: var(--sm-on-hover); }
.smap-n.is-off { display: none; }
.smap-tag { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: calc(var(--sm-k, 1) * 11px); font-weight: 650; fill: var(--ink, #0f172a); dominant-baseline: central; paint-order: stroke; stroke: var(--sm-edge); stroke-width: calc(var(--sm-k, 1) * 3px); stroke-linejoin: round; }
.smap-tag.is-hl { font-weight: 800; }
.smap-canarias { fill: var(--muted, #475569); font-weight: 600; }

/* Leyenda: debajo del mapa por defecto; en el hueco superior izquierdo (donde estaría Portugal) cuando cabe. */
.smap-legend { order: 2; margin: 12px 0 0; color: var(--muted, #475569); font-size: 12px; line-height: 1.3; }
.smap-legend strong { display: block; margin-bottom: 6px; color: var(--ink, #0f172a); font-size: 12px; font-weight: 750; }
.smap-legend ul { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; }
.smap-legend li { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.smap-legend i { flex: none; width: 16px; height: 16px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .12); }
.smap-legend i.smap-b0 { background: var(--sm-0); } .smap-legend i.smap-b1 { background: var(--sm-1); } .smap-legend i.smap-b2 { background: var(--sm-2); } .smap-legend i.smap-b3 { background: var(--sm-3); } .smap-legend i.smap-b4 { background: var(--sm-4); }
.smap-legend-mini { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; font-size: 12px; }
.smap-legend-mini ul { gap: 0; flex-wrap: nowrap; border-radius: 6px; overflow: hidden; }
.smap-legend-mini i { width: 22px; height: 10px; border-radius: 0; box-shadow: none; }
@container (min-width: 620px) {
  .smap-stage > .smap-legend { position: absolute; z-index: 1; top: 4px; left: 0; order: 0; margin: 0; width: 26%; min-width: 150px; max-width: 190px; }
  .smap-stage > .smap-legend ul { flex-direction: column; flex-wrap: nowrap; gap: 5px; }
  .smap-stage > .smap-legend i { width: 18px; height: 14px; }
}

.smap figcaption { margin: 10px 0 0; color: var(--muted, #475569); font-size: 12px; line-height: 1.4; }
.smap-compact { max-width: 460px; margin-inline: auto; }

/* Tarjeta de detalle */
.smap-tip { position: absolute; z-index: 3; display: flex; flex-direction: column; gap: 1px; min-width: 150px; max-width: 240px; padding: 9px 13px 10px; border: 1px solid var(--line, #e2e8f0); border-radius: 10px; background: var(--paper, #ffffff); color: var(--ink, #0f172a); box-shadow: 0 10px 24px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .1); pointer-events: none; font-size: 13px; line-height: 1.35; }
.smap-tip[hidden] { display: none; }
.smap-tip strong { font-size: 15px; font-weight: 750; }
.smap-tip span { color: var(--muted, #475569); font-variant-numeric: tabular-nums; }
.smap-tip em { margin-top: 4px; padding-top: 5px; border-top: 1px solid var(--line, #e2e8f0); color: var(--brand-strong, #1e293b); font-size: 12px; font-style: normal; font-weight: 700; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .smap-tip { box-shadow: 0 10px 24px rgba(0, 0, 0, .5); } }
:root[data-theme="dark"] .smap-tip { box-shadow: 0 10px 24px rgba(0, 0, 0, .5); }

.smap-skip { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.smap-skip:focus { position: static; display: inline-block; width: auto; height: auto; overflow: visible; clip: auto; margin: 0 0 10px; padding: 8px 14px; border-radius: 999px; background: var(--brand-strong, #1e293b); color: var(--paper, #ffffff); font-weight: 700; text-decoration: none; outline: 3px solid var(--sm-hover); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .smap-p { transition: none; } }

/* ---------- Páginas generadas: contenedor del mapa ---------- */
.map-panel { padding: 22px 24px 16px; border: 1px solid var(--line, #e2e8f0); border-radius: 18px; background: var(--paper, #ffffff); }
.map-panel .smap:not(.smap-compact) { max-width: 800px; margin-inline: auto; }
.dx-map .map-panel .smap:not(.smap-compact) { max-width: 700px; }
.map-hint { margin: 12px 0 0; color: var(--muted, #475569); font-size: 14px; }
.pv-more { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-top: 6px; font-weight: 700; }

/* ---------- /provincias/: cuadrícula de tarjetas ---------- */
.pv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.pv-card { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: start; gap: 2px 10px; height: 100%; padding: 13px 15px 14px; border: 1px solid var(--line, #e2e8f0); border-radius: 14px; background: var(--paper, #ffffff); color: var(--ink, #0f172a); text-decoration: none; transition: border-color .12s, box-shadow .12s; }
.pv-card:hover { border-color: #fbbf24; box-shadow: 0 0 0 1px #fbbf24, 0 6px 16px rgba(15, 23, 42, .08); color: var(--ink, #0f172a); }
.pv-card:focus-visible { outline: 3px solid var(--brand, #334155); outline-offset: 3px; }
.pv-name { align-self: center; font: 700 16px/1.25 var(--font-display, system-ui, sans-serif); letter-spacing: -.005em; overflow-wrap: break-word; }
.pv-seats { grid-row: 1; grid-column: 2; text-align: right; font-variant-numeric: tabular-nums; }
.pv-seats b { display: block; font: 800 28px/1 var(--font-display, system-ui, sans-serif); letter-spacing: -.02em; }
.pv-seats small { color: var(--muted, #475569); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pv-pass { grid-column: 1 / -1; align-self: start; margin-top: 2px; color: var(--muted, #475569); font-size: 12.5px; line-height: 1.35; font-variant-numeric: tabular-nums; }
.pv-bar { grid-column: 1 / -1; display: block; height: 4px; margin-top: 9px; border-radius: 999px; background: var(--line, #e2e8f0); overflow: hidden; }
.pv-bar i { display: block; height: 100%; border-radius: 999px; background: var(--sm-3, #64748b); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pv-bar i { background: #94a3b8; } :root:not([data-theme="light"]) .pv-card:hover { box-shadow: 0 0 0 1px #fbbf24, 0 6px 16px rgba(0, 0, 0, .35); } }
:root[data-theme="dark"] .pv-bar i { background: #94a3b8; } :root[data-theme="dark"] .pv-card:hover { box-shadow: 0 0 0 1px #fbbf24, 0 6px 16px rgba(0, 0, 0, .35); }

/* ---------- /provincia/<slug>/ ---------- */
.pv-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: center; }
.pv-top .map-panel { padding: 14px 16px 10px; }
.pv-top .smap figcaption { font-size: 11px; }
.pv-facts { display: grid; gap: 10px; margin: 0; }
.pv-fact { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 2px 16px; margin: 0; padding: 14px 18px; border: 1px solid var(--line, #e2e8f0); border-top: 4px solid #fbbf24; border-radius: 14px; background: var(--paper, #ffffff); }
.pv-fact dt { grid-column: 2; grid-row: 1; margin: 0; font-size: 14px; font-weight: 700; line-height: 1.25; }
.pv-fact dt span { display: block; margin-top: 2px; color: var(--muted, #475569); font-size: 12.5px; font-weight: 400; line-height: 1.35; }
.pv-fact dd { grid-column: 1; grid-row: 1; margin: 0; font: 800 38px/1 var(--font-display, system-ui, sans-serif); letter-spacing: -.02em; font-variant-numeric: tabular-nums; min-width: 1.4ch; text-align: right; }
.pv-note-box { margin: 14px 0 0; color: var(--muted, #475569); font-size: 13px; }
@media (max-width: 760px) {
  .pv-top { grid-template-columns: 1fr; gap: 14px; }
  .pv-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .pv-fact { grid-template-columns: 1fr; padding: 11px 10px 12px; text-align: left; }
  .pv-fact dt, .pv-fact dd { grid-column: 1; grid-row: auto; text-align: left; }
  .pv-fact dt { order: 2; font-size: 12px; margin-top: 4px; }
  .pv-fact dt span { display: none; }
  .pv-fact dd { order: 1; font-size: 30px; }
}

.pv-table { min-width: 0; }
.pv-table thead th { padding-block: 9px; white-space: nowrap; }
.pv-table tbody th, .pv-table tbody td { padding: 12px 12px; vertical-align: top; }
.pv-table tbody th[scope="row"] { min-width: 150px; font-weight: 600; line-height: 1.3; }
.pv-table tbody th a { font-size: 15px; font-weight: 700; }
.pv-table td { color: var(--ink, #0f172a); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pv-table td.pv-muted, .pv-table td .pv-of { color: var(--muted, #475569); }
.pv-table td b { font-weight: 700; }
.pv-table td.pv-none { white-space: normal; text-align: left; color: var(--muted, #475569); font-size: 13px; }
.pv-chip { display: block; width: fit-content; margin-top: 5px; padding: 1px 9px; border: 1px solid var(--line, #e2e8f0); border-radius: 999px; background: var(--soft, #f1f5f9); color: var(--muted, #475569); font-size: 12px; font-weight: 600; line-height: 1.5; }
.pv-note { display: block; margin-top: 4px; color: var(--muted, #475569); font-size: 12px; font-weight: 400; }
@media (max-width: 600px) {
  .pv-table thead th, .pv-table tbody th, .pv-table tbody td { padding-inline: 8px; }
  .pv-table thead th { font-size: 11.5px; text-transform: none; letter-spacing: 0; white-space: normal; line-height: 1.2; }
  .pv-table tbody th[scope="row"] { min-width: 0; }
  .pv-table tbody th a { font-size: 14px; }
}

/* ---------- /diputados/ ---------- */
.dx-search { margin: 0 0 14px; }
.dx-search[hidden] { display: none; }
.dx-search label { display: block; margin-bottom: 6px; font-weight: 700; }
.dx-field { position: relative; }
.dx-field svg { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--muted, #475569); pointer-events: none; }
.dx-field input { width: 100%; min-height: 52px; padding: 0 16px 0 44px; border: 2px solid var(--line-strong, #cbd5e1); border-radius: 14px; background: var(--paper, #ffffff); color: var(--ink, #0f172a); font: inherit; font-size: 17px; }
.dx-field input::placeholder { color: var(--muted, #475569); opacity: .8; }
.dx-field input:focus-visible { outline: 3px solid #fbbf24; outline-offset: 1px; border-color: var(--brand, #334155); }
.dx-legs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; border: 0; }
.dx-legs legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.dx-legs label { position: relative; margin: 0; font-weight: 600; font-size: 14px; }
.dx-legs input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.dx-legs span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border: 1px solid var(--line-strong, #cbd5e1); border-radius: 999px; background: var(--paper, #ffffff); }
.dx-legs input:checked + span { border-color: var(--brand-strong, #1e293b); background: var(--brand-strong, #1e293b); color: var(--paper, #ffffff); }
.dx-legs input:focus-visible + span { outline: 3px solid #fbbf24; outline-offset: 2px; }
.dx-count { margin: 12px 0 0; color: var(--muted, #475569); font-size: 14px; min-height: 1.5em; }
.dx-none { margin: 18px 0; padding: 18px; border: 1px dashed var(--line-strong, #cbd5e1); border-radius: 12px; color: var(--muted, #475569); }
.dx-none[hidden] { display: none; }
.dx-az { margin: 16px 0 6px; }
.dx-az ul { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.dx-az li[hidden] { display: none; }
.dx-az a { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 38px; padding: 0 4px; border: 1px solid var(--line, #e2e8f0); border-radius: 10px; background: var(--paper, #ffffff); color: var(--ink, #0f172a); font-weight: 700; font-size: 14px; text-decoration: none; }
.dx-az a:hover { border-color: #fbbf24; background: #fbbf24; color: #0f172a; }
.dx-az a:focus-visible { outline: 3px solid var(--brand, #334155); outline-offset: 2px; }
.dx-letter { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 0 12px; padding: 18px 0; border-top: 1px solid var(--line, #e2e8f0); scroll-margin-top: 12px; }
.dx-letter[hidden] { display: none; }
.dx-letter h3 { margin: 0; font: 800 34px/1 var(--font-display, system-ui, sans-serif); letter-spacing: -.02em; color: var(--brand-strong, #1e293b); }
.dx-letter h3::after { content: ""; display: block; width: 24px; height: 4px; margin-top: 8px; border-radius: 2px; background: #fbbf24; }
.dx-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 2px 20px; margin: 0; padding: 0; list-style: none; columns: auto; }
.dx-list li { display: flex; flex-direction: column; padding: 7px 0; border-bottom: 1px solid var(--line, #e2e8f0); line-height: 1.3; }
.dx-list li[hidden] { display: none; }
.dx-list a { font-size: 15px; font-weight: 400; text-decoration: none; color: var(--ink, #0f172a); overflow-wrap: anywhere; }
.dx-list a b { font-weight: 700; }
.dx-list a:hover { color: var(--ink, #0f172a); text-decoration: underline; text-decoration-color: #fbbf24; text-decoration-thickness: 3px; }
.dx-list a:focus-visible { outline: 3px solid var(--brand, #334155); outline-offset: 2px; border-radius: 3px; }
.dx-meta { margin-top: 2px; color: var(--muted, #475569); font-size: 12.5px; }
@media (max-width: 600px) {
  .pv-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .pv-card { padding: 11px 12px 12px; border-radius: 12px; }
  .pv-name { font-size: 15px; }
  .pv-seats b { font-size: 24px; }
  .map-panel { padding: 12px 10px 8px; border-radius: 14px; }
  .dx-letter { grid-template-columns: 38px minmax(0, 1fr); gap: 0 8px; }
  .dx-letter h3 { font-size: 28px; }
  .dx-list { grid-template-columns: 1fr; }
}

/* ---------- Portada: «¿Quién te representa?» ---------- */
.qr { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.3fr); gap: 32px; align-items: center; padding: 30px 32px; border: 1px solid var(--line, #e2e8f0); border-radius: 20px; background: var(--paper, #ffffff); }
.qr-kicker { margin: 0 0 8px; color: var(--brand-strong, #1e293b); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.qr h2 { margin: 0 0 12px; font: 800 clamp(26px, 3vw, 36px)/1.08 var(--font-display, system-ui, sans-serif); letter-spacing: -.02em; }
.qr p { color: var(--muted, #475569); font-size: 16px; line-height: 1.55; }
.qr .qr-kicker { margin: 0 0 8px; }
.qr-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 20px 0 0; }
.qr-btn { display: inline-flex; align-items: center; min-height: 48px; padding: 0 22px; border-radius: 999px; background: #334155; color: #fff; font-weight: 750; text-decoration: none; }
.qr-btn:hover { background: #1e293b; color: #fff; }
.qr-btn:focus-visible, .qr-link:focus-visible { outline: 3px solid var(--ink, #0f172a); outline-offset: 3px; }
.qr-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; color: var(--brand-strong, #1e293b); }
.qr-map { min-width: 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .qr-btn { background: #fbbf24; color: #0f172a; } :root:not([data-theme="light"]) .qr-btn:hover { background: #fcd34d; color: #0f172a; } :root:not([data-theme="light"]) .qr-btn:focus-visible, :root:not([data-theme="light"]) .qr-link:focus-visible { outline-color: #fff; } }
:root[data-theme="dark"] .qr-btn { background: #fbbf24; color: #0f172a; } :root[data-theme="dark"] .qr-btn:hover { background: #fcd34d; color: #0f172a; } :root[data-theme="dark"] .qr-btn:focus-visible, :root[data-theme="dark"] .qr-link:focus-visible { outline-color: #fff; }
@media (max-width: 860px) {
  .qr { grid-template-columns: 1fr; gap: 18px; padding: 24px 18px 20px; }
  .qr-btn { width: 100%; justify-content: center; }
}
