/* SPDX-License-Identifier: AGPL-3.0-or-later */
/*
 * OpenChuckCAM user guide: the one stylesheet (decision 0400; user-docs/STYLE.md, "Design").
 * Colours are tokens; each text colour's contrast ratio against --bg is in its comment (WCAG 2.x).
 * Fonts: the interface's IBM Plex files (OFL-1.1), copied in by user-docs/tools/build.py.
 */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("fonts/IBMPlexSans-Regular.ttf") format("truetype"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("fonts/IBMPlexSans-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("fonts/IBMPlexMono-Regular.ttf") format("truetype"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("fonts/IBMPlexMono-SemiBold.ttf") format("truetype"); }

:root {
  color-scheme: light;
  --bg: #fbfaf7;        /* warm off-white */
  --text: #1b1d1f;      /* 16.2:1 */
  --muted: #545860;     /* 6.8:1 */
  --accent: #365569;    /* oxidised steel, 7.6:1 */
  --rule: #d6d2ca;      /* decorative lines only */
  --code-bg: #f2f0eb;   /* text on it 14.8:1 */
  --note-bg: #eef2f4;
  --warn: #7a4e0e;      /* ochre, 6.5:1 on --warn-bg */
  --warn-bg: #faf3e3;
  --nav-bg: #f4f2ed;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --measure: 68ch;
  --step: 1.2;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151719; --text: #e4e2dd; --muted: #a2a6ab; --accent: #9cb6c8; --rule: #34383c;
    --code-bg: #1e2124; --note-bg: #1a2126; --warn: #d8a75e; --warn-bg: #231e15; --nav-bg: #191b1e;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151719; --text: #e4e2dd; --muted: #a2a6ab; --accent: #9cb6c8; --rule: #34383c;
  --code-bg: #1e2124; --note-bg: #1a2126; --warn: #d8a75e; --warn-bg: #231e15; --nav-bg: #191b1e;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 106.25%; /* 17px */ -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 1rem; line-height: 1.65;
  font-kerning: normal;
}

/* Skip link: visible on focus only. */
.skip { position: absolute; left: -999px; top: 0.5rem; background: var(--bg); color: var(--accent);
  padding: 0.4rem 0.8rem; border: 2px solid var(--accent); z-index: 10; }
.skip:focus { left: 0.5rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

/* ---------- Page frame ---------- */
.site-header {
  display: flex; align-items: baseline; gap: 1.25rem; flex-wrap: wrap;
  padding: 0.9rem 1.5rem; border-bottom: 1px solid var(--rule);
}
.site-title { font-weight: 600; color: var(--text); text-decoration: none; letter-spacing: 0.01em; }
.site-title span { color: var(--muted); font-weight: 400; }
.site-header .tools { margin-left: auto; display: flex; gap: 1rem; align-items: baseline; font-size: 0.875rem; }
.site-header .tools a, .site-header .tools button { color: var(--muted); }
.theme-toggle { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
  text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
.theme-toggle[hidden] { display: none; }

.layout { display: grid; grid-template-columns: 17rem minmax(0, 1fr); min-height: calc(100vh - 3.5rem); }
.sidebar { background: var(--nav-bg); border-right: 1px solid var(--rule); padding: 1.25rem 1.25rem 2rem; font-size: 0.9rem; }
.sidebar details > summary { display: none; }
.content { padding: 2.5rem 2.5rem 4rem; }
.content > main, .content > .page { max-width: var(--measure); }

/* Navigation list (mdBook's {{#toc}} markup). */
.sidebar ol { list-style: none; margin: 0; padding: 0; }
.sidebar ol ol { padding-left: 0.9rem; margin: 0.15rem 0 0.4rem; border-left: 1px solid var(--rule); }
.sidebar li { margin: 0.1rem 0; }
.sidebar a { color: var(--text); text-decoration: none; display: inline-block; padding: 0.1rem 0; }
.sidebar a:hover { text-decoration: underline; }
.sidebar a.active, .sidebar a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.sidebar .part-title, .sidebar .nav-part {
  margin: 1.1rem 0 0.3rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}
.sidebar li.chapter-item > span > div, .sidebar .draft { color: var(--muted); }
.sidebar .section-header strong, .sidebar strong[aria-hidden] { font-weight: 400; color: var(--muted); margin-right: 0.35em; }
.sidebar .spacer { border-top: 1px solid var(--rule); margin: 0.8rem 0; }

/* Search. */
.search { margin-bottom: 1.1rem; }
.search label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.2rem; }
.search input {
  width: 100%; font: inherit; font-size: 0.9rem; color: var(--text); background: var(--bg);
  border: 1px solid var(--muted); border-radius: 2px; padding: 0.3rem 0.5rem;
}
.searchresults-outer { margin-top: 0.6rem; }
.searchresults-header { font-size: 0.8rem; color: var(--muted); }
#mdbook-searchresults { list-style: none; padding: 0; margin: 0.3rem 0 0; }
#mdbook-searchresults li { margin: 0.5rem 0; }
#mdbook-searchresults .teaser { display: block; color: var(--muted); font-size: 0.82rem; }
.hidden { display: none !important; }
mark { background: var(--warn-bg); color: inherit; outline: 1px solid var(--warn); }

/* ---------- Text ---------- */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; margin: 2.2em 0 0.6em; letter-spacing: -0.005em; }
h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.5rem; padding-top: 0.4em; border-top: 1px solid var(--rule); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }
h1 + p { font-size: 1.1rem; color: var(--text); }
p, ul, ol, dl, table, figure, pre, blockquote, .callout { margin: 0 0 1.1em; }
li + li { margin-top: 0.3em; }
strong { font-weight: 600; }
.header a, a.header { color: inherit; text-decoration: none; }

code, kbd, pre { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--code-bg); padding: 0.08em 0.3em; border-radius: 2px; overflow-wrap: anywhere; }
pre { background: var(--code-bg); padding: 0.8rem 1rem; overflow-x: auto; border-radius: 2px; line-height: 1.5; }
pre code { background: none; padding: 0; }
kbd { border: 1px solid var(--muted); border-bottom-width: 2px; border-radius: 2px; padding: 0 0.3em; font-size: 0.82em; }

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

/* ---------- Numbered procedures ---------- */
/* An ordered list directly after an "Do this" lead sentence; numbers set in the margin. */
.content ol { counter-reset: step; list-style: none; padding-left: 2.4rem; }
.content ol > li { counter-increment: step; position: relative; }
.content ol > li::before {
  content: counter(step); position: absolute; left: -2.4rem; top: 0.05em;
  width: 1.6rem; text-align: right; font-weight: 600; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.content ol > li + li { margin-top: 0.5em; }

/* ---------- Figures ---------- */
figure { margin: 1.6em 0 1.8em; }
figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--rule); }
figcaption { margin-top: 0.5rem; font-size: 0.875rem; color: var(--muted); line-height: 1.5; }
figcaption b, figcaption strong { color: var(--text); font-weight: 600; }

/* ---------- Tables ---------- */
table { border-collapse: collapse; width: 100%; font-size: 0.94rem; display: block; overflow-x: auto; }
thead th { text-align: left; font-weight: 600; border-bottom: 2px solid var(--text); padding: 0.35rem 0.8rem 0.35rem 0; }
td { border-bottom: 1px solid var(--rule); padding: 0.45rem 0.8rem 0.45rem 0; vertical-align: top; }
td.num, th.num, td[align="right"], th[align="right"] { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Callouts: Note and Warning only ---------- */
/* Written as GitHub alerts (> [!NOTE], > [!WARNING]); mdBook renders them as blockquote.blockquote-tag. */
.callout, blockquote.blockquote-tag {
  border-left: 3px solid var(--accent); background: var(--note-bg);
  padding: 0.75rem 1rem; border-radius: 0; color: var(--text);
}
.callout > :last-child, blockquote.blockquote-tag > :last-child { margin-bottom: 0; }
.callout-title, .blockquote-tag-title {
  display: block; font-weight: 600; font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 0.3rem;
}
.blockquote-tag-title svg { display: none; }
.callout.warning, blockquote.blockquote-tag-warning, blockquote.blockquote-tag-caution { border-left-color: var(--warn); background: var(--warn-bg); }
.callout.warning .callout-title, blockquote.blockquote-tag-warning .blockquote-tag-title,
blockquote.blockquote-tag-caution .blockquote-tag-title { color: var(--warn); }
blockquote:not(.blockquote-tag) { margin-left: 0; padding-left: 1rem; border-left: 2px solid var(--rule); color: var(--muted); }

/* ---------- Glossary ---------- */
a.term { color: inherit; text-decoration-style: dotted; text-decoration-color: var(--accent); }
a.term:hover { color: var(--accent); }
.glossary h2 { font-size: 1.15rem; border-top: 0; padding-top: 0; margin: 1.8em 0 0.3em; }
.glossary h2 + p { margin-top: 0; }
.glossary .see { font-size: 0.9rem; color: var(--muted); }
.letter-index { font-size: 0.9rem; color: var(--muted); }

/* ---------- Page furniture ---------- */
.banner { border-bottom: 1px solid var(--rule); background: var(--note-bg); padding: 0.55rem 1.5rem; font-size: 0.9rem; }
.page-meta { color: var(--muted); font-size: 0.85rem; margin: -0.6rem 0 1.6rem; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: 0.95rem; }
.pager a { text-decoration: none; }
.pager a span { display: block; font-size: 0.8rem; color: var(--muted); }
.pager .next { margin-left: auto; text-align: right; }
.site-footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--rule); font-size: 0.82rem; color: var(--muted); max-width: var(--measure); }
.site-footer p { margin: 0 0 0.4em; }

/* Home page: no hero; a plain lead and a contents table. */
.home-start { border-top: 1px solid var(--rule); }
.home-start dt { font-weight: 600; margin-top: 1rem; }
.home-start dd { margin: 0.1rem 0 0; color: var(--text); }

/* ---------- Narrow screens ---------- */
@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--rule); padding: 0.6rem 1rem; }
  .sidebar details > summary { display: list-item; cursor: pointer; font-weight: 600; padding: 0.3rem 0; }
  .sidebar details:not([open]) > :not(summary) { display: none; }
  .content { padding: 1.5rem 1rem 3rem; }
  .site-header { padding: 0.7rem 1rem; }
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.35rem; }
  .content ol { padding-left: 2rem; }
  .content ol > li::before { left: -2rem; }
}

/* ---------- Print ---------- */
@media print {
  :root, :root[data-theme="dark"] { --bg: #fff; --text: #000; --muted: #333; --accent: #000; --rule: #999;
    --code-bg: #f3f3f3; --note-bg: #fff; --warn: #000; --warn-bg: #fff; color-scheme: light; }
  html { font-size: 11pt; }
  .sidebar, .site-header .tools, .pager, .skip, .banner, .search { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  .content > main, .content > .page, .site-footer { max-width: none; }
  a { color: inherit; text-decoration: none; }
  main a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: var(--muted); word-break: break-all; }
  figure, table, .callout, blockquote, pre { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  #mdbook-content h1 { break-before: page; }
  #mdbook-content > h1:first-child, #mdbook-content > :first-child h1 { break-before: auto; }
  .callout, blockquote.blockquote-tag { border-left-width: 3px; }
  img { max-width: 100% !important; }
}
/* mdBook's search script hides and shows its wrapper; here the box is always shown. */
.search.hidden { display: block !important; }

/* ---------- Home page hero ----------
 * One plain statement, who it is for, two routes, the version, the G-code notice, and a real screenshot.
 * No gradient, no buttons: the routes are a ruled list of links. */
.hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 2.5rem; align-items: start;
  padding: 0 0 1rem; margin: 0 0 1.5rem; }
.nowrap { white-space: nowrap; }
.hero-text { min-width: 0; }
.hero-meta { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.9rem; }
.hero-meta a { color: var(--muted); }
.hero h1 { font-size: 2.35rem; line-height: 1.15; letter-spacing: -0.015em; margin: 0 0 1rem; border: 0; padding: 0; }
.hero-lead { font-size: 1.1rem; margin: 0 0 1.6rem; }
.routes { list-style: none; padding: 0 !important; margin: 0 0 1.5rem; border-top: 1px solid var(--rule); counter-reset: none; }
.routes > li { border-bottom: 1px solid var(--rule); margin: 0 !important; padding: 0; }
.routes > li::before { content: none !important; }
.routes a { display: grid; grid-template-columns: 2rem 1fr; padding: 0.75rem 0; text-decoration: none; color: var(--text); }
.routes a:hover .route-title { text-decoration: underline; }
.route-num { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.route-title { font-weight: 600; color: var(--accent); }
.route-text { grid-column: 2; color: var(--muted); font-size: 0.92rem; }
.hero-notice { border-left: 3px solid var(--warn); padding: 0.1rem 0 0.1rem 0.9rem; font-size: 0.92rem; margin: 0; }
.hero-notice strong { color: var(--warn); }
.hero-figure { margin: 0.4rem 0 0; }
.hero-figure img { width: 100%; }
/* The hero sits in the content column beside the contents, so the column widens on the home page. */
.home .content > main { max-width: 74rem; }
.home .content > main > #mdbook-content > :not(.hero) { max-width: var(--measure); }
@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; gap: 1.5rem; }
  .hero-figure { order: 2; }
}
@media (max-width: 900px) {
  .hero h1 { font-size: 1.8rem; }
}
@media print {
  .hero { display: block; border: 0; }
  .routes a { display: block; }
}

/* ---------- Version switch and the note on an older release (theme/versions.js) ---------- */
.version-switch select { font: inherit; font-size: 0.875rem; color: var(--text); background: var(--bg);
  border: 1px solid var(--muted); border-radius: 2px; padding: 0.05rem 0.3rem; }
.version-switch label { color: var(--muted); margin-right: 0.35rem; }
.older-release { border-bottom: 1px solid var(--rule); background: var(--note-bg); padding: 0.55rem 1.5rem; font-size: 0.9rem; }
@media print { .older-release, .version-switch { display: none !important; } }
