/* Lecciones: texto largo con fórmulas, cajas de definición/ejemplo, ejercicios y widgets. */

main.lesson { max-width: 860px; padding-top: 26px; }
.lesson { font-size: 1.02rem; line-height: 1.7; }
.lesson p, .lesson li { max-width: 72ch; }
.lesson h1 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); margin-bottom: 12px; }
.lesson h2 { font-size: 1.45rem; margin: 0 0 14px; }
.lesson h3 { font-size: 1.1rem; margin: 26px 0 8px; }
.lesson section { padding-top: 34px; scroll-margin-top: calc(var(--mbar-h) + 12px); }
.lesson section + section { border-top: 1px solid var(--border); margin-top: 26px; }
.lesson ul, .lesson ol { padding-left: 1.3em; }
.lesson li { margin-bottom: 0.35em; }
.lesson .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.lesson .katex { font-size: 1.06em; }
.lesson strong { font-weight: 650; }

.eyebrow { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 650; margin-bottom: 6px; }
.lead { font-size: 1.15rem; color: var(--text-muted); line-height: 1.6; }

.objectives {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 18px 0 6px;
}
.objectives h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 6px; }
.objectives ul { margin: 0; }

/* ---------- cajas ---------- */
.box {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 18px 0;
  background: var(--surface);
  border: 1px solid var(--border);
}
.box > :last-child { margin-bottom: 0; }
.box-title {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-muted);
}
.box.def { background: var(--accent-soft); border-color: transparent; }
.box.def .box-title { color: var(--accent); }
.box.thm { background: color-mix(in srgb, var(--s4) 10%, var(--surface)); border-color: transparent; }
.box.thm .box-title { color: var(--s4); }
.box.example .box-title { color: var(--good); }
.box.warn { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border-color: transparent; }
.box.warn .box-title { color: var(--warn); }
.box.tip { background: var(--surface-2); border-color: transparent; }
.box.recipe { background: color-mix(in srgb, var(--s5) 9%, var(--surface)); border-color: transparent; }
.box.recipe .box-title { color: var(--s5); }
.box.recipe ol { margin: 0; }

/* ---------- ejercicios ---------- */
.exercises { counter-reset: ex; display: grid; gap: 14px; margin-top: 10px; }
.exercise {
  counter-increment: ex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.exercise > p:first-child::before {
  content: counter(ex) ". ";
  font-weight: 700;
  color: var(--accent);
}
.exercise .level { font-size: 0.78rem; border-radius: 99px; padding: 1px 8px; margin-left: 6px; background: var(--surface-2); color: var(--text-muted); vertical-align: 1px; }
details.solution { margin-top: 8px; }
details.solution > summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
  padding: 3px 0;
}
details.solution > summary::-webkit-details-marker { display: none; }
details.solution > summary::before { content: "▸"; transition: transform 0.15s; }
details.solution[open] > summary::before { transform: rotate(90deg); }
details.solution > div { padding: 8px 0 2px 14px; border-left: 2px solid var(--border); margin-top: 6px; }

/* ---------- autoevaluación ---------- */
.check { margin: 10px 0; }
.check input { width: 150px; font-family: var(--font-mono); }
.check-msg { font-size: 0.88rem; font-weight: 600; }
.check-msg.ok { color: var(--good); }
.check-msg.ko { color: var(--bad); }
.choice ul { list-style: none; padding: 0; display: grid; gap: 6px; margin: 8px 0; }
.choice li {
  max-width: none;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface);
}
.choice li:hover { border-color: var(--accent); }
.choice li.ok { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.choice li.ko { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }

/* ---------- widgets ---------- */
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin: 22px 0;
  display: grid;
  gap: 10px;
  line-height: 1.5;
}
.widget-plots { display: grid; gap: 12px; }
.widget-plots.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 680px) { .widget-plots.two { grid-template-columns: minmax(0, 1fr); } }
.widget canvas.plot { height: 260px; }
.widget canvas.plot.tall-w { height: 360px; }
.widget canvas.plot.square-w { height: 360px; width: 100%; max-width: 460px; justify-self: center; }
.widget-controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 18px; align-items: end; }
.widget-controls > .row, .widget-controls > .widget-tex { grid-column: 1 / -1; }
.widget-caption { font-size: 0.9rem; color: var(--text-muted); }
.widget-caption p { margin: 0; }
.widget .readout { margin: 0; }
.widget-error { color: var(--bad); }
.osc-scene { width: 100%; height: 130px; display: block; border-radius: 6px; }

/* ---------- varios ---------- */
.lesson table.data td { font-family: inherit; }
.lesson table.data th, .lesson table.data td { text-align: left; vertical-align: top; }
@media (max-width: 680px) { .lesson table.data { display: block; overflow-x: auto; } }
.lesson figure { margin: 20px 0; }
.lesson figure svg { display: block; max-width: 100%; height: auto; margin: 0 auto; color: var(--text); }
.lesson figcaption { font-size: 0.88rem; color: var(--text-muted); text-align: center; margin-top: 6px; }
.key-ideas { display: grid; gap: 8px; padding: 0; list-style: none; }
.key-ideas li { max-width: none; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin: 0; }
.lab-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  margin: 18px 0;
}
.lab-link:hover { background: var(--accent-soft); }
.lab-link strong { color: var(--accent); }
.lesson pre { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font-size: 0.85rem; line-height: 1.5; }

/* ---------- calculadora ---------- */
.calc-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 16px; }
.calc-in { display: grid; gap: 4px; }
.calc-label { font-size: 0.85rem; color: var(--text-muted); }
.calc-field { display: flex; align-items: center; gap: 6px; }
.calc-field input { width: 100%; font-family: var(--font-mono); }
.calc-field .unit, .calc-value .unit { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; }
.calc-outputs { display: grid; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; }
.calc-out { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.calc-value { font: 650 1.25rem var(--font-mono); color: var(--accent); }

/* ---------- diagramas UML, grafo de dependencias y comparador (diagramas.js) ---------- */
.diagram-scroll { overflow-x: auto; }
.uml-svg, .deps-svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.uml-box { fill: var(--surface); stroke: var(--text); stroke-width: 1.2; }
.uml-headbox { fill: var(--accent-soft); stroke: var(--text); stroke-width: 1.2; }
.uml-class.interface .uml-headbox { fill: color-mix(in srgb, var(--s4) 15%, var(--surface)); }
.uml-name { font: 600 13px var(--font-mono); fill: var(--text); text-anchor: middle; }
.uml-stereo { font: 12px var(--font-mono); fill: var(--text-muted); text-anchor: middle; }
.uml-member { font: 13px var(--font-mono); fill: var(--text); }
.uml-name.italic, .uml-member.italic { font-style: italic; }
.uml-member.under { text-decoration: underline; }
.uml-sep { stroke: var(--text); stroke-width: 1; }
.uml-line { stroke: var(--text); stroke-width: 1.3; fill: none; }
.uml-line.dashed { stroke-dasharray: 6 4; }
.uml-head.hollow { fill: var(--surface); stroke: var(--text); stroke-width: 1.3; }
.uml-head.filled { fill: var(--text); stroke: var(--text); }
.uml-mult, .uml-label, .seq-msg {
  font: 12.5px var(--font-sans); fill: var(--text); text-anchor: middle;
  paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round;
}
.uml-mult { fill: var(--text-muted); }
.seq-msg { font-family: var(--font-mono); font-size: 12.5px; }
.seq-msg.start { text-anchor: start; }
.seq-life { stroke: var(--text-muted); stroke-dasharray: 4 4; }
.seq-part { font: 600 13px var(--font-sans); fill: var(--text); text-anchor: middle; }
.seq-actor { fill: none; stroke: var(--text); stroke-width: 1.4; }
.seq-frame-box { fill: none; stroke: var(--border-strong); stroke-width: 1.2; }
.seq-tab { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1.2; }
.seq-kind { font: 600 12px var(--font-sans); fill: var(--text); }
.seq-cond { font: 12px var(--font-sans); fill: var(--text-muted); }
.seq-else { stroke: var(--border-strong); stroke-dasharray: 5 4; }

.deps-node { cursor: pointer; outline: none; }
.deps-node rect { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.4; }
.deps-node:hover rect, .deps-node:focus-visible rect { stroke: var(--accent); }
.deps-node.selected rect { stroke: var(--accent); stroke-width: 2.5; fill: var(--accent-soft); }
.deps-label { font: 600 13px var(--font-sans); fill: var(--text); text-anchor: middle; }
.deps-i { font: 12px var(--font-mono); fill: var(--text-muted); text-anchor: middle; }
.deps-edge { stroke: var(--text-muted); stroke-width: 1.5; }
.deps-edge.head { fill: var(--text-muted); stroke: none; }
.deps-edge.cycle { stroke: var(--bad); stroke-width: 2; }
.deps-edge.cycle.head { fill: var(--bad); stroke: none; }
.deps-edge.sdp { stroke: var(--warn); stroke-width: 2; stroke-dasharray: 6 4; }
.deps-edge.sdp.head { fill: var(--warn); stroke: none; }
.deps-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 680px) { .deps-grid { grid-template-columns: minmax(0, 1fr); } }
.deps-problems ul { margin: 0; padding-left: 1.2em; font-size: 0.9rem; }
.deps-problems li { margin-bottom: 4px; color: var(--bad); }

.compare { margin: 18px 0; }
.compare-tabs { display: flex; gap: 4px; }
.compare-tabs button {
  padding: 5px 12px; border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0;
  background: var(--surface-2); color: var(--text-muted); font: 600 0.84rem var(--font-sans); cursor: pointer;
}
.compare-tabs button[aria-selected="true"] { background: var(--surface); color: var(--accent); }
.compare > [data-label] { margin-top: 0; border: 1px solid var(--border); border-radius: 0 8px 8px 8px; }
.compare > pre[data-label] { background: var(--surface); }

/* ---------- resaltado de código (highlight.js, con los colores del cuaderno) ---------- */
.lesson pre code.hljs { background: none; padding: 0; }
.hljs-keyword, .hljs-selector-tag { color: var(--s4); }
.hljs-string, .hljs-regexp { color: var(--s3); }
.hljs-comment, .hljs-quote { color: var(--text-muted); font-style: italic; }
.hljs-title.class_, .hljs-type, .hljs-built_in { color: var(--s5); }
.hljs-title.function_ { color: var(--s1); }
.hljs-number, .hljs-literal { color: var(--s2); }
.hljs-meta { color: var(--s6); }
.hljs-params, .hljs-variable { color: var(--text); }
