/* QSSTV-Experimental User's Guide - shared stylesheet.
   System fonts only, no external resources. Light/dark follows the OS. */

:root {
  --bg: #ffffff;
  --fg: #1d2530;
  --muted: #5a6572;
  --link: #0b5cad;
  --link-hover: #083f77;
  --border: #d3d9e0;
  --panel: #f3f6f9;
  --accent: #0b5cad;
  --accent-fg: #ffffff;
  --code-bg: #eef1f5;
  --note-bg: #eaf3fc;
  --note-bar: #0b5cad;
  --warn-bg: #fff4e0;
  --warn-bar: #c27a00;
  --shadow: 0 1px 3px rgba(0, 0, 0, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --fg: #dde3ea;
    --muted: #97a3b0;
    --link: #7bb8f5;
    --link-hover: #a9d1fa;
    --border: #2c343d;
    --panel: #1c2229;
    --accent: #3b82c9;
    --accent-fg: #ffffff;
    --code-bg: #212932;
    --note-bg: #17283a;
    --note-bar: #4a90d9;
    --warn-bg: #33270f;
    --warn-bar: #d9962b;
    --shadow: 0 1px 3px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- header / navigation ---- */
.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
}
.site-header .inner { max-width: 62rem; margin: 0 auto; }
.brand {
  display: inline-block;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--fg);
  text-decoration: none;
  margin-bottom: .4rem;
}
.brand span { color: var(--muted); font-weight: 400; }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .35rem;
}
.site-nav a {
  display: block;
  padding: .15rem .55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .85rem;
  text-decoration: none;
  color: var(--fg);
  background: var(--bg);
}
.site-nav a:hover { border-color: var(--accent); }
.site-nav a[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* ---- main content ---- */
main {
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}
h1 { font-size: 2rem; line-height: 1.2; margin: .5rem 0 1rem; }
h2 { font-size: 1.45rem; margin: 2rem 0 .6rem; padding-bottom: .2rem; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.15rem; margin: 1.5rem 0 .4rem; }
h4 { font-size: 1rem; margin: 1.2rem 0 .3rem; }
p, ul, ol, dl, table, figure, pre { margin: 0 0 1rem; }
ul, ol { padding-left: 1.5rem; }
li { margin-bottom: .25rem; }
dt { font-weight: 600; margin-top: .6rem; }
dd { margin: 0 0 .4rem 1.25rem; }

.lead { font-size: 1.1rem; color: var(--muted); }

code, kbd, samp, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .9em;
}
code, kbd, samp { background: var(--code-bg); padding: .08em .35em; border-radius: 4px; }
/* keep option names like --batch from breaking after the first hyphen */
:not(pre) > code { white-space: nowrap; }
code.wrap { white-space: normal; }
code.wrap .nb { display: inline-block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; }
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .7rem .9rem;
  overflow-x: auto;
  white-space: pre;
}
pre code { background: none; padding: 0; font-size: 1em; }

/* menu paths and button names */
.ui { font-weight: 600; }

/* ---- figures ---- */
figure { text-align: center; }
figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
figcaption { font-size: .88rem; color: var(--muted); margin-top: .4rem; }

/* ---- callouts ---- */
.note, .warn {
  border-left: 4px solid var(--note-bar);
  background: var(--note-bg);
  padding: .6rem .9rem;
  border-radius: 0 6px 6px 0;
  margin: 0 0 1rem;
}
.warn { border-left-color: var(--warn-bar); background: var(--warn-bg); }
.note > :last-child, .warn > :last-child { margin-bottom: 0; }
.note strong:first-child, .warn strong:first-child { text-transform: uppercase; font-size: .8rem; letter-spacing: .04em; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; margin: 0 0 1rem; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid var(--border); padding: .35rem .6rem; text-align: left; vertical-align: top; }
th { background: var(--panel); }
table.compact td, table.compact th { font-size: .92rem; padding: .25rem .5rem; }

/* ---- table of contents (index) ---- */
.toc { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .75rem; list-style: none; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block;
  height: 100%;
  padding: .7rem .9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  text-decoration: none;
  color: var(--fg);
}
.toc a:hover { border-color: var(--accent); }
.toc .t { display: block; font-weight: 600; color: var(--link); }
.toc .d { display: block; font-size: .9rem; color: var(--muted); }

/* ---- in-page contents ---- */
.page-toc {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem 1rem;
  margin: 0 0 1.5rem;
  font-size: .95rem;
}
.page-toc strong { display: block; margin-bottom: .2rem; }
.page-toc ul { margin: 0; columns: 2 14rem; }

/* ---- pager ---- */
.pager {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.pager a {
  display: inline-block;
  padding: .4rem .9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  background: var(--panel);
}
.pager a:hover { border-color: var(--accent); }
.pager .next { margin-left: auto; text-align: right; }

.site-footer {
  max-width: 52rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: var(--muted);
  font-size: .85rem;
}

/* ---- narrow screens ---- */
@media (max-width: 40rem) {
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  main { padding: 1rem .75rem 1.5rem; }
  .site-header { padding: .6rem .75rem; }
  .page-toc ul { columns: 1; }
}

/* ---- print ---- */
@media print {
  :root {
    --bg: #fff; --fg: #000; --muted: #333; --link: #000; --border: #999;
    --panel: #fff; --code-bg: #f2f2f2; --note-bg: #fff; --warn-bg: #fff; --shadow: none;
  }
  body { font-size: 11pt; line-height: 1.4; }
  .site-nav, .pager { display: none; }
  .site-header { border: 0; padding: 0 0 .5rem; }
  main { max-width: none; padding: 0; }
  a { text-decoration: none; }
  main a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; }
  h1, h2, h3, h4 { break-after: avoid; }
  figure, pre, table, .note, .warn { break-inside: avoid; }
  figure img { box-shadow: none; max-height: 22cm; }
  .note, .warn { border: 1px solid #999; border-left-width: 4px; }
}
