/*
 * ADC Lab - manual.css
 *
 * Design system: paper sheet on an off-white desk, serif prose, uppercase
 * monospace for everything the machine says, one cobalt accent.
 */

@import url("https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,600;1,400&display=swap");

:root {
  --background: #fbfbfb;
  --sheet: #ffffff;
  --foreground: #171717;

  --color-primary: #306eff;
  --color-primary-hover: #4a80ff;
  --color-primary-active: #175cff;
  --color-error: #ff663b;

  --ink-80: rgba(0, 0, 0, 0.80);
  --ink-50: rgba(0, 0, 0, 0.50);
  --ink-35: rgba(0, 0, 0, 0.35);
  --ink-25: rgba(0, 0, 0, 0.25);
  --ink-12: rgba(0, 0, 0, 0.12);
  --ink-6: rgba(0, 0, 0, 0.06);
  --ink-2: rgba(0, 0, 0, 0.025);

  --font-serif: "EB Garamond", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --font-scale: 1;

  --transition: 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);

  --toc-width: 300px;
  --sheet-max: 1024px;
  --measure: 576px;
  --figure-max: 860px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-serif);
  font-size: calc(14px * var(--font-scale));
  line-height: 1.8;
  display: grid;
  grid-template-columns: var(--toc-width) minmax(0, 1fr) minmax(0, 12vw);
  -webkit-font-smoothing: antialiased;
}

@media (max-width: 1100px) {
  body { grid-template-columns: 1fr; }
  .toc, .ruler { display: none; }
}

/* ------------------------------------------------------------------ */
/* Machine voice                                                       */
/* ------------------------------------------------------------------ */

.mono, .meta, .toc-section, .breadcrumb, .btn, .ch-num, .lab-id, .lab-title,
.ctl-label, .ctl-value, .lab-readouts, .try-id, .ctl-note,
.dict-en, .dict-tag, .dict-tabs, .seg-opt, .dots, .readout, .kicker {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Chinese annotations inside machine-voice labels keep the book voice. */
.ctl-label em, .lab-readouts dt em, .lab-cn, .dict-tabs em {
  font-family: var(--font-serif);
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
}

/* ------------------------------------------------------------------ */
/* Table of contents                                                   */
/* ------------------------------------------------------------------ */

.toc {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 2.5rem 2rem 6rem;
  mask-image: linear-gradient(to bottom, black 88%, transparent 100%);
}

.toc .logo {
  font: 400 16px var(--font-mono);
  text-transform: uppercase;
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: 0.04em;
}

.toc .logo-sub {
  display: block;
  font: 400 10px var(--font-mono);
  text-transform: uppercase;
  color: var(--ink-50);
  margin-top: 0.25rem;
  letter-spacing: 0.05em;
}

.toc-section {
  font-size: 11px;
  color: var(--ink-50);
  margin: 2.25rem 0 0.5rem;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc li a {
  display: flex;
  gap: 0.6em;
  font: 400 14px/1.9 var(--font-serif);
  color: var(--foreground);
  text-decoration: none;
  transition: color 150ms;
}

.toc li a .ch-num {
  font-size: 10px;
  color: var(--ink-35);
  min-width: 2.2em;
  line-height: 2.7;
}

.toc li a.active,
.toc li a:hover { color: var(--color-primary); }

.toc li a.active .ch-num { color: var(--color-primary); }

.toc-figs {
  margin: 0.15rem 0 0.5rem 2.8em;
  padding: 0;
  list-style: none;
}

.toc-figs li a {
  font: 400 10px/2.1 var(--font-mono);
  text-transform: uppercase;
  color: var(--ink-50);
}

.toc-figs li a:hover { color: var(--color-primary); }

/* ------------------------------------------------------------------ */
/* Reading zone, breadcrumb, sheet                                     */
/* ------------------------------------------------------------------ */

.reading-zone { min-width: 0; }

.breadcrumb {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75em;
  padding: 0.9rem 1.5rem;
  background: color-mix(in srgb, var(--background) 92%, transparent);
  backdrop-filter: blur(4px);
  font-size: 11px;
}

.breadcrumb .crumb.parent { color: var(--ink-50); }
.breadcrumb .crumb.sep { color: var(--ink-25); }
.breadcrumb .crumb.current { color: var(--foreground); }
.breadcrumb .crumb.status {
  margin-left: auto;
  color: var(--ink-50);
}

.sheet {
  background: var(--sheet);
  max-width: var(--sheet-max);
  margin: 0.5rem auto 7.5rem;
  padding: 80px 64px 96px;
  border-radius: 2px;
  box-shadow:
    0 1px 4px 1px rgba(0, 0, 0, 0.05),
    0 0 0 0.5px rgba(0, 0, 0, 0.25);
}

@media (max-width: 1100px) {
  .sheet { padding: 48px 24px 64px; }
}

/* ------------------------------------------------------------------ */
/* Article header                                                      */
/* ------------------------------------------------------------------ */

.article-header {
  text-align: center;
  margin-bottom: 5rem;
}

.meta {
  font-size: 11px;
  color: var(--ink-50);
  margin: 0;
}

.meta .sep { color: var(--ink-25); margin: 0 0.5em; }

.article-header h1 {
  font: 400 36px/44px var(--font-serif);
  letter-spacing: -0.5px;
  color: var(--ink-80);
  margin: 1.25rem 0 0.75rem;
}

.lede {
  font: 400 14px/1.7 var(--font-serif);
  color: #4a5565;
  max-width: 34em;
  margin: 0 auto;
}

.dots {
  font-size: 12px;
  color: var(--ink-50);
  letter-spacing: 0.35em;
  margin-top: 2.5rem;
}

/* Datasheet-style stats block under the header. */
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 260px));
  gap: 0.3rem 3rem;
  justify-content: center;
  margin: 2.5rem auto 0;
  font: 400 10px/1.5 var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stats div { display: flex; justify-content: space-between; gap: 1em; }
.stats dt { color: var(--ink-50); }
.stats dd { margin: 0; color: var(--foreground); }

/* ------------------------------------------------------------------ */
/* Prose                                                               */
/* ------------------------------------------------------------------ */

.prose {
  max-width: var(--measure);
  margin: 0 auto;
}

.prose p {
  font-size: calc(14px * var(--font-scale));
  line-height: 1.85;
  text-align: justify;
  hyphens: manual;
  margin: 0 0 1.5em;
}

.chapter { margin: 0 0 7rem; }

.chapter-head {
  max-width: var(--measure);
  margin: 0 auto 2.25rem;
}

.chapter-head .kicker {
  display: block;
  font-size: 11px;
  color: var(--ink-50);
  margin-bottom: 0.6rem;
}

.chapter-head h2 {
  font: 400 24px/1.35 var(--font-serif);
  letter-spacing: -0.3px;
  color: var(--ink-80);
  margin: 0;
}

.prose h3 {
  font: 600 calc(14px * var(--font-scale)) / 1.55 var(--font-serif);
  letter-spacing: -0.2px;
  margin: 3em 0 1em;
}

.prose h3:first-child { margin-top: 0; }

.prose em.aside { font-style: italic; }

.prose strong { font-weight: 600; }

sub, sup { line-height: 0; font-size: 0.75em; }

.prose code, .formula {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--ink-2);
  padding: 2px 3px;
  letter-spacing: 0;
}

.formula {
  display: block;
  text-align: center;
  margin: 1.4em auto;
  padding: 0.6em 1em;
  font-size: 12px;
  line-height: 1.7;
  border-top: 1px solid var(--ink-12);
  border-bottom: 1px solid var(--ink-12);
  background: none;
}

.prose a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--color-primary) 50%, transparent);
  text-underline-offset: 2px;
  transition: text-decoration-color 150ms;
}

.prose a:hover { text-decoration-color: var(--color-primary); }

.prose .term {
  text-decoration: underline dotted rgba(0, 0, 0, 0.5);
  text-underline-offset: 2px;
  cursor: help;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0 2em;
  font-size: 13px;
  line-height: 1.6;
}

.prose th {
  font: 400 10px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-50);
  text-align: left;
  padding: 0.4em 0.6em;
  border-bottom: 1px solid var(--foreground);
}

.prose td {
  padding: 0.45em 0.6em;
  border-bottom: 0.5px solid var(--ink-25);
  vertical-align: top;
}

.prose ul, .prose ol {
  padding-left: 1.4em;
  margin: 0 0 1.5em;
}

.prose li { margin-bottom: 0.4em; text-align: left; }

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  font-size: 12px;
  color: var(--foreground);
  background: #fff;
  border: 1px solid #000;
  border-radius: 3px;
  padding: 0.45em 1em;
  box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.3;
}

.btn:hover { background: #f4f4f4; }

.btn:active {
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.55);
  transform: translate(1px, 2px);
}

.btn-small {
  font-size: 10px;
  padding: 0.35em 0.8em;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.55);
}

.btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary-active); }

/* ------------------------------------------------------------------ */
/* Ruler                                                               */
/* ------------------------------------------------------------------ */

.ruler {
  position: fixed;
  top: 80px;
  right: 0;
  bottom: 40px;
  width: 56px;
  pointer-events: none;
}

.ruler .ticks {
  position: absolute;
  inset: 0 16px 0 auto;
  width: 12px;
  background: repeating-linear-gradient(to bottom, var(--ink-25) 0 1px, transparent 1px 8px);
}

.ruler .major {
  position: absolute;
  right: 12px;
  width: 20px;
  height: 2px;
  background: #000;
}

.ruler .readout {
  position: absolute;
  right: 30px;
  font-size: 12px;
  color: var(--color-primary);
  transform: translateY(-50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Footer                                                              */
/* ------------------------------------------------------------------ */

.colophon {
  max-width: var(--measure);
  margin: 6rem auto 0;
  padding-top: 2rem;
  border-top: 1px solid var(--ink-12);
  font: 400 10px/1.8 var(--font-mono);
  text-transform: uppercase;
  color: var(--ink-50);
  letter-spacing: 0.03em;
}

.colophon a { color: var(--ink-50); }
