/* ==========================================================================
   Celero AI — sistema visual de las páginas legales
   Paleta tomada del logo: azul #78A1FB · tinta #282627 · papel blanco
   ========================================================================== */

:root {
  color-scheme: light;

  --paper:        #FDFDFE;
  --paper-raise:  #FFFFFF;
  --paper-soft:   #F5F7FB;
  --ink:          #1B1D22;
  --ink-soft:     #3E424C;
  --muted:        #6E7382;
  --line:         #E4E7EE;
  --line-strong:  #CDD3E0;

  --accent:       #78A1FB;   /* azul de marca — trazos, marcas, filetes */
  --accent-ink:   #2C4FC0;   /* azul legible sobre papel — enlaces y textos */
  --accent-h1:    #5578EC;   /* azul de titulares: solo texto grande */
  --accent-wash:  #EFF4FE;
  --accent-line:  #C6D7FE;

  --shadow: 0 1px 2px rgba(27, 29, 34, .04), 0 12px 32px -18px rgba(27, 29, 34, .18);

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans:  "Familjen Grotesk", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --measure: 68ch;
  --gutter: clamp(20px, 5vw, 56px);
}

/* El tema claro es el predefinido a proposito: NO se sigue prefers-color-scheme.
   El oscuro entra solo si el visitante pulsa el conmutador (data-theme="dark"). */

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:       #101217;
  --paper-raise: #171A21;
  --paper-soft:  #1A1E26;
  --ink:         #EDEFF5;
  --ink-soft:    #C6CAD6;
  --muted:       #8E95A6;
  --line:        #262B35;
  --line-strong: #39404E;
  --accent:      #8FB0FF;
  --accent-ink:  #AFC7FF;
  --accent-h1:   #9DBAFF;
  --accent-wash: #172033;
  --accent-line: #2C3A55;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 40px -22px rgba(0, 0, 0, .7);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(16.5px, 0.98rem + 0.18vw, 18.5px);
  line-height: 1.68;
  font-variant-numeric: oldstyle-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* halo atmosférico: azul de marca muy diluido, solo en la parte alta */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 60vh;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(90% 100% at 22% -20%, color-mix(in oklab, var(--accent) 14%, transparent) 0%, transparent 62%),
    radial-gradient(60% 90% at 92% -30%, color-mix(in oklab, var(--accent) 9%, transparent) 0%, transparent 70%);
}

/* ---------- barra de progreso de lectura ---------- */
#progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--accent), color-mix(in oklab, var(--accent) 55%, var(--accent-ink)));
  z-index: 60;
}

/* ---------- barra superior ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px var(--gutter);
  background: color-mix(in oklab, var(--paper) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid transparent;
  transition: border-color .25s ease, background .25s ease;
}
.topbar[data-stuck="true"] { border-bottom-color: var(--line); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  border-bottom: 0;
}
.brand img { display: block; height: 23px; width: auto; }
.brand-word {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.04rem;
  letter-spacing: -.022em;
  color: var(--ink);
  line-height: 1;
}
.brand-word span { color: var(--accent-ink); margin-left: .28em; }
.brand .logo-dark { display: none; }
:root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }

.topbar nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 22px);
}
.topbar nav a {
  font-family: var(--sans);
  font-size: .84rem;
  letter-spacing: -.005em;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 2px;
  border-bottom: 1px solid transparent;
  transition: color .18s ease, border-color .18s ease;
}
.topbar nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }
.topbar nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-raise);
  color: var(--muted);
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, transform .18s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ---------- estructura ---------- */
.shell { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }

.hero { padding: clamp(44px, 8vw, 92px) 0 clamp(28px, 4vw, 44px); }
.eyebrow {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin: 0 0 clamp(16px, 3vw, 26px);
  display: flex;
  align-items: center;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}
.eyebrow::after {
  content: "";
  flex: 1 1 auto;
  max-width: 180px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent-line), transparent);
}

h1 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(2.05rem, 1.25rem + 3vw, 3.35rem);
  line-height: 1.03;
  letter-spacing: -.028em;
  margin: 0;
  max-width: 22ch;
  text-wrap: balance;
}
h1 em {
  font-style: normal;
  color: var(--accent-h1);
}

.lede {
  max-width: 56ch;
  margin: clamp(18px, 3vw, 26px) 0 0;
  font-size: 1.06em;
  color: var(--ink-soft);
}

.stamp {
  margin: clamp(24px, 4vw, 34px) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.stamp b { color: var(--ink); font-weight: 500; }

/* ---------- resumen en lenguaje claro ---------- */
.tldr {
  margin: clamp(30px, 5vw, 48px) 0 0;
  padding: clamp(22px, 3.4vw, 34px);
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.tldr > h2 {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}
.tldr ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 16px; }
@media (min-width: 760px) { .tldr ol { grid-template-columns: 1fr 1fr; gap: 18px 34px; } }
.tldr li {
  margin: 0;
  padding-left: 34px;
  position: relative;
  font-size: .96em;
  color: var(--ink-soft);
}
.tldr li::before {
  content: counter(list-item, decimal-leading-zero);
  position: absolute;
  left: 0; top: .18em;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .06em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.tldr strong { color: var(--ink); font-weight: 600; }

/* ---------- cuerpo a dos columnas ---------- */
.layout { display: block; padding: clamp(40px, 7vw, 80px) 0 0; }
@media (min-width: 1040px) {
  .layout {
    display: grid;
    grid-template-columns: 216px minmax(0, 1fr);
    gap: clamp(40px, 5vw, 78px);
    align-items: start;
  }
}

/* índice lateral */
.toc { display: none; }
@media (min-width: 1040px) {
  .toc {
    display: block;
    position: sticky;
    top: 84px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    padding-right: 6px;
  }
}
.toc h2 {
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 500;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 4px;
  align-items: baseline;
  padding: 6px 0 6px 11px;
  margin-left: -12px;
  border: 0;
  border-left: 2px solid transparent;
  font-family: var(--sans);
  font-size: .82rem;
  line-height: 1.35;
  letter-spacing: -.004em;
  color: var(--muted);
  text-decoration: none;
  transition: color .18s ease, border-color .18s ease;
}
.toc a span:first-child {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .05em;
  color: var(--line-strong);
  font-variant-numeric: tabular-nums;
  transition: color .18s ease;
}
.toc a:hover { color: var(--ink); }
.toc a:hover span:first-child { color: var(--accent); }
.toc a.is-active {
  color: var(--ink);
  border-left-color: var(--accent);
}
.toc a.is-active span:first-child { color: var(--accent); }

/* índice plegable, solo en pantallas angostas */
.toc-m {
  margin: 0 0 clamp(30px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-raise);
}
@media (min-width: 1040px) { .toc-m { display: none; } }
.toc-m summary {
  cursor: pointer;
  list-style: none;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: .66rem;
  font-weight: 500;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc-m summary::-webkit-details-marker { display: none; }
.toc-m summary::after {
  content: "";
  margin-left: auto;
  width: 7px; height: 7px;
  border-right: 1.6px solid var(--accent);
  border-bottom: 1.6px solid var(--accent);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .2s ease;
}
.toc-m[open] summary::after { transform: rotate(225deg) translateY(1px); }
.toc-m ol { list-style: none; margin: 0; padding: 0 18px 12px; }
.toc-m li { margin: 0; }
.toc-m a {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 4px;
  padding: 8px 0;
  border: 0;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: .89rem;
  line-height: 1.35;
  color: var(--ink-soft);
}
.toc-m li:first-child a { border-top: 0; }
.toc-m a span:first-child {
  font-family: var(--mono);
  font-size: .66rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 620px) {
  .topbar nav a.hide-sm { display: none; }
}

/* ---------- artículo ---------- */
article { max-width: var(--measure); padding-bottom: clamp(60px, 9vw, 110px); }

section { scroll-margin-top: 84px; padding-top: clamp(34px, 5vw, 54px); }
section + section { margin-top: clamp(6px, 1vw, 12px); }

h2 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(1.4rem, 1.1rem + .85vw, 1.78rem);
  line-height: 1.16;
  letter-spacing: -.02em;
  margin: 0 0 .7em;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  position: relative;
  text-wrap: balance;
}
h2::before {
  content: "";
  position: absolute;
  top: -1px; left: 0;
  width: 46px; height: 1px;
  background: var(--accent);
}
h2 .num {
  display: block;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .16em;
  color: var(--accent-ink);
  margin-bottom: .85em;
  font-variant-numeric: tabular-nums;
}

h3 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.03rem;
  letter-spacing: -.008em;
  margin: 2.1em 0 .5em;
  color: var(--ink);
}

p { margin: 0 0 1.05em; }
p:last-child, ul:last-child, ol:last-child, table:last-child { margin-bottom: 0; }

a {
  color: var(--accent-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
  transition: border-color .18s ease, color .18s ease;
}
a:hover { border-bottom-color: var(--accent-ink); }
:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 3px;
  border-radius: 3px;
}

ul, ol { margin: 0 0 1.15em; padding-left: 1.35em; }
li { margin: .42em 0; }
li::marker { color: var(--accent); }
ul.plain { list-style: none; padding-left: 0; }
ul.plain > li {
  padding-left: 22px;
  position: relative;
}
ul.plain > li::before {
  content: "";
  position: absolute;
  left: 2px; top: .66em;
  width: 7px; height: 7px;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
}

strong { font-weight: 600; color: var(--ink); }
em { font-style: italic; }

.chip {
  font-family: var(--mono);
  font-size: .78em;
  font-weight: 500;
  letter-spacing: .04em;
  padding: .12em .45em;
  background: var(--accent-wash);
  border: 1px solid var(--accent-line);
  border-radius: 5px;
  color: var(--accent-ink);
  white-space: nowrap;
}

/* ---------- tablas ---------- */
.tw {
  margin: 1.6em 0;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  min-width: 460px;
  border-collapse: collapse;
  font-size: .88em;
  line-height: 1.5;
}
thead th {
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 500;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 0 18px .7em 0;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
tbody td, tbody th {
  padding: .85em 18px .85em 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}
tbody th { font-weight: 600; font-family: var(--sans); font-size: .95em; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom-color: var(--line-strong); }
thead th:last-child, tbody td:last-child, tbody th:last-child { padding-right: 0; }

/* ---------- avisos ---------- */
.note {
  margin: 1.7em 0;
  padding: 18px 22px;
  background: var(--paper-soft);
  border-left: 2px solid var(--accent);
  border-radius: 0 12px 12px 0;
  font-size: .94em;
  color: var(--ink-soft);
}
.note > :last-child { margin-bottom: 0; }
.note .label {
  display: block;
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: .5em;
}

.keybox {
  margin: 1.8em 0;
  padding: clamp(22px, 3vw, 30px);
  background: var(--accent-wash);
  border: 1px solid var(--accent-line);
  border-radius: 16px;
}
.keybox > :last-child { margin-bottom: 0; }
.keybox h3:first-child { margin-top: 0; }

.steps { counter-reset: step; list-style: none; padding-left: 0; margin: 1.2em 0; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 44px;
  margin: 0 0 1.1em;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: .05em;
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  background: var(--paper-raise);
  font-family: var(--mono);
  font-size: .74rem;
  font-weight: 500;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

/* ficha de datos (responsable / contacto) */
.facts {
  margin: 1.6em 0;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line-strong);
}
.facts > div {
  display: grid;
  grid-template-columns: minmax(120px, 30%) 1fr;
  gap: 10px 20px;
  padding: .8em 0;
  border-bottom: 1px solid var(--line);
  font-size: .94em;
}
.facts dt, .facts .k {
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: .35em;
}
.facts dd, .facts .v { margin: 0; color: var(--ink); }

/* ---------- pie ---------- */
.foot {
  border-top: 1px solid var(--line);
  padding: clamp(36px, 6vw, 58px) 0 clamp(48px, 7vw, 76px);
  font-size: .86em;
  color: var(--muted);
}
.foot .grid {
  display: grid;
  gap: 28px;
}
@media (min-width: 780px) { .foot .grid { grid-template-columns: 1.3fr 1fr; gap: 48px; } }
.foot img { height: 54px; width: auto; display: block; margin: 0 0 18px -4px; }
.foot .logo-dark { display: none; }
:root[data-theme="dark"] .foot .logo-light { display: none; }
:root[data-theme="dark"] .foot .logo-dark { display: block; }
.foot p { margin: 0 0 .7em; }
.foot a { color: var(--ink-soft); border-bottom-color: var(--line-strong); }
.foot a:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }
.foot .links { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 14px; }
.foot .fine { font-family: var(--mono); font-size: .68rem; letter-spacing: .04em; line-height: 1.7; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 99;
  background: var(--paper-raise);
  border: 1px solid var(--accent);
  padding: 10px 16px;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: .85rem;
}
.skip:focus { left: var(--gutter); }

/* ---------- centro legal (index) ---------- */
.cards {
  display: grid;
  gap: 18px;
  margin: clamp(34px, 5vw, 52px) 0 0;
}
@media (min-width: 760px) { .cards { grid-template-columns: 1fr 1fr; gap: 22px; } }
.card {
  display: block;
  padding: clamp(24px, 3.4vw, 34px);
  background: var(--paper-raise);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-line);
  box-shadow: 0 1px 2px rgba(27, 29, 34, .05), 0 22px 44px -22px rgba(44, 79, 192, .3);
}
.card .k {
  font-family: var(--mono);
  font-size: .64rem;
  font-weight: 500;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.card h2 {
  font-size: 1.28rem;
  border: 0;
  padding: 0;
  margin: .6em 0 .45em;
}
.card h2::before { display: none; }
.card p { color: var(--ink-soft); font-size: .94em; margin: 0; }
.card .go {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 1.1em;
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--accent-ink);
}
.card:hover .go svg { transform: translateX(3px); }
.card .go svg { width: 13px; height: 13px; transition: transform .22s ease; }

/* ---------- entrada escalonada ---------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: rise .7s cubic-bezier(.22, .68, .28, 1) both; }
  .reveal:nth-child(1) { animation-delay: .02s; }
  .reveal:nth-child(2) { animation-delay: .09s; }
  .reveal:nth-child(3) { animation-delay: .16s; }
  .reveal:nth-child(4) { animation-delay: .23s; }
  .reveal:nth-child(5) { animation-delay: .3s; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
  }
}

/* ---------- impresión ---------- */
@media print {
  :root { --paper: #fff; --paper-raise: #fff; --paper-soft: #fff; --ink: #000; --ink-soft: #1a1a1a; --muted: #444; --line: #bbb; --line-strong: #888; --accent: #666; --accent-ink: #000; --accent-wash: #fff; --accent-line: #999; --shadow: none; }
  body { font-size: 10.5pt; line-height: 1.5; }
  body::before, #progress, .topbar, .toc, .toc-m, .theme-toggle, .skip { display: none !important; }
  .shell { max-width: none; padding: 0; }
  .layout { display: block; padding-top: 0; }
  article { max-width: none; }
  .tldr, .keybox, .note, .card { border: 1px solid #999; box-shadow: none; }
  section { page-break-inside: avoid; padding-top: 16pt; }
  h1, h2, h3 { page-break-after: avoid; }
  a { color: #000; border-bottom: 0; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-family: var(--mono); font-size: 8pt; color: #444; }
  .hero { padding: 0 0 12pt; }
}
