/* ═══════════════════════════════════════════════════════════════════
   Visor de documentación offline

   Tipografías del sistema a propósito: ninguna petición a internet.
   Modo oscuro por prefers-color-scheme, con conmutador manual que
   sobrescribe la preferencia del sistema.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --bg:          #f7f7f5;
  --bg-raised:   #ffffff;
  --bg-sunken:   #eeeeea;
  --fg:          #1c1c1a;
  --fg-muted:    #6b6b64;
  --border:      #dededa;
  --accent:      #0f766e;
  --accent-soft: #d7efec;
  --shadow:      0 1px 2px rgba(0, 0, 0, .05), 0 4px 12px rgba(0, 0, 0, .04);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --sidebar-w: 17rem;
  --measure: 46rem;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg:          #16171a;
    --bg-raised:   #1d1f23;
    --bg-sunken:   #111214;
    --fg:          #e6e6e3;
    --fg-muted:    #9a9a94;
    --border:      #2c2f34;
    --accent:      #5eead4;
    --accent-soft: #14343050;
    --shadow:      none;
  }
}

:root[data-theme="dark"] {
  --bg:          #16171a;
  --bg-raised:   #1d1f23;
  --bg-sunken:   #111214;
  --fg:          #e6e6e3;
  --fg-muted:    #9a9a94;
  --border:      #2c2f34;
  --accent:      #5eead4;
  --accent-soft: #14343050;
  --shadow:      none;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.muted { color: var(--fg-muted); }

.skip {
  position: absolute; left: -9999px;
  padding: .6rem 1rem; background: var(--accent); color: #fff; z-index: 100;
}
.skip:focus { left: .5rem; top: .5rem; }

/* ── Barra superior ──────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 1.2rem;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 600; color: var(--fg); text-decoration: none;
  white-space: nowrap;
}
.brand-mark {
  width: .85rem; height: .85rem; border-radius: 3px;
  background: var(--accent); flex: none;
}

.topbar-tech {
  display: inline-flex; align-items: center; gap: .5rem;
  padding-left: 1rem; border-left: 1px solid var(--border);
  white-space: nowrap;
}
.topbar-tech a { color: var(--fg); text-decoration: none; font-weight: 500; }
.topbar-tech a:hover { color: var(--accent); }

.topbar-actions {
  display: flex; align-items: center; gap: .6rem;
  margin-left: auto; min-width: 0;
}

.badge {
  display: inline-block; padding: .05rem .45rem;
  font-size: .75rem; font-weight: 600; font-family: var(--mono);
  color: var(--accent); background: var(--accent-soft);
  border-radius: 999px;
}

.theme-toggle {
  display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem; flex: none;
  font-size: 1rem; line-height: 1; cursor: pointer;
  color: var(--fg-muted); background: transparent;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.theme-toggle:hover { color: var(--fg); border-color: var(--fg-muted); }
.theme-icon { grid-area: 1 / 1; }
.theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .theme-icon-light { display: none; }
  :root[data-theme="auto"] .theme-icon-dark { display: block; }
}

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

.search { position: relative; min-width: 0; flex: 1 1 14rem; max-width: 26rem; }
.search-global { max-width: 34rem; }

.search-input {
  width: 100%; padding: .45rem 2rem .45rem .7rem;
  font: inherit; font-size: .92rem;
  color: var(--fg); background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.search-input:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
  background: var(--bg-raised);
}

.search-hint {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  padding: 0 .3rem; font-family: var(--mono); font-size: .7rem;
  color: var(--fg-muted); background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: 4px;
  pointer-events: none;
}
.search-input:focus ~ .search-hint { display: none; }

.search-results {
  position: absolute; top: calc(100% + .4rem); right: 0;
  width: min(30rem, 90vw); max-height: 65vh; overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 50;
}
.search-results[hidden] { display: none; }

.search-hit {
  display: block; padding: .55rem .8rem;
  color: var(--fg); text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.search-hit:last-child { border-bottom: 0; }
.search-hit:hover, .search-hit.is-active { background: var(--accent-soft); }
.search-hit strong { display: block; font-size: .93rem; }
.search-hit small { color: var(--fg-muted); font-size: .78rem; }
.search-empty { padding: .8rem; color: var(--fg-muted); font-size: .9rem; }

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

.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: 3.4rem; flex: none;
  width: var(--sidebar-w); max-height: calc(100vh - 3.4rem);
  overflow-y: auto; padding: 1.2rem .5rem 3rem 1.2rem;
  border-right: 1px solid var(--border);
}

.nav-section + .nav-section { margin-top: .35rem; }

.nav-section-title {
  margin: 0; padding: .4rem .5rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--fg-muted);
  cursor: pointer; user-select: none; border-radius: var(--radius);
}
.nav-section-title:hover { color: var(--fg); background: var(--bg-sunken); }
.nav-section-title::before {
  content: "▸"; display: inline-block; width: 1em;
  font-size: .9em; transition: transform .15s ease;
}
.nav-section.is-open > .nav-section-title::before { transform: rotate(90deg); }

.nav-list { margin: 0 0 .3rem; padding: 0; list-style: none; }
.nav-section-title + .nav-list { display: none; }
.nav-section.is-open > .nav-list { display: block; }

.nav-list a {
  display: block; padding: .3rem .6rem;
  font-size: .89rem; color: var(--fg); text-decoration: none;
  border-radius: 6px;
}
.nav-list a:hover { background: var(--bg-sunken); }
.nav-list a.is-current {
  color: var(--accent); background: var(--accent-soft); font-weight: 600;
}

.nav-more {
  margin: .8rem .5rem 0; padding-top: .6rem;
  font-size: .82rem; border-top: 1px solid var(--border);
}

.nav-toggle {
  display: none; width: 100%; padding: .6rem 1.2rem;
  font: inherit; font-size: .9rem; text-align: left; cursor: pointer;
  color: var(--fg); background: var(--bg-raised);
  border: 0; border-bottom: 1px solid var(--border);
}
.nav-toggle::before { content: "☰  "; }

.content {
  flex: 1 1 auto; min-width: 0;
  padding: 2rem 2rem 4rem;
}
.content-wide { max-width: 68rem; margin: 0 auto; }

/* ── Documento ───────────────────────────────────────────────────── */

.doc { max-width: var(--measure); }

.doc-title { margin: 0 0 .4rem; font-size: 2rem; line-height: 1.2; }

.doc-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem;
  margin: 0 0 1.5rem; padding-bottom: 1rem;
  font-size: .84rem; border-bottom: 1px solid var(--border);
}

.doc-toc {
  margin: 0 0 2rem; padding: .6rem .9rem;
  background: var(--bg-sunken); border-radius: var(--radius);
  font-size: .9rem;
}
.doc-toc summary { cursor: pointer; font-weight: 600; }
.doc-toc ul { margin: .6rem 0 .2rem; padding-left: 1.1rem; }
.doc-toc li.lvl-3 { padding-left: 1rem; }

.doc-body > *:first-child { margin-top: 0; }
.doc-body h1 { display: none; }
.doc-body h2, .doc-body h3, .doc-body h4 {
  margin: 2.2rem 0 .7rem; line-height: 1.3; scroll-margin-top: 4.5rem;
}
.doc-body h2 {
  font-size: 1.45rem; padding-bottom: .3rem;
  border-bottom: 1px solid var(--border);
}
.doc-body h3 { font-size: 1.15rem; }
.doc-body h4 { font-size: 1rem; }

.doc-body p, .doc-body ul, .doc-body ol { margin: 0 0 1rem; }
.doc-body li { margin-bottom: .25rem; }
.doc-body img { max-width: 100%; height: auto; border-radius: var(--radius); }
.doc-body hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.doc-body blockquote {
  margin: 1.2rem 0; padding: .1rem 1rem;
  color: var(--fg-muted);
  border-left: 3px solid var(--accent);
  background: var(--bg-sunken); border-radius: 0 var(--radius) var(--radius) 0;
}

.doc-body code {
  font-family: var(--mono); font-size: .87em;
  padding: .12em .35em; border-radius: 4px;
  background: var(--bg-sunken); border: 1px solid var(--border);
}
.doc-body pre {
  margin: 0 0 1.2rem; padding: .9rem 1rem; overflow-x: auto;
  background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .87rem; line-height: 1.55;
}
.doc-body pre code {
  padding: 0; background: none; border: 0; font-size: inherit;
}

.doc-body table {
  width: 100%; margin: 0 0 1.4rem; border-collapse: collapse;
  font-size: .92rem; display: block; overflow-x: auto;
}
.doc-body th, .doc-body td {
  padding: .5rem .7rem; text-align: left;
  border: 1px solid var(--border);
}
.doc-body th { background: var(--bg-sunken); font-weight: 600; }

.headerlink {
  margin-left: .4rem; opacity: 0; text-decoration: none;
  font-weight: 400; color: var(--fg-muted);
}
h2:hover .headerlink, h3:hover .headerlink, h4:hover .headerlink { opacity: 1; }

/* ── Paginación ──────────────────────────────────────────────────── */

.pager {
  display: flex; justify-content: space-between; gap: 1rem;
  max-width: var(--measure); margin-top: 3rem; padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.pager a {
  display: flex; flex-direction: column; gap: .1rem;
  max-width: 48%; padding: .6rem .9rem;
  font-size: .92rem; text-decoration: none; color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager a span { font-size: .75rem; }
.pager-next { text-align: right; margin-left: auto; }

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

.hero { padding: 2.5rem 0 1.5rem; max-width: var(--measure); }
.hero h1 { margin: 0 0 .6rem; font-size: 2.1rem; line-height: 1.2; }
.hero p { margin: 0 0 .5rem; }

.cards {
  display: grid; gap: 1rem; margin: 1.5rem 0 3rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}
.card {
  display: flex; flex-direction: column; gap: .4rem;
  padding: 1.1rem 1.2rem; text-decoration: none; color: var(--fg);
  background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card h2 { margin: 0; font-size: 1.15rem; }
.card-meta { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: .85rem; }
.card-foot { margin: auto 0 0; font-size: .78rem; }

.tech-header { margin-bottom: 2rem; }
.tech-header h1 { margin: 0 0 .5rem; font-size: 2rem; }
.tech-section { margin-bottom: 2rem; }
.tech-section h2 {
  font-size: 1.1rem; margin: 0 0 .6rem; padding-bottom: .3rem;
  border-bottom: 1px solid var(--border);
}
.tech-list {
  margin: 0; padding: 0; list-style: none;
  display: grid; gap: .1rem .8rem;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
}
.tech-list a {
  display: block; padding: .25rem .5rem;
  color: var(--fg); text-decoration: none; border-radius: 6px;
  font-size: .93rem;
}
.tech-list a:hover { background: var(--bg-sunken); color: var(--accent); }

.notice, .pending {
  max-width: var(--measure); margin-top: 2rem; padding: 1rem 1.2rem;
  background: var(--bg-sunken); border-radius: var(--radius);
  font-size: .92rem;
}
.notice h2, .pending h2 { margin: 0 0 .5rem; font-size: 1rem; }
.notice p, .pending p { margin: 0; }

/* ── Pie ─────────────────────────────────────────────────────────── */

.site-footer {
  padding: 1.5rem 2rem 2.5rem; text-align: center; font-size: .85rem;
  border-top: 1px solid var(--border);
}
.site-footer p { margin: 0 0 .3rem; }
.site-footer a { color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--accent); }

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: .6rem; }
  .topbar-tech { padding-left: 0; border-left: 0; }
  .topbar-actions { width: 100%; margin-left: 0; }

  .nav-toggle { display: block; }
  .layout { display: block; }

  .sidebar {
    position: static; width: 100%; max-height: none;
    display: none; border-right: 0; border-bottom: 1px solid var(--border);
    padding: .8rem 1.2rem;
  }
  .sidebar.is-visible { display: block; }

  .content { padding: 1.5rem 1.2rem 3rem; }
  .doc-title { font-size: 1.6rem; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
  .pager-next { text-align: left; }
}

@media print {
  .topbar, .sidebar, .nav-toggle, .pager, .site-footer, .doc-toc { display: none; }
  .content { padding: 0; }
  body { font-size: 11pt; }
}
