/* ============================================================
   research.css — página de investigación (paper académico)
   Índice lateral "vivo": el peso de cada entrada aumenta a medida
   que su sección se acerca al punto de foco del scroll (research.js).
   Sólo lo cargan las páginas de /research.
   ============================================================ */

:root {
  --rs-accent: #0768eb;
  --rs-accent-d: #0768eb;
}
[data-theme="dark"] {
  --rs-accent: #0768eb;
  --rs-accent-d: #0768eb;
}

/* ------------------------------------------------------------
   CABECERA DEL PAPER
   ------------------------------------------------------------ */
.rs-head {
  padding-top: 150px;
  max-width: var(--art-col);
  margin: 0 auto 8px;
  padding-left: 24px;
  padding-right: 24px;
}

.rs-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  color: var(--rs-accent);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.rs-badge svg {
  width: 11px;
  height: 11px;
}

.rs-title {
  color: var(--text-strong);
  font-size: 30px;
  font-weight: var(--fw-medium);
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.rs-title em {
  font-style: italic;
  font-weight: var(--fw-regular);
  color: var(--text-body);
}

.rs-note {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--radius-md);
  background: var(--bubble-bg);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}
.rs-note strong {
  color: var(--text-body);
  font-weight: var(--fw-medium);
}
.rs-note a {
  color: var(--rs-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.rs-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--bubble-border);
}
.rs-meta dt {
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.rs-meta dd {
  margin: 3px 0 0;
  color: var(--text-body);
  font-size: 12.5px;
  line-height: 1.4;
}

/* ------------------------------------------------------------
   LAYOUT: ÍNDICE LATERAL + CONTENIDO
   ------------------------------------------------------------ */
.rs-shell {
  max-width: 940px;
  margin: 44px auto 0;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

.rs-toc {
  position: sticky;
  top: 132px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  scrollbar-width: none;
}
.rs-toc::-webkit-scrollbar {
  display: none;
}

.rs-toc__label {
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.rs-toc__list {
  list-style: none;
}

.rs-toc a {
  position: relative;
  display: block;
  padding: 5px 0 5px 15px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 400;
  text-decoration: none;
  transition: color 0.25s var(--ease);
}
.rs-toc a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--tl-rule);
  transform: scale(0.6);
  opacity: 0;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), background-color 0.25s var(--ease);
}
.rs-toc a.is-current {
  color: var(--text-strong);
}
.rs-toc a.is-current::before {
  opacity: 1;
  transform: scale(1);
  background: var(--rs-accent);
}

/* ------------------------------------------------------------
   CONTENIDO
   ------------------------------------------------------------ */
.rs-content h2[id] {
  scroll-margin-top: 132px;
}
.rs-content .art-body h2 {
  font-size: 18px;
}
.rs-content .art-body h3 {
  margin: 30px 0 8px;
  color: var(--text-strong);
  font-size: 14.5px;
  font-weight: var(--fw-medium);
  line-height: 1.4;
}
.rs-content .art-body h3:first-child {
  margin-top: 0;
}

sup.rs-ref {
  font-size: 10px;
  line-height: 0;
}
sup.rs-ref a {
  color: var(--rs-accent);
  text-decoration: none;
}
sup.rs-ref a:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------
   TABLAS (Figuras 1, 2 y 6)
   ------------------------------------------------------------ */
.rs-table-wrap {
  overflow-x: auto;
}

table.rs-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 11.5px;
  line-height: 1.55;
}

.rs-table thead th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--bubble-border);
  background: color-mix(in srgb, var(--rs-accent) 12%, transparent);
  color: var(--rs-accent);
  font-size: 10px;
  font-weight: 600;
  text-align: left;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
[data-theme="dark"] .rs-table thead th {
  color: var(--rs-accent-d);
}

.rs-table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--bubble-border);
  color: var(--text-body);
  vertical-align: top;
}
.rs-table tbody tr:last-child td {
  border-bottom: 0;
}
.rs-table tbody td:first-child {
  color: var(--text-strong);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.rs-table tbody tr {
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}
.rs-table tbody tr:hover {
  background: var(--bg);
}
.rs-table tbody tr.is-selected {
  background: color-mix(in srgb, var(--rs-accent) 9%, transparent);
  box-shadow: inset 3px 0 0 var(--rs-accent);
}
.rs-table tbody tr.is-selected td:first-child {
  color: var(--rs-accent);
}
[data-theme="dark"] .rs-table tbody tr.is-selected td:first-child {
  color: var(--rs-accent-d);
}

/* ------------------------------------------------------------
   BARRAS HORIZONTALES CON UMBRALES (Figura 3)
   ------------------------------------------------------------ */
.rswhbars {
  list-style: none;
}
.rswh {
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  width: 100%;
  display: block;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.rswh + .rswh {
  margin-top: 14px;
}

.rswh__row {
  display: grid;
  grid-template-columns: 112px 1fr 40px;
  align-items: center;
  gap: 12px;
}

.rswh__lab {
  display: block;
  color: var(--text-body);
  font-size: 11px;
  font-weight: var(--fw-medium);
  line-height: 1.3;
}

.rswh__track {
  position: relative;
  display: block;
  height: 16px;
  border-radius: 4px;
  background: var(--w-track);
  overflow: hidden;
}
.rswh__fill {
  display: block;
  height: 100%;
  width: var(--pct);
  border-radius: 4px;
  background: var(--rsw-color, var(--rs-accent));
  transition: filter 0.2s var(--ease);
}
.rswh:hover .rswh__fill,
.rswh.is-open .rswh__fill {
  filter: brightness(1.08);
}

/* Solo la línea guía discontinua; el % ya está en la leyenda del pie,
   repetirlo en cada fila abarrotaba la lista. */
.rswh__thresh {
  display: block;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px dashed color-mix(in srgb, var(--text-body) 35%, transparent);
  pointer-events: none;
}
.rswh__thresh span {
  display: none;
}

.rswh__val {
  color: var(--text-strong);
  font-size: 11px;
  font-weight: var(--fw-medium);
  text-align: right;
}

.rswh__note {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s var(--ease);
}
.rswh.is-open .rswh__note {
  grid-template-rows: 1fr;
}
.rswh__note-inner {
  overflow: hidden;
}
.rswh__note-pad {
  margin: 8px 0 0 106px;
  padding: 8px 10px;
  border-left: 2px solid var(--rsw-color, var(--rs-accent));
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.5;
}

/* ------------------------------------------------------------
   BARRAS DIVERGENTES (Figura 4)
   Construidas por JS (research-charts.js) a partir de una escala
   compartida: todas las barras usan los mismos px por unidad, así
   que sus alturas son comparables entre sí y con la línea de cero.
   ------------------------------------------------------------ */
.rsdiv {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-top: 6px;
}

.rsdiv__zero {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--tl-rule);
}

.rsdivbar {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
}

.rsdivbar__plot {
  position: relative;
  width: 58%;
}

.rsdivbar__fill {
  position: absolute;
  left: 0;
  right: 0;
  border-radius: 4px;
  background: var(--rsw-color, var(--rs-accent));
  transition: filter 0.2s var(--ease), transform 0.2s var(--ease);
}
.rsdivbar:hover .rsdivbar__fill,
.rsdivbar.is-open .rsdivbar__fill {
  filter: brightness(1.1);
  transform: scaleX(1.1);
}

.rsdivbar__val {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-strong);
  font-size: 13px;
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.rsdivbar__lab {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.3;
  text-align: center;
}

.rsdiv__callout {
  margin: 8px 0 0;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px dashed var(--tl-rule);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  pointer-events: none;
}
.rsdiv__callout.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ------------------------------------------------------------
   RADAR (Figura 5)
   ------------------------------------------------------------ */
.rsradar {
  display: flex;
  justify-content: center;
}
.rsradar__svg {
  width: 100%;
  max-width: 380px;
  height: auto;
  overflow: visible;
}
.rsradar__grid {
  fill: none;
  stroke: var(--w-grid);
  stroke-width: 1;
}
.rsradar__spoke {
  stroke: var(--w-grid);
  stroke-width: 1;
}
.rsradar__area {
  fill: var(--rs-accent);
  fill-opacity: 0.16;
  stroke: var(--rs-accent);
  stroke-width: 1.5;
  transition: fill-opacity 0.2s var(--ease);
}
.rsradar__ring-label {
  fill: var(--text-muted);
  font-size: 7px;
}
.rsradar__label {
  fill: var(--text-body);
  font-size: 9.5px;
  font-weight: var(--fw-medium);
  text-anchor: middle;
}
.rsradar__label.is-dim {
  fill: var(--text-muted);
  opacity: 0.55;
}
.rsradar__point {
  fill: var(--bg);
  stroke: var(--rs-accent);
  stroke-width: 2;
  cursor: pointer;
  transition: r 0.2s var(--ease);
}
.rsradar__point:hover,
.rsradar__point.is-active {
  r: 6.5;
  fill: var(--rs-accent);
}
.rsradar__val {
  fill: var(--rs-accent);
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
}
[data-theme="dark"] .rsradar__val {
  fill: var(--rs-accent-d);
}

/* ------------------------------------------------------------
   HOJA DE RUTA (Figura 7)
   ------------------------------------------------------------ */
.rsroad {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rsroad__step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--radius-md);
  background: var(--bg);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.rsroad__step:hover {
  border-color: var(--rs-accent);
}
.rsroad__step.is-open {
  border-color: var(--rs-accent);
  background: color-mix(in srgb, var(--rs-accent) 7%, transparent);
}

.rsroad__num {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--rs-accent);
  color: var(--rs-accent);
  font-size: 11px;
  font-weight: 700;
}

.rsroad__body {
  flex: 1;
  min-width: 0;
}

.rsroad__title {
  color: var(--text-strong);
  font-size: 12.5px;
  font-weight: var(--fw-medium);
}

.rsroad__desc {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.55;
}

/* ------------------------------------------------------------
   BIBLIOGRAFÍA
   ------------------------------------------------------------ */
.rs-biblio {
  list-style: none;
  counter-reset: rsbib;
}
.rs-biblio li {
  counter-increment: rsbib;
  position: relative;
  padding: 10px 0 10px 30px;
  border-bottom: 1px solid var(--bubble-border);
  color: var(--text-body);
  font-size: 11.5px;
  line-height: 1.6;
  scroll-margin-top: 132px;
}
.rs-biblio li::before {
  content: "[" counter(rsbib) "]";
  position: absolute;
  left: 0;
  color: var(--text-muted);
  font-size: 10.5px;
}
.rs-biblio li:target {
  background: color-mix(in srgb, var(--rs-accent) 10%, transparent);
}
.rs-biblio a {
  color: var(--rs-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
[data-theme="dark"] .rs-biblio a {
  color: var(--rs-accent-d);
}

/* ------------------------------------------------------------
   MÓVIL
   ------------------------------------------------------------ */
@media (max-width: 900px) {
  .rs-shell {
    grid-template-columns: minmax(0, 1fr);
    max-width: var(--art-col);
  }
  .rs-toc {
    display: none;
  }
}

@media (max-width: 640px) {
  .rs-head {
    padding-top: 128px;
  }
  .rs-title {
    font-size: 24px;
  }
  .rs-meta {
    grid-template-columns: 1fr 1fr;
  }
  .rswh__row {
    grid-template-columns: 76px 1fr 34px;
  }
  .rswh__note-pad {
    margin-left: 0;
  }
  .rsdiv {
    gap: 8px;
  }
  .rsdivbar__lab {
    font-size: 9.5px;
  }
}
