/* Apunte EDO–EDP — sans-serif, terracota, claro/oscuro automático */
:root {
  --bg: #faf8f5;
  --fg: #292420;
  --muted: #6e655a;
  --accent: #b3492b;
  --surface: #f2ece5;
  --border: #e3dacd;
  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1714;
    --fg: #e8e1d6;
    --muted: #a89a88;
    --accent: #e08a5f;
    --surface: #26211b;
    --border: #3c342a;
  }
}

html { font-size: 18px; }

body {
  margin: 0 auto;
  max-width: var(--measure);
  padding: 1.25rem 1.5rem 4rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto,
               "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: var(--bg); }

/* ---- Nav entre capítulos (la genera build_html.sh) ---- */
.chapnav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .4em 1.5em;
  font-size: .8rem;
}
.chapnav a { color: var(--muted); text-decoration: none; }
.chapnav a:hover { color: var(--accent); }
.chapnav .index {
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}
body > .chapnav:first-child {
  border-bottom: 1px solid var(--border);
  padding-bottom: .8em;
  margin-bottom: 2.5rem;
}
body > .chapnav:last-child {
  border-top: 1px solid var(--border);
  padding-top: .8em;
  margin-top: 3rem;
}

/* ---- TOC ---- */
#TOC {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .9em 1.3em;
  margin-bottom: 2.5rem;
  font-size: .85rem;
}
#TOC ul { list-style: none; padding-left: 0; margin: 0; }
#TOC ul ul { padding-left: 1.1em; }
#TOC li { margin: .3em 0; }
#TOC a { color: var(--fg); text-decoration: none; }
#TOC a:hover { color: var(--accent); }

/* En pantallas anchas: TOC como sidebar fija a la izquierda */
@media (min-width: 82rem) {
  body {
    display: grid;
    grid-template-columns: 15rem var(--measure);
    column-gap: 3.5rem;
    justify-content: center;
    max-width: none;
  }
  body > * { grid-column: 2; min-width: 0; }
  #TOC {
    grid-column: 1;
    grid-row: 1 / span 999;
    align-self: start;
    position: sticky;
    top: 1.25rem;
    max-height: calc(100vh - 2.5rem);
    overflow-y: auto;
    background: none;
    border: none;
    border-left: 2px solid var(--border);
    border-radius: 0;
    padding: 0 0 0 1.1em;
    margin: 0;
  }
}

/* ---- Títulos y texto ---- */
#title-block-header { text-align: center; margin-bottom: 1.5rem; }
#title-block-header .title {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: .3em;
  font-size: 2.1rem;
}

h1 {
  font-size: 1.8rem;
  line-height: 1.25;
  margin: 0 0 1.4em;
  padding-bottom: .45em;
  border-bottom: 3px solid var(--accent);
}
h2 { font-size: 1.3rem; margin: 2.2em 0 .7em; }
h3 { font-size: 1.08rem; margin: 1.8em 0 .5em; }
h4 { font-size: 1rem; margin: 1.5em 0 .5em; }

p { margin: 1em 0; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
a:hover { text-decoration-color: var(--accent); }

ul, ol { padding-left: 1.6em; margin: 1em 0; }
li { margin: .25em 0; }

hr { border: none; border-top: 1px solid var(--border); margin: 2.5em 0; }

/* ---- Figuras ---- */
figure { margin: 2.2em 0; }
img { max-width: 100%; height: auto; }
figure img {
  background: #fff;          /* los PNG tienen fondo blanco: queda como
                                tarjeta y en dark mode no deslumbra */
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .7em;
  box-sizing: border-box;
}
figcaption {
  font-size: .82rem;
  line-height: 1.5;
  color: var(--muted);
  margin-top: .8em;
}

/* ---- Código ---- */
code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo,
               Consolas, monospace;
  font-size: .84em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1em .35em;
}
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .9em 1.1em;
  overflow-x: auto;
}
pre code { background: none; border: none; padding: 0; font-size: .82rem; }

/* ---- Varios ---- */
blockquote {
  margin: 1.5em 0;
  padding: .5em 1.2em;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}
blockquote p { margin: .5em 0; }

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.6em 0;
  font-size: .88rem;
  display: block;
  overflow-x: auto;
}
th, td { padding: .45em .8em; }
thead th { border-bottom: 2px solid var(--fg); text-align: left; }
tbody tr { border-top: 1px solid var(--border); }
tbody { border-bottom: 2px solid var(--fg); }

/* Ecuaciones display anchas: scroll en vez de romper el layout */
.math.display { overflow-x: auto; overflow-y: hidden; padding: .3em 0; }

/* ---- Móvil ---- */
@media (max-width: 40rem) {
  html { font-size: 16px; }
  body { padding: 1rem 1rem 3rem; }
  h1 { font-size: 1.45rem; }
}

/* ---- Impresión ---- */
@media print {
  #TOC, .chapnav { display: none; }
  body { max-width: none; color: #000; background: #fff; }
  figure img { border: none; padding: 0; }
}
