/* ── La tipografía de los números y los rótulos ──
   Vive ACÁ y no en css/portada.css, que es de donde salió, porque la nota no carga esa
   hoja: es la tapa del laboratorio. Un `@font-face` no tiene selector, así que cuando
   se sacó portada.css de la nota —comprobando que ninguna de sus CLASES se usaba— se
   fue con ella la fuente, y todo lo que usa --mono cayó al monoespaciado del sistema.
   styles.css la cargan las dos páginas. */
@font-face {
  font-family: 'Cascadia Mono';
  src: url('../assets/cascadia-mono-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --fondo-arriba: #000000;
  --fondo-abajo: #000000;
  --superficie: #0a0a0a;
  --tinta: #f2f5f7;
  --tinta-2: #b9c6d0;
  --tinta-3: #8497a6;
  --linea: rgba(242, 245, 247, 0.22);
  --turistas: #ffffff;
  --vecinos: #8a8f94;
  --gutter: clamp(16px, 5vw, 88px);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--fondo-abajo); }
body {
  font-family: 'Archivo', system-ui, sans-serif;
  color: var(--tinta);
  background: linear-gradient(180deg, var(--fondo-arriba) 0%, var(--fondo-abajo) 100vh) fixed;
  -webkit-font-smoothing: antialiased;
  /* clip y no hidden. Con overflow-x: hidden y overflow-y: visible, la regla de CSS
     convierte el visible en auto: el body pasa a ser un contenedor de scroll propio, y
     entonces todo position: sticky de adentro se mide contra ESE contenedor —que no
     scrollea— en vez de contra la ventana. O sea: sticky deja de funcionar en toda la
     página, sin ningún aviso. Con clip el otro eje se queda como está y el scroll
     horizontal sigue cortado igual. */
  overflow-x: clip;
}

/* Fijo e `inset: 0`, así que el alto lo da el contenedor; el 100svh queda como
   respaldo para navegadores viejos y evita el salto de la barra de iOS. */
#escena { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100svh; display: block; }

/* ── HUD fijo ─────────────────────────────────────────────────────────── */
.hud { position: fixed; inset: 0; pointer-events: none; transition: opacity 0.4s ease; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.95), 0 0 2px rgba(0, 0, 0, 0.8); }
body.en-datos .hud { opacity: 0; }
body.en-datos .hud * { pointer-events: none !important; }

.panel-izq {
  position: absolute; top: clamp(24px, 6vh, 64px); left: var(--gutter);
  width: min(360px, 32vw);
}
.volanta { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--tinta-3); margin-bottom: 10px; }
h1 { font-size: clamp(28px, 3vw, 44px); font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.bajada { margin-top: 12px; font-size: clamp(15px, 1.15vw, 18px); font-weight: 500; line-height: 1.35; color: var(--tinta-2); text-wrap: pretty; }

.contador { display: flex; align-items: flex-end; gap: 12px; margin-top: 32px; }
.icono-persona { width: 26px; height: 47px; fill: var(--tinta); flex: none; }
.personas { font-size: clamp(22px, 2vw, 30px); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
.personas-label { font-size: 13px; color: var(--tinta-3); margin-top: 4px; }
.personas .personas-label { font-size: 15px; font-weight: 500; color: var(--tinta-2); margin-left: 4px; }
.desglose { margin-top: 6px; font-size: 14px; color: var(--tinta-2); font-variant-numeric: tabular-nums; min-height: 1.2em; }
.dias.oculto { display: none; }

/* Barra del año */
.anio { margin-top: 16px; width: min(320px, 100%); opacity: 0; visibility: hidden; transition: opacity 0.4s ease, visibility 0.4s; }
.anio.visible { opacity: 1; visibility: visible; }
.anio-meses { display: flex; font-size: 10px; color: var(--tinta-3); margin-bottom: 4px; }
.anio-meses span { text-align: center; }
.anio-barra { position: relative; height: 4px; border-radius: 2px; background: rgba(242, 245, 247, 0.18); }
.anio-relleno { position: absolute; inset: 0; border-radius: 2px; background: var(--tinta); transform-origin: left center; transform: scaleX(0); }
.anio-marca { position: absolute; top: 50%; left: 0; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--tinta); box-shadow: 0 0 0 3px #000; }
.anio-mes { margin-top: 8px; font-size: 14px; font-weight: 600; min-height: 1.3em; }
.anio-total { margin-top: 2px; font-size: 13px; color: var(--tinta-2); line-height: 1.35; min-height: 1.35em; }
.anio-total strong { color: var(--tinta); }
.anio-fuente { color: var(--tinta-3); }


/* Indicador de etapas */
.etapas { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; }
.etapas span { width: 5px; height: 5px; border-radius: 50%; background: rgba(242, 245, 247, 0.3); transition: background-color 0.3s ease, transform 0.3s ease; }
.etapas span.activa { background: var(--tinta); transform: scale(1.5); }

/* Scrollytelling: cada módulo tiene un tramo alto en el flujo del documento que
   marca cuánto scroll ocupa. No se ven: el gráfico va fijo encima. El scroll de la
   página nunca se bloquea, salvo en el modo revisión (?escena=, ?b=, ?s=). */
.tramo { width: 100%; pointer-events: none; }
.velo {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background: var(--fondo-abajo, #0a0b0c); opacity: 0;
}
html.sin-recorrido, html.sin-recorrido body { overflow: hidden; overscroll-behavior: none; }
.texto-turistas { color: var(--turistas); }
.texto-organico { color: #4ea672; }

/* Franja de turistas y selector de fuente (paso 3) */
.franja-leyenda {
  display: flex; align-items: center; gap: 8px; margin-top: 16px;
  font-size: 13px; color: var(--tinta-2); font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity 0.4s ease;
}
.franja-leyenda.visible { opacity: 1; }
.muestra-turistas, .muestra-vecinos { width: 10px; height: 10px; border-radius: 50%; background: var(--turistas); flex: none; }
.muestra-vecinos { background: var(--vecinos); }
.muestra-turistas { margin-left: 8px; }

.fuente {
  margin-top: 12px; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s;
}
.fuente.visible { opacity: 1; visibility: visible; pointer-events: auto; }
.fuente-titulo { font-size: 12px; color: var(--tinta-3); margin-bottom: 6px; }
.fuente-opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fuente button {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; min-height: 48px; padding: 8px 10px;
  border: 1px solid var(--linea); border-radius: 8px; text-shadow: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.fuente-nombre { font-size: 13px; font-weight: 600; color: var(--tinta); line-height: 1.2; }
.fuente-dato { font-size: 11px; color: var(--tinta-3); font-variant-numeric: tabular-nums; line-height: 1.25; }
.fuente button:hover { background: rgba(242, 245, 247, 0.08); }
.fuente button[aria-checked="true"] { border-color: var(--tinta); background: rgba(242, 245, 247, 0.12); }
.fuente button:focus-visible { outline: 2px solid var(--tinta); outline-offset: 2px; }
/* El total en toneladas ya no se escribe: sin esto el <p> vacío deja su renglón. */
.total-t:empty { display: none; }
.dias { margin-top: 14px; font-size: 14px; font-weight: 500; color: var(--tinta-2); font-variant-numeric: tabular-nums; }

.panel-der {
  position: absolute; top: clamp(24px, 6vh, 64px); right: var(--gutter);
  width: min(380px, 30vw); pointer-events: auto;
}
.panel-der h2 { font-size: 13px; font-weight: 600; margin-bottom: 14px; }

.leyenda { list-style: none; }
.grupo {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: grid; grid-template-columns: 12px 1fr auto; column-gap: 10px; align-items: center;
  width: 100%; padding: 7px 8px; margin: 0 -8px; border-radius: 6px;
  font-size: 14px; color: var(--tinta); transition: background-color 0.2s ease, color 0.2s ease;
}
.grupo .muestra { grid-row: span 2; }
.grupo .nombre { font-weight: 500; }
.grupo .pct { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.grupo .kg { grid-column: 2 / 4; font-size: 12px; color: var(--tinta-3); font-variant-numeric: tabular-nums; }
.grupo:hover, .grupo.activo { background: rgba(242, 245, 247, 0.08); }
.grupo:focus-visible { outline: 2px solid var(--tinta); outline-offset: 1px; }
.leyenda.hay-activo .grupo:not(.activo) { color: var(--tinta-3); }
/* Una ficha de un tipo que ya se sacó de la pila: no se puede señalar porque no
   está. Tachada y apagada, igual que la escala vieja. Lo marca js/main.js. */
.grupo.sacado { opacity: 0.38; cursor: default; }
.grupo.sacado .nombre, .grupo.sacado .pct { text-decoration: line-through; }
.grupo.sacado:hover { background: none; }

.muestra { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--superficie); flex: none; }

.detalle {
  display: grid; grid-template-columns: 1fr auto; gap: 3px 12px;
  min-height: 84px; padding: 8px 0 0; font-size: 12px; color: var(--tinta-2); font-variant-numeric: tabular-nums;
}
.detalle span:nth-child(even) { text-align: right; }

.total { border-top: 1px solid var(--linea); padding-top: 14px; }
.total-kg { font-size: clamp(30px, 3.3vw, 54px); font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.total-t { font-size: 14px; color: var(--tinta-2); margin-top: 6px; min-height: 1.2em; font-variant-numeric: tabular-nums; }

.escala {
  position: absolute; left: var(--gutter); bottom: clamp(20px, 5vh, 48px);
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--tinta-2);
}
.escala .punto { width: 6px; height: 6px; border-radius: 50%; background: var(--tinta); }
/* Cuando la escena cambia cuánto vale un punto, el pie se enciende. Es el aviso entero:
   la tarjeta que antes lo anunciaba en el centro de la pantalla se iba encima del texto
   del relato y quedaban dos recuadros discutiendo. Ver js/main.js. */
.escala { transition: color 0.4s ease; }
.escala.cambiando { color: var(--tinta); }
.escala.cambiando .punto { background: var(--tinta); box-shadow: 0 0 0 4px rgba(242, 245, 247, 0.18); }


.caption {
  position: absolute; left: var(--gutter); top: clamp(330px, 44vh, 420px);
  width: min(340px, 30vw);
  padding-left: 14px; border-left: 2px solid var(--tinta);
  font-size: clamp(17px, 1.4vw, 21px); line-height: 1.4; text-wrap: pretty;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.9);
  opacity: 0; visibility: hidden;
}
.caption strong { font-weight: 800; }

.pista {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  font-size: 13px; color: var(--tinta-3); transition: opacity 0.4s ease;
}
.pista.oculta { opacity: 0; }
body.en-demo .pista { opacity: 1; }
body.en-demo .pista::after { content: ' · modo demo: movéte con la rueda para tomar el control'; }

/* Comparaciones: etiquetas sobre la cima de cada referencia */
.etiquetas { position: absolute; inset: 0; overflow: hidden; }
.etiqueta-comparacion {
  position: absolute; left: 0; top: 0; will-change: transform;
  display: flex; flex-direction: column; align-items: center;
  /* El ancho se achica con la pantalla. Fijo en 200px, una etiqueta cerca del borde
     izquierdo arrancaba en -100 y se comía la mitad del nombre: medido en un teléfono
     de 390px, siete etiquetas cortadas. */
  --ancho-et: min(200px, 46vw);
  width: var(--ancho-et); margin-left: calc(var(--ancho-et) / -2);
  padding-bottom: 8px; translate: 0 -100%;
  font-size: 12px; line-height: 1.25; text-align: center; opacity: 0;
}
.etiqueta-comparacion::after { content: ''; width: 1px; height: 10px; margin-top: 4px; background: var(--tinta-2); }
.etiqueta-nombre { color: var(--tinta-2); }
.etiqueta-alto { font-size: 15px; font-weight: 700; color: var(--tinta); font-variant-numeric: tabular-nums; }


.aviso-revision {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 10;
  padding: 8px 14px; border-radius: 999px; background: #bb7010; color: #fff;
  font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
}

/* Carga: la simulación de la pila tarda un instante */
.cargador {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 5;
  font-size: 14px; color: var(--tinta-3); background: var(--fondo-abajo);
  transition: opacity 0.5s ease, visibility 0.5s;
}
body:not(.cargando) .cargador { opacity: 0; visibility: hidden; }
body.cargando .hud, body.cargando .datos { visibility: hidden; }

/* ── Recorrido y datos ───────────────────────────────────────────────── */
#recorrido { position: relative; pointer-events: none; min-height: 100vh; }

.datos { position: relative; z-index: 6; background: var(--fondo-abajo); padding: 96px var(--gutter) 120px; }
.datos-inner { max-width: 960px; margin: 0 auto; }
.datos h2 { font-size: clamp(24px, 2.4vw, 34px); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 32px; }
table { width: 100%; border-collapse: collapse; margin-bottom: 48px; font-size: 14px; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-size: 13px; font-weight: 600; color: var(--tinta-2); padding-bottom: 10px; }
th, td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--linea); vertical-align: top; }
thead th { font-size: 12px; font-weight: 600; color: var(--tinta-3); }
tbody th { font-weight: 600; }
tbody th .muestra { margin-right: 8px; }
.metodologia { font-size: 13px; line-height: 1.5; color: var(--tinta-3); /*max-width: 70ch;*/ }

/* ── Celular ─────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .panel-izq { top: 16px; width: calc(100vw - 32px); }
  .volanta { margin-bottom: 6px; }
  h1 { font-size: 26px; }
  .bajada { display: none; }
  .contador { margin-top: 12px; gap: 8px; }
  .icono-persona { width: 16px; height: 29px; }
  .personas { font-size: 20px; }
  .personas .personas-label, .desglose { font-size: 12px; }
  .anio { margin-top: 8px; width: 100%; }
  .anio-total { font-size: 12px; }
  .etapas { right: 6px; }
  .dias { margin-top: 6px; }

  .panel-der { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; }
  .panel-der h2, .grupo .kg { display: none; }
  /* El detalle de cada tipo estaba apagado en el teléfono, y era lo único que lo
     explicaba: de qué está hecho ese 46,7 % de orgánicos. Colgado del hover, en un
     teléfono no existe. Ahora aparece al TOCAR una ficha —el click ya la activa— y se
     va al tocar de nuevo. */
  .detalle { display: none; margin-top: 8px; }
  .leyenda.hay-activo + .detalle { display: grid; }
  .leyenda { display: flex; flex-wrap: wrap; gap: 2px 10px; }
  .grupo { display: flex; gap: 6px; width: auto; margin: 0; padding: 4px 2px; font-size: 12px; }
  .grupo .pct { font-weight: 500; color: var(--tinta-2); }
  .total { display: flex; align-items: baseline; gap: 10px; margin-top: 8px; padding-top: 8px; }
  .total-kg { font-size: 26px; }
  .total-t { margin: 0; font-size: 12px; }
  .franja-leyenda { margin-top: 6px; font-size: 12px; }
  .fuente { margin-top: 8px; }
  .fuente-titulo { font-size: 11px; margin-bottom: 4px; }
  .fuente button { padding: 7px 8px; }
  .fuente-nombre { font-size: 12px; }
  .fuente-dato { font-size: 10px; }

  .dias { display: inline-block; }
  .escala { top: 16px; bottom: auto; left: auto; right: 16px; font-size: 11px; }
  .caption { top: 170px; left: 16px; width: calc(100vw - 32px); font-size: 15px; }
  .pista { bottom: 180px; }
  .aviso-revision { top: 44px; bottom: auto; font-size: 11px; white-space: normal; width: calc(100vw - 32px); text-align: center; }
  table { font-size: 12px; display: block; overflow-x: auto; }
}

/* ── Corte del subsuelo: lo que baja a las napas ─────────────────────────── */
#corte { position: fixed; inset: 0; z-index: 1; display: block; pointer-events: none; }
body:not([data-modulo="basura"]) #corte { opacity: 0; visibility: hidden; transition: opacity 0.6s ease, visibility 0.6s; }
.corte-etiquetas { position: fixed; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
.corte-etiqueta {
  position: absolute; left: 0; top: 0; opacity: 0; will-change: transform;
  display: grid; gap: 1px; width: max-content; max-width: 240px;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.95);
}
.corte-etiqueta strong { font-size: 13px; font-weight: 600; }
.corte-etiqueta span { font-size: 11px; line-height: 1.35; color: var(--tinta-3); }
.corte-napa strong, .corte-lluvia strong { color: #4aa0d6; }
.corte-izq strong, .corte-der strong { color: #4aa0d6; }
.corte-izq, .corte-der { translate: 0 -100%; }
.corte-divisoria { translate: -50% -100%; }
.corte-divisoria strong { font-weight: 500; color: var(--tinta-2); font-size: 12px; }
/* La aclaración de escala va fija abajo a la izquierda, no sobre el dibujo. */
.corte-escala { position: fixed; left: var(--gutter); top: auto; bottom: 10px; translate: 0 0 !important; max-width: min(460px, 44vw); }
.corte-escala span { font-size: 11px; color: var(--tinta-3); }
/* El aviso de que las marcas del corte se abren. Va primero y en el acento, para que se
   lea antes que la salvedad de la escala. El texto cambia entre mouse y teléfono. */
.corte-escala .corte-pista { display: block; margin-bottom: 3px; color: #e77d32; }
.corte-escala .corte-pista::before { content: 'Tocá cada marca para leer qué es.'; }
@media (hover: hover) and (pointer: fine) {
  .corte-escala .corte-pista::before { content: 'Pasá el mouse por cada marca para leer qué es.'; }
}
.texto-lixiviado { color: #7ec45a; }

/* Cita de cierre del gráfico de basura */
.cita-pila {
  position: fixed; left: 50%; top: 50%; z-index: 4;
  width: min(820px, calc(100vw - 2 * var(--gutter)));
  transform: translate(-50%, -46%); opacity: 0; visibility: hidden;
  transition: opacity 0.6s ease, transform 0.6s ease, visibility 0.6s;
}
.cita-pila.visible { opacity: 1; visibility: visible; transform: translate(-50%, -50%); }
.cita-pila p { font-size: clamp(21px, 2.4vw, 32px); font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; text-wrap: balance; }
.cita-pila footer { margin-top: 16px; font-size: 14px; color: var(--tinta-2); }
body.en-cita-pila #escena, body.en-cita-pila #corte { opacity: 0.12; transition: opacity 0.6s ease; }
body.en-cita-pila .corte-etiquetas, body.en-cita-pila .caption,
body.en-cita-pila .panel-der, body.en-cita-pila .escala { opacity: 0; transition: opacity 0.5s ease; }

@media (max-width: 767px) {
  .corte-etiqueta { max-width: 44vw; }
  .corte-etiqueta strong { font-size: 11px; }
  .corte-etiqueta span { font-size: 10px; }
  .corte-escala { display: none; }
  /* Los tres que bajan al pie del dibujo (ver js/corte.js) tienen ahí el ancho que no
     tenían encima: el del subsuelo cruza entero —en 44vw salía en tres renglones
     apretados— y las dos cuencas se reparten la mitad cada una. */
  .corte-cantera { max-width: calc(100vw - 24px); }
  .corte-izq, .corte-der { max-width: 46vw; }
}

/* ── Índice de trabajo: saltar entre gráficos y etapas ───────────────────── */
.indice { position: fixed; left: 12px; bottom: 12px; z-index: 40; font-size: 12px; }
.indice-abrir {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border: 1px solid var(--linea); border-radius: 999px;
  background: rgba(10, 10, 10, 0.9); color: var(--tinta-2);
  letter-spacing: 0.06em; text-transform: uppercase; font-size: 10px;
}
.indice-abrir:hover { color: var(--tinta); border-color: var(--tinta-3); }
.indice-abrir:focus-visible { outline: 2px solid var(--tinta); outline-offset: 2px; }
.indice-panel {
  position: absolute; left: 0; bottom: 42px; width: min(440px, calc(100vw - 24px));
  max-height: min(60vh, 520px); overflow: auto;
  padding: 14px 16px; border: 1px solid var(--linea); border-radius: 12px;
  background: rgba(8, 8, 8, 0.97); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
}
.indice-modulo + .indice-modulo { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--linea); }
.indice-modulo h3 {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--tinta-3); margin-bottom: 7px; font-weight: 600;
}
.indice-modulo.activo h3 { color: var(--tinta); }
.indice-etapas { display: flex; flex-wrap: wrap; gap: 5px; }
.indice-etapa {
  all: unset; cursor: pointer; padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--linea); color: var(--tinta-2); font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.indice-etapa:hover { background: rgba(242, 245, 247, 0.1); color: var(--tinta); }
.indice-etapa:focus-visible { outline: 2px solid var(--tinta); outline-offset: 1px; }
.indice-etapa.aqui { border-color: var(--tinta); color: var(--tinta); background: rgba(242, 245, 247, 0.14); }
@media (max-width: 767px) { .indice { left: 8px; bottom: 8px; } }

/* El porcentaje de la franja resaltada, al lado de la pila. Se ubica proyectando un
   punto del mundo, como las etiquetas de las comparaciones. */
.franja-pct {
  position: absolute; left: 0; top: 0; margin: 0;
  translate: 0 -50%;
  padding-left: 10px;
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(15px, 1.5vw, 22px);
  color: var(--c, #fff);
  opacity: 0; pointer-events: none; white-space: nowrap;
  transition: opacity 0.2s ease;
}
