/* ============================================================
   MEMORIA BB — CAPA VISUAL v3
   Se carga DESPUÉS de style.css: solo añade y refina.

   REGLA DE ESTA CAPA
   ------------------
   El texto NUNCA se mueve. No hay revelados, contadores,
   subrayados que crecen ni títulos que entran: la lectura es
   quieta. Lo único que se anima son los ARTEFACTOS dibujados
   (objetos SVG) y el cromo de navegación.

   ------------------------------------------------------------
   1.  Tokens y temas
   2.  Imagen de fondo de sección (25 %)
   3.  Figuras de apoyo
   4.  Artefactos animados
   5.  Cromo de navegación
   6.  Plantas interactivas
   7.  Matriz, barras y galería
   8.  Varios
   9.  Impresión y movimiento reducido
   ============================================================ */

/* ============================================================
   1. TOKENS Y TEMAS
   ============================================================ */
:root {
  --grain: 0.025;
  --shadow-s: 0 1px 2px rgba(28, 26, 23, 0.05);
  --shadow-m: 0 8px 26px -12px rgba(28, 26, 23, 0.22);
  --shadow-l: 0 26px 60px -24px rgba(28, 26, 23, 0.32);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fondo-op: 0.25;
  --sidebar-w: 272px;
  --maxw: 880px;
}

html[data-theme="noche"] {
  --paper: #14161b;
  --paper-2: #1c1f26;
  --ink: #eceae4;
  --ink-soft: #a8a49b;
  --line: #2e323b;
  --blue-deep: #0e1117;
  --blue: #8fa9d4;
  --green: #8fbf6c;
  --orange: #e5a25c;
  --red: #dd7b78;
  --purple: #a98fd0;
  --yellow: #e0c46a;
  --brown: #b08e69;
  --gray: #7c8189;
  --gray-dark: #6a6f77;
  --grain: 0.05;
  --fondo-op: 0.16;
}
html[data-theme="noche"] body { background: var(--paper); }
html[data-theme="noche"] .card,
html[data-theme="noche"] .stat,
html[data-theme="noche"] .decision,
html[data-theme="noche"] .acc,
html[data-theme="noche"] .chart,
html[data-theme="noche"] .barchart,
html[data-theme="noche"] .table-wrap,
html[data-theme="noche"] .floorplan__stage,
html[data-theme="noche"] .censo-scroll,
html[data-theme="noche"] .floorplan__tabs button,
html[data-theme="noche"] .artefacto,
html[data-theme="noche"] .apoyo__marco { background: var(--paper-2); }
html[data-theme="noche"] table.t th { background: #0b0d12; }
html[data-theme="noche"] table.t tbody tr:nth-child(even) { background: #191c22; }
html[data-theme="noche"] table.t tbody tr:hover { background: #232832; }
html[data-theme="noche"] table.t tr.total-row td { background: #2a2415; }
html[data-theme="noche"] .note { background: #241d12; }
html[data-theme="noche"] .note.pending { background: #2a1a1a; }
html[data-theme="noche"] #matrix-msg { background: #191c22; }
html[data-theme="noche"] table.matrix td.rowh { background: #1c1f26; }
html[data-theme="noche"] .floorplan__tabs button.is-active { background: #0b0d12; border-color: #0b0d12; color: #fff; }
html[data-theme="noche"] .chip { background: var(--paper-2); }
html[data-theme="noche"] .planta-aviso { background: #241f12; }
html[data-theme="noche"] .hero__meta div { background: rgba(8, 10, 14, 0.6); }

/* Textura de papel: quita el aspecto de pantalla plana */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: var(--grain);
  background-image:
    radial-gradient(circle at 18% 27%, #000 0.4px, transparent 0.5px),
    radial-gradient(circle at 73% 61%, #000 0.4px, transparent 0.5px),
    radial-gradient(circle at 41% 82%, #000 0.4px, transparent 0.5px);
  background-size: 7px 7px, 11px 11px, 13px 13px;
  mix-blend-mode: multiply;
}
html[data-theme="noche"] body::before { mix-blend-mode: screen; }

/* ============================================================
   2. IMAGEN DE FONDO DE SECCIÓN — opacidad 25 %
   ============================================================ */
.chapter,
.hero { position: relative; }

/* Numeral fantasma del capítulo: estático, nunca se anima */
.chapter__num {
  position: absolute;
  top: 30px;
  right: clamp(8px, 4vw, 54px);
  font-family: var(--serif);
  font-size: clamp(110px, 16vw, 220px);
  line-height: 0.8;
  font-style: italic;
  color: var(--ink);
  opacity: 0.045;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}
html[data-theme="noche"] .chapter__num { opacity: 0.07; }

.chapter.con-fondo { isolation: isolate; }

.chapter.con-fondo::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--fondo);
  background-size: cover;
  background-position: var(--fondo-pos, center);
  background-repeat: no-repeat;
  opacity: var(--fondo-op);
  filter: grayscale(0.4) contrast(0.92);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 9%, #000 91%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 9%, #000 91%, transparent 100%);
}
html[data-theme="noche"] .chapter.con-fondo::before {
  filter: grayscale(0.6) contrast(0.8) brightness(1.35);
}

.chapter__inner { position: relative; z-index: 1; }

/* Las tarjetas y tablas tapan el fondo: es correcto, el agua
   solo se ve en los blancos de la maqueta. */
.chapter.con-fondo .card,
.chapter.con-fondo .stat,
.chapter.con-fondo .table-wrap,
.chapter.con-fondo .acc,
.chapter.con-fondo .chart,
.chapter.con-fondo .decision { position: relative; z-index: 2; }

/* ============================================================
   3. FIGURAS DE APOYO
   ============================================================ */
figure.apoyo {
  margin: 30px 0 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  position: relative;
  z-index: 2;
}
html[data-theme="noche"] figure.apoyo { background: var(--paper-2); }

figure.apoyo .apoyo__marco {
  background:
    linear-gradient(180deg, #fff, var(--paper-2));
  display: grid;
  place-items: center;
  padding: 0;
  cursor: zoom-in;
  border: 0;
  width: 100%;
  font: inherit;
}
figure.apoyo .apoyo__marco img {
  width: 100%;
  height: auto;
  max-height: 68vh;
  object-fit: contain;
  display: block;
  transition: transform 0.6s var(--ease);
}
figure.apoyo .apoyo__marco:hover img { transform: scale(1.015); }
figure.apoyo .apoyo__marco:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }

figure.apoyo figcaption {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 13px 18px 15px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
}
figure.apoyo figcaption b {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #fff;
  background: var(--blue-deep);
  padding: 4px 9px;
  border-radius: 4px;
}
html[data-theme="noche"] figure.apoyo figcaption b { background: var(--blue); color: #10131a; }

/* Variante: figura alta, a sangre dentro de la columna */
figure.apoyo--ancha { margin-left: calc(-1 * clamp(0px, 3vw, 40px)); margin-right: calc(-1 * clamp(0px, 3vw, 40px)); }

/* Figuras de a dos */
.apoyo-par {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 30px 0 34px;
  position: relative;
  z-index: 2;
}
.apoyo-par figure.apoyo { margin: 0; }

/* ============================================================
   4. ARTEFACTOS ANIMADOS
   Lo único que se mueve en la página. Objetos dibujados:
   piezas que se arman, niveles que se apilan, materia que cae.
   ============================================================ */
.artefacto {
  margin: 30px 0 34px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 22px 18px;
  position: relative;
  z-index: 2;
  overflow: hidden;
}
.artefacto__lienzo {
  display: grid;
  place-items: center;
}
.artefacto svg {
  width: 100%;
  height: auto;
  max-height: 460px;
  display: block;
  overflow: visible;
}
.artefacto figcaption {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.artefacto figcaption b {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--orange);
  display: block;
  margin-bottom: 5px;
}
.artefacto__pausa {
  position: absolute;
  top: 14px;
  right: 14px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  z-index: 3;
  transition: border-color 0.2s, color 0.2s;
}
.artefacto__pausa:hover { border-color: var(--orange); color: var(--blue-deep); }
html[data-theme="noche"] .artefacto__pausa:hover { color: var(--ink); }
.artefacto.is-pausado svg * { animation-play-state: paused !important; }

/* --- Animaciones de los artefactos --- */
/* A1 · La huella sobre el predio */
@keyframes a1-predio {
  0%        { stroke-dashoffset: 1; }
  18%, 94%  { stroke-dashoffset: 0; }
  100%      { stroke-dashoffset: 1; }
}
@keyframes a1-huella {
  0%, 22%   { transform: scale(0.02); opacity: 0; }
  46%       { transform: scale(1); opacity: 1; }
  94%       { transform: scale(1); opacity: 1; }
  100%      { transform: scale(0.02); opacity: 0; }
}
@keyframes a1-aparece {
  0%, 50%   { opacity: 0; transform: translateY(8px); }
  64%, 94%  { opacity: 1; transform: translateY(0); }
  100%      { opacity: 0; transform: translateY(8px); }
}
.a1-predio { stroke-dasharray: 1; animation: a1-predio 13s var(--ease) infinite; }
.a1-huella { transform-box: fill-box; transform-origin: 0 0; animation: a1-huella 13s var(--ease) infinite; }
.a1-verde  { animation: a1-aparece 13s var(--ease) infinite; }
.a1-verde:nth-of-type(2) { animation-delay: 0.35s; }
.a1-verde:nth-of-type(3) { animation-delay: 0.7s; }
.a1-verde:nth-of-type(4) { animation-delay: 1.05s; }

/* A2 · El módulo del puesto */
@keyframes a2-arma {
  0%, 6%    { opacity: 0; transform: translateY(26px); }
  22%, 92%  { opacity: 1; transform: translateY(0); }
  100%      { opacity: 0; transform: translateY(26px); }
}
@keyframes a2-techo {
  0%, 34%   { opacity: 0; transform: translateY(-18px); }
  50%, 92%  { opacity: 1; transform: translateY(0); }
  100%      { opacity: 0; transform: translateY(-18px); }
}
@keyframes a2-generico {
  0%, 44%   { opacity: 0; transform: scale(0.6); }
  58%, 92%  { opacity: 1; transform: scale(1); }
  100%      { opacity: 0; transform: scale(0.6); }
}
.a2-base  { animation: a2-arma 12s var(--ease) infinite; }
.a2-frente{ animation: a2-arma 12s var(--ease) infinite 0.5s; }
.a2-postes{ animation: a2-arma 12s var(--ease) infinite 1s; }
.a2-techo { animation: a2-techo 12s var(--ease) infinite; }
.a2-caja  { transform-box: fill-box; transform-origin: center bottom; animation: a2-generico 12s var(--ease) infinite; }
.a2-caja:nth-of-type(2) { animation-delay: 0.18s; }
.a2-caja:nth-of-type(3) { animation-delay: 0.36s; }

/* A3 · El apilado de niveles */
/* A3 · El apilado de niveles
   La pila se dibuja separada y se ensambla. El nivel 1 (sótano)
   es el que no se mueve: los de arriba bajan a su sitio. */
@keyframes a3-n2 {
  0%, 12%   { transform: translateY(-50px); }
  42%, 74%  { transform: translateY(0); }
  100%      { transform: translateY(-50px); }
}
@keyframes a3-n3 {
  0%, 12%   { transform: translateY(-100px); }
  42%, 74%  { transform: translateY(0); }
  100%      { transform: translateY(-100px); }
}
@keyframes a3-n4 {
  0%, 12%   { transform: translateY(-150px); }
  42%, 74%  { transform: translateY(0); }
  100%      { transform: translateY(-150px); }
}
.a3-nivel--1 { animation: none; }
.a3-nivel--2 { animation: a3-n2 14s var(--ease) infinite; animation-delay: 0.18s; }
.a3-nivel--3 { animation: a3-n3 14s var(--ease) infinite; animation-delay: 0.36s; }
.a3-nivel--4 { animation: a3-n4 14s var(--ease) infinite; animation-delay: 0.54s; }

@keyframes a3-guia {
  0%, 12%   { opacity: 0; }
  42%, 74%  { opacity: 1; }
  100%      { opacity: 0; }
}
.a3-guia { animation: a3-guia 14s var(--ease) infinite; }

/* A4 · El ciclo del shut */
@keyframes a4-cae {
  0%        { transform: translateY(0); opacity: 0; }
  6%        { opacity: 1; }
  26%       { transform: translateY(210px); opacity: 1; }
  32%, 100% { transform: translateY(210px); opacity: 0; }
}
@keyframes a4-bandeja {
  0%, 30%   { opacity: 0.25; }
  40%, 82%  { opacity: 1; }
  92%, 100% { opacity: 0.25; }
}
@keyframes a4-camion {
  0%, 62%   { transform: translateX(0); opacity: 0; }
  70%, 88%  { transform: translateX(105px); opacity: 1; }
  96%, 100% { transform: translateX(0); opacity: 0; }
}
.a4-residuo { animation: a4-cae 10s linear infinite; }
.a4-residuo:nth-of-type(2) { animation-delay: 0.9s; }
.a4-residuo:nth-of-type(3) { animation-delay: 1.8s; }
.a4-residuo:nth-of-type(4) { animation-delay: 2.7s; }
.a4-bandeja { animation: a4-bandeja 10s var(--ease) infinite; }
.a4-bandeja:nth-of-type(2) { animation-delay: 0.9s; }
.a4-bandeja:nth-of-type(3) { animation-delay: 1.8s; }
.a4-bandeja:nth-of-type(4) { animation-delay: 2.7s; }
.a4-camion { animation: a4-camion 10s var(--ease) infinite; }

/* A5 · La retícula de 1,25 m */
@keyframes a5-linea {
  0%        { stroke-dashoffset: 1; opacity: 0; }
  6%        { opacity: 1; }
  30%, 92%  { stroke-dashoffset: 0; opacity: 1; }
  100%      { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes a5-celda {
  0%, 30%   { opacity: 0; }
  34%, 92%  { opacity: 1; }
  100%      { opacity: 0; }
}
.a5-linea { stroke-dasharray: 1; animation: a5-linea 12s var(--ease) infinite; }
.a5-linea:nth-of-type(2n) { animation-delay: 0.12s; }
.a5-linea:nth-of-type(3n) { animation-delay: 0.24s; }
.a5-celda { animation: a5-celda 12s linear infinite; }

/* ============================================================
   5. CROMO DE NAVEGACIÓN
   (El cromo sí se mueve: es interfaz, no texto del documento.)
   ============================================================ */
.lectura {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  z-index: 9999;
  background: linear-gradient(90deg, var(--green), var(--yellow) 38%, var(--orange) 70%, var(--red));
  transition: width 0.1s linear;
}

.cinta {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  z-index: 9990;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 clamp(28px, 6vw, 84px);
  background: rgba(250, 247, 240, 0.9);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
html[data-theme="noche"] .cinta { background: rgba(20, 22, 27, 0.9); }
.cinta.is-visible { opacity: 1; visibility: visible; }
.cinta b { color: var(--blue-deep); font-weight: 700; }
html[data-theme="noche"] .cinta b { color: var(--ink); }
.cinta .cinta__num {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  color: var(--orange);
  text-transform: none;
  letter-spacing: 0;
}
.cinta .cinta__bar { flex: 1; height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.cinta .cinta__bar i { display: block; height: 100%; width: 0; background: var(--orange); }

.barra-flotante {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9997;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.boton-redondo {
  position: relative;
  min-width: 44px;
  height: 44px;
  padding: 0 17px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--blue-deep);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-m);
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.boton-redondo:hover { border-color: var(--orange); }
.boton-redondo:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }
html[data-theme="noche"] .boton-redondo { background: rgba(28, 31, 38, 0.92); color: var(--ink); }
.boton-redondo[hidden] { display: none; }

/* Índice lateral: capítulo activo */
.sidebar__nav a { position: relative; overflow: hidden; transition: background 0.18s, color 0.18s; }
.sidebar__nav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 0 3px 3px 0;
  background: var(--orange);
  transform: translateY(-50%);
  transition: height 0.35s var(--ease);
}
.sidebar__nav a.is-active::before { height: 70%; }
/* Sin desplazamiento de texto: el capítulo activo se marca solo
   con el riel y el color, nunca moviendo la línea. */

/* Portada: capas de imagen (sin animación de texto) */
.hero { isolation: isolate; }
.hero__fondo {
  position: absolute;
  inset: -6%;
  z-index: 0;
  background-image: var(--hero-img);
  background-size: cover;
  background-position: center 40%;
  opacity: 0.32;
  filter: grayscale(0.65) contrast(1.12) brightness(1.05);
  mix-blend-mode: luminosity;
  will-change: transform;
}
.hero__velo {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 90% at 12% 8%, rgba(16, 24, 35, 0.3), rgba(16, 24, 35, 0.87) 62%),
    linear-gradient(180deg, rgba(16, 24, 35, 0.55), rgba(16, 24, 35, 0.92));
}
.hero__rejilla {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.14) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(80% 70% at 30% 30%, #000 20%, transparent 78%);
  mask-image: radial-gradient(80% 70% at 30% 30%, #000 20%, transparent 78%);
}
.hero::after { z-index: 0; }
.hero__inner { position: relative; z-index: 2; }
.hero__meta div { transition: background 0.3s var(--ease); }
.hero__meta div:hover { background: rgba(240, 196, 138, 0.16); }
.hero__meta dd { font-variant-numeric: tabular-nums; }

.hero__scroll {
  position: relative;
  z-index: 2;
  max-width: var(--maxw);
  margin: 34px auto 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: #93a3ba;
}
.hero__scroll i { display: block; width: 46px; height: 1px; background: linear-gradient(90deg, var(--orange), transparent); }

/* ============================================================
   6. PLANTAS INTERACTIVAS
   ============================================================ */
.floorplan__panel { display: none; }
.floorplan__panel.is-active { display: block; }
.floorplan__tabs button:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }

.zone { cursor: pointer; transition: opacity 0.22s, filter 0.22s; }
.zone:hover { opacity: 0.86; filter: saturate(1.25) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.16)); }

.legend span {
  cursor: default;
  transition: opacity 0.2s, background 0.2s;
  padding: 2px 6px;
  border-radius: 5px;
}
.legend span:hover { background: var(--paper-2); }
.legend.is-filtrando span { opacity: 0.32; }
.legend.is-filtrando span.is-on { opacity: 1; }
.floorplan__panel .zone.is-apagada { opacity: 0.14; filter: grayscale(0.7); }

.planta-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--ink-soft);
}
.planta-tools button {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.planta-tools button:hover { border-color: var(--orange); color: var(--blue-deep); }
html[data-theme="noche"] .planta-tools button:hover { color: var(--ink); }
.planta-tools button[aria-pressed="true"] { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }

.planta-aviso {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
  border-left: 3px solid var(--yellow);
  padding: 9px 14px;
  background: #fffaf0;
  border-radius: 0 6px 6px 0;
  position: relative;
  z-index: 2;
}

/* ============================================================
   7. MATRIZ, BARRAS Y GALERÍA
   ============================================================ */
table.matrix td.cell {
  font-size: 0;
  position: relative;
  min-width: 58px;
  transition: box-shadow 0.2s, background 0.2s;
}
table.matrix td.cell::after {
  content: attr(data-marca);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  display: block;
  line-height: 1;
}
table.matrix td.cell[data-estado="ok"]  { background: rgba(123, 160, 91, 0.16); }
table.matrix td.cell[data-estado="ojo"] { background: rgba(217, 180, 74, 0.2); }
table.matrix td.cell[data-estado="no"]  { background: rgba(192, 80, 77, 0.14); }
/* El realce no escala la celda: la marca nunca se mueve ni cambia de tamaño */
table.matrix td.cell:hover { box-shadow: inset 0 0 0 2px var(--orange); z-index: 4; }
table.matrix td.cell.is-foco { box-shadow: inset 0 0 0 2px var(--orange); }
table.matrix tr.is-foco th,
table.matrix tr.is-foco td.rowh { background: var(--blue); color: #fff; }

.areas-barras {
  margin: 24px 0 30px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  position: relative;
  z-index: 2;
}
html[data-theme="noche"] .areas-barras { background: var(--paper-2); }
.areas-barras h5 {
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 18px;
}
.area-fila { margin-bottom: 11px; }
.area-fila__cab {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 5px;
}
.area-fila__cab b { font-weight: 600; color: var(--ink); }
.area-fila__cab span { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--blue-deep); }
html[data-theme="noche"] .area-fila__cab span { color: var(--ink); }
.area-fila__pista { height: 12px; border-radius: 7px; background: var(--paper-2); overflow: hidden; }
html[data-theme="noche"] .area-fila__pista { background: #12151b; }
.area-fila__pista i { display: block; height: 100%; width: 0; border-radius: 7px; transition: width 1.15s var(--ease); }

.flujo-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--ink-soft);
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}
.flujo-tools button {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.flujo-tools button:hover { border-color: var(--orange); }
.flujo-tools button[aria-pressed="true"] { background: var(--blue-deep); color: #fff; border-color: var(--blue-deep); }

/* Galería */
.galeria {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 14px;
  margin: 26px 0 32px;
  position: relative;
  z-index: 2;
}
.galeria__item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  cursor: zoom-in;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
html[data-theme="noche"] .galeria__item { background: var(--paper-2); }
.galeria__item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  transition: transform 0.7s var(--ease);
}
.galeria__item:hover { box-shadow: var(--shadow-l); border-color: #cfc6b4; }
.galeria__item:hover img { transform: scale(1.06); }
.galeria__item:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; }
.galeria__pie { display: block; padding: 11px 14px 13px; border-top: 1px solid var(--line); }
.galeria__pie b { display: block; font-size: 12.5px; font-weight: 700; color: var(--blue-deep); }
html[data-theme="noche"] .galeria__pie b { color: var(--ink); }
.galeria__pie span { display: block; font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }
.galeria__lupa {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(16, 24, 35, 0.62);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s;
}
.galeria__item:hover .galeria__lupa { opacity: 1; }

/* Visor */
.visor {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(10, 13, 18, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
}
.visor.is-abierto {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
}
@keyframes visor-entra {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}
.visor__cuerpo img.visor__img-anim { animation: visor-entra 0.15s ease both; }
.visor__cab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 22px;
  color: #e9e6de;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.visor__cab .visor__cuenta { font-variant-numeric: tabular-nums; color: #9aa7b8; }
.visor__cuerpo { position: relative; overflow: auto; display: grid; place-items: center; padding: 22px; }
.visor__cuerpo img {
  max-width: 96vw;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transition: transform 0.35s var(--ease);
  transform-origin: center center;
}
.visor__cuerpo img.zoom { cursor: zoom-out; }
.visor__pie { padding: 13px 22px 18px; color: #9aa7b8; font-size: 12.5px; text-align: center; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.visor__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.visor__nav:hover { background: rgba(255, 255, 255, 0.2); }
.visor__nav.previa { left: 18px; }
.visor__nav.siguiente { right: 18px; }
.visor__cerrar {
  min-width: 38px;
  height: 38px;
  width: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #fff;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
}
.visor__cerrar:hover { background: rgba(255, 255, 255, 0.14); }

/* ============================================================
   8. VARIOS
   ============================================================ */
.chapter h2::after {
  content: "";
  display: block;
  width: 116px;
  height: 2px;
  margin-top: 14px;
  background: linear-gradient(90deg, var(--orange), rgba(217, 138, 61, 0));
}

.card, .stat, .decision { transition: box-shadow 0.35s var(--ease), border-color 0.3s; }
.card:hover, .stat:hover { box-shadow: var(--shadow-m); border-color: #cfc6b4; }
html[data-theme="noche"] .card:hover,
html[data-theme="noche"] .stat:hover { border-color: #3c424d; }

/* El acordeón abre en seco: el texto no se desliza ni aparece en fundido */
.acc__body {
  display: grid !important;
  grid-template-rows: 0fr;
  overflow: hidden;
  padding: 0 20px;
  opacity: 0;
  transition: none;
}
.acc__body > * { min-height: 0; }
.acc__item.is-open .acc__body { grid-template-rows: 1fr; padding: 0 20px 18px; opacity: 1; }

.chapter p a {
  border-bottom: 1px solid rgba(60, 80, 112, 0.35);
  text-decoration: none;
  transition: border-color 0.2s;
}
html[data-theme="noche"] .chapter p a { border-bottom-color: rgba(143, 169, 212, 0.4); }
.chapter p a:hover { border-bottom-color: var(--orange); text-decoration: none; }

/* Índice de artefactos: pequeño mapa al final de la página */
.mapa-artefactos {
  margin: 30px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  background: #fff;
  position: relative;
  z-index: 2;
}
html[data-theme="noche"] .mapa-artefactos { background: var(--paper-2); }
.mapa-artefactos h5 { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--blue); margin-bottom: 14px; }
.mapa-artefactos ul { list-style: none; display: grid; gap: 9px; }
.mapa-artefactos li { font-size: 13.5px; color: var(--ink-soft); display: flex; gap: 10px; align-items: baseline; }
.mapa-artefactos li a { font-weight: 600; color: var(--blue); }
.mapa-artefactos li span { color: var(--ink-soft); }

/* --- Figuras pendientes: se leen como marcador, no como imagen final --- */
figure.apoyo--pendiente {
  border: 1px dashed var(--orange);
  background: repeating-linear-gradient(
    135deg,
    rgba(217, 138, 61, 0.05) 0 14px,
    transparent 14px 28px
  ), #fff;
}
html[data-theme="noche"] figure.apoyo--pendiente { background-color: var(--paper-2); }
figure.apoyo--pendiente .apoyo__marco { background: transparent; }
figure.apoyo--pendiente .apoyo__marco img {
  opacity: 0.95;
  max-height: 52vh;
}
figure.apoyo--pendiente figcaption { border-top-color: rgba(217, 138, 61, 0.45); }
figure.apoyo--pendiente figcaption b.apoyo__tag {
  background: var(--orange);
  color: #fff;
}

/* --- Pie de página sin marca --- */
.site-footer__inner { justify-content: flex-start; }
.site-footer__meta { text-align: left; }

/* ============================================================
   9. IMPRESIÓN Y MOVIMIENTO REDUCIDO
   ============================================================ */
@media print {
  .sidebar, .barra-flotante, .cinta, .lectura, .hero__fondo, .hero__velo,
  .hero__rejilla, .visor, .floorplan__tabs, .planta-tools, .flujo-tools,
  .galeria__lupa, .hero__scroll, .artefacto__pausa { display: none !important; }
  .app { display: block; }
  body { background: #fff; font-size: 10.5pt; }
  body::before { display: none; }
  .chapter { padding: 12mm 0; break-inside: avoid; }
  .chapter.con-fondo::before { opacity: 0.12; -webkit-mask-image: none; mask-image: none; }
  .floorplan__panel { display: block !important; break-after: page; }
  .acc__body { grid-template-rows: 1fr !important; opacity: 1 !important; padding-bottom: 14px !important; }
  .artefacto svg * { animation: none !important; }
  .a1-predio { stroke-dashoffset: 0 !important; }
  .a1-huella { transform: none !important; opacity: 1 !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #666; }
}

@media (prefers-reduced-motion: reduce) {
  .artefacto svg * { animation: none !important; }
  .a1-predio { stroke-dashoffset: 0 !important; }
  .a1-huella { transform: none !important; opacity: 1 !important; }
  .a1-verde, .a4-residuo, .a4-bandeja, .a4-camion, .a5-celda { opacity: 1 !important; }
  .hero__fondo { transform: none !important; }
  * { scroll-behavior: auto !important; }
}

@media (max-width: 980px) {
  :root { --sidebar-w: 0px; }
  .cinta { left: 0; }
  .artefacto { padding: 16px 14px 14px; }
}

@media (max-width: 640px) {
  .visor__nav { width: 40px; height: 40px; font-size: 17px; }
  .visor__nav.previa { left: 8px; }
  .visor__nav.siguiente { right: 8px; }
  .apoyo-par figure.apoyo { margin: 0; }
}
