/* =============================================================================
   MANUAL DE ARANGES · ESTILOS
   =============================================================================
   Los colores son los mismos tokens que usa el back office (packages/client/
   src/styles.scss), en formato «r g b» para poder darles opacidad con
   rgb(var(--token) / 0.4). Si allí cambia la marca, aquí solo hay que copiar
   los dos bloques de variables.
   ========================================================================== */

:root {
  --c-primary: 30 41 114;
  --c-secondary: 61 130 211;
  --c-success: 126 196 86;
  --c-brand: 30 41 114;
  --c-brand-2: 61 130 211;
  --c-warning: 217 119 6;
  --c-danger: 220 38 38;

  --s-app: 244 245 250;
  --s-surface: 255 255 255;
  --s-sunken: 248 249 252;
  --s-elevated: 255 255 255;
  --s-line: 226 231 240;
  --s-tint: 238 240 251;
  --s-ink: 26 26 46;
  --s-ink-muted: 100 110 130;

  --sombra: 0 1px 2px rgb(15 23 42 / 0.06), 0 8px 24px rgb(15 23 42 / 0.06);
  --ancho-nav: 16.5rem;
  --ancho-lateral: 14rem;
  --alto-cabecera: 3.75rem;
}

.dark {
  --c-primary: 128 152 245;
  --c-secondary: 104 168 236;
  --c-success: 150 214 112;
  --c-warning: 245 158 11;
  --c-danger: 248 113 113;

  --s-app: 9 13 26;
  --s-surface: 21 27 48;
  --s-sunken: 14 19 36;
  --s-elevated: 28 35 60;
  --s-line: 44 54 88;
  --s-tint: 32 42 74;
  --s-ink: 233 237 247;
  --s-ink-muted: 148 160 184;

  --sombra: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.35);
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--alto-cabecera) + 1.5rem); }

body {
  margin: 0;
  background: rgb(var(--s-app));
  color: rgb(var(--s-ink));
  font: 400 0.9375rem/1.7 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: rgb(var(--c-secondary)); text-decoration: none; }
a:hover { text-decoration: underline; }

.saltar {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  padding: 0.75rem 1.25rem; border-radius: 0 0 0.75rem 0;
  background: rgb(var(--c-primary)); color: #fff;
}
.saltar:focus { left: 0; }

/* ── Cabecera ─────────────────────────────────────────────────────────────── */

.cabecera {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  height: var(--alto-cabecera);
  padding: 0 1.25rem;
  background: rgb(var(--s-surface) / 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgb(var(--s-line));
}

.cabecera__menu {
  display: none; flex-direction: column; gap: 4px;
  width: 2.25rem; height: 2.25rem; padding: 0.5rem;
  background: none; border: 0; cursor: pointer;
}
.cabecera__menu span { display: block; height: 2px; border-radius: 2px; background: rgb(var(--s-ink)); }

.marca { display: flex; align-items: center; gap: 0.625rem; color: inherit; }
.marca:hover { text-decoration: none; }
.marca__logo { height: 2rem; width: auto; display: block; }
.marca__texto { display: flex; flex-direction: column; font-weight: 700; line-height: 1.15; }
.marca__texto small { font-weight: 500; font-size: 0.6875rem; color: rgb(var(--s-ink-muted)); }

.cabecera__tema {
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem; margin-left: auto;
  border: 1px solid rgb(var(--s-line)); border-radius: 0.75rem;
  background: rgb(var(--s-surface)); color: rgb(var(--s-ink-muted)); cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.cabecera__tema:hover { color: rgb(var(--c-secondary)); border-color: rgb(var(--c-secondary) / 0.5); }
.icono-sol { display: none; }
.dark .icono-luna { display: none; }
.dark .icono-sol { display: block; }

/* ── Buscador ─────────────────────────────────────────────────────────────── */

.buscador { position: relative; flex: 1; max-width: 30rem; margin-left: auto; }

.buscador input {
  width: 100%; height: 2.375rem; padding: 0 2.25rem 0 0.875rem;
  border: 1px solid rgb(var(--s-line)); border-radius: 0.75rem;
  background: rgb(var(--s-sunken)); color: rgb(var(--s-ink));
  font: inherit; font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.buscador input::placeholder { color: rgb(var(--s-ink-muted)); }
.buscador input:focus {
  outline: none;
  border-color: rgb(var(--c-secondary));
  box-shadow: 0 0 0 3px rgb(var(--c-secondary) / 0.25);
}

.buscador__atajo {
  position: absolute; right: 0.625rem; top: 50%; transform: translateY(-50%);
  padding: 0.0625rem 0.375rem; border: 1px solid rgb(var(--s-line)); border-radius: 0.3125rem;
  background: rgb(var(--s-surface)); color: rgb(var(--s-ink-muted));
  font-size: 0.6875rem; font-family: inherit; pointer-events: none;
}
.buscador input:focus ~ .buscador__atajo { display: none; }

.resultados {
  position: absolute; top: calc(100% + 0.5rem); left: 0; right: 0; z-index: 50;
  max-height: 26rem; overflow-y: auto;
  padding: 0.375rem;
  background: rgb(var(--s-elevated)); border: 1px solid rgb(var(--s-line));
  border-radius: 0.875rem; box-shadow: var(--sombra);
}
.resultados__vacio { padding: 1.25rem; color: rgb(var(--s-ink-muted)); text-align: center; font-size: 0.875rem; }

.resultado { display: block; padding: 0.625rem 0.75rem; border-radius: 0.625rem; color: inherit; }
.resultado:hover, .resultado.marcado { background: rgb(var(--s-tint)); text-decoration: none; }
/* El display:block no es decorativo: los tres son <span>, y sin él la miga de
   pan y el título se pegan en la misma línea («CÓMO MOVERSELas tres zonas») y
   el margen del título, al ser inline, tampoco surte efecto. */
.resultado__ruta { display: block; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.04em; color: rgb(var(--s-ink-muted)); }
.resultado__titulo { display: block; font-weight: 600; font-size: 0.875rem; margin: 0.0625rem 0; }
.resultado__texto {
  font-size: 0.8125rem; color: rgb(var(--s-ink-muted));
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.resultado mark { background: rgb(var(--c-secondary) / 0.28); color: inherit; border-radius: 0.1875rem; padding: 0 0.125rem; }

/* ── Disposición ──────────────────────────────────────────────────────────── */

.disposicion {
  display: grid;
  grid-template-columns: var(--ancho-nav) minmax(0, 1fr) var(--ancho-lateral);
  gap: 2.5rem;
  max-width: 96rem; margin: 0 auto; padding: 0 1.5rem;
}

.nav {
  position: sticky; top: var(--alto-cabecera); align-self: start;
  max-height: calc(100vh - var(--alto-cabecera)); overflow-y: auto;
  padding: 1.75rem 0 3rem;
}
.nav__grupo + .nav__grupo { margin-top: 1.5rem; }
.nav__titulo {
  margin: 0 0 0.5rem; padding-left: 0.75rem;
  font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: rgb(var(--s-ink-muted));
}
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav a {
  display: block; padding: 0.375rem 0.75rem; border-radius: 0.5rem;
  color: rgb(var(--s-ink-muted)); font-size: 0.875rem;
  border-left: 2px solid transparent;
}
.nav a:hover { background: rgb(var(--s-tint)); color: rgb(var(--s-ink)); text-decoration: none; }
.nav a.activo {
  background: rgb(var(--c-secondary) / 0.12);
  border-left-color: rgb(var(--c-secondary));
  color: rgb(var(--c-secondary)); font-weight: 600;
}

.contenido { min-width: 0; padding: 2.25rem 0 4rem; }

.lateral {
  position: sticky; top: var(--alto-cabecera); align-self: start;
  max-height: calc(100vh - var(--alto-cabecera)); overflow-y: auto;
  padding: 2.25rem 0 3rem;
}
.sumario__titulo {
  margin: 0 0 0.625rem;
  font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: rgb(var(--s-ink-muted));
}
.sumario ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid rgb(var(--s-line)); }
.sumario a {
  display: block; padding: 0.3125rem 0.875rem; margin-left: -1px;
  border-left: 2px solid transparent;
  color: rgb(var(--s-ink-muted)); font-size: 0.8125rem;
}
.sumario a:hover, .sumario a.activo {
  color: rgb(var(--c-secondary)); border-left-color: rgb(var(--c-secondary)); text-decoration: none;
}

/* ── Prosa ────────────────────────────────────────────────────────────────── */

.prosa { max-width: 52rem; }
.prosa h1 { font-size: 2rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 1rem; }
.prosa h2 {
  font-size: 1.375rem; line-height: 1.3; letter-spacing: -0.01em;
  margin: 2.75rem 0 0.875rem; padding-top: 1.5rem;
  border-top: 1px solid rgb(var(--s-line));
}
.prosa h3 { font-size: 1.0625rem; margin: 2rem 0 0.625rem; }
.prosa h2, .prosa h3 { position: relative; scroll-margin-top: calc(var(--alto-cabecera) + 1rem); }

.ancla {
  position: absolute; left: -1.25rem; width: 1.25rem;
  color: rgb(var(--s-ink-muted)); opacity: 0; font-weight: 400;
  transition: opacity 0.15s;
}
h2:hover .ancla, h3:hover .ancla, .ancla:focus { opacity: 1; text-decoration: none; }

.prosa p { margin: 0 0 1rem; }
.prosa ul, .prosa ol { margin: 0 0 1rem; padding-left: 1.375rem; }
.prosa li { margin-bottom: 0.375rem; }
.prosa li > ul, .prosa li > ol { margin-top: 0.375rem; }
.prosa strong { font-weight: 650; color: rgb(var(--s-ink)); }
.prosa hr { margin: 2.5rem 0; border: 0; border-top: 1px solid rgb(var(--s-line)); }

.prosa code {
  padding: 0.125rem 0.375rem; border-radius: 0.375rem;
  background: rgb(var(--s-tint)); border: 1px solid rgb(var(--s-line));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125em;
}
.prosa pre {
  margin: 0 0 1.25rem; padding: 1rem 1.125rem; overflow-x: auto;
  background: rgb(var(--s-sunken)); border: 1px solid rgb(var(--s-line)); border-radius: 0.75rem;
}
.prosa pre code { padding: 0; background: none; border: 0; font-size: 0.8125rem; }

.prosa table {
  width: 100%; margin: 0 0 1.5rem; border-collapse: collapse;
  border: 1px solid rgb(var(--s-line)); border-radius: 0.75rem; overflow: hidden;
  font-size: 0.875rem;
}
.prosa thead { background: rgb(var(--s-sunken)); }
.prosa th, .prosa td { padding: 0.625rem 0.875rem; text-align: left; border-bottom: 1px solid rgb(var(--s-line)); }
.prosa th { font-weight: 650; }
.prosa tbody tr:last-child td { border-bottom: 0; }

.prosa blockquote {
  margin: 0 0 1.25rem; padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid rgb(var(--s-line)); color: rgb(var(--s-ink-muted));
}

/* Las tablas anchas se desplazan solas en lugar de romper la página. */
.prosa .tabla-ancha { overflow-x: auto; }

/* ── Capturas ─────────────────────────────────────────────────────────────── */

.captura { margin: 1.5rem 0 1.75rem; }
.captura__lupa {
  display: block; width: 100%; padding: 0; cursor: zoom-in;
  background: rgb(var(--s-sunken));
  border: 1px solid rgb(var(--s-line)); border-radius: 0.875rem;
  overflow: hidden; box-shadow: var(--sombra);
  transition: border-color 0.15s;
}
.captura__lupa:hover { border-color: rgb(var(--c-secondary) / 0.6); }
.captura img { display: block; width: 100%; height: auto; }
.captura figcaption {
  margin-top: 0.625rem; font-size: 0.8125rem; color: rgb(var(--s-ink-muted)); text-align: center;
}

.visor { width: min(94vw, 1600px); padding: 0; border: 0; border-radius: 1rem; background: transparent; }
.visor::backdrop { background: rgb(0 0 0 / 0.82); }
.visor img { display: block; width: 100%; height: auto; border-radius: 1rem; }
.visor__cerrar {
  position: absolute; top: 0.75rem; right: 0.75rem;
  width: 2.25rem; height: 2.25rem; border: 0; border-radius: 50%;
  background: rgb(0 0 0 / 0.55); color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer;
}

/* ── Avisos ───────────────────────────────────────────────────────────────── */

.aviso {
  display: flex; gap: 0.875rem; align-items: flex-start;
  margin: 1.25rem 0; padding: 0.875rem 1.125rem;
  border: 1px solid rgb(var(--s-line)); border-left-width: 3px; border-radius: 0.75rem;
  background: rgb(var(--s-sunken));
}
.aviso__marca {
  display: grid; place-items: center; flex: none;
  width: 1.375rem; height: 1.375rem; margin-top: 0.1875rem; border-radius: 50%;
  font-size: 0.75rem; font-weight: 700; color: #fff;
}
.aviso__cuerpo { min-width: 0; }
.aviso__titulo { margin: 0 0 0.25rem; font-weight: 650; }
.aviso__cuerpo > :last-child { margin-bottom: 0; }

.aviso--nota    { border-left-color: rgb(var(--c-secondary)); }
.aviso--nota    .aviso__marca { background: rgb(var(--c-secondary)); }
.aviso--consejo { border-left-color: rgb(var(--c-success)); }
.aviso--consejo .aviso__marca { background: rgb(var(--c-success)); }
.aviso--aviso   { border-left-color: rgb(var(--c-warning)); }
.aviso--aviso   .aviso__marca { background: rgb(var(--c-warning)); }
.aviso--cuidado { border-left-color: rgb(var(--c-danger)); }
.aviso--cuidado .aviso__marca { background: rgb(var(--c-danger)); }

/* ── Portada ──────────────────────────────────────────────────────────────── */

.portada { padding: 1.5rem 0 0.5rem; }
.portada__logo { height: 4rem; width: auto; display: block; margin-bottom: 1.25rem; }
.portada__antetitulo {
  margin: 0 0 0.5rem;
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgb(var(--c-secondary));
}
.portada h1 { font-size: 2.5rem; }
.portada__entrada { font-size: 1.0625rem; color: rgb(var(--s-ink-muted)); max-width: 44rem; }

.tarjeta-seccion { margin-top: 2.75rem; }
.tarjeta-seccion h2 {
  margin: 0 0 0.375rem; padding: 0; border: 0;
  font-size: 1.25rem; scroll-margin-top: calc(var(--alto-cabecera) + 1rem);
}
.tarjeta-seccion__texto { margin: 0 0 1rem; color: rgb(var(--s-ink-muted)); }

.rejilla {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem;
}
.rejilla a {
  display: flex; flex-direction: column; gap: 0.25rem; height: 100%;
  padding: 0.875rem 1rem; border-radius: 0.875rem;
  border: 1px solid rgb(var(--s-line)); background: rgb(var(--s-surface));
  color: inherit; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.rejilla a:hover {
  text-decoration: none; transform: translateY(-2px);
  border-color: rgb(var(--c-secondary) / 0.55); box-shadow: var(--sombra);
}
.rejilla strong { font-size: 0.9375rem; }
.rejilla span { font-size: 0.8125rem; color: rgb(var(--s-ink-muted)); }

/* ── Pie de navegación ────────────────────────────────────────────────────── */

.pie {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid rgb(var(--s-line));
}
.pie__enlace {
  display: flex; flex-direction: column; gap: 0.125rem;
  padding: 0.75rem 1.125rem; border-radius: 0.875rem;
  border: 1px solid rgb(var(--s-line)); background: rgb(var(--s-surface)); color: inherit;
  max-width: 20rem; transition: border-color 0.15s;
}
.pie__enlace:hover { text-decoration: none; border-color: rgb(var(--c-secondary) / 0.55); }
.pie__enlace span { font-size: 0.75rem; color: rgb(var(--s-ink-muted)); }
.pie__enlace--adelante { text-align: right; }

/* ── Pantallas estrechas ──────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .disposicion { grid-template-columns: var(--ancho-nav) minmax(0, 1fr); }
  .lateral { display: none; }
}

@media (max-width: 860px) {
  .disposicion { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .cabecera__menu { display: flex; }
  .marca__texto small { display: none; }

  .nav {
    position: fixed; top: var(--alto-cabecera); bottom: 0; left: 0; z-index: 45;
    width: min(20rem, 84vw); max-height: none; padding: 1.5rem 1rem;
    background: rgb(var(--s-surface)); border-right: 1px solid rgb(var(--s-line));
    transform: translateX(-102%); transition: transform 0.22s ease;
  }
  .nav.abierta { transform: none; }

  .velo { position: fixed; inset: var(--alto-cabecera) 0 0; z-index: 44; background: rgb(0 0 0 / 0.45); }
  .buscador { max-width: none; }
  .prosa h1 { font-size: 1.625rem; }
  .portada h1 { font-size: 1.875rem; }
  .pie { flex-direction: column; }
  .pie__enlace { max-width: none; }
}

@media print {
  .cabecera, .nav, .lateral, .pie, .saltar, .ancla { display: none !important; }
  .disposicion { display: block; padding: 0; }
  .contenido { padding: 0; }
  .prosa { max-width: none; }
  .captura__lupa { box-shadow: none; }
  .prosa h2 { break-after: avoid; }
  .captura { break-inside: avoid; }
}
