/* SchoolCAD Help: the look of every Help page (the pages are made by tools/help-build.mjs).
 * Colours are the app's tokens (css/app.css), so Help matches SchoolCAD in light and dark. */
:root {
  --bg: #f4f5f7; --panel: #ffffff; --panel-2: #f6f7f9; --line: #d5d9e0; --line-strong: #b9bfca;
  --ink: #1b1d22; --muted: #5f6673; --accent: #2a55c9; --accent-ink: #ffffff; --accent-weak: #e2e9fb;
  --ok: #2c8350; --warn: #9a6200; --err: #c0362b; --timber: #a8603f;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.08), 0 6px 24px rgba(20, 24, 33, 0.06);
  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --logo-bg: #2a55c9; --logo-fg: #ffffff;
  --hd: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a; --panel: #1c1f25; --panel-2: #22262d; --line: #2d3139; --line-strong: #3d434e;
    --ink: #e7e9ee; --muted: #9aa2b0; --accent: #7d9dff; --accent-ink: #0d1430; --accent-weak: #222e52;
    --ok: #5cc285; --warn: #e3a83a; --err: #ff7a6b; --timber: #d79a79;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.35);
    --logo-bg: #7d9dff; --logo-fg: #0d1430;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a; --panel: #1c1f25; --panel-2: #22262d; --line: #2d3139; --line-strong: #3d434e;
  --ink: #e7e9ee; --muted: #9aa2b0; --accent: #7d9dff; --accent-ink: #0d1430; --accent-weak: #222e52;
  --ok: #5cc285; --warn: #e3a83a; --err: #ff7a6b; --timber: #d79a79;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 28px rgba(0, 0, 0, 0.35);
  --logo-bg: #7d9dff; --logo-fg: #0d1430;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--hd) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font-ui); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip:focus { left: 8px; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 5px; text-align: center;
  font: 600 0.78em/1.7 var(--font-mono); color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; vertical-align: 0.06em;
}
code { font: 0.9em var(--font-mono); background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
pre code { border: 0; padding: 0; background: none; }

/* ---------- header ---------- */
.hd {
  position: sticky; top: 0; z-index: 30; height: var(--hd); display: flex; align-items: center; gap: 14px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.hd-brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; flex: none; }
.hd-brand .logo-mark { width: 28px; height: 28px; flex: none; }
.hd-brand .logo-word { height: 16px; width: auto; fill: currentColor; }
.lm-bg, .lm-node { fill: var(--logo-bg); }
.lm-line, .lm-node { stroke: var(--logo-fg); }
.hd-help { font: 600 17px var(--font-display); color: var(--accent); padding-left: 9px; border-left: 1px solid var(--line); }
.hd-search { position: relative; flex: 1; max-width: 560px; margin-left: auto; }
.hd-search .help-search { width: 100%; padding: 8px 34px 8px 12px; }
.hd-slash { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.hd-app { flex: none; padding: 8px 14px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.hd-app:hover { filter: brightness(1.08); }
.hd-menu { display: none; flex: none; width: 38px; height: 38px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); cursor: pointer; }
.help-search {
  font: 15px var(--font-ui); color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.help-search:focus { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 3px var(--accent-weak); }
.help-search::-webkit-search-cancel-button { cursor: pointer; }

/* search results */
.search-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 40; list-style: none; margin: 0; padding: 4px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow);
  max-height: min(70vh, 520px); overflow-y: auto; text-align: left;
}
.search-list li { border-radius: 7px; }
.search-list a { display: block; padding: 8px 10px; color: var(--ink); text-decoration: none; }
.search-list li[aria-selected="true"] { background: var(--accent-weak); }
.search-list .r-title { font-weight: 600; }
.search-list .r-via { margin-left: 8px; color: var(--accent); font-size: 12.5px; font-weight: 500; }
.search-list .r-sec { float: right; margin-left: 8px; color: var(--muted); font-size: 12px; }
.search-list .r-text { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; margin-top: 2px; }
.search-list .r-none { padding: 10px 12px; color: var(--muted); font-size: 14px; }

/* ---------- layout ---------- */
.wrap { display: grid; grid-template-columns: 264px minmax(0, 1fr); max-width: 1240px; margin: 0 auto; }
.nav {
  position: sticky; top: var(--hd); align-self: start; height: calc(100vh - var(--hd)); overflow-y: auto;
  padding: 18px 10px 40px 16px; border-right: 1px solid var(--line); font-size: 14.5px;
}
.nav-sec + .nav-sec { margin-top: 6px; }
.nav summary { cursor: pointer; padding: 6px 8px; font-weight: 650; color: var(--ink); border-radius: 6px; list-style-position: inside; }
.nav summary:hover { background: var(--panel-2); }
.nav ul { list-style: none; margin: 2px 0 6px; padding: 0 0 0 14px; }
.nav li a { display: block; padding: 4px 10px; color: var(--muted); text-decoration: none; border-radius: 6px; border-left: 2px solid transparent; }
.nav li a:hover { color: var(--ink); background: var(--panel-2); }
.nav li a[aria-current="page"] { color: var(--accent); background: var(--accent-weak); font-weight: 600; }
.main { min-width: 0; padding: 26px clamp(16px, 4vw, 56px) 64px; max-width: 880px; }

/* ---------- a page ---------- */
.crumbs { margin: 0 0 6px; font-size: 13.5px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
h1 { display: flex; align-items: center; gap: 12px; margin: 0 0 6px; font: 700 clamp(26px, 4vw, 34px)/1.2 var(--font-display); letter-spacing: -0.01em; }
.h1-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 10px; background: var(--accent-weak); color: var(--accent); }
.h1-icon svg { width: 28px; height: 28px; }
.h1-icon.glyph { font: 700 22px var(--font-ui); }
.lead { margin: 0 0 18px; font-size: 18px; color: var(--muted); }
.article h2 { margin: 34px 0 10px; font: 700 22px/1.3 var(--font-display); padding-top: 4px; }
.article h3 { margin: 24px 0 8px; font-size: 17.5px; }
.article p, .article li { max-width: 72ch; }
.article ul, .article ol { padding-left: 1.4em; }
.article li { margin: 4px 0; }
.article ol > li::marker { font-weight: 700; color: var(--accent); }
.article img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.article figure { margin: 18px 0; }
.article figcaption { color: var(--muted); font-size: 14px; margin-top: 6px; }
.article hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.anchor { margin-left: 8px; color: var(--line-strong); text-decoration: none; font-weight: 400; opacity: 0; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
a.ext::after { content: "↗"; font-size: 0.8em; margin-left: 2px; }

/* tables */
.table { overflow-x: auto; margin: 14px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); }
thead th { background: var(--panel-2); font-size: 13.5px; color: var(--muted); font-weight: 650; }
tbody tr:last-child > * { border-bottom: 0; }
td:first-child { white-space: normal; }
table.keys td { padding: 5px 12px; }
table.keys td.k { width: 1%; white-space: nowrap; }
.none { color: var(--line-strong); }

/* boxes */
.callout { margin: 18px 0; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--panel); }
.callout p { margin: 6px 0; }
.callout-label { color: var(--accent); }
.callout.tip { border-left-color: var(--ok); } .callout.tip .callout-label { color: var(--ok); }
.callout.warn { border-left-color: var(--warn); } .callout.warn .callout-label { color: var(--warn); }
.callout.teacher { border-left-color: var(--timber); } .callout.teacher .callout-label { color: var(--timber); }
.callout.try { border-left-color: var(--accent); background: var(--accent-weak); }

/* the tool box at the top of a tool's page */
.toolbox { margin: 0 0 22px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.tb-tools { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tb-tools li { display: flex; gap: 10px; align-items: flex-start; }
.tb-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }
.tb-icon svg { width: 22px; height: 22px; }
.tb-icon.glyph { font: 700 15px var(--font-ui); }
.tb-text { min-width: 0; }
.tb-name { font-weight: 650; }
.tb-where { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.35; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 650; color: var(--accent); border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; line-height: 1.6; vertical-align: 0.1em; }
.toolbox .table { margin: 14px 0 0; box-shadow: none; }
.tb-names caption { text-align: left; padding: 8px 12px 4px; font-size: 13px; font-weight: 650; color: var(--muted); }
.tb-names td, .tb-names th { font-size: 14.5px; }
.tb-names tbody th { font-weight: 650; }

/* cards (home page and Related) */
.cards { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.cards a {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-content: start; column-gap: 10px; height: 100%;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink); text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cards a:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.card-icon { grid-row: span 2; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent-weak); color: var(--accent); }
.card-icon svg { width: 20px; height: 20px; }
.card-icon.glyph { font: 700 15px var(--font-ui); }
.card-title { font-weight: 650; }
.card-text { grid-column: 2; font-size: 13.5px; color: var(--muted); line-height: 1.4; }
.cards a:not(:has(.card-icon)) { grid-template-columns: 1fr; }
.cards a:not(:has(.card-icon)) .card-text { grid-column: 1; }
.related { margin-top: 40px; }
.related h2 { font: 700 18px var(--font-display); margin: 0; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; gap: 2px; max-width: 48%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; font-weight: 600; background: var(--panel); }
.pager a span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.pager .next { text-align: right; margin-left: auto; }
.pager a:hover { border-color: var(--accent); }

/* the home page */
.hero { padding: 18px 0 8px; }
.hero h1 { font-size: clamp(30px, 5vw, 42px); }
.hero .lead { max-width: 62ch; }
.hero-search { position: relative; max-width: 640px; }
.hero-search .help-search { width: 100%; padding: 13px 16px; font-size: 17px; border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.quick { color: var(--muted); font-size: 15px; }
.home-sec { margin-top: 34px; }
.home-sec h2 { margin: 0; font: 700 22px var(--font-display); }
.home-sec > p { margin: 4px 0 0; }

/* the home page has no page list beside it: the sections are the page */
body.home .wrap { grid-template-columns: minmax(0, 1fr); max-width: 1120px; }
body.home .nav, body.home .hd-menu, body.home .hd-search { display: none; }
body.home .hd-app { margin-left: auto; }
body.home .main { max-width: none; }

/* glossary */
.glossary { margin: 14px 0; display: grid; gap: 10px; }
.gl-word { padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.gl-word dt { font-weight: 700; font-size: 17px; }
.gl-word dd { margin: 2px 0 0; }
.gl-word dd p { margin: 4px 0; }
.gl-aka { color: var(--muted); font-size: 14px; }
.gl-langs { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14.5px; }
.gl-tr { white-space: nowrap; }
.gl-lang { color: var(--muted); font-size: 12px; margin-right: 2px; }
.gl-roman { color: var(--muted); font-size: 13px; }
.gl-word:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }

.ft { border-top: 1px solid var(--line); padding: 18px 16px 28px; text-align: center; font-size: 14px; background: var(--panel); }
.ft p { margin: 4px 0; }

/* ---------- narrow screens ---------- */
@media (max-width: 860px) {
  .wrap { display: block; }
  .hd-menu { display: inline-flex; }
  .nav {
    position: fixed; top: var(--hd); left: 0; bottom: 0; z-index: 25; width: min(320px, 86vw); height: auto;
    background: var(--panel); box-shadow: var(--shadow); transform: translateX(-105%); transition: transform 0.2s;
  }
  body.nav-open .nav { transform: none; }
  .hd-app { padding: 7px 10px; font-size: 13px; }
}
@media (max-width: 600px) {
  /* other programs' names: one tool under another instead of a wide table */
  .tb-names thead { display: none; }
  .tb-names caption { display: block; width: auto; }
  .tb-names, .tb-names tbody, .tb-names tr, .tb-names th, .tb-names td { display: block; }
  .tb-names tr { padding: 8px 12px; border-bottom: 1px solid var(--line); }
  .tb-names tbody tr:last-child { border-bottom: 0; }
  .tb-names th, .tb-names td { padding: 1px 0; border: 0; }
  .tb-names td { display: flex; gap: 8px; }
  .tb-names td::before { content: attr(data-label); flex: 0 0 96px; color: var(--muted); font-size: 13px; }
  .hd { gap: 8px; }
  .hd-brand .logo-word { display: none; }
  .hd-help { border-left: 0; padding-left: 0; }
  .hd-slash { display: none; }
  .hd-app { display: none; }
  .main { padding-top: 18px; }
  .pager a { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { .nav, .cards a { transition: none; } }
@media print {
  .hd, .nav, .ft, .pager, .related, .anchor { display: none !important; }
  .wrap { display: block; }
  .main { max-width: none; padding: 0; }
  body { background: #fff; color: #000; }
}
