/* Des-arroyos — estética común
   Materiales de la calle: vereda de hormigón, hierro fundido de tapa,
   agua de cada cuenca, y el amarillo reflectante del chaleco solo donde hay intervención. */

:root {
  color-scheme: light;

  --vereda: #e4e5e0;        /* fondo: hormigón claro */
  --vereda-2: #d7d9d2;      /* paneles, franjas */
  --junta: #b9bcb4;         /* líneas finas, juntas de baldosa */
  --hierro: #22272b;        /* tinta principal: tapa de hierro fundido */
  --hierro-suave: #555c61;  /* texto secundario */
  --otras-aguas: #a2a7a0;   /* el resto de la red entubada */

  --radio-antiguo: #8c5a2b; /* barro */
  --maldonado: #2e6e74;     /* arroyo turbio */
  --medrano: #3f5a8c;       /* pizarra */

  --reflectante: #e8d100;   /* chaleco: solo sitios de intervención y página actual */

  --cuenca: var(--hierro);  /* cada página de cuenca lo redefine */

  --sistema: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fuente: var(--sistema);                  /* textos: las fuentes del sistema */
  --titulos: "Inter", var(--sistema);        /* títulos y rótulos de la red */
  --medida: 68ch;
  --margen: clamp(1rem, 4vw, 3rem);
}

.cuenca-radio-antiguo { --cuenca: var(--radio-antiguo); }
.cuenca-maldonado     { --cuenca: var(--maldonado); }
.cuenca-medrano       { --cuenca: var(--medrano); }

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--vereda);
  color: var(--hierro);
  font-family: var(--fuente);
  font-size: 1.125rem;
  line-height: 1.55;
}

img, svg { display: block; max-width: 100%; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--hierro);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--reflectante);
}

/* ---------- Tipografía ---------- */

h1, h2, h3 { margin: 0; line-height: 1.08; font-family: var(--titulos); }

h1 {
  font-size: clamp(3rem, 10.5vw, 7.5rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.92;
}

h2 {
  font-size: clamp(1.6rem, 3.6vw, 2.4rem);
  font-weight: 650;
  letter-spacing: -0.025em;
}

h3 {
  font-size: 1.25rem;
  font-weight: 650;
}

p { margin: 0 0 1em; max-width: var(--medida); }

.bajada {
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
  line-height: 1.4;
  max-width: 42ch;
}

.dato {
  font-size: 0.875rem;
  color: var(--hierro-suave);
  font-feature-settings: "tnum";
}

.completar {
  background: var(--vereda-2);
  border-bottom: 1px dashed var(--hierro-suave);
  padding: 0 0.25em;
}

/* ---------- Navegación ---------- */

.navegacion {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 1rem var(--margen);
  border-bottom: 1px solid var(--junta);
}

.navegacion .marca {
  font-family: var(--titulos);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
  margin-right: auto;
}

.navegacion .marca [data-emblema] { display: block; width: 2.1rem; height: 2.1rem; }
.navegacion .marca svg { width: 100%; height: 100%; }

.navegacion ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.navegacion a { text-decoration: none; padding: 0.2rem 0; }

.navegacion a[aria-current="page"] {
  box-shadow: inset 0 -0.45em 0 var(--reflectante);
}

/* ---------- Estructura ---------- */

main > section,
.cabecera {
  padding: clamp(2.5rem, 7vw, 5rem) var(--margen);
}

main > section + section { border-top: 1px solid var(--junta); }

.encabezado-seccion { margin-bottom: 1.5rem; }
.encabezado-seccion p { color: var(--hierro-suave); margin-top: 0.5rem; }

/* ---------- Portada: la ciudad dibujada con su agua ---------- */

.portada {
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) minmax(0, 1.25fr);
  grid-template-areas:
    "titulo titulo"
    "texto  red";
  gap: 1.5rem clamp(1.5rem, 4vw, 4rem);
  align-items: start;
  padding: clamp(2rem, 5vw, 4rem) var(--margen) clamp(2rem, 5vw, 4rem);
}

.portada h1 { grid-area: titulo; }
.portada .texto { grid-area: texto; position: sticky; top: 1.5rem; }
.portada .bajada { margin: 0; }
.portada .leyenda-red { margin-top: 1.5rem; flex-direction: column; gap: 0.4rem; }
.portada [data-red] { grid-area: red; }

.red {
  width: 100%;
  height: auto;
  max-height: 82vh;
  margin-inline: auto;
}

@media (max-width: 52rem) {
  .portada {
    grid-template-columns: 1fr;
    grid-template-areas: "titulo" "texto" "red";
  }
  .portada .texto { position: static; }
  .red { max-height: none; }
}

.red path {
  fill: none;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.red .otras { stroke: var(--otras-aguas); stroke-width: 1.25; }
.red .radio-antiguo { stroke: var(--radio-antiguo); }
.red .maldonado { stroke: var(--maldonado); }
.red .medrano { stroke: var(--medrano); }
.red .destacada { stroke-width: 3.5; }

.red text {
  font-family: var(--titulos);
  font-size: 26px;
  font-weight: 650;
}
.red text.radio-antiguo { fill: var(--radio-antiguo); }
.red text.maldonado { fill: var(--maldonado); }
.red text.medrano { fill: var(--medrano); }

.dibujando path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: correr 2.8s cubic-bezier(.4, 0, .2, 1) forwards;
}
.dibujando path.destacada { animation-delay: 0.6s; animation-duration: 3.4s; }

@keyframes correr { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .dibujando path { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; }
}

.leyenda-red {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.leyenda-red span::before {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 3px;
  margin-right: 0.5rem;
  vertical-align: middle;
  background: var(--color);
}

/* ---------- Las tres cuencas ---------- */

.cuencas { display: grid; gap: 0; }

.cuenca-fila {
  display: grid;
  grid-template-columns: minmax(7rem, 14rem) 1fr;
  gap: 1.5rem 2.5rem;
  align-items: center;
  padding: 1.75rem 0;
  border-top: 1px solid var(--junta);
  text-decoration: none;
}
.cuenca-fila:last-child { border-bottom: 1px solid var(--junta); }

.cuenca-fila h3 {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--cuenca);
}

.cuenca-fila p { margin: 0.4rem 0 0; }

.cuenca-fila .entrar {
  display: inline-block;
  margin-top: 0.75rem;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.cuenca-fila:hover .entrar { text-decoration-thickness: 2px; }

.silueta path { fill: none; vector-effect: non-scaling-stroke; stroke: var(--cuenca); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.silueta .otras { stroke: var(--junta); stroke-width: 1.2; }

@media (max-width: 40rem) {
  .cuenca-fila { grid-template-columns: 1fr; }
  .cuenca-fila .silueta { max-width: 12rem; }
}

/* ---------- Tres tiempos ---------- */

.tiempos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.tiempo h3 { font-weight: 750; }
.tiempo .par { color: var(--hierro-suave); font-weight: 400; }
.tiempo p { margin-top: 0.5rem; }

@media (max-width: 52rem) {
  .tiempos { grid-template-columns: 1fr; }
}

/* En la página de cuenca, cada tiempo es una franja con espacio para el grupo. */

.franja-tiempo {
  display: grid;
  grid-template-columns: minmax(12rem, 20rem) 1fr;
  gap: 1rem 3rem;
  padding: 2rem 0;
  border-top: 1px solid var(--junta);
}
.franja-tiempo:last-child { border-bottom: 1px solid var(--junta); }

.franja-tiempo h3 {
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}
.franja-tiempo .par { display: block; font-weight: 400; color: var(--cuenca); font-size: 1.1rem; margin-top: 0.3rem; }

@media (max-width: 52rem) {
  .franja-tiempo { grid-template-columns: 1fr; }
}

/* ---------- Espacios vacíos: una invitación ---------- */

.espera {
  border: 1.5px dashed var(--junta);
  padding: 1.25rem 1.5rem;
  color: var(--hierro-suave);
  background: color-mix(in srgb, var(--vereda-2) 45%, transparent);
}
.espera p:last-child { margin-bottom: 0; }

/* ---------- Mapa ---------- */

.mapa {
  height: clamp(22rem, 60vh, 38rem);
  border: 1px solid var(--junta);
  background: var(--vereda-2);
}

.leaflet-container { font-family: var(--fuente); background: var(--vereda-2); }

/* El mapa base en grises y apagado: la calle queda de fondo, el agua al frente. */
.leaflet-tile-pane { filter: grayscale(1) contrast(0.85) brightness(1.06); opacity: 0.75; }

.mapa-pie { margin-top: 0.75rem; }

/* Fichas de los aportes, al tocar un punto del mapa */
.popup-ficha .leaflet-popup-content-wrapper { border-radius: 2px; background: var(--vereda); color: var(--hierro); }
.popup-ficha .leaflet-popup-tip { background: var(--vereda); }
.popup-ficha .leaflet-popup-content { margin: 0.8rem 0.9rem; font-family: var(--fuente); }
.ficha p { margin: 0 0 0.4rem; max-width: none; }
.ficha .ficha-codigo {
  font-family: var(--titulos);
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-feature-settings: "tnum";
}
.ficha img {
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: cover;
  margin: 0.2rem 0 0.5rem;
  border: 1px solid var(--junta);
}
.ficha audio, .ficha video { width: 100%; margin: 0.2rem 0 0.5rem; }
.ficha .ficha-texto { font-size: 0.95rem; line-height: 1.4; }
.ficha .ficha-transcripcion { font-size: 0.9rem; line-height: 1.4; font-style: italic; color: var(--hierro-suave); }
.ficha .ficha-pie { font-size: 0.8rem; color: var(--hierro-suave); margin-bottom: 0; }
.ficha-separador { border: 0; border-top: 1px solid var(--junta); margin: 0.8rem 0; }
.popup-ficha .leaflet-popup-content { max-height: 22rem; overflow-y: auto; }

/* ---------- Cabecera de cuenca ---------- */

.cabecera {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 2rem 3rem;
  align-items: end;
  border-bottom: 1px solid var(--junta);
}

.cabecera h1 { color: var(--cuenca); font-size: clamp(2.8rem, 8vw, 6.5rem); }
.cabecera .bajada { margin-top: 1rem; }

.cabecera .silueta { width: 100%; }

@media (max-width: 52rem) {
  .cabecera { grid-template-columns: 1fr; }
}

/* ---------- La esfera ---------- */

.esfera {
  position: relative;
  aspect-ratio: 2 / 1;
  max-height: 26rem;
  width: 100%;
  display: grid;
  place-items: center;
  background: var(--vereda-2);
  border: 1px solid var(--junta);
  text-align: center;
  padding: 1.5rem;
}

.esfera [data-emblema] { display: block; width: clamp(7rem, 18vw, 12rem); color: var(--cuenca); margin: 0 auto 1rem; }
.esfera svg { width: 100%; height: auto; }
.esfera p { margin: 0 auto; max-width: 36ch; color: var(--hierro-suave); }

/* Esfera activa: la imagen 2:1 del taller, como puerta al visor */
.esfera.esfera-activa { padding: 0; overflow: hidden; }
.esfera-enlace { position: absolute; inset: 0; display: block; text-decoration: none; }
.esfera-enlace img { width: 100%; height: 100%; object-fit: cover; }
.esfera-rotulo {
  position: absolute; left: 1rem; bottom: 1rem;
  background: var(--hierro); color: var(--vereda);
  font-family: var(--titulos); font-weight: 650; font-size: 1rem;
  padding: 0.5rem 0.9rem;
}
.esfera-enlace:hover .esfera-rotulo { box-shadow: 0 0 0 4px var(--reflectante); }

/* Lecturas semanales del agente */
.lecturas { display: grid; gap: 2.5rem; }
.lectura { border-top: 4px solid var(--cuenca); padding-top: 1rem; max-width: var(--medida); }
.lectura h3 { margin-bottom: 0.2rem; }
.lectura h4 { font-family: var(--titulos); font-size: 1.05rem; margin: 1.2rem 0 0.3rem; }
.lectura p { font-size: 1.02rem; }

/* ---------- Cuadrillas ---------- */

.cuadrillas {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.cuadrilla { border-top: 4px solid var(--cuenca); padding-top: 1rem; }
.cuadrilla p { font-size: 1rem; }
.cuadrilla .espera { margin-top: 1rem; font-size: 0.95rem; }

@media (max-width: 52rem) {
  .cuadrillas { grid-template-columns: 1fr; }
}

/* ---------- Conversación ---------- */

.conversacion {
  max-width: 44rem;
  border: 1px solid var(--junta);
  background: var(--vereda-2);
}

.conversacion .mensajes { padding: 1.5rem; min-height: 9rem; }

.conversacion form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--junta);
  background: var(--vereda);
}

.conversacion input {
  flex: 1;
  font: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--junta);
  background: #fff;
  color: var(--hierro);
}

.conversacion button,
.boton {
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  padding: 0.6rem 1.1rem;
  border: 0;
  background: var(--hierro);
  color: var(--vereda);
  cursor: pointer;
}

.conversacion :disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Acerca ---------- */

.texto-largo h2 { margin-bottom: 1rem; }
.texto-largo h3 { margin: 1.75rem 0 0.5rem; }

.lista-sobria { padding-left: 1.2rem; max-width: var(--medida); }
.lista-sobria li { margin-bottom: 0.4rem; }

/* ---------- Pie ---------- */

.pie {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem 2rem;
  padding: 2rem var(--margen) 3rem;
  border-top: 1px solid var(--junta);
  color: var(--hierro-suave);
  font-size: 0.95rem;
}
.pie [data-emblema] { display: block; width: 2.75rem; height: 2.75rem; color: var(--hierro-suave); }
.pie svg { width: 100%; height: 100%; }
.pie p { margin: 0 0 0.3rem; }

@media (max-width: 40rem) {
  .pie { grid-template-columns: 1fr; }
}

@media (max-width: 52rem) {
  .red text { font-size: 56px; }
}

/* ---------- Documentos del proyecto ---------- */

.documentos-nav {
  padding: 0.9rem var(--margen);
  border-bottom: 1px solid var(--junta);
  background: var(--vereda-2);
}
.documentos-nav p { margin: 0 0 0.4rem; }
.documentos-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.95rem;
}
.documentos-nav a { text-decoration: none; }
.documentos-nav a:hover { text-decoration: underline; }
.documentos-nav a[aria-current="page"] { box-shadow: inset 0 -0.45em 0 var(--reflectante); }

.documento {
  padding: clamp(2.5rem, 6vw, 4.5rem) var(--margen) clamp(3rem, 7vw, 5rem);
  max-width: calc(72ch + 2 * var(--margen));
}

.documento h1 {
  font-size: clamp(2.2rem, 5.5vw, 4rem);
  margin-bottom: 1.25rem;
}
.documento h1 + h2 {
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
  font-weight: 500;
  font-family: var(--fuente);
  letter-spacing: 0;
  color: var(--hierro-suave);
  margin: -0.5rem 0 2rem;
}
.documento h2 { margin: 2.75rem 0 1rem; }
.documento h3 { margin: 2rem 0 0.6rem; }
.documento h4 { margin: 1.5rem 0 0.5rem; font-size: 1.05rem; }

.documento p,
.documento li { max-width: 72ch; }
.documento ul,
.documento ol { padding-left: 1.3rem; margin: 0 0 1em; }
.documento li { margin-bottom: 0.35rem; }
.documento li > ul { margin: 0.35rem 0 0; }

.documento hr {
  border: 0;
  border-top: 1px solid var(--junta);
  margin: 2.5rem 0;
}

.documento blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 4px solid var(--hierro);
  max-width: 72ch;
}
.documento blockquote p { color: var(--hierro); }

.documento code {
  font-size: 0.9em;
  background: var(--vereda-2);
  padding: 0.05em 0.3em;
}
.documento pre {
  overflow-x: auto;
  background: var(--vereda-2);
  border: 1px solid var(--junta);
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  line-height: 1.4;
}
.documento pre code { background: none; padding: 0; }

.documento .tabla {
  overflow-x: auto;
  margin: 1.25rem 0 1.75rem;
  max-width: 100%;
}
.documento table {
  border-collapse: collapse;
  font-size: 0.95rem;
  min-width: 34rem;
}
.documento th,
.documento td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid var(--junta);
}
.documento th {
  font-weight: 650;
  border-bottom: 2px solid var(--hierro);
}

.documento .footnote {
  margin-top: 3rem;
  font-size: 0.9rem;
  color: var(--hierro-suave);
}
.documento .footnote hr { margin: 1rem 0; }

/* ---------- Comunes a todas las páginas (antes en cada HTML) ---------- */

.navegacion .item-des-arroyos { font-weight: 700; }
.marca abbr { text-decoration: none; }
.pie .logo-pie { display: block; width: 140px; height: auto; flex-shrink: 0; }

/* ---------- Visor de la esfera ---------- */

.visor-esfera { position: relative; }

.visor-esfera .visor-controles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}
.visor-esfera .visor-vistas { display: flex; gap: 0; }
.visor-esfera .visor-vistas .boton { background: var(--vereda-2); color: var(--hierro); border: 1px solid var(--junta); }
.visor-esfera .visor-vistas .boton.activo { background: var(--hierro); color: var(--vereda); border-color: var(--hierro); }
.visor-esfera .visor-controles label { font-size: 0.95rem; display: inline-flex; gap: 0.4rem; align-items: center; }

.visor-lienzo {
  position: relative;
  height: clamp(22rem, 70vh, 44rem);
  background: var(--vereda-2);
  border: 1px solid var(--junta);
  cursor: grab;
  touch-action: none;
  overflow: hidden;
}
.visor-lienzo:active { cursor: grabbing; }
.visor-lienzo canvas { display: block; width: 100%; height: 100%; }
.visor-espera { position: absolute; inset: 1.5rem; display: grid; place-items: center; text-align: center; }

.visor-circulo canvas {
  width: min(100%, 38rem);
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto;
}
.visor-circulo-opciones {
  display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; justify-content: center;
  margin: 1rem 0 0.5rem;
}
.visor-circulo .dato { text-align: center; max-width: none; }

.visor-ficha {
  position: absolute;
  right: 1rem;
  top: 4.5rem;
  width: min(20rem, calc(100% - 2rem));
  max-height: 70%;
  overflow-y: auto;
  background: var(--vereda);
  border: 1px solid var(--junta);
  padding: 0.9rem 1rem;
  box-shadow: 0 6px 24px rgba(34, 39, 43, 0.18);
}
.visor-cerrar {
  float: right;
  border: 0; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--hierro);
}
.visor-ayuda { margin-top: 0.75rem; }

.otras-esferas {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
}
.otra-esfera { text-decoration: none; display: grid; gap: 0.4rem; }
.otra-esfera img { aspect-ratio: 2 / 1; width: 100%; object-fit: cover; border: 1px solid var(--junta); }
