/*
 * AprenderSQL.es — Sistema visual 2026
 * Diseño editorial minimalista, mobile first y accesible.
 * Orden: tokens · reset · base · layout · componentes · páginas · responsive · temas · impresión.
 */

/* 1. TOKENS */
:root {
  color-scheme: light;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.0625rem;
  --text-lg: 1.1875rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;
  --text-4xl: 3.25rem;

  --leading-tight: 1.15;
  --leading-heading: 1.25;
  --leading-body: 1.72;

  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f2f4f7;
  --surface-code: #111827;
  --surface-code-toolbar: #182235;
  --text: #182230;
  --text-soft: #475467;
  --text-faint: #667085;
  --border: #e4e7ec;
  --border-strong: #cfd4dc;
  --primary: #2457d6;
  --primary-hover: #1946b7;
  --primary-soft: #eef3ff;
  --primary-border: #c9d7ff;
  --success: #087a55;
  --success-soft: #edf9f4;
  --success-border: #b8e6d4;
  --warning: #936000;
  --warning-soft: #fff8e6;
  --warning-border: #f0d590;
  --danger: #b42334;
  --danger-soft: #fff1f2;
  --danger-border: #fecdd3;
  --focus: #f5a623;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.125rem;
  --radius-pill: 999px;

  --shadow-focus: 0 0 0 4px color-mix(in srgb, var(--focus) 25%, transparent);
  --shadow-float: 0 16px 40px rgba(16, 24, 40, 0.08);

  --container: 72rem;
  --reading: 46rem;
  --wide-reading: 55rem;
  --sidebar: 16.5rem;
  --header-height: 4rem;
  --control-height: 2.75rem;
  --transition: 150ms ease;
}

/* 2. RESET */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 1.5rem); }
body { margin: 0; min-width: 20rem; }
img, picture, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
table { border-collapse: collapse; border-spacing: 0; }
fieldset { min-width: 0; }
[hidden] { display: none !important; }

/* 3. BASE */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
main { min-height: 55vh; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--primary-hover); text-decoration-thickness: 2px; }
p, ul, ol, dl, blockquote, figure { margin-top: 0; }
figure { margin-inline: 0; }
p, ul, ol { margin-bottom: var(--space-4); }
ul, ol { padding-left: 1.35rem; }
li + li { margin-top: var(--space-2); }
h1, h2, h3, h4 {
  color: var(--text);
  font-weight: 760;
  line-height: var(--leading-heading);
  letter-spacing: -0.025em;
  margin: 0 0 var(--space-4);
  text-wrap: balance;
}
h1 { font-size: clamp(2.2rem, 7vw, var(--text-4xl)); line-height: 1.08; }
h2 { font-size: clamp(1.55rem, 4vw, var(--text-2xl)); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
strong { color: var(--text); }
small { font-size: var(--text-sm); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-10) 0; }
code, pre { font-family: var(--font-mono); font-variant-ligatures: none; }
code:not(pre code) {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9em;
  padding: 0.08em 0.32em;
  overflow-wrap: anywhere;
}
::selection { background: color-mix(in srgb, var(--primary) 24%, transparent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; box-shadow: var(--shadow-focus); }

/* 4. UTILIDADES Y LAYOUT */
.container { width: min(calc(100% - 2rem), var(--container)); margin-inline: auto; }
.narrow { width: min(calc(100% - 2rem), var(--reading)); margin-inline: auto; }
.centered { margin-inline: auto; }
.full { grid-column: 1 / -1; }
.wide { grid-column: 1 / -1; }
.full-width { max-width: none !important; }
.section { padding-block: clamp(3rem, 7vw, var(--space-20)); }
.section-compact { padding-top: var(--space-4); }
.section-soft { background: var(--bg-subtle); border-block: 1px solid var(--border); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--space-4); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-6); }
.actions-center { justify-content: center; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.skip-link {
  position: fixed;
  z-index: 1000;
  top: var(--space-3);
  left: var(--space-3);
  translate: 0 -180%;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.9rem;
  font-weight: 750;
  text-decoration: none;
  transition: translate var(--transition);
}
.skip-link:focus { translate: 0; }

/* 5. HEADER Y NAVEGACIÓN */
.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  min-height: var(--header-height);
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.nav { min-height: var(--header-height); display: flex; align-items: center; gap: var(--space-2); }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: -0.02em;
}
.nav-links { margin-left: auto; display: flex; align-items: center; gap: var(--space-1); }
.nav-links a {
  border-radius: var(--radius-md);
  color: var(--text-soft);
  font-size: var(--text-sm);
  font-weight: 680;
  padding: 0.5rem 0.65rem;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.nav-links a:hover, .nav-links a[aria-current="page"] { background: var(--surface-muted); color: var(--text); }
.menu-btn, .icon-btn, .theme-btn {
  width: var(--control-height);
  height: var(--control-height);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.menu-btn:hover, .icon-btn:hover, .theme-btn:hover { background: var(--surface-muted); border-color: var(--border-strong); color: var(--text); }
.menu-btn { display: none; }
.menu-icon { width: 1.15rem; height: 0.875rem; position: relative; }
.menu-icon::before, .menu-icon::after, .menu-icon span {
  position: absolute; left: 0; width: 100%; height: 2px; border-radius: 2px; background: currentColor; content: ""; transition: transform var(--transition), top var(--transition), opacity var(--transition);
}
.menu-icon::before { top: 0; }
.menu-icon span { top: calc(50% - 1px); }
.menu-icon::after { bottom: 0; }
.menu-btn[aria-expanded="true"] .menu-icon::before { top: calc(50% - 1px); transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] .menu-icon span { opacity: 0; }
.menu-btn[aria-expanded="true"] .menu-icon::after { bottom: calc(50% - 1px); transform: rotate(-45deg); }
.theme-icon { width: 1.15rem; height: 1.15rem; border: 2px solid currentColor; border-radius: 50%; position: relative; overflow: hidden; }
.theme-icon::after { content: ""; position: absolute; inset: -2px -2px -2px 48%; background: currentColor; }
[data-theme="dark"] .theme-icon::after { inset: 12% 12% 12% 45%; border-radius: 50%; background: var(--surface); }

/* 6. BOTONES Y CONTROLES */
.btn {
  min-height: var(--control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.6rem 0.95rem;
  font-size: var(--text-sm);
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), translate var(--transition);
}
.btn:hover { text-decoration: none; translate: 0 -1px; }
.btn:active { translate: 0; }
.btn:disabled { cursor: not-allowed; opacity: 0.5; translate: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-muted); color: var(--text); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--primary); }
.btn-quiet:hover { background: var(--primary-soft); color: var(--primary-hover); }
.btn-small { min-height: 2.35rem; padding: 0.45rem 0.75rem; }

.fieldset-reset { border: 0; padding: 0; margin: 0; }
.field label { display: block; margin-bottom: var(--space-2); color: var(--text); font-size: var(--text-sm); font-weight: 700; }
.field input, .field textarea, .field select, .search-box input, .sql-input {
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  padding: 0.7rem 0.8rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.field input:hover, .field textarea:hover, .field select:hover, .search-box input:hover, .sql-input:hover { border-color: color-mix(in srgb, var(--primary) 48%, var(--border-strong)); }
.field input:focus, .field textarea:focus, .field select:focus, .search-box input:focus, .sql-input:focus { border-color: var(--primary); outline: 0; box-shadow: 0 0 0 4px var(--primary-soft); }
.field textarea { min-height: 11rem; resize: vertical; }
.form-grid { display: grid; gap: var(--space-5); }

/* 7. ETIQUETAS Y META */
.eyebrow, .pill, .difficulty, .term-category {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 750;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.eyebrow { color: var(--primary); margin-bottom: var(--space-4); text-transform: uppercase; letter-spacing: 0.085em; }
.pill { border: 1px solid var(--border); background: var(--surface-muted); color: var(--text-soft); padding: 0.38rem 0.65rem; }
.difficulty { background: var(--primary-soft); color: var(--primary); padding: 0.35rem 0.6rem; }
.dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--success); }
.lead { max-width: 43rem; color: var(--text-soft); font-size: clamp(1.05rem, 2vw, var(--text-lg)); line-height: 1.62; }
.notice { color: var(--text-faint); font-size: var(--text-sm); }
.meta-line, .content-meta { color: var(--text-faint); font-size: var(--text-sm); }

/* 8. HOME */
.hero { padding-block: clamp(3.5rem, 10vw, 7rem); border-bottom: 1px solid var(--border); }
.hero-grid { display: grid; gap: clamp(2rem, 6vw, 5rem); align-items: center; }
.hero h1 { max-width: 15ch; }
.hero .lead { max-width: 38rem; }
.hero-card { min-width: 0; }
.code-demo {
  overflow: hidden;
  border: 1px solid #27364d;
  border-radius: var(--radius-xl);
  background: var(--surface-code);
  color: #e8eef9;
  box-shadow: var(--shadow-float);
}
.code-demo pre { overflow: auto; margin: 0; padding: clamp(1.1rem, 4vw, 1.65rem); font-size: clamp(0.82rem, 2vw, 0.95rem); line-height: 1.75; }
.code-demo .kw { color: #8ab4ff; font-weight: 700; }
.code-demo .str { color: #9be9c5; }
.demo-result { border-top: 1px solid #2b3a50; background: #0d1523; }
.demo-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.demo-row span { min-width: 0; padding: 0.55rem 0.8rem; border-right: 1px solid #26354a; border-top: 1px solid #26354a; font-size: var(--text-sm); overflow-wrap: anywhere; }
.demo-row span:last-child { border-right: 0; }
.demo-row:first-child span { border-top: 0; color: #b7c8e7; font-weight: 700; }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-6); margin-bottom: var(--space-8); }
.section-head > div { max-width: 42rem; }
.section-head p { max-width: 38rem; margin: 0; color: var(--text-soft); }
.card, .trust-card {
  min-width: 0;
  border-top: 1px solid var(--border);
  padding-block: var(--space-6);
}
a.card, a.trust-card { color: var(--text); text-decoration: none; }
a.card:hover, a.trust-card:hover { color: var(--text); }
.card h2, .card h3, .trust-card h2 { margin-bottom: var(--space-2); font-size: var(--text-xl); }
.card p, .trust-card p { margin-bottom: 0; color: var(--text-soft); }
.card-icon { width: 2rem; height: 2rem; display: grid; place-items: center; margin-bottom: var(--space-4); border: 1px solid var(--primary-border); border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); font-size: var(--text-xs); font-weight: 800; }
.stat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-8); }
.stat { border-left: 2px solid var(--border); padding-left: var(--space-4); }
.stat b { display: block; font-size: var(--text-xl); line-height: 1.25; }
.stat span { color: var(--text-faint); font-size: var(--text-sm); }

/* 9. PAGE HERO Y BREADCRUMBS */
.page-hero { padding-block: clamp(2.75rem, 7vw, 5rem) clamp(2rem, 5vw, 3.5rem); border-bottom: 1px solid var(--border); background: var(--bg-subtle); }
.page-hero .narrow, .page-hero .lesson-heading { width: min(calc(100% - 2rem), var(--reading)); margin-inline: auto; }
.lesson-heading { max-width: var(--wide-reading) !important; }
.page-hero h1 { max-width: 18ch; }
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.55rem; margin-bottom: var(--space-6); color: var(--text-faint); font-size: var(--text-sm); }
.breadcrumbs a { color: var(--text-faint); }
.breadcrumbs span[aria-hidden="true"] { color: var(--border-strong); }
.lesson-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-5); }
.mobile-progress { display: none; margin-top: var(--space-6); }
.progress-wrap { width: 100%; height: 0.42rem; overflow: hidden; border-radius: var(--radius-pill); background: var(--surface-muted); }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width 220ms ease; }
.progress-label { margin: var(--space-2) 0 0; color: var(--text-faint); font-size: var(--text-sm); }

/* 10. ARTÍCULO Y SIDEBAR */
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-10); align-items: start; }
.article { min-width: 0; }
.article > * { max-width: var(--reading); }
.article > .full-width, .article > .lesson-nav, .article > .content-meta { max-width: none; }
.article h2 { margin-top: clamp(2.75rem, 6vw, 4rem); scroll-margin-top: calc(var(--header-height) + 1.5rem); }
.article h3 { margin-top: var(--space-8); }
.article p, .article li, .article dd { color: var(--text-soft); }
.article a:not(.btn) { text-decoration: underline; }
.content-meta { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); padding-bottom: var(--space-5); margin-bottom: var(--space-8); border-bottom: 1px solid var(--border); }
.content-meta a { font-weight: 680; }
.sidebar { display: none; }
.side-card { padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle); }
.side-card + .side-card { margin-top: var(--space-4); }
.side-card h2 { margin-bottom: var(--space-3); font-size: var(--text-base); }
.side-card a { display: block; border-radius: var(--radius-sm); color: var(--text-soft); font-size: var(--text-sm); font-weight: 620; padding: 0.4rem 0; text-decoration: none; }
.side-card a:hover { color: var(--primary); }
.toc a { border-left: 2px solid var(--border); padding-left: var(--space-3); }

/* 11. BLOQUES PEDAGÓGICOS */
.objectives, .summary-box {
  margin-block: var(--space-8);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-lg);
  background: var(--primary-soft);
  padding: clamp(1.1rem, 4vw, 1.5rem);
}
.objectives h2, .summary-box h2 { margin: 0 0 var(--space-3); font-size: var(--text-xl); }
.objectives p:last-child, .objectives ul:last-child, .summary-box p:last-child, .summary-box ul:last-child { margin-bottom: 0; }
.recap { display: flex; gap: var(--space-3); align-items: flex-start; margin-block: var(--space-6); padding-block: var(--space-4); border-block: 1px solid var(--border); }
.recap-icon { width: 1.75rem; height: 1.75rem; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--surface-muted); color: var(--text-soft); font-weight: 800; }
.recap p { margin: 0; }
.callout { margin-block: var(--space-6); padding: var(--space-4) var(--space-5); border-left: 3px solid var(--primary); background: var(--primary-soft); }
.callout.success { border-color: var(--success); background: var(--success-soft); }
.callout.warning { border-color: var(--warning); background: var(--warning-soft); }
.callout.danger { border-color: var(--danger); background: var(--danger-soft); }
.callout > :last-child { margin-bottom: 0; }
.steps { counter-reset: steps; list-style: none; padding: 0; }
.steps li { position: relative; min-height: 2rem; padding-left: 2.8rem; }
.steps li + li { margin-top: var(--space-4); }
.steps li::before { counter-increment: steps; content: counter(steps); position: absolute; top: 0.05rem; left: 0; width: 1.8rem; height: 1.8rem; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface); color: var(--text); font-size: var(--text-xs); font-weight: 800; }
.mistake { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-4); margin-block: var(--space-6); padding: var(--space-5); border: 1px solid var(--danger-border); border-radius: var(--radius-lg); background: var(--danger-soft); }
.mistake-icon { width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border-radius: 50%; background: var(--danger); color: #fff; font-size: var(--text-sm); font-weight: 850; }
.mistake h3 { margin-top: 0; font-size: var(--text-lg); }
.independent { margin-block: var(--space-8); padding-block: var(--space-6); border-block: 1px solid var(--border); }
.independent h3 { margin-top: var(--space-3); }
.independent details { margin-top: var(--space-4); }
details { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
summary { cursor: pointer; padding: var(--space-4); color: var(--text); font-weight: 700; }
details[open] summary { border-bottom: 1px solid var(--border); }
details > :not(summary) { margin-inline: var(--space-4); }
details > :last-child { margin-bottom: var(--space-4); }
.related-links { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.related-links a { border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); color: var(--text-soft); padding: 0.4rem 0.7rem; font-size: var(--text-sm); font-weight: 650; text-decoration: none !important; }
.related-links a:hover { border-color: var(--primary-border); background: var(--primary-soft); color: var(--primary); }

/* 12. CÓDIGO */
.code-block, .syntax-box { margin-block: var(--space-6); overflow: hidden; border: 1px solid #26344a; border-radius: var(--radius-lg); background: var(--surface-code); color: #e8eef9; }
.code-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 2.6rem; padding: 0.45rem 0.7rem 0.45rem 1rem; border-bottom: 1px solid #2b3b52; background: var(--surface-code-toolbar); color: #aebbd0; font-size: 0.7rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.copy-btn { min-height: 2rem; border: 1px solid #3d4d66; border-radius: var(--radius-sm); background: transparent; color: #e5ebf5; padding: 0.28rem 0.6rem; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0; text-transform: none; cursor: pointer; }
.copy-btn:hover { background: #25334a; border-color: #536580; }
.code-block pre, .syntax-box pre { margin: 0; overflow: auto; padding: clamp(1rem, 4vw, 1.4rem); font-size: clamp(0.79rem, 2.3vw, 0.925rem); line-height: 1.75; tab-size: 2; }
.code-block code, .syntax-box code { color: inherit; }

/* 13. TABLAS */
.data-example { margin-block: var(--space-6); }
.data-example figcaption { margin-bottom: var(--space-2); color: var(--text-faint); font-size: var(--text-sm); font-weight: 680; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overscroll-behavior-inline: contain; }
.table-wrap:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.data-table, .policy-table { width: 100%; min-width: 32rem; text-align: left; font-size: var(--text-sm); }
.data-table th, .data-table td, .policy-table th, .policy-table td { border-bottom: 1px solid var(--border); padding: 0.7rem 0.85rem; vertical-align: top; }
.data-table th, .policy-table th { background: var(--bg-subtle); color: var(--text); font-weight: 750; white-space: nowrap; }
.data-table tr:last-child td, .policy-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:nth-child(even) td, .policy-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-subtle) 55%, transparent); }
.policy-table { display: table; margin-block: var(--space-6); border: 1px solid var(--border); }
.null-value { color: var(--text-faint); font-family: var(--font-mono); font-size: 0.9em; }

/* 14. AUTOEVALUACIÓN Y EJERCICIOS */
.checkpoint { margin-block: var(--space-8); padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle); }
.checkpoint legend { margin-bottom: var(--space-3); color: var(--text); font-size: var(--text-lg); font-weight: 760; }
.choice-list { display: grid; gap: var(--space-2); margin-block: var(--space-4); }
.choice { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3); align-items: start; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); padding: 0.75rem 0.85rem; color: var(--text-soft); cursor: pointer; }
.choice:hover { border-color: var(--primary-border); background: var(--primary-soft); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.choice input { width: 1.05rem; height: 1.05rem; margin-top: 0.28rem; accent-color: var(--primary); }
.quiz-feedback, .feedback { min-height: 1.5rem; margin-top: var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 630; }
.quiz-feedback.success, .feedback.success { border: 1px solid var(--success-border); background: var(--success-soft); color: var(--success); padding: var(--space-3) var(--space-4); }
.quiz-feedback.error, .feedback.error { border: 1px solid var(--danger-border); background: var(--danger-soft); color: var(--danger); padding: var(--space-3) var(--space-4); }
.exercise { margin-block: var(--space-8); overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-xl); background: var(--surface); }
.exercise-head { padding: clamp(1.1rem, 4vw, 1.5rem); border-bottom: 1px solid var(--border); background: var(--bg-subtle); }
.exercise-head h3 { margin: var(--space-3) 0 var(--space-2); }
.exercise-head p:last-child { margin-bottom: 0; }
.exercise-body { padding: clamp(1.1rem, 4vw, 1.5rem); }
.sql-input { min-height: 10rem; background: var(--surface-code); border-color: #34435a; color: #eef3fa; font-family: var(--font-mono); font-size: max(0.875rem, 16px); line-height: 1.65; resize: vertical; }
.sql-input::placeholder { color: #8290a6; }
.sql-input:focus { border-color: #7da2ff; box-shadow: 0 0 0 4px color-mix(in srgb, #7da2ff 24%, transparent); }
.exercise-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); }
.hints { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
.hint { border-left: 3px solid var(--warning); background: var(--warning-soft); color: var(--text-soft); padding: var(--space-3) var(--space-4); }
.solution { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--border); }
.solution h4 { margin-bottom: var(--space-3); }

/* 15. NAVEGACIÓN DE LECCIÓN */
.lesson-nav { display: grid; gap: var(--space-3); margin-top: var(--space-12); padding-top: var(--space-6); border-top: 1px solid var(--border); }
.complete-wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); }
.complete-btn.is-complete { background: var(--success); color: #fff; border-color: var(--success); }
.lesson-nav .next { margin-left: auto; }

/* 16. CURSO */
.continue-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-5); margin-bottom: var(--space-10); padding: var(--space-5); border: 1px solid var(--primary-border); border-radius: var(--radius-lg); background: var(--primary-soft); }
.continue-card p { margin: 0; color: var(--text-soft); }
.continue-title { margin: 0 0 var(--space-1); font-size: var(--text-xl); }
.module-list { display: grid; gap: var(--space-12); }
.module { display: grid; gap: var(--space-5); padding-top: var(--space-6); border-top: 1px solid var(--border-strong); }
.module-head h2 { margin-bottom: var(--space-2); }
.module-head p { max-width: 40rem; margin-bottom: 0; color: var(--text-soft); }
.course-list { border-top: 1px solid var(--border); }
.lesson-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-4); align-items: start; border-bottom: 1px solid var(--border); color: var(--text); padding-block: var(--space-4); text-decoration: none; }
.lesson-card:hover { color: var(--text); background: var(--bg-subtle); text-decoration: none; }
.lesson-number { width: 2rem; height: 2rem; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--surface); color: var(--text-soft); font-size: var(--text-sm); font-weight: 750; }
.lesson-card h3 { margin: 0 0 var(--space-1); font-size: var(--text-md); }
.lesson-card p { margin: 0; color: var(--text-soft); font-size: var(--text-sm); }
.lesson-card-meta { grid-column: 2; color: var(--text-faint); font-size: var(--text-xs); line-height: 1.45; }
.lesson-card.done .lesson-number { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.lesson-card.done h3 { color: var(--success); }

/* 17. GLOSARIO */
.search-box { position: relative; max-width: 45rem; margin-bottom: var(--space-4); }
.search-box::before { content: ""; position: absolute; z-index: 1; top: 50%; left: 0.9rem; width: 0.85rem; height: 0.85rem; border: 2px solid var(--text-faint); border-radius: 50%; translate: 0 -60%; pointer-events: none; }
.search-box::after { content: ""; position: absolute; z-index: 1; top: calc(50% + 0.35rem); left: 1.7rem; width: 0.45rem; height: 2px; background: var(--text-faint); rotate: 45deg; pointer-events: none; }
.search-box input { padding-left: 2.65rem; padding-right: 6rem; min-height: 3.15rem; font-size: max(1rem, 16px); }
.search-clear { position: absolute; z-index: 2; top: 50%; right: 0.45rem; min-height: 2.25rem; translate: 0 -50%; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-faint); padding: 0.35rem 0.55rem; font-size: var(--text-sm); font-weight: 700; cursor: pointer; }
.search-clear:hover { background: var(--surface-muted); color: var(--text); }
.filter-row { display: flex; gap: var(--space-2); overflow-x: auto; padding: 0 0 var(--space-3); scrollbar-width: thin; }
.filter-btn { min-height: 2.35rem; flex: 0 0 auto; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); color: var(--text-soft); padding: 0.4rem 0.75rem; font-size: var(--text-sm); font-weight: 650; cursor: pointer; }
.filter-btn:hover { border-color: var(--border-strong); color: var(--text); }
.filter-btn[aria-pressed="true"] { border-color: var(--primary); background: var(--primary); color: #fff; }
.glossary-grid { display: grid; margin-top: var(--space-6); border-top: 1px solid var(--border); }
.term-card { position: relative; display: grid; gap: var(--space-1); border-bottom: 1px solid var(--border); color: var(--text); padding: var(--space-5) 0; text-decoration: none; }
.term-card:hover { color: var(--text); text-decoration: none; }
.term-card::after { content: "→"; position: absolute; top: var(--space-5); right: var(--space-1); color: var(--text-faint); transition: translate var(--transition), color var(--transition); }
.term-card:hover::after { color: var(--primary); translate: 3px 0; }
.term-card h2 { max-width: calc(100% - 2rem); margin: 0; font-size: var(--text-md); }
.term-card p { max-width: 38rem; margin: 0; color: var(--text-soft); font-size: var(--text-sm); }
.term-category { margin-top: var(--space-2); color: var(--text-faint); }
.empty-state { display: none; margin-top: var(--space-8); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: var(--space-8); text-align: center; }
.empty-state h2 { font-size: var(--text-xl); }

/* 18. FAQ */
.faq { border-bottom: 1px solid var(--border); }
.faq:first-child { border-top: 1px solid var(--border); }
.faq > button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); border: 0; background: transparent; color: var(--text); padding: var(--space-5) 0; font-weight: 720; text-align: left; cursor: pointer; }
.faq > button span:last-child { width: 1.5rem; height: 1.5rem; display: grid; place-items: center; flex: 0 0 auto; color: var(--text-faint); font-size: var(--text-lg); transition: rotate var(--transition); }
.faq.open > button span:last-child { rotate: 45deg; }
.faq-panel { display: block; max-width: 42rem; padding: 0 0 var(--space-5); color: var(--text-soft); }
.js .faq-panel { display: none; }
.js .faq.open .faq-panel { display: block; }

/* 19. PÁGINAS DE CONFIANZA, LEGALES Y CONTACTO */
.trust-grid, .contact-channels, .sitemap-sections { display: grid; gap: var(--space-4); }
.required-box, .status-box { margin-bottom: var(--space-6); border-left: 3px solid var(--warning); background: var(--warning-soft); padding: var(--space-4) var(--space-5); }
.status-box { border-color: var(--success); background: var(--success-soft); }
.required-box p:last-child, .status-box p:last-child { margin-bottom: 0; }
.legal-data { display: grid; grid-template-columns: minmax(9rem, 0.45fr) minmax(0, 1fr); border-top: 1px solid var(--border); }
.legal-data dt, .legal-data dd { margin: 0; border-bottom: 1px solid var(--border); padding: var(--space-3) 0; }
.legal-data dt { color: var(--text); font-weight: 700; }
.legal-data dd { color: var(--text-soft); }
.privacy-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block: var(--space-5); }
.contact-channels { margin-bottom: var(--space-10); }
.contact-email { font-size: clamp(1rem, 4vw, var(--text-xl)); font-weight: 750; overflow-wrap: anywhere; }
.source-list { padding-left: 0; list-style: none; }
.source-list li { padding-block: var(--space-3); border-bottom: 1px solid var(--border); }
.sitemap-group { min-width: 0; padding-top: var(--space-5); border-top: 1px solid var(--border); }
.sitemap-group h2 { font-size: var(--text-xl); }
.sitemap-group ul { columns: 1; }
.author-profile { display: grid; gap: var(--space-5); align-items: start; margin-bottom: var(--space-8); }
.author-avatar { width: 4.5rem; height: 4.5rem; display: grid; place-items: center; border: 1px solid var(--primary-border); border-radius: var(--radius-lg); background: var(--primary-soft); color: var(--primary); font-weight: 850; }
.legal-nav { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* 20. FOOTER */
.footer { margin-top: var(--space-16); border-top: 1px solid var(--border); background: var(--bg-subtle); padding-block: var(--space-12) var(--space-6); }
.footer-grid { display: grid; gap: var(--space-8); }
.footer-grid > div:first-child { max-width: 24rem; }
.footer-grid h3 { margin-bottom: var(--space-3); font-size: var(--text-sm); letter-spacing: 0.02em; }
.footer-grid > div > a:not(.brand) { display: block; width: fit-content; margin-block: 0.42rem; color: var(--text-soft); font-size: var(--text-sm); text-decoration: none; }
.footer-grid > div > a:not(.brand):hover { color: var(--primary); text-decoration: underline; }
.footer-bottom { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-10); padding-top: var(--space-5); border-top: 1px solid var(--border); color: var(--text-faint); font-size: var(--text-xs); }

/* 21. 404 */
.not-found { width: min(calc(100% - 2rem), 42rem); margin-inline: auto; padding-block: clamp(4rem, 14vw, 8rem); text-align: center; }
.big { color: var(--primary); font-size: clamp(5rem, 23vw, 10rem); font-weight: 850; letter-spacing: -0.08em; line-height: 0.9; }
.not-found .lead { margin-inline: auto; }

/* 22. RESPONSIVE — TABLET */
@media (min-width: 40rem) {
  .container, .narrow, .page-hero .narrow, .page-hero .lesson-heading { width: min(calc(100% - 3rem), var(--container)); }
  .narrow, .page-hero .narrow { max-width: var(--reading); }
  .grid-2, .contact-channels, .trust-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson-card { grid-template-columns: auto minmax(0, 1fr) 6rem; align-items: center; padding-inline: var(--space-2); }
  .lesson-card-meta { grid-column: 3; text-align: right; }
  .glossary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-8); }
  .term-card:nth-child(2) { border-top: 0; }
  .sitemap-sections { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sitemap-group.wide, .sitemap-group.full { grid-column: 1 / -1; }
  .sitemap-group ul { columns: 2; column-gap: var(--space-8); }
  .author-profile { grid-template-columns: auto minmax(0, 1fr); }
  .footer-grid { grid-template-columns: 1.3fr repeat(3, 1fr); }
  .footer-bottom { flex-direction: row; justify-content: space-between; }
  .lesson-nav { grid-template-columns: 1fr auto; align-items: center; }
}

/* 23. RESPONSIVE — DESKTOP */
@media (min-width: 56rem) {
  .hero-grid { grid-template-columns: minmax(0, 1.08fr) minmax(22rem, 0.92fr); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .article-layout { grid-template-columns: minmax(0, 1fr) var(--sidebar); gap: clamp(2rem, 5vw, 4.5rem); }
  .sidebar { display: block; position: sticky; top: calc(var(--header-height) + var(--space-6)); }
  .module { grid-template-columns: minmax(13rem, 0.38fr) minmax(0, 1fr); gap: clamp(2rem, 5vw, 5rem); }
  .module-head { position: sticky; top: calc(var(--header-height) + var(--space-6)); align-self: start; }
  .trust-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card, .trust-card { padding-right: var(--space-5); }
}

/* 24. RESPONSIVE — MENÚ MÓVIL */
@media (max-width: 47.99rem) {
  :root { --header-height: 3.75rem; }
  body.menu-open { overflow: hidden; }
  .nav { position: relative; }
  .brand { max-width: calc(100% - 6.25rem); }
  .js .menu-btn { display: inline-grid; margin-left: auto; }
  .js .nav-links {
    position: fixed;
    z-index: 99;
    inset: var(--header-height) 0 auto;
    max-height: calc(100dvh - var(--header-height));
    display: none;
    overflow: auto;
    margin: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    padding: var(--space-3) 1rem var(--space-5);
    box-shadow: 0 12px 20px rgba(16, 24, 40, 0.08);
  }
  .js .nav-links.open { display: grid; }
  html:not(.js) .nav { flex-wrap: wrap; height: auto; padding-block: var(--space-2); }
  html:not(.js) .nav-links { order: 3; width: 100%; display: grid; margin: 0; border-top: 1px solid var(--border); padding-top: var(--space-2); }
  .nav-links a { min-height: 2.85rem; display: flex; align-items: center; border-bottom: 1px solid var(--border); border-radius: 0; padding-inline: 0.25rem; }
  .nav-links a:last-child { border-bottom: 0; }
  .mobile-progress { display: block; }
  .section-head { align-items: start; flex-direction: column; }
  .section-head .btn { width: 100%; }
  .actions .btn { flex: 1 1 12rem; }
  .exercise-actions .btn { width: 100%; }
  .complete-wrap { align-items: stretch; flex-direction: column; }
  .complete-wrap .btn, .lesson-nav .next { width: 100%; margin-left: 0; }
  .legal-data { grid-template-columns: 1fr; }
  .legal-data dt { border-bottom: 0; padding-bottom: 0; }
  .footer { margin-top: var(--space-12); }
}

@media (max-width: 24rem) {
  .container, .narrow, .page-hero .narrow, .page-hero .lesson-heading { width: min(calc(100% - 1.25rem), var(--container)); }
  .brand > span:last-child { font-size: var(--text-sm); }
  .brand-mark { width: 2rem; height: 2rem; }
  .page-hero { padding-top: var(--space-10); }
  .pill { white-space: normal; }
  .mistake { grid-template-columns: minmax(0, 1fr); }
}

/* 25. TEMA OSCURO */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-subtle: #121821;
  --surface: #111720;
  --surface-raised: #161e29;
  --surface-muted: #1a2330;
  --surface-code: #070b10;
  --surface-code-toolbar: #101722;
  --text: #edf2f7;
  --text-soft: #b5c0cf;
  --text-faint: #8e9aac;
  --border: #27313d;
  --border-strong: #3b4655;
  --primary: #8caaff;
  --primary-hover: #b1c3ff;
  --primary-soft: #172442;
  --primary-border: #304878;
  --success: #63d5ab;
  --success-soft: #122a23;
  --success-border: #245b49;
  --warning: #f5c15d;
  --warning-soft: #2b2414;
  --warning-border: #665021;
  --danger: #ff919e;
  --danger-soft: #30191d;
  --danger-border: #6d3039;
  --focus: #ffc35b;
  --shadow-float: 0 16px 40px rgba(0, 0, 0, 0.34);
}
[data-theme="dark"] .btn-primary, [data-theme="dark"] .filter-btn[aria-pressed="true"] { color: #07101f; }
[data-theme="dark"] .page-hero { background: #10161f; }
[data-theme="dark"] .site-header { background: color-mix(in srgb, var(--bg) 96%, transparent); }
[data-theme="dark"] .sql-input { background: #080d14; }
[data-theme="dark"] .data-table tbody tr:nth-child(even) td, [data-theme="dark"] .policy-table tbody tr:nth-child(even) td { background: #121923; }

/* 26. MOVIMIENTO REDUCIDO */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* 27. IMPRESIÓN */
@media print {
  :root { --bg: #fff; --text: #000; --text-soft: #222; --text-faint: #444; --border: #bbb; --primary: #000; --primary-soft: #fff; }
  body { font-size: 11pt; line-height: 1.5; }
  .site-header, .footer, .sidebar, .breadcrumbs, .actions, .exercise-actions, .copy-btn, .mobile-progress, .complete-wrap, .lesson-nav, .filter-row, .search-box { display: none !important; }
  .page-hero { padding: 0 0 1.2rem; border-bottom: 1px solid #bbb; background: #fff; }
  .section, .section-compact { padding: 1rem 0; }
  .container, .narrow, .page-hero .narrow, .page-hero .lesson-heading { width: 100%; max-width: none; }
  .article-layout { display: block; }
  .article > * { max-width: none; }
  .code-block, .syntax-box, .sql-input { border-color: #555; background: #fff; color: #000; break-inside: avoid; }
  .code-toolbar { background: #eee; color: #000; border-bottom-color: #999; }
  .table-wrap { overflow: visible; border-color: #777; }
  .data-table, .policy-table { min-width: 0; font-size: 9pt; }
  .exercise, .mistake, .objectives, .summary-box, .checkpoint, figure, table { break-inside: avoid; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #444; overflow-wrap: anywhere; }
}
