/* ============================================================
   Estilo compartido del curso "Impresión 3D"
   Todas las lecciones y referencias enlazan este archivo.
   Diseño: serif para lectura larga, medidas cortas, tinta sobre papel.
   ============================================================ */

:root {
  --ink: #16130f;
  --ink-soft: #4a443c;
  --paper: #fffdf9;
  --paper-alt: #f5f1e8;
  --rule: #ded7c9;
  --accent: #9a3412;      /* naranja quemado: filamento caliente */
  --accent-soft: #fdf0e6;
  --good: #1a6b45;
  --bad: #a12525;
  --measure: 34rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece7de;
    --ink-soft: #a39c90;
    --paper: #16150f;
    --paper-alt: #201e17;
    --rule: #38342a;
    --accent: #e8834a;
    --accent-soft: #2a1d13;
    --good: #63c093;
    --bad: #e8797a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  padding: 4rem 1.5rem 8rem;
  max-width: var(--measure);
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 19px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Tipografía ---------- */

h1, h2, h3 { line-height: 1.2; font-weight: 600; }

h1 {
  font-size: 2.1rem;
  margin: 0 0 .3rem;
  letter-spacing: -.02em;
}

h2 {
  font-size: 1.35rem;
  margin: 3.2rem 0 .8rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

h3 { font-size: 1.08rem; margin: 2rem 0 .4rem; }

p { margin: 0 0 1.1rem; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { background: var(--accent-soft); }

strong { font-weight: 600; }

code, .mono {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: .82em;
  background: var(--paper-alt);
  padding: .1em .35em;
  border-radius: 3px;
}

pre {
  background: var(--paper-alt);
  border-left: 3px solid var(--rule);
  padding: .9rem 1rem;
  overflow-x: auto;
  font-size: .8rem;
  line-height: 1.5;
}
pre code { background: none; padding: 0; font-size: 1em; }

/* ---------- Cabecera de lección ---------- */

.kicker {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 .9rem;
}

.dek {
  font-size: 1.12rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0 0 2.5rem;
}

.meta-line {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: .78rem;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.2rem;
  margin-bottom: 2.4rem;
}

/* ---------- Bloques destacados ---------- */

.callout {
  background: var(--paper-alt);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.2rem;
  margin: 1.8rem 0;
  font-size: .95rem;
}
.callout > :last-child { margin-bottom: 0; }
.callout .label {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: .45rem;
}

.myth {
  border-left-color: var(--bad);
}
.myth .label { color: var(--bad); }

/* Nota al margen: al lado en pantallas anchas, en flujo si no cabe */
.sidenote {
  font-size: .8rem;
  line-height: 1.45;
  color: var(--ink-soft);
  border-left: 2px solid var(--rule);
  padding-left: .8rem;
  margin: 1.2rem 0;
}

@media (min-width: 1100px) {
  .sidenote {
    float: right;
    clear: right;
    width: 15rem;
    margin-right: -17.5rem;
    border-left: none;
    padding-left: 0;
  }
}

/* ---------- Tablas ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: .82rem;
  margin: 1.5rem 0;
}
th, td {
  text-align: left;
  padding: .5rem .6rem .5rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  font-weight: 600;
  border-bottom: 1.5px solid var(--ink-soft);
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.table-wrap { overflow-x: auto; }

/* ---------- Diagrama de flujo (cadena de producción) ---------- */

.pipeline {
  display: grid;
  gap: .5rem;
  margin: 2rem 0;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
.pipeline .step {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: .8rem;
  align-items: start;
  background: var(--paper-alt);
  padding: .7rem .9rem;
  border-radius: 4px;
}
.pipeline .n {
  width: 1.7rem; height: 1.7rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .8rem;
  font-weight: 600;
}
.pipeline .step b { font-size: .92rem; }
.pipeline .step p { margin: .15rem 0 0; font-size: .82rem; color: var(--ink-soft); line-height: 1.45; }

/* ---------- Quiz (ver assets/quiz.js) ---------- */

.quiz {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.2rem 1.3rem;
  margin: 1.8rem 0;
  background: var(--paper);
}
.quiz .q {
  font-weight: 600;
  margin: 0 0 .9rem;
  font-size: 1rem;
}
.quiz .opts { display: grid; gap: .45rem; }
.quiz button.opt {
  font: inherit;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: .88rem;
  text-align: left;
  padding: .6rem .8rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.quiz button.opt:hover:not(:disabled) { background: var(--paper-alt); }
.quiz button.opt:disabled { cursor: default; opacity: .55; }
.quiz button.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); opacity: 1; }
.quiz button.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); opacity: 1; }
.quiz .fb {
  margin-top: .9rem;
  font-size: .86rem;
  line-height: 1.5;
  display: none;
  padding-top: .8rem;
  border-top: 1px dashed var(--rule);
}
.quiz .fb.show { display: block; }
.quiz .score {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .8rem;
}

/* ---------- Widget genérico (calculadoras, simuladores) ---------- */

.widget {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.2rem 1.3rem;
  margin: 1.8rem 0;
  background: var(--paper-alt);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: .88rem;
}
.widget label { display: block; margin: .7rem 0 .2rem; font-size: .78rem; color: var(--ink-soft); }
.widget input[type=range] { width: 100%; accent-color: var(--accent); }
.widget .readout {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 1.4rem;
  color: var(--accent);
  margin-top: 1rem;
}
.widget .readout small { font-size: .8rem; color: var(--ink-soft); display: block; font-family: -apple-system, sans-serif; margin-top: .2rem; }

/* ---------- Widget de decisión (ver assets/decision.js) ---------- */

.decision .dq { margin-bottom: 1.1rem; }
.decision .dq-q { font-weight: 600; margin: 0 0 .45rem; font-size: .9rem; }
.decision .dq-opts { display: flex; flex-wrap: wrap; gap: .4rem; }
.decision .dq-opt {
  font: inherit;
  font-size: .82rem;
  padding: .45rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  flex: 1 1 12rem;
  text-align: left;
}
.decision .dq-opt:hover { border-color: var(--accent); }
.decision .dq-opt.on {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.decision-out {
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px dashed var(--rule);
}
.decision-wait { color: var(--ink-soft); font-size: .85rem; margin: 0; }
.decision-head { margin: 0 0 .6rem; font-size: 1rem; }
.decision-head b { color: var(--accent); }

table.decision-table { font-size: .8rem; margin: .5rem 0; }
table.decision-table td { padding: .35rem .5rem .35rem 0; border-bottom: 1px solid var(--rule); }
table.decision-table td.num { font-family: "SF Mono", ui-monospace, Menlo, monospace; white-space: nowrap; }
table.decision-table td.why { color: var(--ink-soft); font-size: .74rem; }
table.decision-table tr.fail { opacity: .45; }
table.decision-table tr.pass td:first-child { color: var(--good); font-weight: 700; }

.decision-delta { font-size: .85rem; margin: .8rem 0 0; }
.decision-note { font-size: .82rem; color: var(--ink-soft); margin: .6rem 0 0; line-height: 1.5; }

/* ---------- Simulador de veladuras (ver assets/blend.js) ---------- */

.blend-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .8rem;
  margin-top: .8rem;
}
@media (max-width: 34rem) { .blend-controls { grid-template-columns: 1fr; } }

.blend select {
  width: 100%;
  font: inherit;
  font-size: .82rem;
  padding: .4rem .5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}

.blend-ramp {
  display: flex;
  height: 2.6rem;
  margin: .9rem 0 1rem;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.blend-cell { flex: 1; position: relative; }
.blend-cell.on {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 1;
}

.blend-result {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: .9rem;
  align-items: start;
}
.blend-chip {
  height: 4.5rem;
  border-radius: 4px;
  border: 1px solid var(--rule);
}
.blend-text { margin: 0; font-size: .84rem; line-height: 1.5; }
.blend-text small { color: var(--ink-soft); font-size: .76rem; }

/* ---------- Visualizador de orientación (ver assets/orient.js) ---------- */

.orient-cases { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.orient-case {
  font: inherit; font-size: .8rem;
  padding: .35rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
}
.orient-case.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.orient-brief { font-size: .84rem; margin: 0 0 .9rem; color: var(--ink-soft); }

.orient-opts { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; }
.orient-opt {
  font: inherit; font-size: .82rem;
  padding: .45rem .8rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  flex: 1 1 8rem;
}
.orient-opt.on { border-color: var(--accent); background: var(--accent); color: #fff; }

.orient-svg {
  width: 100%;
  height: auto;
  display: block;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.orient-body { fill: var(--ink-soft); }
.orient-layer { stroke: var(--paper); stroke-width: 1.1; opacity: .6; }
.orient-bed { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.orient-arrow { stroke: var(--accent); stroke-width: 2.5; }
.orient-arrow-head { fill: var(--accent); }
.orient-flag { stroke: var(--bad); stroke-width: 2.5; stroke-dasharray: 4 3; }
.orient-flag-t { fill: var(--bad); font-size: 8px; font-family: -apple-system, sans-serif; }

.orient-scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: .5rem .9rem;
  margin: .9rem 0 .2rem;
}
.orient-score { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.orient-score .k { font-size: .74rem; color: var(--ink-soft); }
.orient-score .bar { display: flex; gap: 2px; }
.orient-score .bar span {
  width: .8rem; height: .42rem;
  border-radius: 1px;
  background: var(--rule);
}
.orient-score .bar span.on.s3 { background: var(--good); }
.orient-score .bar span.on.s2 { background: var(--accent); }
.orient-score .bar span.on.s1 { background: var(--bad); }

.orient-verdict { font-size: .84rem; line-height: 1.5; margin: .8rem 0 0; }

/* ---------- Simulador de slicer (ver assets/slice.js) ---------- */

.slice-cases { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.slice-case {
  font: inherit; font-size: .8rem;
  padding: .35rem .7rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
}
.slice-case.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.slice-brief { font-size: .84rem; margin: 0 0 1rem; color: var(--ink-soft); }

.slice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
  align-items: start;
}
@media (max-width: 34rem) { .slice-grid { grid-template-columns: 1fr; } }

.slice-seg { display: flex; gap: .3rem; margin-bottom: .2rem; }
.slice-seg button {
  font: inherit; font-size: .8rem;
  flex: 1;
  padding: .4rem .2rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  line-height: 1.2;
}
.slice-seg button small { display: block; font-size: .58rem; color: var(--ink-soft); }
.slice-seg button.on { border-color: var(--accent); background: var(--accent); color: #fff; }
.slice-seg button.on small { color: #fff; opacity: .8; }

.slice-val {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  color: var(--accent);
  font-size: .8rem;
}

.slice-num {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 1.35rem;
  color: var(--accent);
  margin-bottom: .8rem;
}
.slice-num small {
  display: block;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: .74rem;
  color: var(--ink-soft);
  margin-top: .15rem;
}

.slice-score { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .35rem; }
.slice-score .k { font-size: .74rem; color: var(--ink-soft); }
.slice-score .bar { display: flex; gap: 2px; }
.slice-score .bar span { width: .8rem; height: .42rem; border-radius: 1px; background: var(--rule); }
.slice-score .bar span.on.s3 { background: var(--good); }
.slice-score .bar span.on.s2 { background: var(--accent); }
.slice-score .bar span.on.s1 { background: var(--bad); }

.slice-goals { margin-top: 1rem; display: grid; gap: .3rem; }
.slice-goal { font-size: .8rem; color: var(--ink-soft); }
.slice-goal.ok { color: var(--good); }
.slice-goal.done {
  color: var(--good);
  font-weight: 600;
  border-top: 1px dashed var(--rule);
  padding-top: .5rem;
  margin-top: .3rem;
}

.slice-coach {
  margin: 1.1rem 0 0;
  padding-top: .9rem;
  border-top: 1px dashed var(--rule);
  font-size: .84rem;
  line-height: 1.5;
}
.slice-fine { font-size: .7rem; color: var(--ink-soft); margin: .7rem 0 0; }

/* ---------- Simulador de calces (ver assets/fit.js) ---------- */

.fit-vis {
  width: 100%;
  height: auto;
  display: block;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin-bottom: .8rem;
}
.fit-nominal { fill: none; stroke: var(--rule); stroke-width: 1.5; stroke-dasharray: 3 3; }
.fit-hole { fill: none; stroke: var(--ink-soft); stroke-width: 2; }
.fit-mate { fill: var(--accent); opacity: .85; }
.fit-mate.bad { fill: var(--bad); }
.fit-tag { fill: var(--ink-soft); font-size: 8.5px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

.fit-code pre { margin: .8rem 0 0; font-size: .68rem; }

.fit-read {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: .78rem;
  color: var(--ink-soft);
  display: grid;
  gap: .2rem;
  margin-bottom: .9rem;
}
.fit-read b { color: var(--accent); font-weight: 600; }

/* ---------- Pie de lección ---------- */

.footer {
  margin-top: 4rem;
  padding-top: 1.4rem;
  border-top: 2px solid var(--ink-soft);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: .84rem;
  color: var(--ink-soft);
}
.footer h3 {
  font-family: inherit;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 1.6rem 0 .4rem;
}
.footer ul { padding-left: 1.1rem; margin: .3rem 0; }
.footer li { margin-bottom: .3rem; }

.ask {
  background: var(--accent-soft);
  border-radius: 5px;
  padding: .9rem 1.1rem;
  margin-top: 1.8rem;
  font-size: .86rem;
  color: var(--ink);
}

/* ---------- Impresión en papel ---------- */

@media print {
  :root {
    --ink: #000; --ink-soft: #444; --paper: #fff;
    --paper-alt: #f2f2f2; --rule: #ccc; --accent: #8a2b0a;
  }
  body { font-size: 11pt; padding: 0; max-width: none; }
  .quiz button.opt { display: block; }
  h2 { break-after: avoid; }
  .callout, .pipeline, .quiz, table { break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 7pt; color: #666; word-break: break-all; }
  .sidenote { float: none; width: auto; margin: 1rem 0; }
}
