/* =========================================================
   ALT METRICA — estilos del sitio público
   Concepto: papel blanco, mapa negro (como la referencia) y un
   solo acento: el morado del isologo. Tipografía ancha y pesada
   para titulares, cifras en monoespaciada como en una ficha técnica.
   ========================================================= */
:root {
  --ink: #0B0A0D;          /* casi negro, ligeramente violáceo */
  --ink-2: #2A2630;
  --paper: #FFFFFF;
  --mist: #F6F4F8;         /* fondos suaves */
  --line: #E7E3EC;
  --muted: #6C6575;
  --brand: #C103FE;        /* morado del logo */
  --brand-ink: #9A00CF;    /* morado legible para texto pequeño */
  --brand-soft: #F6E6FF;
  --map-fill: #0B0A0D;
  --map-line: #4C4654;
  --ok: #1E8E4E;
  --danger: #C2352B;

  --f-display: "Archivo", "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Figtree", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r-sm: 8px; --r-md: 14px; --r-lg: 22px;
  --wrap: 1200px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.55 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--f-display); font-stretch: 112%; line-height: 1.05; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.wrap {
  max-width: var(--wrap); margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}

/* ---------- Encabezado ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 60; background: var(--paper); }
.site-head {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 68px; }
.brand img { height: 30px; width: auto; }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a { text-decoration: none; font-weight: 600; font-size: 15px; padding: 8px 12px; border-radius: 999px; color: var(--ink-2); }
.nav a:hover { background: var(--mist); }
.nav a.is-current { color: var(--brand-ink); }
@media (max-width: 640px) { .nav a.hide-sm { display: none; } .brand img { height: 26px; } }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid transparent; border-radius: 999px; padding: 12px 22px;
  font-weight: 700; font-size: 15px; text-decoration: none; cursor: pointer; line-height: 1;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 9px 16px; font-size: 14px; }
.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-ink); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: var(--mist); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 15px; }

/* ---------- Portada ---------- */
.hero { padding-block: clamp(40px, 7vw, 88px) clamp(20px, 3vw, 32px); }
.hero-kicker { font-family: var(--f-mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.hero-kicker::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--brand); }
.hero h1 {
  margin-top: 18px; font-size: clamp(40px, 7.4vw, 96px); font-weight: 850; letter-spacing: -0.03em; max-width: 14ch;
}
.hero h1 em { font-style: normal; color: var(--brand); }
.hero-sub { margin-top: 22px; max-width: 56ch; color: var(--muted); font-size: clamp(16px, 1.6vw, 19px); }

.map-section { padding-block: 8px 56px; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
@media (max-width: 960px) { .map-layout { grid-template-columns: minmax(0, 1fr); } }
.map-box { position: relative; }
.mx-map { width: 100%; height: auto; display: block; overflow: visible; }
.mx-map .st { fill: var(--map-fill); stroke: var(--map-line); stroke-width: .7; stroke-linejoin: round; transition: fill .18s ease; }
.mx-map.is-interactive .st { cursor: pointer; outline: none; }
.mx-map.is-interactive .st:hover, .mx-map.is-interactive .st:focus-visible { fill: var(--brand); stroke: #fff; stroke-width: 1.2; }
.mx-map .st.is-active { fill: var(--brand); stroke: #fff; stroke-width: 1; }
.mx-map .pin { fill: var(--brand); stroke: #fff; stroke-width: 1.5; pointer-events: none; }
.mx-map .pin-ring { fill: none; stroke: var(--brand); stroke-width: 2; pointer-events: none; transform-box: fill-box; transform-origin: center; animation: ring 2.4s ease-out infinite; }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(3.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mx-map .pin-ring { animation: none; opacity: 0; } }
.map-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 14px)); pointer-events: none; z-index: 5;
  background: var(--ink); color: #fff; border-radius: 10px; padding: 8px 12px; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(11, 10, 13, .25); display: grid; gap: 1px;
}
.map-tip strong { font-size: 14px; }
.map-tip span { font-size: 12px; color: #CFC8D8; }
.map-hint { font-family: var(--f-mono); font-size: 12px; color: var(--muted); margin-top: 10px; }

.side-panel { border-top: 2px solid var(--ink); padding-top: 14px; display: grid; gap: 14px; }
.side-panel h2 { font-size: 20px; }
.side-list { list-style: none; margin: 0; padding: 0; display: grid; }
.side-list a { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-decoration: none; padding: 11px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.side-list a:hover { color: var(--brand-ink); }
.count-pill { font-family: var(--f-mono); font-size: 12px; font-weight: 500; background: var(--brand-soft); color: var(--brand-ink); border-radius: 999px; padding: 3px 9px; }
.side-empty { color: var(--muted); font-size: 14px; }

.states-index { padding-block: 40px; border-top: 1px solid var(--line); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.section-title h2 { font-size: clamp(26px, 3.2vw, 38px); }
.section-title p { color: var(--muted); }
.state-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.state-grid a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r-sm); text-decoration: none; font-weight: 600; font-size: 15px;
}
.state-grid a:hover { border-color: var(--ink); }
.state-grid a.has-data { border-color: var(--brand); }
.state-grid .muted { color: var(--muted); font-weight: 400; font-size: 13px; }

.recent { padding-block: 48px 72px; background: var(--mist); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 18px; }

/* ---------- Tarjeta de encuesta ---------- */
.poll-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: clamp(18px, 2.4vw, 28px); display: grid; gap: 18px; min-width: 0; align-content: start;
}
.eyebrow { font-family: var(--f-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-ink); }
.eyebrow span { color: var(--line); margin: 0 4px; }
.poll-title { font-size: clamp(20px, 2.1vw, 26px); font-weight: 800; margin-top: 8px; }
.poll-compact .poll-title { font-size: 19px; }
.poll-desc { margin-top: 8px; color: var(--muted); }
.poll-empty { color: var(--muted); font-size: 14px; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.res { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--mist); flex: none; }
.avatar-ini { display: grid; place-items: center; font: 700 15px/1 var(--f-display); color: #fff; background: var(--c); }
.avatar-dot { display: grid; place-items: center; background: transparent; border: 2px solid var(--line); }
.avatar-dot::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--c); }
.res-main { min-width: 0; display: grid; gap: 6px; }
.res-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.res-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.res-sub { font-size: 13px; color: var(--muted); margin-top: -4px; }
.res-pct { margin-left: auto; font: 600 17px/1 var(--f-mono); font-variant-numeric: tabular-nums; }
.res-lead .res-pct { font-size: 22px; color: var(--ink); }
.res-lead .avatar { width: 52px; height: 52px; box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--brand); }
.chip-party {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  font: 600 11px/1 var(--f-mono); letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 7px; border-radius: 6px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--paper));
}
.chip-party img { width: 14px; height: 14px; object-fit: contain; }
.bar { height: 10px; background: var(--mist); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.res-more { font-size: 13px; color: var(--muted); padding-left: 56px; }
.poll-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; border-top: 1px dashed var(--line); padding-top: 14px; }
.ficha { display: grid; gap: 4px; font-family: var(--f-mono); font-size: 12px; color: var(--muted); min-width: 0; flex: 1 1 220px; }
.ficha-main { color: var(--ink-2); font-weight: 500; }
.ficha-note { font-size: 11px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 500; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }
.metodo summary { cursor: pointer; color: var(--brand-ink); }
.metodo p { margin-top: 6px; font-family: var(--f-body); font-size: 13px; line-height: 1.5; }
.poll-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Página de estado ---------- */
.state-hero { padding-block: 36px 24px; border-bottom: 1px solid var(--line); }
.state-hero .wrap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 28px; align-items: end; }
@media (max-width: 760px) { .state-hero .wrap { grid-template-columns: minmax(0, 1fr); } .state-locator { max-width: 220px; } }
.crumbs { font-family: var(--f-mono); font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.state-hero h1 { font-size: clamp(40px, 6.5vw, 80px); font-weight: 850; letter-spacing: -0.03em; margin-top: 12px; }
.state-meta { margin-top: 14px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.state-select { border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; background: var(--paper); font-weight: 600; }
.state-locator .mx-map .st { fill: #E9E5EE; stroke: #fff; stroke-width: .8; }
.state-locator .mx-map .st.is-active { fill: var(--brand); stroke: var(--brand); }

.tabs-bar { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 68px); z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-block: 10px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 9px 16px;
  font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center;
}
.tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab .n { font: 500 11px/1 var(--f-mono); opacity: .7; }

.state-body { padding-block: 32px 72px; display: grid; gap: 40px; }
.place-group { display: grid; gap: 16px; }
.place-group > h2 { font-size: 22px; display: flex; gap: 10px; align-items: baseline; }
.place-group > h2 small { font: 500 12px/1 var(--f-mono); color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.empty-state { text-align: center; padding: 64px 16px; border: 1.5px dashed var(--line); border-radius: var(--r-lg); color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty-state h2 { color: var(--ink); font-size: 24px; }

/* ---------- Votación ---------- */
.vote-page { background: var(--mist); min-height: 100vh; }
.vote-wrap { max-width: 640px; margin: 0 auto; padding: 28px max(16px, env(safe-area-inset-right, 0px)) 64px max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 18px; }
.vote-top { display: flex; justify-content: space-between; align-items: center; }
.vote-top img { height: 26px; width: auto; }
.vote-card { background: var(--paper); border-radius: var(--r-lg); border: 1px solid var(--line); padding: clamp(20px, 4vw, 32px); display: grid; gap: 20px; }
.vote-card h1 { font-size: clamp(24px, 4.6vw, 34px); font-weight: 850; }
.choices { display: grid; gap: 10px; border: 0; padding: 0; margin: 0; }
.choice { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-md); cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--ink-2); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .avatar { width: 52px; height: 52px; }
.choice .c-name { font-weight: 700; font-size: 17px; display: block; }
.choice .c-sub { font-size: 13px; color: var(--muted); }
.choice .tick { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice:has(input:checked) .tick { border-color: var(--brand); background: var(--brand); }
.choice:has(input:checked) .tick::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.choice:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 2px; }
.vote-msg { padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; }
.vote-msg.ok { background: #E7F6EE; color: var(--ok); }
.vote-msg.err { background: #FBEAEA; color: var(--danger); }
.vote-msg.info { background: var(--brand-soft); color: var(--brand-ink); }
.vote-legal { font-size: 12px; color: var(--muted); text-align: center; }
.vote-card .poll-card { border: 0; padding: 0; }

/* ---------- Pie ---------- */
.site-foot { background: var(--ink); color: #D9D3E0; padding-block: 40px; }
.site-foot .wrap { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; align-items: center; }
.site-foot img { height: 28px; width: auto; }
.site-foot small { font-family: var(--f-mono); font-size: 12px; color: #9C95A6; }
.site-foot a { color: #fff; }

/* ---------- Varios ---------- */
.demo-banner { background: var(--ink); color: #fff; font-size: 13px; text-align: center; padding: 8px 16px; }
.demo-banner code { font-family: var(--f-mono); color: #E3A6FF; }
.skeleton { background: linear-gradient(90deg, var(--mist), #EEEAF2, var(--mist)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: var(--r-lg); min-height: 220px; }
@keyframes sk { to { background-position: -200% 0; } }
.sheet { position: fixed; inset: 0; background: rgba(11, 10, 13, .45); z-index: 100; display: grid; place-items: end center; padding: 16px; }
@media (min-width: 640px) { .sheet { place-items: center; } }
.sheet-card { background: var(--paper); border-radius: var(--r-lg); padding: 20px; width: min(460px, 100%); display: grid; gap: 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h4 { font-size: 18px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; font-family: var(--f-mono); font-size: 13px; background: var(--mist); }
.share-btns { display: flex; gap: 8px; flex-wrap: wrap; }
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); }
