/* Wiki del Cerebro — estética GitHub docs con acentos Empujón.
   Base limpia clara (#ffffff / #f6f8fa), texto #1f2328, links #046dc5,
   naranja #f46e1b solo para acentos (nav activa, focus). Sin CDNs. */

:root {
  --naranja: #f46e1b;
  --naranja-suave: rgba(244, 110, 27, 0.09);
  --tinta: #1f2328;
  --muted: #59636e;
  --link: #046dc5;
  --borde: #d8dee4;
  --borde-suave: #e7ebef;
  --gris: #f6f8fa;
  --blanco: #ffffff;
  --topbar-h: 49px;
  --sidebar-w: 296px;
  --toc-w: 232px;
  --fuente: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--blanco);
  color: var(--tinta);
  font-family: var(--fuente);
  font-size: 16px;
  line-height: 1.6;
}

::selection { background: rgba(244, 110, 27, 0.25); }

a:focus-visible, button:focus-visible, input:focus-visible, label:focus-visible {
  outline: 2px solid var(--naranja);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Top bar fina con breadcrumb ─────────────────────────────────────── */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  background: var(--blanco);
  border-bottom: 1px solid var(--borde);
  z-index: 40;
}

.nav-toggle { display: none; }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }

.crumb { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-root { color: var(--tinta); font-weight: 600; text-decoration: none; }
.crumb-root:hover { color: var(--naranja); }
.crumb-muted { color: var(--muted); }
.crumb-current { color: var(--tinta); font-weight: 600; }
.crumb-sep { color: var(--muted); flex: none; }

/* ── Sidebar clara (GitHub-style) ────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--gris);
  border-right: 1px solid var(--borde);
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 12px;
  text-decoration: none;
  color: var(--tinta);
}

.brand-glyph { font-size: 24px; line-height: 1; }

.brand-text {
  display: flex;
  flex-direction: column;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-text small { font-size: 12px; font-weight: 500; color: var(--muted); }

.nav-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 16px 8px;
  padding: 6px 12px;
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-radius: 8px;
  color: var(--muted);
}

.nav-search:focus-within { border-color: var(--naranja); box-shadow: 0 0 0 3px rgba(244, 110, 27, 0.15); }

.nav-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--tinta);
}

.nav-search input::placeholder { color: var(--muted); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 16px 16px; }

.nav-group { margin-top: 14px; }

.nav-group-label {
  margin: 0 0 2px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.nav-link {
  display: block;
  padding: 5px 8px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  color: var(--tinta);
  text-decoration: none;
  font-size: 14px;
}

.nav-link:hover { background: rgba(31, 35, 40, 0.06); }

.nav-link.active {
  background: var(--naranja-suave);
  border-left-color: var(--naranja);
  color: #bc4c00;
  font-weight: 600;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  border-top: 1px solid var(--borde);
  font-size: 13px;
}

.iso-foot { width: 16px; height: auto; color: var(--naranja); flex: none; }

.sidebar-foot a { color: var(--muted); text-decoration: none; }
.sidebar-foot a:hover { color: var(--naranja); }

/* ── Layout de 3 columnas ────────────────────────────────────────────── */

.layout {
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  display: flex;
  justify-content: center;
  gap: 24px;
}

.content { max-width: 800px; min-width: 0; flex: 1; padding: 36px 40px 80px; }

.toc-col { width: var(--toc-w); flex: none; }

.layout:not(.has-toc) .toc-col { display: none; }

.toc {
  position: sticky;
  top: calc(var(--topbar-h) + 36px);
  max-height: calc(100vh - var(--topbar-h) - 72px);
  overflow-y: auto;
  padding: 0 16px 16px 0;
  font-size: 13px;
}

.toc-title { margin: 0 0 6px; font-size: 12px; font-weight: 700; color: var(--tinta); }

.toc-link {
  display: block;
  padding: 4px 10px;
  border-left: 2px solid var(--borde-suave);
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
}

.toc-link.lvl3 { padding-left: 24px; }

.toc-link:hover { color: var(--tinta); }

.toc-link.active { border-left-color: var(--naranja); color: var(--naranja); font-weight: 600; }

/* ── Markdown estilo GitHub ──────────────────────────────────────────── */

.md-body h1 {
  margin: 0 0 16px;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--borde-suave);
  font-size: 2em;
  font-weight: 600;
  line-height: 1.25;
}

.md-body h2 {
  margin: 1.6em 0 16px;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--borde-suave);
  font-size: 1.5em;
  font-weight: 600;
  line-height: 1.25;
}

.md-body h3 { margin: 1.5em 0 12px; font-size: 1.2em; font-weight: 600; }
.md-body h4 { margin: 1.4em 0 12px; font-size: 1em; font-weight: 600; }

.md-body p { margin: 0 0 16px; }

.md-body a { color: var(--link); text-decoration: none; }
.md-body a:hover { text-decoration: underline; }

.md-body blockquote {
  margin: 0 0 16px;
  padding: 10px 18px;
  background: #fff6ed;
  border-left: 4px solid var(--naranja);
  border-radius: 0 8px 8px 0;
  color: #513a29;
}
.md-body blockquote p { margin: 6px 0; }

.md-body code {
  font-family: var(--mono);
  font-size: 85%;
  background: rgba(31, 35, 40, 0.07);
  border-radius: 6px;
  padding: 0.2em 0.4em;
}

.md-body pre {
  margin: 0 0 16px;
  padding: 16px 20px;
  background: #171d17;
  color: #e8ece8;
  border-radius: 10px;
  overflow-x: auto;
  line-height: 1.5;
}
.md-body pre code { background: none; padding: 0; color: inherit; font-size: 85%; }

.table-wrap {
  overflow-x: auto;
  margin: 0 0 16px;
  border: 1px solid var(--borde);
  border-radius: 8px;
}

.md-body table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.md-body th, .md-body td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--borde-suave);
  text-align: left;
  vertical-align: top;
}
.md-body th { background: var(--gris); font-weight: 600; }
.md-body tbody tr:nth-child(2n) { background: var(--gris); }
.md-body tr:last-child td { border-bottom: none; }

.md-body ul, .md-body ol { margin: 0 0 16px; padding-left: 2em; }
.md-body li { margin: 0.25em 0; }
.md-body li.task { list-style: none; margin-left: -1.4em; }
.md-body li.task input { margin-right: 0.5em; vertical-align: middle; }

.md-body hr { border: none; border-top: 1px solid var(--borde-suave); height: 0; margin: 24px 0; }

.md-body img { max-width: 100%; border-radius: 8px; }

/* ── Chips de estado ─────────────────────────────────────────────────── */

.chip {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.7;
  white-space: nowrap;
  vertical-align: baseline;
}

.chip-firme     { background: #dafbe1; color: #116329; }
.chip-direccion { background: #ddf4ff; color: #0a5394; }
.chip-abierta   { background: #fff8c5; color: #7d4e00; }
.chip-propuesta { background: #fbefff; color: #6639ba; }
.chip-draft     { background: #eff1f3; color: #59636e; }

/* ── Pie de página: metadata git + prev/next ─────────────────────────── */

.page-foot { margin-top: 40px; border-top: 1px solid var(--borde-suave); padding-top: 16px; }

.page-meta { margin: 0 0 20px; font-size: 13px; color: var(--muted); }
.page-meta code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--gris);
  border: 1px solid var(--borde-suave);
  border-radius: 6px;
  padding: 1px 6px;
}

.pager { display: flex; gap: 16px; }

.pager-spacer { flex: 1; }

.pager-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--borde);
  border-radius: 8px;
  text-decoration: none;
  min-width: 0;
}

.pager-link:hover { border-color: var(--naranja); }
.pager-link small { font-size: 12px; color: var(--muted); }
.pager-link span { font-size: 14.5px; font-weight: 600; color: var(--link); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager-next { text-align: right; align-items: flex-end; }

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

.nav-toggle-box { display: none; }
.nav-scrim { display: none; }

@media (max-width: 1100px) {
  .toc-col { display: none; }
}

@media (max-width: 900px) {
  .nav-toggle {
    display: flex;
    align-items: center;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    margin-left: -6px;
  }
  .nav-toggle:hover { color: var(--tinta); }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 6px 0 24px rgba(31, 35, 40, 0.18);
    z-index: 50;
  }

  .nav-toggle-box:checked ~ .sidebar { transform: none; }

  .nav-toggle-box:checked ~ .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(31, 35, 40, 0.4);
    z-index: 45;
  }

  .layout { margin-left: 0; }
  .content { padding: 24px 20px 64px; }
}

/* ── Variantes por audiencia: selector + banners ─────────────────────── */

.variant-switch {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.variant-label { font-size: 12px; font-weight: 700; color: var(--muted); margin-right: 2px; }

.variant-pill {
  display: inline-block;
  padding: 4px 14px;
  border: 1px solid var(--borde);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  background: var(--blanco);
}

.variant-pill:hover { border-color: var(--naranja); color: var(--tinta); }

.variant-pill.active {
  background: var(--naranja-suave);
  border-color: var(--naranja);
  color: #bc4c00;
}

.banner {
  margin: 0 0 14px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
}

.banner-draft { background: #fff8c5; border: 1px solid #e0c14e; color: #7d4e00; }

.banner-outdated { background: #fff6ed; border: 1px solid var(--naranja); color: #bc4c00; }

/* ── Grafo de la wiki ────────────────────────────────────────────────── */

.content-wide { max-width: none; padding: 24px 28px 28px; display: flex; }

.graph-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--topbar-h) - 52px);
  background: var(--gris);
  border: 1px solid var(--borde);
  border-radius: 12px;
  overflow: hidden;
}

.graph-head { padding: 18px 24px 10px; }

.graph-head h1 { margin: 0 0 4px; font-size: 1.25em; font-weight: 600; }

.graph-hint { margin: 0; font-size: 13px; color: var(--muted); }

.graph-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }

.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1.5px solid var(--blanco);
  box-shadow: 0 0 0 1px rgba(31, 35, 40, 0.12);
}

#graph-canvas { flex: 1; width: 100%; display: block; touch-action: none; }

/* ── Login (modo oscuro de marca, pulido) ────────────────────────────── */

.login-body {
  background: #171d17;
  background-image: radial-gradient(ellipse 70% 55% at 50% -10%, rgba(247, 144, 69, 0.13), transparent);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #2a302a;
  border: 1px solid rgba(228, 231, 228, 0.08);
  border-radius: 28px;
  padding: 44px 38px 40px;
  color: #f4f5f5;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}

.iso-login { width: 46px; height: auto; color: #f79045; margin-bottom: 14px; }

.login-card h1 { margin: 0 0 6px; font-size: 1.45rem; font-weight: 800; letter-spacing: 0.01em; color: #ffffff; }

.login-sub { margin: 0 0 24px; font-size: 14px; color: #9aa39a; }

.login-error {
  background: rgba(247, 69, 83, 0.14);
  border: 1px solid rgba(247, 69, 83, 0.55);
  color: #ffb9bf;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin: 0 0 18px;
}

.login-card form { display: flex; flex-direction: column; text-align: left; gap: 6px; }

.login-card label { font-size: 13px; font-weight: 700; color: #d1d6d1; margin: 8px 4px 0; }

.login-card input {
  font: inherit;
  font-size: 15px;
  color: #ffffff;
  background: #171d17;
  border: 1px solid #3a413a;
  border-radius: 999px;
  padding: 11px 18px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-card input:focus { border-color: #f79045; box-shadow: 0 0 0 5px rgba(247, 144, 69, 0.2); }

.login-card button {
  margin-top: 22px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: #171d17;
  background: #f79045;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.login-card button:hover { background: #f9a86b; }
.login-card button:active { transform: scale(0.97); }
.login-card button:focus-visible { outline: 2px solid #f79045; outline-offset: 3px; }
