/* ═══════════════════════════════════════════════════════════
   SalsifyTraining — hoja de estilos compartida
   La usan el hub de la ruta y todas las paginas de modulo.
   Cada pagina define su propio --accent en un <style> corto.
   ═══════════════════════════════════════════════════════════ */

:root {
  --assets-version: "20260818";   /* si esta línea no está, el CSS es viejo */
  --bg:        #0b1224;
  --bg-deep:   #070d1b;
  --panel:     #111c33;
  --panel-hi:  #16243f;
  --line:      #23334f;
  --line-soft: #1a2740;
  --text:      #e8eef9;
  --muted:     #93a4c4;
  --focus:     #7aa2ff;
  --grid:      rgba(122,162,255,.075);
  --shadow:    0 18px 40px -24px rgba(0,0,0,.9);

  --ok:   #34d399;
  --bad:  #f87171;
  --warn: #fbbf24;

  --accent:      #8a25f9;   /* lo sobreescribe cada pagina */
  --accent-soft: #b57bff;

  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --body:    'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  --r:   14px;
  --toc: 268px;
}

html[data-theme="light"] {
  --bg:        #f1f4fb;
  --bg-deep:   #e7ecf7;
  --panel:     #ffffff;
  --panel-hi:  #f8faff;
  --line:      #dbe2f1;
  --line-soft: #e6ebf6;
  --text:      #101a2e;
  --muted:     #55658a;
  --grid:      rgba(30,64,140,.07);
  --shadow:    0 18px 40px -28px rgba(23,42,84,.35);
  --ok:   #0f9d63;
  --bad:  #d93b3b;
  --warn: #b7791f;
  --accent-soft: #6d1fc7;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  transition: background .35s ease, color .35s ease;
}

.sheet {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 38px 38px;
  -webkit-mask-image: radial-gradient(120% 80% at 50% 0%, #000 30%, transparent 100%);
          mask-image: radial-gradient(120% 80% at 50% 0%, #000 30%, transparent 100%);
}
.bloom {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(56vw 40vh at 80% -10%, color-mix(in srgb, var(--accent) 24%, transparent) 0%, transparent 70%);
}

a { color: var(--accent-soft); }

/* ═══════════ BARRA SUPERIOR ═══════════ */
.bar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 26px;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.crumbs { display: flex; align-items: center; gap: 8px; margin-right: auto; min-width: 0; }
.crumbs a, .crumbs span {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.crumbs a:hover { color: var(--text); }
.crumbs .sep { opacity: .45; }
.crumbs .here { color: var(--text); overflow: hidden; text-overflow: ellipsis; }

.bar-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex-shrink: 0;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--line); border-radius: 9px;
  cursor: pointer; text-decoration: none;
  transition: color .2s, border-color .2s, background .2s;
}
.bar-btn:hover { color: var(--text); border-color: var(--accent); }
.bar-btn.wide { width: auto; padding: 0 13px; gap: 7px; font-family: var(--mono); font-size: 11.5px; }

.toc-toggle { display: none; }

/* ═══════════ BUSCADOR DEL DOCUMENTO ═══════════ */
.search { position: relative; flex: 0 1 290px; min-width: 0; }
.search-btn { display: none; }

.search .field { position: relative; }
.search input {
  width: 100%;
  font-family: var(--body); font-size: 13.5px; color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 42px 9px 34px;
  transition: border-color .2s, box-shadow .2s;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: grid; pointer-events: none; }
.search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
  pointer-events: none;
}
.search input:focus ~ kbd { opacity: 0; }

.results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 60;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: min(62vh, 440px); overflow-y: auto;
  display: none;
}
.results.on { display: block; }
.results .count {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding: 11px 15px 8px; border-bottom: 1px solid var(--line-soft);
}
.results a {
  display: block; padding: 11px 15px;
  text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--line-soft);
}
.results a:last-child { border-bottom: none; }
.results a:hover, .results a.cur { background: var(--panel-hi); }
.results .sec {
  display: block; margin-bottom: 4px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .09em;
  text-transform: uppercase; color: var(--accent-soft);
}
.results .snip { font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.results mark {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--text); border-radius: 3px; padding: 0 2px;
}
.results .none { padding: 20px 15px; font-size: 14px; color: var(--muted); }
.results .none b { color: var(--text); }

/* resaltado del bloque al que se salta */
@keyframes flash {
  0%, 55% { background: color-mix(in srgb, var(--accent) 26%, transparent); }
  100%    { background: transparent; }
}
.hit, .hit td { animation: flash 2.4s ease-out both; border-radius: 4px; }

/* barra de progreso de lectura */
.readbar {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: var(--accent); z-index: 50;
  transition: width .1s linear;
}

/* ═══════════ LAYOUT DE DOCUMENTO ═══════════ */
.doc {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--toc) minmax(0, 1fr);
  gap: 0 46px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 26px 96px;
}

/* ── Indice lateral ── */
.toc {
  position: sticky; top: 72px;
  align-self: start;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 34px 0 40px;
  scrollbar-width: thin;
}
.toc-title {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted);
  padding-bottom: 12px; margin-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.toc a {
  display: block;
  padding: 5px 12px 5px 14px;
  border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none;
  font-size: 13.5px; line-height: 1.45;
  transition: color .18s, border-color .18s, background .18s;
}
.toc a:hover { color: var(--text); }
.toc a.lv3 { padding-left: 26px; font-size: 12.5px; }
.toc a.on { color: var(--text); border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); }
.toc a.lv2 { font-weight: 600; margin-top: 6px; }

/* ── Cuerpo ── */
.main { min-width: 0; padding-top: 34px; }

.hero { padding: 26px 0 40px; border-bottom: 1px solid var(--line-soft); margin-bottom: 40px; }
.kicker {
  font-family: var(--mono); font-size: 11px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--accent-soft);
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
}
.kicker::after { content: ''; height: 1px; flex: 1; background: linear-gradient(to right, var(--line), transparent); }

.hero h1 {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(2.1rem, 5.4vw, 3.3rem);
  line-height: 1.02; letter-spacing: -.03em;
}
.hero .sub { color: var(--muted); margin-top: 16px; max-width: 60ch; }

.facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.facts span {
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em;
  color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px;
}

/* ── Tipografia de contenido ── */
.main h2 {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(1.45rem, 3.2vw, 1.95rem);
  letter-spacing: -.02em; line-height: 1.15;
  margin: 64px 0 6px;
  padding-top: 26px;
  border-top: 1px solid var(--line-soft);
  scroll-margin-top: 80px;
}
.main h2:first-of-type { margin-top: 0; border-top: none; padding-top: 0; }
.main h3 {
  font-family: var(--display); font-weight: 600;
  font-size: 1.16rem; letter-spacing: -.01em;
  margin: 40px 0 10px;
  color: var(--text);
  scroll-margin-top: 80px;
}
.main h3::before {
  content: ''; display: inline-block;
  width: 6px; height: 6px; border-radius: 2px;
  background: var(--accent); margin-right: 10px;
  vertical-align: middle;
}
.main p  { margin: 0 0 14px; max-width: 74ch; }
.main ul, .main ol { margin: 0 0 16px; padding-left: 22px; max-width: 74ch; }
.main li { margin-bottom: 7px; }
.main li::marker { color: var(--accent-soft); }
.main strong { color: var(--text); font-weight: 600; }
.main em { color: var(--muted); }

/* termino en ingles */
.en {
  font-family: var(--mono); font-size: .86em;
  color: var(--accent-soft);
}
.small { font-size: 13.5px; color: var(--muted); }

/* ── Tablas ── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin: 0 0 22px;
  background: var(--panel);
  -webkit-overflow-scrolling: touch;
  /* sombras que aparecen solo cuando la tabla se desborda */
  background-image:
    linear-gradient(to right,  var(--panel), transparent),
    linear-gradient(to left,   var(--panel), transparent),
    linear-gradient(to right,  rgba(0,0,0,.28), transparent),
    linear-gradient(to left,   rgba(0,0,0,.28), transparent);
  background-position: 0 0, 100% 0, 0 0, 100% 0;
  background-repeat: no-repeat;
  background-size: 26px 100%, 26px 100%, 13px 100%, 13px 100%;
  background-attachment: local, local, scroll, scroll;
}
.main table { border-collapse: collapse; width: 100%; min-width: 600px; font-size: 14.5px; background: transparent; }
.main th {
  text-align: left; font-family: var(--mono); font-weight: 500;
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  padding: 13px 16px;
  background: var(--panel-hi);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.main td {
  padding: 13px 16px; vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
  line-height: 1.6;
}
.main tr:last-child td { border-bottom: none; }
.main tbody tr:hover td, .main table tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.main table tr:first-child:hover td { background: var(--panel-hi); }

/* ── Cajas de nota ── */
.note {
  --nc: var(--accent);
  position: relative;
  background: color-mix(in srgb, var(--nc) 7%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--nc) 32%, var(--line));
  border-left: 3px solid var(--nc);
  border-radius: 4px var(--r) var(--r) 4px;
  padding: 18px 22px;
  margin: 0 0 22px;
  font-size: 15px;
}
.note.warn { --nc: var(--warn); }
.note.tip  { --nc: var(--ok); }
.note > .t {
  display: block;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--nc);
  margin-bottom: 8px; font-weight: 500;
}
.note p:last-child, .note ul:last-child, .note ol:last-child { margin-bottom: 0; }

/* ── Banco de preguntas con respuesta oculta ── */
.qa-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 0 0 22px;
}
.btn {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em;
  color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 14px; cursor: pointer;
  transition: color .18s, border-color .18s, background .18s;
}
.btn:hover { color: var(--text); border-color: var(--accent); }
.btn.primary {
  color: #fff; background: var(--accent);
  border-color: var(--accent); font-weight: 500;
}
.btn.primary:hover { filter: brightness(1.12); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.qa {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px 22px;
  margin: 0 0 12px;
}
.qa-stem { margin: 0 0 10px !important; font-weight: 500; }
.qa-num {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 7px; margin-right: 10px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  color: var(--accent-soft);
  font-family: var(--mono); font-size: 11.5px;
  vertical-align: 2px;
}
.qa-opts { font-size: 14.5px; color: var(--muted); margin-bottom: 12px; line-height: 1.7; }
.qa details { border-top: 1px dashed var(--line); padding-top: 12px; }
.qa summary {
  list-style: none; cursor: pointer;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em;
  color: var(--accent-soft);
  display: inline-flex; align-items: center; gap: 7px;
}
.qa summary::-webkit-details-marker { display: none; }
.qa summary::before { content: '▸'; transition: transform .18s; display: inline-block; }
.qa details[open] summary::before { transform: rotate(90deg); }
.qa details[open] summary { margin-bottom: 10px; }
.qa .ans { font-size: 15px; }
.qa .ans b { color: var(--ok); }

/* ── Filtro del glosario ── */
.filter-wrap { position: relative; margin: 0 0 18px; max-width: 340px; }
.filter-wrap input {
  width: 100%; font-family: var(--body); font-size: 14px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px 10px 36px;
}
.filter-wrap input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.filter-wrap input::placeholder { color: var(--muted); }
.filter-wrap .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); display: grid; }
.filter-count { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-left: 12px; }

/* ── Pie ── */
.foot {
  margin-top: 64px; padding-top: 22px;
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 8px 16px;
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--text); }

/* boton volver arriba */
.up {
  position: fixed; right: 20px; bottom: 20px; z-index: 30;
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 50%; cursor: pointer;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--line);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, color .2s, border-color .2s;
}
.up.show { opacity: 1; pointer-events: auto; }
.up:hover { color: var(--text); border-color: var(--accent); }

/* ═══════════ RESPONSIVO ═══════════ */
@media (max-width: 1080px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 22px 80px; }
  .toc-toggle { display: inline-grid; }
  .toc {
    position: fixed; inset: 57px 0 0 auto;
    width: min(320px, 86vw);
    max-height: none; height: calc(100vh - 57px);
    background: var(--panel);
    border-left: 1px solid var(--line);
    padding: 22px 16px 40px;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.2,.7,.3,1);
    z-index: 45;
  }
  body.toc-open .toc { transform: none; }
  body.toc-open .scrim { opacity: 1; pointer-events: auto; }
  .scrim {
    position: fixed; inset: 57px 0 0; z-index: 44;
    background: rgba(3,7,18,.6);
    opacity: 0; pointer-events: none;
    transition: opacity .28s;
  }
  .main { padding-top: 26px; }
}

@media (max-width: 720px) {
  .search { position: static; flex: 0 0 auto; }
  .search-btn { display: inline-grid; }
  .search .field {
    position: absolute; top: calc(100% + 8px); left: 14px; right: 14px;
    display: none; z-index: 61;
  }
  body.search-open .search .field { display: block; }
  .search kbd { display: none; }
  .results { top: calc(100% + 56px); left: 14px; right: 14px; }
}

@media (max-width: 620px) {
  body { font-size: 15.5px; }
  .bar { padding: 10px 16px; gap: 8px; }
  .doc { padding: 0 16px 72px; }
  .hero { padding: 18px 0 30px; margin-bottom: 30px; }
  .main h2 { margin-top: 46px; }
  .note { padding: 16px 16px; border-radius: 3px 10px 10px 3px; }
  .qa { padding: 16px 16px; }
  .crumbs .hide-sm { display: none; }
  .bar-btn.wide span { display: none; }
  .bar-btn.wide { width: 36px; padding: 0; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto; }
}

@media print {
  .bar, .toc, .up, .scrim, .readbar, .qa-tools, .filter-wrap, .sheet, .bloom { display: none !important; }
  .doc { display: block; padding: 0; max-width: none; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .qa details { display: block; }
  .qa details > div { display: block !important; }
  a { color: #000; text-decoration: none; }
}
