:root {
  --ink: #182235;
  --muted: #56647a;
  --paper: #fff;
  --canvas: #f4f6fa;
  --line: #dce3ee;
  --brand: #163e78;
  --soft: #eaf1ff;
  --focus: #b54708;
  --good: #08744a;
  --bad: #a12626;
  --shadow: 0 16px 42px rgb(26 45 77 / 8%);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  min-width: 0;
  margin: 0;
  background: linear-gradient(135deg, #f8fafc, #eef3fa);
  color: var(--ink);
  font: 1rem/1.75 Inter, ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", sans-serif;
  overflow-wrap: break-word;
}

/* Enlace para saltar directamente al contenido */
.skip-link {
  position: fixed;
  z-index: 30;
  top: -6rem;
  left: 1rem;
  padding: .65rem 1rem;
  border-radius: .45rem;
  background: #fff;
  color: #111;
  box-shadow: var(--shadow);
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 1rem;
}

/* Cabecera y navegación */
header {
  padding: clamp(3rem, 8vw, 6.5rem) 1.5rem 4rem;
  background:
    radial-gradient(circle at 18% 0, #3367b6 0, transparent 30%),
    linear-gradient(125deg, #0d244a, #173f7a);
  color: #fff;
  text-align: center;
}

.eyebrow {
  margin: 0 0 .65rem;
  color: #d6e5ff;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1 {
  max-width: 25ch;
  margin: 0 auto;
  font-size: clamp(2.1rem, 5vw, 3.7rem);
  line-height: 1.12;
  letter-spacing: -.035em;
  text-wrap: balance;
}

nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
  backdrop-filter: blur(14px);
}

nav a {
  display: inline-block;
  padding: .48rem .82rem;
  border-radius: 999px;
  color: #35435a;
  text-decoration: none;
  font-size: .92rem;
  line-height: 1.45;
}

nav a:hover,
nav a[aria-current="page"] {
  background: var(--soft);
  color: var(--brand);
  font-weight: 750;
}

nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: .2em;
}

/* Estructura principal */
main {
  width: min(94vw, 96rem);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 5rem) 0;
}

section {
  min-width: 0;
  max-width: 88rem;
  margin: 0 auto clamp(2rem, 4vw, 3.5rem);
  padding: clamp(1.4rem, 3vw, 2.5rem);
  border: 1px solid rgb(220 227 238 / 85%);
  border-radius: 1rem;
  background: var(--paper);
  box-shadow: 0 2px 10px rgb(26 45 77 / 3.5%);
}

section > section {
  max-width: none;
  margin: 1.5rem 0 0;
  padding: 1.1rem;
  border-radius: .7rem;
  box-shadow: none;
}

h2 {
  margin: 0 0 1rem;
  color: #122f5b;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -.025em;
  text-wrap: balance;
}

h3 {
  margin: 1.8rem 0 .6rem;
  color: #1d3d6f;
  font-size: 1.2rem;
  line-height: 1.35;
}

h4 {
  margin: 1.4rem 0 .5rem;
  color: #263f65;
  font-size: 1.05rem;
  line-height: 1.4;
}

p,
li,
th,
td {
  overflow-wrap: break-word;
}

p {
  margin: .75rem 0 1rem;
}

ul,
ol {
  padding-left: 1.6rem;
}

li + li {
  margin-top: .35rem;
}

.lead {
  max-width: 72ch;
  margin-top: 0;
  font-size: clamp(1.07rem, 1.4vw, 1.18rem);
  line-height: 1.7;
  color: #30415b;
}

/* Destacados pedagógicos */
.note,
.activity,
.check,
.warning {
  min-width: 0;
  margin: 1.3rem 0;
  padding: 1rem 1.2rem;
  border-left: 4px solid var(--brand);
  border-radius: 0 .65rem .65rem 0;
  background: #f5f8ff;
}

.activity {
  border-left-color: #a96706;
  background: #fff8e8;
}

.check {
  border-left-color: var(--good);
  background: #edf9f3;
}

.warning {
  border-left-color: var(--bad);
  background: #fff3f3;
}

.note > :first-child,
.activity > :first-child,
.check > :first-child,
.warning > :first-child {
  margin-top: 0;
}

.note > :last-child,
.activity > :last-child,
.check > :last-child,
.warning > :last-child {
  margin-bottom: 0;
}

/* Tarjetas */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 1rem;
}

.card {
  min-width: 0;
  height: 100%;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: linear-gradient(145deg, #fff, #f8faff);
  box-shadow: 0 8px 22px rgb(26 45 77 / 5%);
}

.card h3 {
  margin-top: 0;
}

.card > :last-child {
  margin-bottom: 0;
}

/* Enlaces, controles y foco visible */
a {
  color: #154b9c;
  text-underline-offset: .16em;
}

a:hover {
  text-decoration-thickness: .12em;
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--brand);
  width: 1.1rem;
  height: 1.1rem;
  vertical-align: middle;
}

/* Código, ejemplos y tablas */
code {
  padding: .1em .32em;
  border-radius: .3rem;
  background: #eef2f8;
  color: #223654;
  font-size: .93em;
  overflow-wrap: anywhere;
}

pre {
  max-width: 100%;
  overflow-x: auto;
  margin: 1.1rem 0;
  padding: 1.2rem;
  border-radius: .75rem;
  background: #10213f;
  color: #f2f6ff;
  font-size: .92rem;
  line-height: 1.6;
  tab-size: 2;
}

pre code {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  overflow-wrap: normal;
  white-space: pre;
}

table {
  width: 100%;
  max-width: 100%;
  margin: 1.25rem 0;
  border: 1px solid var(--line);
  border-radius: .7rem;
  border-spacing: 0;
  border-collapse: separate;
  background: #fff;
}

caption {
  padding: .75rem;
  text-align: left;
  color: var(--muted);
  font-weight: 750;
}

th,
td {
  min-width: 0;
  padding: .85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f4fa;
  color: #233c65;
}

tr:last-child td,
tr:last-child th {
  border-bottom: 0;
}

/* Paneles desplegables */
details {
  margin: 1.4rem 0;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: #f9fbff;
}

summary {
  padding: 1rem 1.15rem;
  color: #173f7a;
  font-weight: 750;
  cursor: pointer;
}

details > div {
  padding: 0 1.15rem 1.15rem;
}

details[open] summary {
  border-bottom: 1px solid var(--line);
}

/* Autoevaluaciones y checklists existentes */
.quiz fieldset,
fieldset[data-checklist] {
  min-width: 0;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
}

.quiz legend,
fieldset[data-checklist] legend {
  max-width: 100%;
  padding: 0 .3rem;
  font-weight: 750;
  line-height: 1.5;
}

.quiz label,
fieldset[data-checklist] label {
  display: block;
  margin: .7rem 0;
  cursor: pointer;
}

.quiz label:has(input:checked),
fieldset[data-checklist] label:has(input:checked) {
  font-weight: 650;
}

.quiz button {
  min-height: 2.75rem;
  padding: .7rem 1.1rem;
  border: 0;
  border-radius: .5rem;
  background: var(--brand);
  color: #fff;
  font-weight: 750;
}

.quiz button:hover {
  background: #0d2d5b;
}

.feedback {
  margin: .45rem 0 0;
}

.result,
.checklist-status {
  margin-top: 1rem;
  font-weight: 750;
}

.correct {
  color: var(--good);
}

.incorrect {
  color: var(--bad);
}

/* Vídeo responsivo */
.video {
  max-width: 66rem;
  margin: 1.5rem auto;
  overflow: hidden;
  border-radius: .8rem;
  background: #10213f;
  box-shadow: var(--shadow);
}

.video iframe {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 0;
}

footer {
  padding: 2rem 1rem;
  background: #10213f;
  color: #e8efff;
  text-align: center;
}

/* Adaptación a pantallas pequeñas */
@media (max-width: 42rem) {
  html {
    scroll-padding-top: 7rem;
  }

  main {
    width: calc(100% - 1rem);
    padding: 1.3rem 0 2rem;
  }

  header {
    padding: 2.8rem 1rem 3rem;
  }

  nav {
    justify-content: flex-start;
    padding: .5rem;
    gap: .25rem;
  }

  nav a {
    padding: .45rem .6rem;
    font-size: .85rem;
  }

  section {
    padding: 1.15rem;
    border-radius: .75rem;
  }

  section > section {
    padding: .9rem;
  }

  .note,
  .activity,
  .check,
  .warning {
    padding: .9rem 1rem;
  }

  .card {
    padding: 1rem;
  }

  pre {
    padding: 1rem;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  th,
  td {
    min-width: 9rem;
    padding: .7rem;
  }
}

/* Respeto a la preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

h2{scroll-margin-top:5.5rem}.topic-index{position:static;display:flex;align-items:center;gap:.45rem;flex-wrap:wrap;max-width:88rem;margin:0 auto 1.5rem;padding:.8rem 1rem;border:1px solid var(--line);border-radius:.7rem;background:#f9fbff}.topic-index span{margin-right:.25rem;color:var(--muted);font-size:.85rem;font-weight:800;text-transform:uppercase;letter-spacing:.06em}.topic-index a{padding:.28rem .5rem;border-radius:.35rem;text-decoration:none;font-size:.88rem}.topic-index a:hover{background:var(--soft)}details.expandable{background:#fbfcff}.expandable summary{display:flex;align-items:center;gap:.5rem}.expandable summary::after{content:"+";margin-left:auto;font-size:1.25rem;line-height:1}.expandable[open] summary::after{content:"–"}.expandable.code-example{margin:1.25rem 0}.expandable.code-example>div{padding-top:1rem}@media(max-width:42rem){.topic-index{align-items:flex-start}.topic-index span{width:100%}}