/* ============================================================
   article-widgets.css — visualizaciones de los editoriales
   Sólo lo cargan los artículos que llevan gráficos, así el resto
   del sitio no paga este CSS.

   Todo el color sale de --w-accent / --w-accent-2, que cambian
   con el tema. Los gráficos son HTML+CSS (y un SVG estirado para
   la línea): sin librerías, el texto es texto de verdad y el
   cambio de tema es instantáneo porque no hay nada que repintar.
   ============================================================ */

:root {
  --w-accent: #65a2ce;
  --w-accent-2: #c8a0b7;
  --w-grid: rgba(19, 19, 19, 0.07);
  --w-track: rgba(19, 19, 19, 0.05);
}

[data-theme="dark"] {
  --w-accent: #99bec5;
  --w-accent-2: #c8a0b7;
  --w-grid: rgba(250, 250, 250, 0.08);
  --w-track: rgba(250, 250, 250, 0.06);
}

/* ------------------------------------------------------------
   CONTENEDOR COMÚN
   ------------------------------------------------------------ */
.wdg {
  margin: 40px 0 44px;
  padding: 22px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--tl-radius);
  background: var(--bubble-bg);
}

.wdg__head {
  margin-bottom: 18px;
}

.wdg__title {
  color: var(--text-strong);
  font-size: 13px;
  font-weight: var(--fw-medium);
  line-height: 1.35;
}

.wdg__sub {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

/* Pie de fuente, común a todos los widgets */
.wdg__source {
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--bubble-border);
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.5;
}
.wdg__source a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wdg__source a:hover {
  color: var(--text-body);
}

/* ------------------------------------------------------------
   MÉTRICAS DESTACADAS
   ------------------------------------------------------------ */
.wmetrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.wmetric {
  padding: 14px 16px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.wmetric__label {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.4;
}

.wmetric__value {
  margin: 5px 0 2px;
  color: var(--w-accent);
  font-size: 26px;
  font-weight: var(--fw-medium);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.wmetric__sub {
  color: var(--tl-subtitle);
  font-size: 10px;
}

/* ------------------------------------------------------------
   PESTAÑAS
   ------------------------------------------------------------ */
.wtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.wtab {
  padding: 6px 12px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
    background-color 0.2s var(--ease);
}
.wtab:hover {
  color: var(--text-body);
  border-color: var(--tl-rule);
}
.wtab[aria-selected="true"] {
  border-color: var(--w-accent);
  background: color-mix(in srgb, var(--w-accent) 12%, transparent);
  color: var(--w-accent);
}

.wpanel[hidden] {
  display: none;
}

/* Leyenda de cada panel */
.wlegend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 10px;
}
.wlegend::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--w-accent);
}

/* ------------------------------------------------------------
   GRÁFICO DE BARRAS VERTICALES
   Las barras son divs: el alto sale de --pct y el texto sigue
   siendo texto (se indexa, se selecciona y no se deforma).
   ------------------------------------------------------------ */
.wbars {
  display: flex;
  gap: 12px;
}

/* Etiquetas del eje Y, repartidas de arriba abajo */
.wbars__axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 180px;
  padding-bottom: 1px;
  color: var(--text-muted);
  font-size: 9px;
  text-align: right;
  white-space: nowrap;
}

.wbars__plot {
  position: relative;
  flex: 1;
  min-width: 0;
}

/* Líneas de referencia, una por cada etiqueta del eje */
.wbars__grid {
  position: absolute;
  inset: 0 0 auto;
  height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.wbars__grid span {
  height: 1px;
  background: var(--w-grid);
}

.wbars__list {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  list-style: none;
}

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

.wbar__track {
  display: flex;
  align-items: flex-end;
  height: 180px;
}

.wbar__fill {
  position: relative;
  width: 100%;
  min-height: 2px;
  height: var(--pct);
  border-radius: 4px 4px 0 0;
  background: var(--w-accent);
}

/* El valor va flotando justo encima de su barra */
.wbar__val {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 5px;
  color: var(--text-body);
  font-size: 10px;
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.wbar__lab {
  display: block;
  margin-top: 9px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.25;
  text-align: center;
  /* En columnas estrechas las palabras largas parten; con guion se leen
     mucho mejor que cortadas en seco a mitad de sílaba. */
  overflow-wrap: break-word;
  hyphens: auto;
}

/* ------------------------------------------------------------
   GRÁFICO DE BARRAS HORIZONTALES
   ------------------------------------------------------------ */
.whbars {
  list-style: none;
}

.whbar {
  display: grid;
  grid-template-columns: 108px 1fr 34px;
  align-items: center;
  gap: 10px;
}
.whbar + .whbar {
  margin-top: 10px;
}

.whbar__lab {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.3;
}

.whbar__track {
  height: 16px;
  border-radius: 4px;
  background: var(--w-track);
}

.whbar__fill {
  height: 100%;
  width: var(--pct);
  border-radius: 4px;
  background: var(--w-accent);
}

.whbar__val {
  color: var(--text-body);
  font-size: 10px;
  font-weight: var(--fw-medium);
  text-align: right;
}

/* ------------------------------------------------------------
   GRÁFICO DE LÍNEA
   El SVG se estira con preserveAspectRatio="none"; el trazo
   mantiene su grosor gracias a vector-effect, y los puntos y las
   etiquetas son HTML colocado en porcentajes.
   ------------------------------------------------------------ */
.wline {
  display: flex;
  gap: 12px;
}

.wline__axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 180px;
  color: var(--text-muted);
  font-size: 9px;
  text-align: right;
  white-space: nowrap;
}

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

.wline__plot {
  position: relative;
  height: 180px;
}

.wline__grid {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.wline__grid span {
  height: 1px;
  background: var(--w-grid);
}

.wline__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.wline__area {
  fill: var(--w-accent);
  opacity: 0.1;
}

.wline__stroke {
  fill: none;
  stroke: var(--w-accent);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.wline__dot {
  position: absolute;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: var(--w-accent);
}
/* El valor de cada punto, encima del punto */
.wline__dot b {
  position: absolute;
  bottom: 11px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-body);
  font-size: 10px;
  font-weight: var(--fw-medium);
  white-space: nowrap;
}
/* Los extremos se anclan en lugar de centrarse: centrados se saldrían
   del recuadro en pantallas estrechas. */
.wline__dot:first-child b {
  left: 0;
  transform: none;
}
.wline__dot:last-child b {
  left: auto;
  right: 0;
  transform: none;
}

.wline__xlabels {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  list-style: none;
  color: var(--text-muted);
  font-size: 10px;
}

/* ------------------------------------------------------------
   ESTIMACIÓN DE COSTES (acordeón + tamaño de flota)
   ------------------------------------------------------------ */
.wcost {
  margin: 34px 0 40px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--tl-radius);
  background: var(--bubble-bg);
  overflow: hidden;
}

.wcost__sizes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 16px 18px 0;
}

.wcost__size {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 12px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
    background-color 0.2s var(--ease);
}
.wcost__size span {
  font-size: 9px;
  opacity: 0.7;
}
.wcost__size:hover {
  color: var(--text-body);
  border-color: var(--tl-rule);
}
.wcost__size[aria-pressed="true"] {
  border-color: var(--w-accent);
  background: color-mix(in srgb, var(--w-accent) 12%, transparent);
  color: var(--w-accent);
}

.wcost__toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 16px 18px;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

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

.wcost__badge {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--w-track);
  color: var(--text-muted);
  font-size: 9px;
  white-space: nowrap;
}

.wcost__chev {
  width: 13px;
  height: 13px;
  margin-left: auto;
  flex: none;
  color: var(--tl-chevron);
  transition: transform 0.3s var(--ease);
}
.wcost.is-open .wcost__chev {
  transform: rotate(180deg);
}

/* 0fr → 1fr anima hasta la altura real del contenido sin fijarla */
.wcost__body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s var(--ease);
}
.wcost.is-open .wcost__body {
  grid-template-rows: 1fr;
}

.wcost__inner {
  overflow: hidden;
  visibility: hidden;
  transition: visibility 0s 0.35s;
}
.wcost.is-open .wcost__inner {
  visibility: visible;
  transition: visibility 0s;
}

.wcost__pad {
  padding: 0 18px 18px;
}

.wcost__cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  padding-top: 4px;
}

.wcost__lab {
  color: var(--text-muted);
  font-size: 10px;
}

.wcost__val {
  margin-top: 3px;
  color: var(--text-strong);
  font-size: 15px;
  font-weight: var(--fw-medium);
}
/* La inversión es el dato que cambia al elegir flota */
.wcost__val--accent {
  color: var(--w-accent);
}

.wcost__detail {
  margin-top: 16px;
  color: var(--text-body);
  font-size: 12px;
  line-height: 1.65;
}

.wcost__risks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  list-style: none;
}

.wcost__risks li {
  padding: 4px 9px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 10px;
}

/* ------------------------------------------------------------
   DATO ÚNICO GRANDE (EUROCONTROL)
   ------------------------------------------------------------ */
.wstat {
  display: flex;
  align-items: center;
  gap: 24px;
}

.wstat__figure {
  flex: none;
  text-align: center;
}

.wstat__number {
  color: var(--w-accent);
  font-size: 46px;
  font-weight: var(--fw-medium);
  line-height: 1;
  letter-spacing: -0.03em;
}

.wstat__unit {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.4;
}

.wstat__rule {
  flex: none;
  align-self: stretch;
  width: 1px;
  background: var(--bubble-border);
}

.wstat__headline {
  color: var(--text-strong);
  font-size: 13px;
  font-weight: var(--fw-medium);
  line-height: 1.45;
}

.wstat__desc {
  margin-top: 8px;
  color: var(--text-body);
  font-size: 12px;
  line-height: 1.65;
}

/* ------------------------------------------------------------
   REJILLA DE DATOS (contrails)
   ------------------------------------------------------------ */
.wfacts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.wfact {
  padding: 15px 16px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.wfact__number {
  color: var(--w-accent);
  font-size: 27px;
  font-weight: var(--fw-medium);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.wfact__label {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.45;
}

.wfacts__desc {
  margin-top: 16px;
  color: var(--text-body);
  font-size: 12px;
  line-height: 1.65;
}

/* ------------------------------------------------------------
   MAPA DE IMPACTO
   Las tarjetas son HTML estático (se indexan); el filtro sólo
   oculta las que no tocan.
   ------------------------------------------------------------ */
.wfilters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.wfilter {
  padding: 6px 12px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease),
    background-color 0.2s var(--ease);
}
.wfilter:hover {
  color: var(--text-body);
  border-color: var(--tl-rule);
}
.wfilter[aria-pressed="true"] {
  border-color: var(--w-accent);
  background: color-mix(in srgb, var(--w-accent) 12%, transparent);
  color: var(--w-accent);
}

.wmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  list-style: none;
}

.wcard {
  display: flex;
  flex-direction: column;
  padding: 15px 16px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--radius-md);
  background: var(--bg);
}
.wcard[hidden] {
  display: none;
}

.wcard__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.wcard__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--w-accent) 14%, transparent);
  color: var(--w-accent);
}
.wcard__icon svg {
  width: 15px;
  height: 15px;
}
/* Ingresos y pasajero usan el segundo color de la paleta */
.wcard[data-cat="rev"] .wcard__icon,
.wcard[data-cat="pax"] .wcard__icon {
  background: color-mix(in srgb, var(--w-accent-2) 16%, transparent);
  color: var(--w-accent-2);
}

.wcard__score {
  text-align: right;
  line-height: 1;
}
.wcard__score b {
  color: var(--text-strong);
  font-size: 19px;
  font-weight: var(--fw-medium);
  letter-spacing: -0.02em;
}
.wcard__score span {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 9px;
}

.wcard__area {
  color: var(--text-strong);
  font-size: 12px;
  font-weight: var(--fw-medium);
  line-height: 1.35;
}

.wcard__tech {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
}

.wcard__bar {
  height: 3px;
  margin: 11px 0;
  border-radius: 2px;
  background: var(--w-track);
}
.wcard__bar span {
  display: block;
  height: 100%;
  width: var(--pct);
  border-radius: 2px;
  background: var(--w-accent);
}
.wcard[data-cat="rev"] .wcard__bar span,
.wcard[data-cat="pax"] .wcard__bar span {
  background: var(--w-accent-2);
}

.wcard__result {
  color: var(--text-body);
  font-size: 11px;
  line-height: 1.55;
}

.wcard__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 13px;
}

.wcard__pill {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--w-accent) 12%, transparent);
  color: var(--w-accent);
  font-size: 9px;
  white-space: nowrap;
}
.wcard[data-cat="rev"] .wcard__pill,
.wcard[data-cat="pax"] .wcard__pill {
  background: color-mix(in srgb, var(--w-accent-2) 14%, transparent);
  color: var(--w-accent-2);
}

.wcard__source {
  color: var(--text-muted);
  font-size: 9px;
  text-align: right;
  line-height: 1.3;
}

/* ------------------------------------------------------------
   ÍNDICE Y ANCLAS DE SECCIÓN
   ------------------------------------------------------------ */
.art-toc {
  margin: 34px 0 8px;
  padding: 18px 20px;
  border: 1px solid var(--bubble-border);
  border-radius: var(--tl-radius);
  background: var(--bubble-bg);
}

.art-toc__label {
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.art-toc ol {
  margin: 0;
  padding-left: 17px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.9;
}

.art-toc a {
  color: var(--text-body);
  text-decoration: none;
}
.art-toc a:hover {
  color: var(--w-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* La cabecera es fija: sin este margen el título quedaría debajo */
.art-body h2[id] {
  scroll-margin-top: 118px;
}

/* ------------------------------------------------------------
   MÓVIL
   ------------------------------------------------------------ */
@media (max-width: 640px) {
  .wdg {
    padding: 18px 16px;
  }

  .wbars__list {
    gap: 5px;
  }
  .wbar {
    position: relative;
  }
  .wbar__val {
    font-size: 9px;
  }
  /* En columnas tan estrechas ninguna palabra cabe entera en horizontal
     ("Maintenance", "Passenger" partían a media palabra). En vez de
     encogerlas hasta ser ilegibles, se inclinan como hace cualquier
     librería de gráficos en pantallas estrechas: la etiqueta entera
     sigue cabiendo y se lee de un tirón. El ancla queda en la esquina
     superior derecha de su propia columna, así el giro no invade la
     barra de al lado. */
  .wbar__lab {
    position: absolute;
    top: 100%;
    right: 50%;
    margin-top: 10px;
    transform: rotate(-40deg);
    transform-origin: top right;
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
    overflow-wrap: normal;
    hyphens: none;
    text-align: right;
  }
  /* La rotación saca la etiqueta del flujo normal: sin esta altura fija
     el pie del widget quedaría pegado a las barras. */
  .wbars__list {
    margin-bottom: 34px;
  }

  .whbar {
    grid-template-columns: 88px 1fr 30px;
    gap: 8px;
  }

  /* En vertical el dato grande va encima del texto, no al lado */
  .wstat {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .wstat__rule {
    align-self: stretch;
    width: 100%;
    height: 1px;
  }
  .wstat__number {
    font-size: 38px;
  }

  .wcost__pad,
  .wcost__toggle {
    padding-left: 16px;
    padding-right: 16px;
  }
  .wcost__sizes {
    padding: 14px 16px 0;
  }
  /* El badge de coste sobra en pantallas estrechas */
  .wcost__badge {
    display: none;
  }

  .wmap {
    grid-template-columns: 1fr;
  }
}
