/* Las páginas legales. Son documentos con índice, así que se montan como el
   manual público de la aplicación (static/css/publico.css): cabecera fija,
   panel de tinta con el índice numerado y el contenido al lado. El texto va en
   una hoja con el filo de la casa, sobre la teja del acceso (acceso.css).

   Las abren la aplicación y la landing, pero viven aquí y se sirven solas: los
   tokens y las medidas están copiados de static/css/autodoc.css y publico.css.
   Si se mueven allí, hay que moverlos aquí. Como la aplicación, siguen el modo
   del sistema; la landing es la única que va siempre a oscuras.

   Sin JavaScript se lee igual: se pierden el índice de la página (lo arma
   legal.js con los h2) y el inglés.

   Bloques: fuentes · tokens · base · cabecera · panel · hoja · texto · tablas ·
   pie · pantalla estrecha · impresión. */

@font-face { font-family: "Space Grotesk"; src: url("../fonts/space-grotesk-latin.woff2") format("woff2"); font-weight: 400 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Space Grotesk"; src: url("../fonts/space-grotesk-latin-ext.woff2") format("woff2"); font-weight: 400 700; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-latin-ext.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* --- Tokens ---------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --tinta: #1B2230;
  --tinta-fuerte: #12161F;
  --tinta-tenue: #ECEDF1;
  --acento: #D89A3C;
  --acento-texto: #8F5F14;  /* el ámbar se queda en 2,4:1 sobre blanco: las letras van en este */
  --sobre-tinta: #FFFFFF;

  --texto: #1A1E26;
  --texto-medio: #454B57;
  --texto-tenue: #666D7B;

  --fondo: #F5F4F1;
  --superficie: #FFFFFF;
  --superficie-baja: #FBFAF7;
  --borde: #E2E0DA;
  --borde-suave: #EBE9E3;
  --hondo: #1B2230;

  --panel: #1B2230;
  --panel-texto: #E7E9EE;
  --panel-tenue: #9AA1B0;
  --panel-linea: rgba(255, 255, 255, .1);
  --panel-actual: rgba(255, 255, 255, .07);

  --sombra: 18 22 31;
  --teja: url("../img/patron.png");

  --alto-cabecera: 64px;
  --ancho-lateral: 272px;
  --radio-caja: 10px;
  --filo: 3px;
  --filo-ambar: 56px;

  --display: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tinta: #E6E4DF;
    --tinta-fuerte: #F5F4F1;
    --tinta-tenue: #252A35;
    --acento-texto: #E3B567;
    --sobre-tinta: #12161F;

    --texto: #DAD8D3;
    --texto-medio: #BABEC6;
    --texto-tenue: #888E9A;

    --fondo: #0F1217;
    --superficie: #171B22;
    --superficie-baja: #1B2028;
    --borde: #2A2F39;
    --borde-suave: #222731;
    --hondo: #0A0C10;

    --panel: #181C24;

    --sombra: 0 0 0;
    --teja: url("../img/patron-oscuro.png");
  }
}

/* --- Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--alto-cabecera) + 24px); }
/* El fundido entre un documento y otro, el de la aplicación. */
@view-transition { navigation: auto; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--fondo) var(--teja) repeat;
  background-size: 256px 256px;
  color: var(--texto);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--tinta); outline-offset: 2px; }
.lateral :focus-visible { outline-color: var(--panel-texto); outline-offset: -2px; }

.saltar {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 4;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--tinta);
  color: var(--sobre-tinta);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.saltar:focus { transform: none; }

/* --- Cabecera -------------------------------------------------------------- */

.cabecera {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 18px;
  height: var(--alto-cabecera);
  padding: 0 24px;
  background: var(--superficie);
  border-bottom: 1px solid var(--borde);
}
.cabecera__marca { display: block; flex-shrink: 0; border-radius: 6px; }
.cabecera__marca img { display: block; width: auto; height: 30px; }
.cabecera picture { display: contents; }
.cabecera__separador { width: 1px; height: 30px; flex-shrink: 0; background: var(--borde); }
.cabecera__nombre {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--tinta);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* El selector de idioma de la aplicación: dos botones en una cápsula. */
.idioma {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--borde);
  border-radius: 999px;
}
.idioma-opcion {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--superficie);
  color: var(--texto-medio);
  cursor: pointer;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  transition: background 140ms ease, color 140ms ease;
}
.idioma-opcion:hover { background: var(--tinta-tenue); color: var(--tinta-fuerte); }
.idioma-opcion.es-actual, .idioma-opcion.es-actual:hover { background: var(--tinta); color: var(--superficie); cursor: default; }

/* --- Panel ------------------------------------------------------------------
   Corre entero de arriba abajo, y lo que lleva dentro se queda quieto mientras
   rueda el texto. */

.pagina { flex: 1 0 auto; display: flex; }

.lateral {
  flex: 0 0 var(--ancho-lateral);
  width: var(--ancho-lateral);
  background: var(--panel);
  color: var(--panel-texto);
}
.lateral__dentro {
  position: sticky;
  top: var(--alto-cabecera);
  max-height: calc(100vh - var(--alto-cabecera));
  max-height: calc(100dvh - var(--alto-cabecera));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 0 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-tenue) transparent;
}

.lateral__titulo {
  display: block;
  margin: 0 0 10px;
  padding: 0 24px;
  color: var(--panel-tenue);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .22em;
  line-height: 1.6;
  text-transform: uppercase;
  list-style: none;
}
.lateral__titulo::-webkit-details-marker { display: none; }

.documentos { display: flex; flex-direction: column; }
.documentos__enlace {
  padding: 7px 18px 7px 24px;
  color: var(--panel-texto);
  font-size: .92rem;
  line-height: 1.4;
  text-decoration: none;
  transition: background-color .15s;
}
.documentos__enlace:hover { background: var(--panel-actual); }
.documentos__enlace[aria-current] {
  background: var(--panel-actual);
  box-shadow: inset 3px 0 0 var(--acento);
  font-weight: 600;
}

.indice { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--panel-linea); }
@media (min-width: 960px) {
  .indice summary { pointer-events: none; }
}

/* Las etapas de un camino, como los pasos del manual: el número en un círculo
   y una línea que enhebra todos. El apartado en el que se está va en ámbar. */
.indice__lista { position: relative; margin: 0; padding: 0; list-style: none; }
.indice__lista::before {
  content: "";
  position: absolute;
  left: 35px;               /* el centro de los círculos: 24 de relleno + 12 */
  top: 20px;
  bottom: 20px;
  width: 2px;
  background: var(--panel-linea);
}
.indice__enlace {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 7px 18px 7px 24px;
  color: var(--panel-texto);
  font-size: .92rem;
  line-height: 1.4;
  text-decoration: none;
  transition: background-color .15s;
}
.indice__enlace:hover { background: var(--panel-actual); }
.indice__enlace.es-actual { background: var(--panel-actual); box-shadow: inset 3px 0 0 var(--acento); }
.indice__numero {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-top: -1px;
  border: 2px solid var(--panel-linea);
  border-radius: 50%;
  background: var(--panel);
  color: var(--panel-tenue);
  font-size: .7rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: background-color .15s, border-color .15s, color .15s;
}
.indice__enlace.es-pasado .indice__numero { border-color: var(--panel-tenue); color: var(--panel-texto); }
.indice__enlace.es-actual .indice__numero { background: var(--acento); border-color: var(--acento); color: var(--panel); }
.indice__enlace.es-actual .indice__texto { font-weight: 600; }

/* --- Hoja ------------------------------------------------------------------- */

.contenido { flex: 1 1 auto; min-width: 0; padding: 40px 32px 64px; }

.hoja {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  padding: 44px 56px 56px;
  border: 1px solid var(--borde);
  border-top: 0;
  border-radius: 0 0 var(--radio-caja) var(--radio-caja);
  background: var(--superficie);
  box-shadow: 0 18px 44px -32px rgb(var(--sombra) / .3);
}
.hoja::before {
  content: "";
  position: absolute;
  inset: 0 -1px auto;
  height: var(--filo);
  background: linear-gradient(to right, var(--acento) 0 var(--filo-ambar), var(--tinta) var(--filo-ambar));
}

.antetitulo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 20px;
  color: var(--tinta);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .2em;
  line-height: 1.4;
  text-transform: uppercase;
}
.antetitulo::before { content: ""; width: 34px; height: 2px; flex-shrink: 0; background: var(--acento); }

/* --- Texto ------------------------------------------------------------------ */

h1, h2 { color: var(--tinta-fuerte); font-family: var(--display); text-wrap: balance; }
h1 { margin: 0 0 10px; font-size: clamp(2rem, 5vw, 2.75rem); font-weight: 600; letter-spacing: -.03em; line-height: 1.08; }
h2 {
  margin: 40px 0 12px;
  padding-top: 32px;
  border-top: 1px solid var(--borde-suave);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.25;
}
p, ul { margin: 0 0 14px; }
p:last-child, ul:last-child { margin-bottom: 0; }
ul { padding-left: 1.25rem; }
li { margin-bottom: 6px; padding-left: 2px; }
li::marker { color: var(--acento); }
strong { color: var(--tinta-fuerte); font-weight: 600; }
a { color: var(--tinta); text-decoration: underline; text-decoration-color: var(--acento); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--acento-texto); }

.legal-fecha { margin: 0 0 28px; color: var(--texto-tenue); font-size: .875rem; }

/* Lo esencial de cada documento, con el filo de ámbar a la izquierda: la pieza
   del token recién creado, lo que no hay que dejar de leer. */
.legal-resumen {
  margin: 0 0 8px;
  padding: 16px 20px;
  border: 1px solid var(--borde);
  border-left: 3px solid var(--acento);
  border-radius: var(--radio-caja);
  background: var(--superficie-baja);
  color: var(--tinta-fuerte);
  font-size: 1.03rem;
  line-height: 1.55;
  text-wrap: pretty;
}

/* --- Tablas: las de la aplicación ------------------------------------------- */

table {
  width: 100%;
  margin: 18px 0;
  border: 1px solid var(--borde);
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radio-caja);
  font-size: .92rem;
  line-height: 1.5;
  overflow: hidden;
}
th, td { padding: 12px 16px; border-bottom: 1px solid var(--borde-suave); text-align: left; vertical-align: top; }
tr:last-child > td { border-bottom: 0; }
th {
  background: var(--superficie-baja);
  color: var(--texto-tenue);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
td:first-child { color: var(--tinta-fuerte); }

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

.pie {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  padding: 16px 20px;
  background: var(--hondo);
  color: #FFFFFF;
  font-size: 13px;
  line-height: 1.5;
}
.pie a { color: inherit; text-decoration-color: rgba(255, 255, 255, .4); }
.pie a:hover { color: inherit; text-decoration-color: currentColor; }
@media (prefers-color-scheme: dark) {
  .pie { border-top: 1px solid var(--borde-suave); color: var(--texto-medio); }
}

/* --- Pantalla estrecha ------------------------------------------------------
   El panel pasa a ser una banda encima de la hoja: los cuatro documentos, y el
   índice plegado (legal.js lo abre solo en pantalla ancha). */

@media (max-width: 959px) {
  html { scroll-padding-top: calc(var(--alto-cabecera) + 16px); }
  .pagina { display: block; }
  .lateral { width: 100%; }
  .lateral__dentro { position: static; max-height: none; padding: 14px 0; overflow: visible; }
  .lateral__dentro > .lateral__titulo { display: none; }
  .documentos { flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 0 12px; }
  .documentos__enlace { padding: 6px 10px; border-radius: 999px; font-size: .8125rem; white-space: nowrap; }
  .documentos__enlace[aria-current] { background: var(--acento); box-shadow: none; color: var(--panel); }
  .indice { margin-top: 12px; padding-top: 12px; }
  .indice summary { display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 4px 24px; cursor: pointer; }
  .indice summary::after {
    content: "";
    width: 8px;
    height: 8px;
    margin-right: 3px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform .15s;
  }
  .indice[open] summary::after { transform: translateY(2px) rotate(-135deg); }
  .indice__lista { margin-top: 8px; }
  .contenido { padding: 20px 14px 40px; }
  .hoja { padding: 32px 28px 40px; }
}

@media (max-width: 640px) {
  .cabecera { gap: 12px; padding: 0 16px; }
  .cabecera__separador, .cabecera__nombre { display: none; }
  .idioma { margin-left: auto; }
  .hoja { padding: 28px 20px 32px; }

  /* Tres columnas no caben: cada fila, una ficha. El rótulo de cada celda lo
     pone legal.js en data-rotulo; sin él, las celdas se apilan igual. */
  table, tbody, tr, td { display: block; }
  tr:has(> th) { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); }
  tr { padding: 12px 16px; border-bottom: 1px solid var(--borde-suave); }
  tr:last-child { border-bottom: 0; }
  td, tr:last-child > td { padding: 0; border: 0; }
  td + td { margin-top: 8px; }
  td:first-child { font-weight: 600; }
  td[data-rotulo]:not(:first-child)::before {
    content: attr(data-rotulo);
    display: block;
    margin-bottom: 1px;
    color: var(--texto-tenue);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  @view-transition { navigation: none; }
}

/* --- Impresión: papel blanco, y solo el documento ---------------------------- */

@page { margin: 18mm 20mm; }

@media print {
  :root {
    color-scheme: light;
    --tinta: #1B2230;
    --tinta-fuerte: #12161F;
    --acento-texto: #1B2230;
    --texto: #1A1E26;
    --texto-tenue: #555;
    --superficie: #fff;
    --superficie-baja: #fff;
    --borde: #ccc;
    --borde-suave: #ddd;
  }
  body { background: #fff; display: block; font-size: 11pt; }
  .saltar, .cabecera, .lateral, .pie { display: none; }
  .pagina { display: block; }
  .contenido { padding: 0; }
  .hoja { max-width: none; padding: 0; border: 0; box-shadow: none; }
  .hoja::before { display: none; }
  .antetitulo::before { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  h2 { break-after: avoid; }
  tr { break-inside: avoid; }
}
