/* Design for Manufacturing and Assembly: From Prototype to Production
   Shared stylesheet. Plain HTML/CSS, no build step. */

:root {
  --bg: #fdfdfb;
  --fg: #1c1c1c;
  --muted: #5a5a5a;
  --line: #d8d8d2;
  --accent: #0b5cad;
  --accent-soft: #e8f0fa;
  --ok: #1f7a3a;
  --bad: #a83a2a;
  --code-bg: #f1f1ec;
  --nav-bg: #f5f5f0;
  --max: 46rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161715;
    --fg: #e6e6e1;
    --muted: #a5a59e;
    --line: #3a3b37;
    --accent: #6fa8e6;
    --accent-soft: #1d2a3a;
    --ok: #5cc27a;
    --bad: #e07a6a;
    --code-bg: #22231f;
    --nav-bg: #1d1e1b;
  }
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

/* Layout: header, sidebar, main */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--nav-bg);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-header .brand {
  font-weight: 600;
  text-decoration: none;
  color: var(--fg);
  font-size: 1.05rem;
}

.site-header .brand span { color: var(--muted); font-weight: 400; }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: none;
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  min-height: calc(100vh - 3.5rem);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--nav-bg);
  padding: 1.25rem 1rem 2rem;
  font-size: 0.92rem;
}

.sidebar h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 1rem 0 0.4rem;
}

.sidebar ol { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin: 0; }
.sidebar li a,
.sidebar li span {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  text-decoration: none;
  color: var(--fg);
}
.sidebar li a:hover { background: var(--accent-soft); }
.sidebar li.current a { background: var(--accent-soft); font-weight: 600; }
.sidebar li span.planned { color: var(--muted); }
.sidebar li .num { display: inline-block; min-width: 1.6rem; color: var(--muted); }
.sidebar li.done .num::after { content: " ✓"; color: var(--ok); }

main {
  padding: 2rem 1.5rem 4rem;
  max-width: calc(var(--max) + 3rem);
  width: 100%;
  min-width: 0;
}

.sidebar, main { min-width: 0; }

/* Typography */

h1, h2, h3, h4 { line-height: 1.25; margin: 2.2rem 0 0.8rem; font-weight: 650; }
h1 { font-size: 1.9rem; margin-top: 0.5rem; }
h2 { font-size: 1.45rem; border-bottom: 1px solid var(--line); padding-bottom: 0.3rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

p, li { max-width: var(--max); }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.4rem; }
li { margin-bottom: 0.35rem; }

.kicker { color: var(--muted); font-size: 0.9rem; margin: 0; text-transform: uppercase; letter-spacing: 0.05em; }
.lead { font-size: 1.1rem; }

small, .small { font-size: 0.88rem; color: var(--muted); }

code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; background: var(--code-bg); padding: 0.05em 0.3em; border-radius: 3px; }

blockquote { margin: 1rem 0; padding: 0.2rem 0 0.2rem 1rem; border-left: 3px solid var(--line); color: var(--muted); }

hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

sup.cite { font-size: 0.75em; }
sup.cite a { text-decoration: none; }

/* Tables */

.table-wrap { overflow-x: auto; margin: 1rem 0 1.5rem; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
caption { text-align: left; color: var(--muted); padding: 0 0 0.4rem; font-size: 0.9rem; }
th, td { border: 1px solid var(--line); padding: 0.45rem 0.6rem; text-align: left; vertical-align: top; }
th { background: var(--nav-bg); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* Figures and SVG diagrams */

figure { margin: 1.5rem 0; max-width: var(--max); }
figure svg { width: 100%; height: auto; display: block; color: var(--fg); }
figcaption { font-size: 0.9rem; color: var(--muted); margin-top: 0.5rem; }
.diagram-accent { stroke: var(--accent); }
.diagram-accent-fill { fill: var(--accent); }
.diagram-soft { fill: var(--accent-soft); }
.diagram-text { font-family: inherit; font-size: 12px; fill: var(--fg); }
.diagram-text-muted { font-family: inherit; font-size: 11px; fill: var(--muted); }

/* Callouts: plain, bordered, no decorative colour boxes */

.note { border-left: 3px solid var(--accent); padding: 0.4rem 0 0.4rem 1rem; margin: 1.2rem 0; max-width: var(--max); }
.note > :last-child { margin-bottom: 0; }

/* Details / collapsible */

details { border: 1px solid var(--line); border-radius: 4px; padding: 0.6rem 1rem; margin: 1rem 0; max-width: var(--max); }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 0.6rem; }

/* Quiz */

.quiz fieldset { border: 1px solid var(--line); border-radius: 4px; margin: 1rem 0; padding: 0.8rem 1rem; max-width: var(--max); }
.quiz legend { font-weight: 600; padding: 0 0.3rem; }
.quiz label { display: block; padding: 0.25rem 0; cursor: pointer; }
.quiz input[type="radio"] { margin-right: 0.5rem; }
.quiz input[type="number"], .quiz input[type="text"] { font: inherit; padding: 0.3rem 0.5rem; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--fg); width: 10rem; }
.quiz input:focus-visible, .quiz button:focus-visible, .nav-toggle:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.quiz .explain { margin: 0.5rem 0 0; font-size: 0.92rem; color: var(--muted); }
.quiz fieldset.correct { border-color: var(--ok); }
.quiz fieldset.incorrect { border-color: var(--bad); }
.quiz .verdict { font-weight: 600; margin-left: 0.5rem; }
.quiz fieldset.correct .verdict { color: var(--ok); }
.quiz fieldset.incorrect .verdict { color: var(--bad); }
.quiz button {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
}
.quiz button.secondary { background: transparent; color: var(--accent); }
.quiz-pre fieldset { margin: 0.6rem 0; padding: 0.6rem 0.9rem; }
.quiz-score { display: block; margin-top: 1rem; font-weight: 600; }
.quiz-score.pass { color: var(--ok); }
.quiz-score.fail { color: var(--bad); }

/* Progress bar (index) */

.progress { margin: 1rem 0 2rem; max-width: var(--max); }
.progress-bar { height: 0.7rem; background: var(--code-bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress-bar > div { height: 100%; background: var(--accent); width: 0; transition: width 0.3s; }
.progress p { margin: 0.4rem 0 0; font-size: 0.9rem; color: var(--muted); }

/* Module list on index */

.module-list { list-style: none; padding: 0; }
.module-list li { border-bottom: 1px solid var(--line); padding: 0.7rem 0; display: grid; grid-template-columns: 2.5rem 1fr auto; gap: 0.6rem; align-items: baseline; }
.module-list .num { color: var(--muted); }
.module-list .status { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.module-list .status.done { color: var(--ok); }
.module-list .desc { display: block; font-size: 0.92rem; color: var(--muted); margin-top: 0.15rem; }

/* Prev / next */

.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 3rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); max-width: var(--max); }
.pager a, .pager span { max-width: 48%; }
.pager span { color: var(--muted); }
.pager .label { display: block; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Objectives / takeaways */

.objectives li, .takeaways li { margin-bottom: 0.5rem; }

/* References */

.glossary dt { font-weight: 600; margin-top: 1rem; }
.glossary dd { margin: 0.2rem 0 0 0; }
.glossary dt:target { background: var(--accent-soft); }

.references { font-size: 0.92rem; padding-left: 2.2rem; }
.references li { margin-bottom: 0.6rem; overflow-wrap: anywhere; }
.references li:target { background: var(--accent-soft); }
.references .tag { font-size: 0.8rem; color: var(--muted); }

/* Footer */

.site-footer { border-top: 1px solid var(--line); padding: 1.5rem; font-size: 0.88rem; color: var(--muted); }
.site-footer p { margin: 0.2rem 0; }

/* Responsive */

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar.open { display: block; }
  .nav-toggle { display: inline-block; }
  main { padding: 1.5rem 1rem 3rem; }
  html { font-size: 16px; }
}

/* Print */

@media print {
  .site-header, .sidebar, .nav-toggle, .pager, .quiz button, .site-footer .no-print { display: none !important; }
  .layout { display: block; }
  main { max-width: none; padding: 0; }
  body { color: #000; background: #fff; font-size: 11pt; }
  a { color: #000; text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #444; }
  .references a[href^="http"]::after { content: ""; }
  details { border: 0; padding: 0; }
  details > summary { list-style: none; }
  details:not([open]) > *:not(summary) { display: block; }
  .table-wrap { overflow: visible; }
  figure svg { max-height: 9cm; }
  h2, h3 { page-break-after: avoid; }
  table, figure, fieldset { page-break-inside: avoid; }
}
