/*
 * charts_idra.css — ÚNICO CSS del proyecto (experimento de programas electorales, IDRA).
 *   1) BLOQUE BASE  -> copia LITERAL de shared/styles/tokens.css + shared/styles/base.css.
 *   2) ESPECÍFICO   -> todo bajo .chart-idra.
 */

/* =====================================================================
   1) BLOQUE BASE — copiado de shared/styles/tokens.css + shared/styles/base.css
   ===================================================================== */

:root {
  /* Colores de marca */
  --ed-rojo: #D0021B;
  --ed-negro: #1a1a1a;
  --ed-amarillo: #ECDC19;
  --ed-azul: #4A90E2;
  --ed-azul-principal: #005695;

  /* Grises de UI / ejes */
  --ed-gris-900: #333333;
  --ed-gris-700: #4a4a4a;
  --ed-gris-500: #939393;
  --ed-gris-300: #c5c5c5;
  --ed-gris-200: #dedede;
  --ed-gris-100: #eaeaea;

  /* Texto */
  --ed-texto: #1a1a1a;
  --ed-texto-suave: #4a4a4a;

  --ed-radio: 4px;

  /* Tipografías */
  --ed-fuente: 'Encode Sans', 'Helvetica Neue', Arial, sans-serif;
  --ed-fuente-titulo: 'Sanomat-Bold', Georgia, 'Times New Roman', serif;
}

.ed-rectos { --ed-radio: 0px; }

.ed-chart,
.ed-chart *,
.ed-chart *::before,
.ed-chart *::after {
  box-sizing: border-box;
}

.ed-chart {
  font-family: var(--ed-fuente);
  color: var(--ed-texto);
  line-height: 1.4;
  margin: 24px 0;
  text-align: left;
  clear: left;
}

.ed-titulo {
  font-family: var(--ed-fuente);
  font-weight: 700;
  color: var(--ed-negro);
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 4px;
}
.ed-titulo.ed-display,
.ed-display .ed-titulo {
  font-family: var(--ed-fuente-titulo);
}
.ed-subtitulo {
  font-family: var(--ed-fuente);
  color: var(--ed-texto-suave);
  font-size: 14px;
  margin: 0 0 16px;
}
.ed-fuente {
  font-family: var(--ed-fuente);
  color: var(--ed-gris-500);
  font-size: 12px;
  margin-top: 8px;
}

.ed-chart .ed-svg { display: block; width: 100%; height: auto; overflow: visible; }
.ed-chart .ed-svg text { font-family: var(--ed-fuente); }
.ed-chart .ed-eje text { font-size: 14px; fill: var(--ed-gris-500); }
.ed-chart .ed-eje path { stroke-width: 0; }
.ed-chart .ed-eje line { stroke: var(--ed-gris-500); stroke-width: 1; }
.ed-chart .ed-eje-grid line { stroke: var(--ed-gris-300); stroke-width: 0.5; stroke-dasharray: 3; }

.ed-chart .ed-halo { stroke: #fff; stroke-width: 3px; stroke-opacity: 0.9; paint-order: stroke; }

.ed-chart .ed-highlight-layer rect,
.ed-chart .ed-highlight-layer circle,
.ed-chart .ed-highlight-layer path { fill: none; stroke: var(--ed-negro); stroke-width: 2px; }

/* =====================================================================
   2) ESPECÍFICO DEL PROYECTO (.chart-idra)
   ===================================================================== */

.chart-idra .ed-fuente { margin: 4px 0 0; }

/* --- Gráfico de dirección: una línea por partido dentro de cada tema --- */
.chart-idra .idra-dir-fila {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.chart-idra .idra-dir-tema { padding: 12px 0 10px; border-top: 1px solid var(--ed-gris-200); }
.chart-idra .idra-dir-tema:first-child { border-top: 0; padding-top: 0; }
.chart-idra .idra-dir-unidad { margin: 0 0 10px; font-size: 12px; color: var(--ed-gris-500); text-align: center; }

/* Cabecera de cada tema: opción izquierda | tema centrado | opción derecha, a la misma altura */
.chart-idra .idra-dir-cabecera {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px; align-items: center; margin-bottom: 4px;
}
.chart-idra .idra-dir-nombre { margin: 0; max-width: 220px; font-size: 15px; font-weight: 700; text-align: center; line-height: 1.2; }
.chart-idra .idra-dir-izq,
.chart-idra .idra-dir-der { font-size: 12px; color: var(--ed-texto-suave); line-height: 1.25; }
/* Las opciones van pegadas al nombre del tema, no a los bordes */
.chart-idra .idra-dir-izq { text-align: right; }
.chart-idra .idra-dir-der { text-align: left; }
.chart-idra .idra-dir-partido { font-size: 13px; color: var(--ed-texto-suave); text-align: right; }

/* Línea: rejilla punteada de la casa + 0 en gris medio sólido */
.chart-idra .idra-dir-linea { position: relative; height: 24px; }
.chart-idra .idra-dir-linea::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px;
  /* Punteado suave y espaciado: 2px de gris claro cada 7px */
  background: repeating-linear-gradient(to right, var(--ed-gris-200) 0 2px, transparent 2px 7px);
}
.chart-idra .idra-dir-cero { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--ed-gris-500); }
.chart-idra .idra-dir-tallo { position: absolute; top: 50%; height: 3px; margin-top: -1.5px; opacity: 0.45; }
.chart-idra .idra-dir-punto {
  position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0, 0, 0, 0.25); cursor: pointer;
}
.chart-idra .idra-dir-punto:hover { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ed-negro); }
.chart-idra .idra-dir-valor {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums;
}

.chart-idra .idra-dir-escala {
  position: relative; height: 20px; margin-top: 4px;
  border-top: 1px solid var(--ed-gris-500);
  font-size: 12px; color: var(--ed-gris-500); font-variant-numeric: tabular-nums;
}
.chart-idra .idra-dir-escala span { position: absolute; top: 3px; transform: translateX(-50%); }
.chart-idra .idra-dir-escala span.primero { transform: none; }
.chart-idra .idra-dir-escala span.ultimo { transform: translateX(-100%); }
.chart-idra .idra-dir-leyenda {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 11px; color: var(--ed-gris-500); margin-bottom: 8px;
}
.chart-idra .idra-dir-leyenda span:last-child { text-align: right; }

/* --- Gráfico 2 en barras: «X frente a Y» por partido y tema --- */
/* Dos columnas de temas en escritorio; una en móvil */
.chart-idra .idra-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.chart-idra .idra-bar-tema { padding: 12px 0 10px; border-top: 1px dotted var(--ed-gris-500); }
.chart-idra .idra-bar-tema:nth-child(-n+2) { border-top: 0; padding-top: 0; }
.chart-idra .idra-bar-nombre { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.chart-idra .idra-bar-fila {
  display: grid; grid-template-columns: 56px minmax(0, 1fr);
  column-gap: 8px; align-items: stretch; cursor: pointer;
}
/* El partido va a la altura del texto de la comparación */
.chart-idra .idra-bar-partido {
  font-size: 13px; color: var(--ed-texto-suave); text-align: right; line-height: 1.25;
  padding: 4px 0;
}
.chart-idra .idra-bar-celda { min-width: 0; padding: 4px 0; }
.chart-idra .idra-bar-texto { margin-bottom: 3px; }
.chart-idra .idra-bar-pista { position: relative; height: 18px; }
.chart-idra .idra-bar-barra { position: absolute; left: 0; top: 0; bottom: 0; }
.chart-idra .idra-bar-valor {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.chart-idra .idra-bar-texto { font-size: 13px; line-height: 1.25; }
.chart-idra .idra-bar-frente { color: var(--ed-texto-suave); }
.chart-idra .idra-bar-fila:hover .idra-bar-barra { box-shadow: inset 0 0 0 2px var(--ed-negro); }

/* --- Heatmap del ranking: cada columna en el color de su partido --- */
.chart-idra .idra-rank {
  width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed;
  margin-bottom: 8px; font-size: 14px;
}
.chart-idra .idra-rank th {
  font-weight: 400; font-size: 13px; text-align: left; vertical-align: bottom;
  padding: 6px 8px; color: var(--ed-negro);
}
.chart-idra .idra-rank thead th { border-bottom: 4px solid transparent; }
.chart-idra .idra-rank thead th:first-child,
.chart-idra .idra-rank tbody th { width: 112px; font-weight: 400; color: var(--ed-texto-suave); }
.chart-idra .idra-rank tbody th { vertical-align: middle; }
.chart-idra .idra-rank td { padding: 8px; vertical-align: middle; line-height: 1.25; hyphens: auto; overflow-wrap: break-word; }
.chart-idra .idra-rank-principal { display: block; font-weight: 700; }
.chart-idra .idra-rank-principal.idra-rank-normal { font-weight: 400; }
.chart-idra .idra-rank-secundaria { display: block; margin-top: 3px; font-size: 12px; font-weight: 400; }
.chart-idra .idra-rank-empate { display: block; margin-bottom: 3px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; opacity: 0.85; }
/* Celda combinada de un empate: los temas uno debajo de otro, separados por una línea fina */
.chart-idra .idra-rank td.idra-rank-combinada { vertical-align: middle; }
.chart-idra .idra-rank-item { padding: 6px 0; }
.chart-idra .idra-rank-item + .idra-rank-item { border-top: 1px solid currentColor; border-top-color: rgba(127, 127, 127, 0.45); }
/* Variante punteada: celdas pegadas y separadas por líneas de puntos */
.chart-idra .idra-rank.idra-rank-punteada { border-collapse: collapse; border-spacing: 0; }
.chart-idra .idra-rank-punteada td,
.chart-idra .idra-rank-punteada tbody th { border: 1px dotted var(--ed-gris-500); }
/* Columna de puestos: solo líneas horizontales, sin bordes verticales */
.chart-idra .idra-rank-punteada tbody th { border-left: none; border-right: none; }
.chart-idra .idra-rank-punteada tbody th + td { border-left: none; }
/* Encabezados: solo la línea de abajo (franja de color en los partidos, punteada en «Puesto») */
.chart-idra .idra-rank-punteada thead th:first-child { border-bottom: 1px dotted var(--ed-gris-500); }
.chart-idra .idra-rank-punteada thead th { border-bottom-width: 4px; border-bottom-style: solid; }
/* Hover: cada celda (o cada tema dentro de una celda combinada) se marca con un borde interior */
.chart-idra .idra-rank-hover { cursor: pointer; }
.chart-idra .idra-rank-hover:hover { box-shadow: inset 0 0 0 2px var(--ed-negro); }
/* Celdas combinadas: borde continuo y más grueso para distinguirlas de las punteadas */
.chart-idra .idra-rank-punteada td.idra-rank-combinada { border: 2px solid var(--ed-negro); }
.chart-idra .idra-rank-punteada .idra-rank-item + .idra-rank-item { border-top: 1px dashed currentColor; }

/* Puestos cortos (1º, 2º…): columna de puestos estrecha */
.chart-idra .idra-rank-cortos thead th:first-child,
.chart-idra .idra-rank-cortos tbody th { width: 64px; }

/* Tabla traspuesta: partidos en filas, puestos en columnas; los empates combinan en horizontal */
.chart-idra .idra-rank-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-idra .idra-rank-traspuesta { min-width: 640px; }
.chart-idra .idra-rank-traspuesta thead th { vertical-align: bottom; }
.chart-idra .idra-rank-traspuesta tbody th {
  width: 120px; text-align: right; vertical-align: middle;
  border-right: 4px solid transparent; color: var(--ed-negro);
}
.chart-idra .idra-rank-traspuesta td { vertical-align: middle; }
/* Dentro de la celda combinada, los temas empatados van uno debajo de otro */
.chart-idra .idra-rank-items { display: flex; flex-direction: column; }
.chart-idra .idra-rank-items .idra-rank-item { padding: 5px 6px; }
.chart-idra .idra-rank td,
.chart-idra .idra-rank thead th { text-align: center; }
.chart-idra .idra-rank thead th:first-child,
.chart-idra .idra-rank tbody th { text-align: right; }

@media (max-width: 599px) {
  .chart-idra .idra-dir-fila { grid-template-columns: 44px minmax(0, 1fr); gap: 6px; }
  .chart-idra .idra-dir-cabecera { gap: 6px; }
  .chart-idra .idra-dir-nombre { max-width: 110px; font-size: 13px; }
  .chart-idra .idra-dir-izq,
  .chart-idra .idra-dir-der { font-size: 11px; }
  .chart-idra .idra-bar { grid-template-columns: minmax(0, 1fr); }
  .chart-idra .idra-bar-tema:nth-child(2) { border-top: 1px dotted var(--ed-gris-500); padding-top: 12px; }
  .chart-idra .idra-bar-fila { grid-template-columns: 50px minmax(0, 1fr); }
  .chart-idra .idra-bar-texto,
  .chart-idra .idra-bar-partido { font-size: 12px; }
  .chart-idra .idra-rank { font-size: 12px; }
  .chart-idra .idra-rank thead th:first-child,
  .chart-idra .idra-rank tbody th { width: 34px; padding: 4px; }
  .chart-idra .idra-rank td { padding: 6px 5px; }
  .chart-idra .idra-rank-secundaria { font-size: 11px; }
  .chart-idra .idra-rank-traspuesta { min-width: 560px; }
  .chart-idra .idra-rank-traspuesta tbody th { width: 52px; text-align: left; }
}
