/* Atlas del Índice Metropolitano de Proximidad: plantilla de los atlas del motor (Chile, Bogotá) con la escala tipográfica del
   sitio: nada por debajo de 13 px; en el teléfono sólo 13 · 15 · 16 · 18 · 19 · 24 · 30 · 34. */
:root {
  --paper: #f7f5f0;
  --paper-2: #efece5;
  --ink: #1b1b1a;
  --ink-2: #4a4843;
  --ink-3: #6b675e;
  --rule: #d9d5cb;
  --accent: #d6452b;
  --accent-soft: rgba(214, 69, 43, .10);
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rail: clamp(320px, 26vw, 420px);
  --ctrl-h: 58px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans);
  display: grid; grid-template-columns: var(--rail) 1fr; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
select { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* carga */
#loading { position: fixed; inset: 0; z-index: 99; background: var(--paper); display: grid; place-items: center; transition: opacity .5s; }
#loading > div { display: flex; flex-direction: column; gap: 6px; align-items: center; }
#loading .ld-k { font: 600 13px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
#loading #ld-msg { font: 400 24px var(--serif); }
#loading.done { opacity: 0; pointer-events: none; }

/* franja narrativa */
#rail { height: 100vh; overflow-y: auto; border-right: 1px solid var(--rule); background: var(--paper); position: relative; scroll-behavior: smooth; }
.rail-head { padding: 34px 28px 10px 44px; }
.kick, .num, .lbl { font: 600 13px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
h1 { font: 500 34px/1.05 var(--serif); margin: 10px 0 14px; letter-spacing: -.01em; }
h2 { font: 500 24px/1.15 var(--serif); margin: 8px 0 14px; letter-spacing: -.005em; }
h3 { font: 600 13px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.thesis { font: 400 18px/1.45 var(--serif); color: var(--ink-2); margin: 0 0 14px; }
.hint { color: var(--ink-3); font-size: 13px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

#dots { position: sticky; top: 0; float: left; width: 34px; margin-left: 4px; padding-top: 40vh; display: flex; flex-direction: column; gap: 6px; z-index: 2; height: 0; }
#dots button { width: 30px; height: 18px; border: 0; background: none; padding: 0; display: flex; align-items: center; gap: 3px; font: 600 13px var(--sans); color: var(--ink-3); }
#dots button::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--rule); flex: none; }
#dots button.on { color: var(--ink); }
#dots button.on::before { background: var(--accent); }

.scene { min-height: 92vh; padding: 28vh 28px 10vh 44px; }
.scene:first-child { padding-top: 14vh; }
.claim { font: 400 18px/1.45 var(--serif); margin: 0 0 16px; }
.note { color: var(--ink-3); font-size: 13px; border-left: 2px solid var(--rule); padding-left: 10px; margin: 14px 0; }
blockquote.final { font: 500 24px/1.3 var(--serif); margin: 22px 0; padding: 0; }
.explore-btn { border: 1px solid var(--ink); background: var(--ink); color: var(--paper); padding: 11px 26px; font: 600 13px var(--sans); letter-spacing: .12em; text-transform: uppercase; }
.explore-btn:hover { background: var(--accent); border-color: var(--accent); }
.colophon { padding: 8vh 28px 16vh 44px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-2); }
.colophon dl { margin: 0; }
.colophon dt { font-weight: 600; color: var(--ink); margin-top: 10px; }
.colophon dd { margin: 2px 0 0; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 14px 0; }
.kpis div { border-top: 1px solid var(--rule); padding-top: 6px; }
.kpis b { display: block; font: 500 24px/1.1 var(--serif); }
.kpis span { font-size: 13px; color: var(--ink-3); }

/* recuadros del recorrido (recorrido.js los dibuja con letra menor: aquí, al mínimo del sitio) */
#rail .cg-recorrido, #rail .cg-papel, #rail .cg-unidad span, #rail .cg-ms dt { font-size: 13px !important; letter-spacing: .06em !important; }
#rail .cg-ms, #rail .cg-unidad { font-size: 13px !important; }
#stage #legend .cg-lg-u { font-size: 13px !important; }

/* segmentados y exploración */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule); background: #fff; }
.seg button { border: 0; background: none; padding: 6px 10px; font-size: 13px; color: var(--ink-2); border-right: 1px solid var(--rule); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }
.seg.small button { padding: 4px 9px; font-size: 13px; }
#explore-panel { padding: 30px 26px 40px 44px; }
#explore-panel select { max-width: 100%; padding: 4px 5px; border: 1px solid var(--rule); background: #fff; font-size: 13px; }
.xgroup { margin: 16px 0; display: flex; flex-direction: column; gap: 6px; }
.chk { font-size: 13px; color: var(--ink-2); display: flex; gap: 8px; align-items: center; }

/* escenario */
#stage { position: relative; height: 100vh; overflow: hidden; background: #eeece6; }
#map { position: absolute; inset: 0; }
#ctrl {
  position: absolute; z-index: 5; top: 0; left: 0; right: 0; min-height: var(--ctrl-h);
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 16px; padding: 8px 16px 9px;
  background: rgba(247, 245, 240, .93); backdrop-filter: blur(6px); border-bottom: 1px solid var(--rule);
}
#ctrl .c { display: flex; flex-direction: column; gap: 3px; }
#ctrl .c > span { font: 600 13px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
#ctrl select { border: 1px solid var(--rule); background: #fff; padding: 3px 4px; font-size: 13px; max-width: 220px; }
#ctrl .end { margin-left: auto; flex-direction: row; gap: 6px; }
#ctrl .ghost, #ctrl .solid { border: 1px solid var(--ink); padding: 5px 11px; font: 600 13px var(--sans); letter-spacing: .04em; text-transform: uppercase; background: transparent; }
#ctrl .solid { background: var(--ink); color: #fff; }
#ctrl .solid:hover { background: var(--accent); border-color: var(--accent); }
#ctrl-toggle { display: none; }

.card { position: absolute; z-index: 4; background: rgba(247, 245, 240, .94); border: 1px solid var(--rule); padding: 9px 11px; font-size: 13px; }
#legend { left: 14px; bottom: 30px; max-width: 280px; }
#legend .lg-t { font: 600 13px/1.3 var(--sans); letter-spacing: .02em; color: var(--ink-3); margin: 6px 0 4px; }
#legend .lg-t:first-child { margin-top: 0; }
#legend .row { display: flex; align-items: center; gap: 6px; line-height: 1.5; }
#legend .sw { width: 12px; height: 10px; flex: none; }
#legend .ramp { display: flex; height: 8px; margin: 2px 0; }
#legend .ramp i { flex: 1; }
#legend .ends { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 13px; }
#legend .muted { color: var(--ink-3); font-size: 13px; }
#north { position: absolute; right: 14px; bottom: 34px; z-index: 3; opacity: .8; }
.maplibregl-ctrl-scale { background: rgba(247, 245, 240, .85) !important; border-color: var(--ink-2) !important; color: var(--ink-2) !important; font: 13px var(--sans) !important; }

/* panel inferior */
.sheet { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; max-height: 52vh; overflow-y: auto; background: rgba(247, 245, 240, .965); border-top: 1px solid var(--rule); padding: 10px 16px 12px; backdrop-filter: blur(4px); }
.sheet-h { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; margin-bottom: 4px; }
.sheet-h > span:first-child { font: 600 13px var(--sans); letter-spacing: .06em; text-transform: uppercase; }
.sheet-h .sub { color: var(--ink-3); font-size: 13px; }
#bottom-body { overflow-x: auto; }
#bottom-body svg { display: block; }
.prof text { font: 13px var(--sans); fill: var(--ink-2); }
.prof .rowlbl { font: 600 13px var(--sans); letter-spacing: 0; text-transform: none; fill: var(--ink-2); }

/* ficha */
.drawer { position: absolute; z-index: 6; right: 0; top: var(--ctrl-h); bottom: 0; width: 330px; background: rgba(247, 245, 240, .98); border-left: 1px solid var(--rule); padding: 18px 20px 24px; overflow-y: auto; }
.drawer .x { position: absolute; right: 10px; top: 8px; border: 0; background: none; font-size: 24px; color: var(--ink-3); }
.ficha h4 { font: 600 13px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 16px 0 4px; }
.ficha .clave { font: 500 19px/1.2 var(--serif); letter-spacing: .01em; }
.ficha table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ficha td { padding: 3px 0; border-bottom: 1px dotted var(--rule); vertical-align: top; }
.ficha td:first-child { color: var(--ink-3); width: 52%; }
.ficha td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.ficha .muted { color: var(--ink-3); font-size: 13px; }
.ficha button { font-size: 13px; }

#synth { position: absolute; z-index: 4; right: 0; top: var(--ctrl-h); bottom: 0; width: min(66%, 1000px); background: rgba(247, 245, 240, .97); border-left: 1px solid var(--rule); overflow-y: auto; padding: 16px 22px 30px; font-size: 13px; }

#tip { position: absolute; z-index: 20; pointer-events: none; background: #1b1b1a; color: #f5f3ee; font-size: 13px; line-height: 1.45; padding: 7px 9px; max-width: 300px; display: none; }
#tip b { color: #fff; }
#tip .m { color: #b9b5ab; }

/* exploración */
body.explore #story, body.explore #dots, body.explore .rail-head .hint { display: none; }
/* en Explorar la cabecera se queda con el título: la tesis y la unidad de análisis vuelven con el relato, y los controles caben sin desplazar (1440×860) */
body.explore #rail .rail-head .thesis, body.explore #rail .rail-head .cg-unidad { display: none; }
body.explore #explore-panel { display: block !important; }

/* teléfono */
@media (max-width: 900px) {
  html, body { height: auto; }
  body { display: block; overflow: visible; font-size: 15px; }
  #stage { position: fixed; top: 0; left: 0; right: 0; height: 56vh; z-index: 3; border-bottom: 1px solid var(--rule); }
  #rail { height: auto; overflow: visible; border-right: 0; padding-top: 56vh; }
  .scene { min-height: 62vh; padding: 6vh 16px 10vh; }
  .scene:first-child { padding-top: 6vh; }
  .rail-head { padding: 22px 16px 6px; }
  h1 { font-size: 30px; }
  h2 { font-size: 24px; }
  .claim, .thesis { font-size: 18px; }
  blockquote.final { font-size: 19px; }
  .colophon, #explore-panel { padding-left: 16px; padding-right: 16px; }
  #dots { display: none; }
  #ctrl { min-height: 40px; padding: 6px 10px; gap: 6px 10px; }
  #ctrl .c:not(.end) { display: none; }
  #ctrl.open .c { display: flex; }
  #ctrl .end { margin-left: 0; }
  #ctrl-toggle { display: inline-block; border: 1px solid var(--ink); background: #fff; padding: 4px 9px; font-size: 13px; margin-left: auto; }
  #legend, #north { display: none; }
  .sheet { max-height: 60%; }
  #synth { width: 100%; }
  .drawer { width: 100%; }
}

/* modo nocturno (vista 3D de Explorar y menú Aa): los selectores segmentados sobre el panel oscuro, con contraste */
html.cg-noche .seg { background: transparent; border-color: #4a4f4c; }
html.cg-noche .seg button { color: #ece9e1; border-color: #4a4f4c; }
html.cg-noche .seg button.on, html.cg-noche .seg button[aria-pressed="true"] { background: #ece9e1; color: #151716; }

/* flecha del norte: la letra en HTML, a 13 px como el resto de los textos */
#north { text-align: center; }
#north svg { display: block; margin: 0 auto; }
#north .n { display: block; font: 600 13px/1 var(--sans); color: var(--ink); margin-top: 1px; }
html.cg-noche #north svg path { fill: #ece9e1; }
html.cg-noche #north .n { color: #ece9e1; }
