/* ============================================================
   MainDocs — Estilos globales (landing + documentación)
   ============================================================ */

/* Paleta corporativa: #3d5a80 (azul oscuro) · #98c1d9 (azul claro) · #e0fbfc (celeste) */
:root {
  --bg: #e0fbfc;
  --bg-elevated: #ffffff;
  --bg-soft: #c9eef3;
  --text: #14233a;
  --text-muted: #3d5a80;
  --border: #a7cde0;
  --accent: #3d5a80;
  --accent-2: #98c1d9;
  --accent-3: #6b8eac;
  --gradient: linear-gradient(120deg, var(--accent), var(--accent-2));
  --shadow: 0 8px 30px rgba(61, 90, 128, .12);
  --shadow-lg: 0 18px 50px rgba(61, 90, 128, .2);
  --radius: 16px;
  --nav-h: 68px;
  --code-bg: #16222f;
}

html[data-theme="dark"] {
  --bg: #0e1722;
  --bg-elevated: #16242f;
  --bg-soft: #20354a;
  --text: #e0fbfc;
  --text-muted: #98c1d9;
  --border: #3d5a80;
  --accent: #98c1d9;
  --accent-2: #e0fbfc;
  --accent-3: #bcd9ea;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
  --code-bg: #0b121b;
}

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

/* ===== Iconos SVG monocromos (js/icons.js) ===== */
.ico {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  flex-shrink: 0;
}
[data-icon] { display: inline-flex; align-items: center; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .3s ease, color .3s ease;
  overflow-x: hidden;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

a { color: inherit; text-decoration: none; }

/* ===== Fondo decorativo ===== */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .25;
  pointer-events: none;
  z-index: 0;
}
.bg-glow-1 {
  width: 600px; height: 600px;
  background: var(--accent);
  top: -200px; right: -150px;
  animation: float 14s ease-in-out infinite;
}
.bg-glow-2 {
  width: 500px; height: 500px;
  background: var(--accent-2);
  bottom: -180px; left: -120px;
  animation: float 18s ease-in-out infinite reverse;
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(40px, -30px) scale(1.08); }
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .35;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent);
          mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent);
  pointer-events: none;
  z-index: 0;
}

/* ===== Navbar ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-bottom: 1px solid var(--border);
}
.navbar-inner {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
}
.logo-img {
  height: 32px;
  width: auto;
  display: block;
}
.logo-for-dark { display: none; }
html[data-theme="dark"] .logo-for-light { display: none; }
html[data-theme="dark"] .logo-for-dark {
  display: block;
  /* TEMPORAL: logo3s-light.png aún es la versión oscura del logo;
     se invierte para que sea visible en tema oscuro. Eliminar este
     filter cuando exista la versión clara real del archivo. */
  filter: invert(1);
}
.accent { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-weight: 500;
  font-size: .95rem;
}
.nav-links a:not(.btn) { color: var(--text-muted); transition: color .2s; }
.nav-links a:not(.btn):hover { color: var(--text); }

.theme-toggle {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  font-size: 1rem;
  display: grid;
  place-items: center;
  transition: transform .2s;
}
.theme-toggle:hover { transform: scale(1.08); }
html[data-theme="dark"] .icon-moon { display: none; }
html:not([data-theme="dark"]) .icon-sun { display: none; }

/* ===== Botones ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  font-size: .95rem;
  border: none;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, background .2s;
}
.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 6px 20px rgba(61, 90, 128, .4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(61, 90, 128, .55); }
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn-ghost {
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text) !important;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent) !important; }

/* ===== Hero ===== */
.hero {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 96px 0 64px;
}
.hero .container {
  position: relative;
  z-index: 2;
}

/* ----- Animación del hero: red de conocimiento ----- */
#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: .8;
  /* Desvanecido hacia los bordes para fundirse con la página */
  -webkit-mask-image: radial-gradient(ellipse 80% 75% at 50% 42%, black 40%, transparent 82%);
          mask-image: radial-gradient(ellipse 80% 75% at 50% 42%, black 40%, transparent 82%);
  animation: hero-canvas-in 1.6s ease both;
}
html[data-theme="dark"] #hero-canvas { opacity: .9; }
@keyframes hero-canvas-in {
  from { opacity: 0; }
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.hero-title {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -.03em;
  margin-bottom: 22px;
}
.gradient-text {
  background: linear-gradient(120deg, var(--accent), var(--accent-3), var(--accent-2));
  background-size: 200% 200%;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-shift 6s ease infinite;
}
@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
.hero-subtitle {
  max-width: 560px;
  margin: 0 auto 36px;
  font-size: 1.15rem;
  color: var(--text-muted);
}
.hero-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 64px;
}

/* ===== Ventana de código ===== */
.code-window {
  max-width: 640px;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  background: var(--code-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.code-window-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, .04);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.red    { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green  { background: #28c840; }
.code-window-title {
  margin-left: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .78rem;
  color: #8b91a7;
}
.code-window-body {
  padding: 22px 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .88rem;
  line-height: 1.8;
  color: #e4e9fa;
  overflow-x: auto;
}
.c-comment { color: #98c1d9; font-weight: 600; }
.c-key     { color: #e0fbfc; }
.c-str     { color: #bcd9ea; }

/* ===== Secciones ===== */
.section {
  position: relative;
  z-index: 1;
  padding: 72px 0;
}
.section-title {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -.02em;
  text-align: center;
  margin-bottom: 12px;
}
.section-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 44px;
}

/* ===== Tarjetas de temas ===== */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
  margin-top: 44px;
}
.topic-card {
  position: relative;
  display: block;
  padding: 28px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
  overflow: hidden;
}
.topic-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--topic-color, var(--gradient));
  opacity: 0;
  transition: opacity .25s;
}
.topic-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
.topic-card:hover::before { opacity: 1; }
.topic-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 14px;
  font-size: 1.5rem;
  background: var(--bg-soft);
  margin-bottom: 18px;
}
.topic-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.topic-card p {
  font-size: .92rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.topic-meta {
  font-size: .82rem;
  font-weight: 600;
  color: var(--accent);
}

/* ===== Características ===== */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px;
  margin-top: 44px;
}
.feature-card {
  padding: 26px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: transform .25s, box-shadow .25s;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.feature-icon { font-size: 1.7rem; margin-bottom: 14px; color: var(--accent); }
.feature-card h3 { font-size: 1.05rem; margin-bottom: 8px; }
.feature-card p { font-size: .9rem; color: var(--text-muted); }

/* ===== Footer ===== */
.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 28px 0;
  margin-top: 40px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: .9rem;
  font-weight: 500;
}
.footer-muted { color: var(--text-muted); }

/* ===== Animación de aparición ===== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .7s ease, transform .7s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   PÁGINA DE DOCUMENTACIÓN
   ============================================================ */

.docs-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  min-height: calc(100vh - var(--nav-h));
  position: relative;
  z-index: 1;
}

/* --- Sidebar --- */
.docs-sidebar {
  border-right: 1px solid var(--border);
  padding: 28px 18px;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg-elevated) 60%, transparent);
}
.search-box {
  position: relative;
  margin-bottom: 22px;
}
.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 90, 128, .15);
}
.search-box::before {
  content: '';
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  background: var(--text-muted);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") center / contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") center / contain no-repeat;
}
.search-kbd {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: .7rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  background: var(--bg-soft);
}

.sidebar-topic { margin-bottom: 6px; }
.sidebar-topic-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background .2s;
}
.sidebar-topic-header:hover { background: var(--bg-soft); }
.sidebar-topic-header .chevron {
  margin-left: auto;
  font-size: .65rem;
  transition: transform .25s;
  color: var(--text-muted);
}
.sidebar-topic.open .chevron { transform: rotate(90deg); }

.sidebar-articles {
  display: none;
  padding: 4px 0 6px 14px;
  margin-left: 14px;
  border-left: 1px solid var(--border);
}
.sidebar-topic.open .sidebar-articles { display: block; }
.sidebar-article {
  display: block;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: .88rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.sidebar-article:hover { color: var(--text); background: var(--bg-soft); }
.sidebar-article.active {
  color: var(--accent);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* --- Resultados de búsqueda --- */
.search-results { padding: 4px 0; }
.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}
.search-result:hover { background: var(--bg-soft); }
.search-result .sr-topic {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
}
.search-result .sr-title { font-size: .9rem; font-weight: 600; }
.search-result .sr-snippet {
  font-size: .8rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-empty {
  padding: 16px 12px;
  font-size: .88rem;
  color: var(--text-muted);
  text-align: center;
}

/* --- Contenido --- */
.docs-content {
  padding: 44px 56px 80px;
  max-width: 860px;
  width: 100%;
}
.breadcrumb {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 26px;
  font-weight: 500;
}
.breadcrumb .accent { font-weight: 600; }

/* Markdown renderizado */
.markdown h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: 18px;
  line-height: 1.2;
}
.markdown h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 38px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.markdown h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 28px 0 10px;
}
.markdown p { margin-bottom: 16px; color: var(--text); }
.markdown ul, .markdown ol { margin: 0 0 16px 24px; }
.markdown li { margin-bottom: 6px; }
.markdown a { color: var(--accent); font-weight: 500; }
.markdown a:hover { text-decoration: underline; }
.markdown strong { font-weight: 700; }
.markdown blockquote {
  border-left: 4px solid var(--accent);
  background: var(--bg-soft);
  padding: 14px 20px;
  border-radius: 0 10px 10px 0;
  margin-bottom: 16px;
  color: var(--text-muted);
}
.markdown code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .85em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
}
.markdown pre {
  background: var(--code-bg);
  border-radius: 12px;
  padding: 20px 22px;
  overflow-x: auto;
  margin-bottom: 18px;
  border: 1px solid var(--border);
}
.markdown pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e4e9fa;
  font-size: .87rem;
  line-height: 1.7;
}
.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
  font-size: .92rem;
}
.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
.markdown th { background: var(--bg-soft); font-weight: 700; }
.markdown img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin: 6px 0 16px;
}
.markdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 30px 0;
}

/* Navegación entre artículos */
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.article-nav-link {
  flex: 1;
  max-width: 48%;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: var(--bg-elevated);
  transition: border-color .2s, transform .2s;
}
.article-nav-link:hover { border-color: var(--accent); transform: translateY(-2px); }
.article-nav-link.next { text-align: right; margin-left: auto; }
.article-nav-label {
  display: block;
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}
.article-nav-title { font-weight: 600; font-size: .95rem; color: var(--accent); }

/* --- Índice "En esta página" (columna derecha) --- */
.toc-panel {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  padding: 44px 20px 40px 4px;
}
.toc-panel.empty { visibility: hidden; }
.toc-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-left: 12px;
}
.toc-link {
  display: block;
  padding: 5px 12px;
  font-size: .83rem;
  line-height: 1.4;
  color: var(--text-muted);
  border-left: 2px solid var(--border);
  transition: color .15s, border-color .15s;
}
.toc-link:hover { color: var(--text); }
.toc-link.toc-h3 { padding-left: 26px; }
.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

/* Iconos en sidebar y breadcrumb */
.sidebar-ico { display: inline-flex; color: var(--accent); }
.breadcrumb .ico { vertical-align: -0.18em; }
.sr-topic .ico { vertical-align: -0.15em; }

/* Botón menú móvil */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 200;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--gradient);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(61, 90, 128, .5);
}

/* ===== Responsive ===== */
@media (max-width: 1180px) {
  .docs-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .toc-panel { display: none; }
}
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-sidebar {
    position: fixed;
    inset: var(--nav-h) auto 0 0;
    width: min(320px, 85vw);
    z-index: 150;
    background: var(--bg-elevated);
    transform: translateX(-100%);
    transition: transform .3s ease;
    box-shadow: var(--shadow-lg);
  }
  .docs-sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: grid; place-items: center; }
  .docs-content { padding: 32px 22px 80px; }
  .nav-links a[href="#temas"],
  .nav-links a[href="#caracteristicas"] { display: none; }
}
