/* ============================================================
   atlas.css — Mapa de dominio a pantalla completa (versión
   mexicana del mapa por casilla de VoteHub 2024).
   Reutiliza los tokens de styles.css (superficies, tinta, acento
   magenta INE, Archivo / Inter / Space Grotesk).
   ============================================================ */

:root {
  --ax-sky: #e9ecf3;
  --ax-land: #eceef1;
  --ax-shadow: 0 1px 2px rgba(20, 22, 26, .06), 0 6px 22px rgba(20, 22, 26, .12);
  --ax-shadow-lg: 0 2px 4px rgba(20, 22, 26, .06), 0 14px 40px rgba(20, 22, 26, .16);
  --ax-muted: #8a909b;
  --ax-up: #12804a;
  --ax-down: #b4322a;
  --ax-note: #f2a900;
}
[data-theme="dark"] {
  --ax-sky: #101217;
  --ax-land: #1b1e24;
  --ax-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .45);
  --ax-shadow-lg: 0 2px 4px rgba(0, 0, 0, .5), 0 16px 44px rgba(0, 0, 0, .55);
  --ax-muted: #7d8594;
  --ax-up: #4cc38a;
  --ax-down: #f07a70;
}

/* Icono SVG del botón de tema del topbar. */
.theme-icon { display: inline-flex; }
.theme-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Modo atlas: la vista ocupa todo el alto bajo el topbar ---------- */
body.atlas-mode { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.atlas-mode .app { flex: 1 1 auto; min-height: 0; max-width: none; margin: 0; padding: 0; }
body.atlas-mode .app > section { margin: 0; }
body.atlas-mode .foot { display: none; }

.ax {
  position: relative; height: 100%; overflow: hidden;
  font-family: var(--font-body); color: var(--ink);
  -webkit-user-select: none; user-select: none;
}
.ax svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:where(.ax) button { font: inherit; color: inherit; }
.ax [hidden] { display: none !important; }
.ax :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Motor (atlas.js) ---------- */
.ax-map { position: absolute; inset: 0; }
.atlas-viewport {
  overflow: hidden; touch-action: none; cursor: grab;
  background: linear-gradient(180deg, var(--ax-sky), var(--ax-land) 60%);
}
.atlas-viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.atlas-viewport.is-pointing { cursor: pointer; }
.atlas-viewport.is-grabbing { cursor: grabbing; }
.atlas-plane { position: absolute; background: var(--ax-land); will-change: transform; }
.atlas-c { position: absolute; left: 0; top: 0; display: block; }
.atlas-spikes { position: absolute; inset: 0; pointer-events: none; }
.atlas-box {
  position: absolute; pointer-events: none; border-radius: 3px;
  border: 1.5px dashed var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.atlas-box[data-mode="remove"] { border-color: var(--ax-down); background: color-mix(in srgb, var(--ax-down) 12%, transparent); }
.atlas-viewport.is-tilted .atlas-plane { box-shadow: 0 -30px 60px -20px rgba(0, 0, 0, .18); }

/* ---------- Superficies flotantes ---------- */
.ax-tools, .ax-bar .ax-btn, .ax-layers, .ax-panel, .ax-tip, .ax-legend, .ax-status, .ax-tools-open {
  background: var(--surface); box-shadow: var(--ax-shadow);
}

/* Herramientas (arriba a la izquierda) */
.ax-tools { position: absolute; z-index: 6; top: 16px; left: 16px; width: 132px; border-radius: 12px; padding: 4px 0 8px; }
.ax-tools-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--hair-2); margin-bottom: 6px; }
.ax-tools-head span { font-family: var(--font-data); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.ax-tools-row { display: grid; grid-template-columns: 38px 18px 1fr; align-items: center; gap: 6px; padding: 5px 12px; font-size: .74rem; color: var(--ink-2); }
.ax-tools-row svg { width: 18px; height: 18px; color: var(--ink-2); }
.ax kbd {
  justify-self: start; font-family: var(--font-data); font-size: .7rem; font-weight: 700; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--hair); border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; line-height: 1.2;
}
.ax-tools-open { position: absolute; z-index: 6; top: 16px; left: 16px; width: 40px; height: 40px; border: 0; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.ax-tools-open svg { width: 20px; height: 20px; }
.ax-icon-sm {
  flex: none; width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.ax-icon-sm svg { width: 16px; height: 16px; }
.ax-icon-sm:hover { background: var(--surface-2); color: var(--ink); }

/* Barra de controles (arriba a la derecha) */
.ax-bar { position: absolute; z-index: 7; top: 16px; right: 16px; display: flex; gap: 10px; }
.ax-btn {
  width: 46px; height: 46px; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 11px; color: var(--ink-2);
  transition: color .15s, box-shadow .15s, transform .12s cubic-bezier(.2, .8, .2, 1);
}
.ax-btn svg { width: 20px; height: 20px; }
.ax-btn:hover { color: var(--ink); }
.ax-btn:active { transform: scale(.94); }
.ax-btn.is-on { color: var(--accent); box-shadow: var(--ax-shadow), inset 0 0 0 1.5px var(--accent); }

/* Popover de capas */
.ax-layers {
  position: absolute; z-index: 8; top: 74px; right: 16px; width: 252px;
  border-radius: 14px; padding: 14px; display: grid; gap: 12px;
  transform-origin: top right; animation: axPop .18s cubic-bezier(.2, .8, .2, 1);
}
@keyframes axPop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.ax-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ax-modes button {
  height: 34px; border: 1px solid var(--hair); border-radius: 8px; background: var(--surface);
  font-size: .8rem; font-weight: 600; color: var(--ink-2); cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.ax-modes button:hover { border-color: var(--ink-2); color: var(--ink); }
.ax-modes button[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.ax-sub { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--hair-2); }
.ax-sub-h { margin: 0; font-size: .78rem; font-weight: 600; color: var(--ink); }
.ax-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ax-chips button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 10px;
  border: 1px solid var(--hair); border-radius: 8px; background: var(--surface);
  font-size: .76rem; font-weight: 500; color: var(--ink-2); cursor: pointer;
  transition: border-color .15s, color .15s, background-color .15s;
}
.ax-chips button:hover { border-color: var(--ink-2); color: var(--ink); }
.ax-chips button[aria-checked="true"] { border-color: var(--accent); color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); box-shadow: inset 0 0 0 .5px var(--accent); }
.ax-chips-party button { padding: 4px 9px; }
.ax-note {
  margin: 0; padding: 8px 10px; border-radius: 8px; font-size: .72rem; line-height: 1.4; color: var(--ink-2);
  background: color-mix(in srgb, var(--ax-note) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ax-note) 45%, transparent);
}
.ax-toggle {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; text-align: left;
  border: 1px solid var(--hair); border-radius: 8px; background: var(--surface); cursor: pointer;
  font-size: .8rem; font-weight: 500; color: var(--ink-2);
}
.ax-toggle:hover { border-color: var(--ink-2); color: var(--ink); }
.ax-toggle-box { width: 16px; height: 16px; border: 1.5px solid var(--hair); border-radius: 4px; display: grid; place-items: center; transition: background-color .15s, border-color .15s; }
.ax-toggle[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); }
.ax-toggle[aria-pressed="true"] .ax-toggle-box { background: var(--accent); border-color: var(--accent); }
.ax-toggle[aria-pressed="true"] .ax-toggle-box::after { content: ""; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.ax-layers-legend { display: none; }

/* ---------- Panel de resultados (abajo a la izquierda) ---------- */
.ax-panel {
  position: absolute; z-index: 5; left: 16px; bottom: 16px; width: 384px;
  max-height: calc(100% - 152px); display: flex; flex-direction: column;
  border-radius: 14px; overflow: hidden;
}
.ax-ph { flex: none; display: flex; align-items: center; gap: 6px; min-height: 54px; padding: 8px 10px 8px 20px; border-bottom: 1px solid var(--hair-2); }
.ax-scope { flex: 1 1 auto; min-width: 0; margin: 0; font-family: var(--font-body); font-size: .9rem; font-weight: 600; letter-spacing: 0; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ax-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--hair) transparent; }
.ax-panel.is-collapsed .ax-body { display: none; }
.ax-panel.is-collapsed .ax-ph { border-bottom: 0; }

.ax-intro { padding: 18px 20px 18px; border-bottom: 1px solid var(--hair-2); }
.ax-title { margin: 0; font-family: var(--font-display); font-size: 1.62rem; font-weight: 800; line-height: 1.1; letter-spacing: -.022em; text-wrap: balance; }
.ax-by { margin: 10px 0 0; font-size: .76rem; line-height: 1.45; color: var(--muted); }
.ax-seats { margin-top: 16px; }
.ax-seats-lbl { display: flex; gap: 2px; margin-bottom: 5px; }
.ax-seats-lbl span { min-width: 0; font-family: var(--font-data); font-size: .66rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.ax-seats-bar { display: flex; gap: 2px; height: 26px; border-radius: 999px; overflow: hidden; }
.ax-seats-bar span {
  min-width: 22px; display: flex; align-items: center; justify-content: center;
  background: var(--c); color: var(--t); font-family: var(--font-data); font-size: .8rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ax-seats-cap { margin: 6px 0 0; font-size: .7rem; color: var(--muted); }

.ax-search { position: relative; padding: 16px 20px; border-bottom: 1px solid var(--hair-2); }
.ax-search > svg { position: absolute; left: 33px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.ax-search input {
  width: 100%; height: 42px; padding: 0 12px 0 40px; border: 1px solid var(--hair); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: 400 .88rem var(--font-body);
  -webkit-user-select: text; user-select: text; caret-color: var(--accent);
  transition: border-color .15s, box-shadow .15s;
}
.ax-search input::placeholder { color: var(--muted); }
.ax-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.ax-search input::-webkit-search-cancel-button { display: none; }
.ax-results {
  position: absolute; z-index: 3; left: 20px; right: 20px; top: calc(100% - 12px); margin: 0; padding: 4px; list-style: none;
  max-height: 268px; overflow-y: auto; background: var(--surface); border-radius: 10px; box-shadow: var(--ax-shadow-lg);
}
.ax-results li { display: grid; gap: 1px; padding: 9px 12px; border-radius: 7px; cursor: pointer; }
.ax-results li b { font-size: .86rem; font-weight: 600; }
.ax-results li span { font-size: .7rem; color: var(--muted); }
.ax-results li[aria-selected="true"], .ax-results li:hover { background: var(--surface-2); }
.ax-results .ax-r-empty { cursor: default; font-size: .8rem; color: var(--muted); }
.ax-results .ax-r-empty:hover { background: none; }

/* Tabla por fuerza */
.ax-t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ax-t thead th {
  padding: 12px 20px 10px; text-align: right; white-space: nowrap;
  font-family: var(--font-body); font-size: .7rem; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--hair);
}
.ax-t thead th:first-child { text-align: left; }
.ax-t tbody th { padding: 11px 6px 11px 20px; text-align: left; font-weight: 400; }
.ax-t tbody th { display: flex; align-items: center; gap: 10px; }
.ax-t td { padding: 11px 20px 11px 8px; text-align: right; white-space: nowrap; font-family: var(--font-data); font-size: .95rem; font-weight: 700; color: var(--ink); }
.ax-t td:last-child { font-weight: 500; color: var(--ink-2); font-size: .88rem; }
.ax-t tbody tr + tr > * { border-top: 1px solid var(--hair-2); }
.ax-t tbody tr.is-on { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.ax-t4 td { padding-left: 4px; padding-right: 14px; font-size: .84rem; }
.ax-t4 td:last-child { padding-right: 20px; font-weight: 700; }
.ax-t td.is-up { color: var(--ax-up); }
.ax-t td.is-down { color: var(--ax-down); }
.ax-pn { min-width: 0; display: grid; gap: 1px; }
.ax-pn > span { display: flex; align-items: center; gap: 6px; font-size: .94rem; font-weight: 600; color: var(--ink); }
.ax-pn em { font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ax-lead {
  font-family: var(--font-data); font-size: .58rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 11%, var(--surface)); border-radius: 4px; padding: 1px 5px;
}
.ax-dot { flex: none; width: 11px; height: 11px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.ax-shift { margin: 0; padding: 10px 20px 12px; font-size: .8rem; color: var(--ink-2); border-top: 1px solid var(--hair); }
.ax-shift b { color: var(--ink); font-family: var(--font-data); }
.ax-empty { margin: 0; padding: 18px 20px; font-size: .84rem; line-height: 1.45; color: var(--muted); }

.ax-pfoot { padding: 12px 20px 16px; border-top: 1px solid var(--hair); background: var(--surface-2); }
.ax-pfoot p { margin: 0 0 4px; font-size: .78rem; line-height: 1.45; color: var(--ink-2); }
.ax-pfoot b { font-family: var(--font-data); font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.ax-pfoot .ax-src { margin-top: 6px; font-size: .68rem; color: var(--muted); }
.ax-link {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 0; border: 0; background: none; cursor: pointer;
  font-size: .82rem; font-weight: 600; color: var(--accent-ink) !important; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.ax-link svg { width: 15px; height: 15px; transition: transform .15s; }
.ax-link:hover svg { transform: translateX(2px); }

/* ---------- Tooltip ---------- */
.ax-tip {
  position: absolute; z-index: 20; left: 0; top: 0; pointer-events: none;
  min-width: 232px; max-width: 290px; padding: 10px 14px 9px; border-radius: 10px; font-size: .8rem;
}
.ax-tip-h { display: grid; gap: 1px; margin-bottom: 7px; }
.ax-tip-h b { font-size: .88rem; font-weight: 700; }
.ax-tip-h span { font-size: .7rem; color: var(--muted); }
.ax-tip-row { display: grid; grid-template-columns: 11px 1fr auto 46px; align-items: center; gap: 8px; padding: 3px 0; }
.ax-tip-row b { font-family: var(--font-data); font-weight: 600; font-variant-numeric: tabular-nums; }
.ax-tip-row i { font-style: normal; text-align: right; color: var(--ink-2); font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.ax-tip-g { margin: 7px 0 0; font-size: .74rem; color: var(--ink-2); }
.ax-tip-f { margin: 7px 0 0; padding-top: 7px; border-top: 1px solid var(--hair-2); font-size: .7rem; color: var(--muted); }
.ax-tip-h + .ax-tip-f { margin-top: 0; padding-top: 0; border-top: 0; }

/* ---------- Estado de carga ---------- */
.ax-status {
  position: absolute; z-index: 9; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  font-size: .76rem; font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.ax-status[data-kind="info"]::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--hair); border-top-color: var(--accent); animation: axSpin .8s linear infinite;
}
.ax-status[data-kind="warn"] { background: color-mix(in srgb, var(--ax-note) 16%, var(--surface)); color: var(--ink); white-space: normal; max-width: min(460px, 70vw); }
@keyframes axSpin { to { transform: rotate(360deg); } }

/* ---------- Leyenda ---------- */
.ax-legend { position: absolute; z-index: 4; right: 16px; bottom: 34px; padding: 10px 12px; border-radius: 10px; font-size: .68rem; color: var(--ink-2); }
.ax-lg-h { margin: 0 0 6px; font-weight: 600; color: var(--ink); }
.ax-lg-grid { display: grid; grid-template-columns: auto auto; align-items: center; gap: 4px 10px; }
.ax-lg-n { font-family: var(--font-data); font-weight: 700; letter-spacing: .03em; }
.ax-lg-ramp { display: flex; gap: 1px; }
.ax-lg-ramp i { width: 16px; height: 9px; }
.ax-lg-ramp i:first-child { border-radius: 2px 0 0 2px; }
.ax-lg-ramp i:last-child { border-radius: 0 2px 2px 0; }
.ax-lg-2 i { width: 40px; }
.ax-lg-wide i { width: 28px; }
.ax-lg-scale { display: flex; justify-content: space-between; gap: 12px; margin-top: 5px; color: var(--muted); }
.ax-lg-sw { display: flex; flex-wrap: wrap; gap: 6px 12px; max-width: 220px; }
.ax-lg-sw span { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-data); font-weight: 700; }
.ax-lg-sw .ax-dot { width: 10px; height: 10px; border-radius: 3px; }
.ax-lg-spike { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; padding-top: 7px; border-top: 1px solid var(--hair-2); }
.ax-lg-spike svg { width: 10px; height: 12px; fill: var(--ink-2); stroke: none; }

.ax-attr {
  position: absolute; z-index: 4; right: 10px; bottom: 8px; margin: 0;
  font-size: .62rem; color: var(--muted); background: color-mix(in srgb, var(--surface) 82%, transparent);
  padding: 2px 7px; border-radius: 4px;
}
.ax-attr a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.ax ::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }

/* ---------- Tabletas y móviles ---------- */
@media (max-width: 860px) {
  .ax-tools, .ax-tools-open { display: none !important; }
  .ax-bar { top: 12px; right: 12px; gap: 6px; }
  .ax-btn { width: 42px; height: 42px; border-radius: 10px; }
  .ax-layers { top: 64px; right: 12px; left: auto; width: min(300px, calc(100% - 24px)); }
  .ax-layers-legend { display: block; padding-top: 12px; border-top: 1px solid var(--hair-2); font-size: .68rem; color: var(--ink-2); }
  .ax-legend { display: none; }
  .ax-status { top: 64px; }
  .ax-attr { top: 62px; bottom: auto; right: 12px; }
  .ax-panel {
    left: 0; right: 0; bottom: 0; width: auto; max-height: 50%;
    border-radius: 16px 16px 0 0; box-shadow: var(--ax-shadow-lg);
  }
  .ax-ph { min-height: 50px; padding-left: 16px; }
  .ax-intro { padding: 14px 16px; }
  .ax-title { font-size: 1.3rem; }
  .ax-search { padding: 12px 16px; }
  .ax-search > svg { left: 29px; }
  .ax-results { left: 16px; right: 16px; }
  .ax-t thead th { padding-left: 16px; padding-right: 16px; }
  .ax-t tbody th { padding-left: 16px; }
  .ax-t td { padding-right: 16px; }
  .ax-pfoot { padding: 12px 16px 16px; }
  .ax-tip { min-width: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  .ax-layers { animation: none; }
  .ax-status[data-kind="info"]::before { animation-duration: 2.4s; }
}

/* Topbar compacto en teléfonos (todas las vistas). */
@media (max-width: 560px) {
  .live-since, .theme-text, .demo-badge { display: none; }
  .topbar { gap: .75rem; }
}
