/*
 * Oxide: the RustyGet design system.
 *
 * Metals and their oxides. Iron oxide (rust) is the accent, copper oxide
 * (patina) marks healthy and verified states, steel marks references, and
 * cast iron is the ink. Every text color passes WCAG AA on every background
 * it's used on, in both themes. The design-system page documents the tokens.
 */

:root {
  color-scheme: light;
  --paper: #f7f4ef;
  --surface: #ffffff;
  --sunken: #f0eae2;
  --ink: #1c1916;
  --muted: #5c534b;
  --line: #e4dcd2;
  --line-strong: #cfc4b8;
  --rust: #a8400f;
  --rust-soft: #f7e6dc;
  --patina: #1d6f60;
  --patina-soft: #dcefe9;
  --steel: #3d5a73;
  --steel-soft: #e1e9f0;
  --amber: #8a5a00;
  --amber-soft: #f6ebd2;
  --ember: #b02a1f;
  --ember-soft: #f8e1de;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px #1c19160d, 0 8px 24px #1c19160a;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --masthead: 60px;
  --gutter: 40px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #12100e;
    --surface: #1b1714;
    --sunken: #1e1915;
    --ink: #f1eae2;
    --muted: #b3a79b;
    --line: #352e28;
    --line-strong: #4a4038;
    --rust: #f08c5a;
    --rust-soft: #3b2318;
    --patina: #6cc9b4;
    --patina-soft: #16302a;
    --steel: #9ab8d1;
    --steel-soft: #1d2a35;
    --amber: #e3b45a;
    --amber-soft: #352914;
    --ember: #f2867a;
    --ember-soft: #3a1c18;
    --on-accent: #12100e;
    --shadow: 0 1px 2px #0006, 0 8px 24px #0004;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #12100e;
  --surface: #1b1714;
  --sunken: #1e1915;
  --ink: #f1eae2;
  --muted: #b3a79b;
  --line: #352e28;
  --line-strong: #4a4038;
  --rust: #f08c5a;
  --rust-soft: #3b2318;
  --patina: #6cc9b4;
  --patina-soft: #16302a;
  --steel: #9ab8d1;
  --steel-soft: #1d2a35;
  --amber: #e3b45a;
  --amber-soft: #352914;
  --ember: #f2867a;
  --ember-soft: #3a1c18;
  --on-accent: #12100e;
  --shadow: 0 1px 2px #0006, 0 8px 24px #0004;
}

/* ---------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--masthead) + 20px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 var(--font-sans);
  text-rendering: optimizeLegibility;
}

a { color: var(--rust); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a.ext::after { content: "\2009\2197"; font-size: .8em; }

:focus-visible { outline: 2px solid var(--rust); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.02em; margin: 0 0 .8rem; font-weight: 680; }
h1 { font-size: clamp(2rem, 3.4vw, 2.75rem); letter-spacing: -.035em; }
h2 { font-size: 1.55rem; margin-top: 2.6rem; padding-top: .2rem; }
h3 { font-size: 1.15rem; margin-top: 1.9rem; }
h4 { font-size: 1rem; margin-top: 1.4rem; }
p, ul, ol, dl { margin: 0 0 1rem; }
li { margin: .25rem 0; }
li > ul, li > ol { margin: .25rem 0 .4rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
img, svg { max-width: 100%; }
strong { font-weight: 650; }

code, kbd, pre, samp { font-family: var(--font-mono); }
:not(pre) > code {
  font-size: .86em;
  padding: .12em .4em;
  border-radius: 4px;
  background: var(--sunken);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
kbd {
  font-size: .8em;
  padding: .1em .45em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
}

.skip {
  position: absolute; left: 16px; top: -100px; z-index: 50;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.skip:focus { top: 10px; }

/* ------------------------------------------------------------ masthead */

.masthead {
  position: sticky; top: 0; z-index: 20;
  height: var(--masthead);
  display: flex; align-items: center; gap: 20px;
  padding: 0 var(--gutter) 0 24px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand-name span { color: var(--rust); }
.brand-tag {
  font: 500 .72rem/1 var(--font-mono);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
}
.masthead-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.masthead-link { color: var(--muted); font-size: .9rem; text-decoration: none; padding: 6px 4px; }
.masthead-link:hover { color: var(--ink); }

.search { position: relative; }
.search input {
  width: 260px; height: 36px;
  padding: 0 34px 0 12px;
  font: inherit; font-size: .9rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.search input::placeholder { color: var(--muted); }
.search kbd { position: absolute; right: 8px; top: 8px; pointer-events: none; }
.search-results {
  position: absolute; right: 0; top: 44px; width: min(460px, calc(100vw - 32px));
  max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px; margin: 0; list-style: none;
}
.search-results[hidden] { display: none; }
.search-results li { margin: 0; }
.search-results a { display: block; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; }
.search-results a:hover, .search-results a[aria-selected="true"] { background: var(--rust-soft); }
.search-results .r-path { display: block; font: .72rem var(--font-mono); color: var(--muted); }
.search-results .r-text { display: block; font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .r-empty { padding: 10px; color: var(--muted); font-size: .88rem; }

.icon-button {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  cursor: pointer; font: inherit;
}
.icon-button svg { width: 18px; height: 18px; }

/* -------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 220px;
  max-width: 1560px;
  margin: 0 auto;
}

.sidebar { border-right: 1px solid var(--line); }
.navigation {
  position: sticky; top: var(--masthead);
  max-height: calc(100vh - var(--masthead));
  overflow-y: auto;
  padding: 24px 16px 40px 24px;
}
.navigation > summary { display: none; }
.nav-group { margin-bottom: 22px; }
.nav-label {
  margin: 0 10px 6px;
  font: 600 .7rem/1.4 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-group a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: .92rem;
  line-height: 1.4;
}
.nav-group a:hover { color: var(--ink); background: var(--sunken); }
.nav-group a[aria-current="page"] {
  color: var(--ink);
  font-weight: 620;
  background: var(--rust-soft);
  border-left-color: var(--rust);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

main { min-width: 0; padding: 36px var(--gutter) 0; }
.content { max-width: 800px; }
.content-wide { max-width: 1120px; }

.toc { padding: 36px 24px 40px 8px; }
.toc nav { position: sticky; top: calc(var(--masthead) + 28px); max-height: calc(100vh - var(--masthead) - 56px); overflow-y: auto; }
.toc p { font: 600 .7rem/1.4 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.toc a { display: block; padding: 4px 0 4px 12px; border-left: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: .82rem; line-height: 1.4; }
.toc a.l3 { padding-left: 24px; font-size: .78rem; }
.toc a:hover, .toc a.active { color: var(--rust); border-left-color: var(--rust); }

/* -------------------------------------------------------- page header */

.path {
  font: .78rem var(--font-mono);
  color: var(--muted);
  margin: 0 0 14px;
  overflow-wrap: anywhere;
}
.path a { color: var(--muted); text-decoration: none; }
.path a:hover { color: var(--rust); }
.path b { color: var(--rust); font-weight: 600; }

.eyebrow {
  font: 600 .74rem/1.4 var(--font-mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--rust);
  margin: 0 0 10px;
}
.lede { font-size: 1.15rem; line-height: 1.6; color: var(--muted); max-width: 68ch; margin-bottom: 1.6rem; }
.lede-sm { color: var(--muted); }
.page-head { padding-bottom: 22px; margin-bottom: 30px; border-bottom: 1px solid var(--line); }
.page-head h1 { margin-bottom: 14px; }
.page-head .lede { margin-bottom: 0; }

/* ----------------------------------------------------------------- prose */

.prose { overflow-wrap: break-word; }
.prose > h2:first-child { margin-top: 0; }
.prose p, .prose li { max-width: 76ch; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose ul li::marker { color: var(--rust); }
.prose ol li::marker { font-family: var(--font-mono); font-size: .88em; color: var(--muted); }
.prose h2 a.anchor, .prose h3 a.anchor { margin-left: .4rem; color: var(--line-strong); text-decoration: none; font-weight: 400; opacity: 0; }
.prose h2:hover a.anchor, .prose h3:hover a.anchor, .prose a.anchor:focus { opacity: 1; }
.prose blockquote { margin: 1.2rem 0; padding: .2rem 0 .2rem 1rem; border-left: 3px solid var(--line-strong); color: var(--muted); }
.prose dt { font-weight: 650; }
.prose dd { margin: 0 0 .8rem 1.2rem; color: var(--muted); }

.table-wrap { overflow-x: auto; margin: 1.4rem 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: .9rem; line-height: 1.5; }
.table-wrap th, .table-wrap td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap th { font-size: .78rem; font-weight: 650; letter-spacing: .02em; color: var(--muted); background: var(--sunken); white-space: nowrap; }
.table-wrap td code { white-space: nowrap; }

/* Code blocks: a header bar names the language and holds the copy button. */
.code { margin: 1.4rem 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunken); overflow: hidden; }
.code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px 6px 14px;
  border-bottom: 1px solid var(--line);
  font: .72rem var(--font-mono); color: var(--muted);
}
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: .86rem; line-height: 1.6; tab-size: 4; }
.copy {
  font: .72rem var(--font-mono);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 9px;
  cursor: pointer;
}
.copy:hover { color: var(--ink); border-color: var(--line-strong); }

/*
 * Diagnostics: callouts modeled on compiler output. A level word, a colon,
 * a title, then a gutter rule down the left of the body.
 */
.diag {
  --diag: var(--steel);
  --diag-soft: var(--steel-soft);
  margin: 1.4rem 0;
  padding: 12px 16px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.diag-help { --diag: var(--patina); --diag-soft: var(--patina-soft); }
.diag-important { --diag: var(--rust); --diag-soft: var(--rust-soft); }
.diag-warning { --diag: var(--amber); --diag-soft: var(--amber-soft); }
.diag-caution { --diag: var(--ember); --diag-soft: var(--ember-soft); }
.diag-head { margin: 0 0 6px; font: 600 .9rem/1.5 var(--font-mono); }
.diag-level { color: var(--diag); }
.diag-body { padding-left: 14px; border-left: 2px solid var(--diag-soft); margin-left: 3px; }
.diag-body > :last-child { margin-bottom: 0; }

/* ------------------------------------------------------------ components */

.tag {
  display: inline-block;
  font: 600 .68rem/1.5 var(--font-mono);
  letter-spacing: .03em;
  padding: 1px 7px;
  border-radius: 4px;
  vertical-align: .12em;
  background: var(--sunken);
  color: var(--muted);
  border: 1px solid var(--line);
}
.tag-new, .tag-primary { background: var(--rust-soft); color: var(--rust); border-color: transparent; }
.tag-twin, .tag-ok { background: var(--patina-soft); color: var(--patina); border-color: transparent; }
.tag-alt, .tag-ref { background: var(--steel-soft); color: var(--steel); border-color: transparent; }
.tag-warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.tag-bad { background: var(--ember-soft); color: var(--ember); border-color: transparent; }

.button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  font-weight: 600; font-size: .92rem;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
}
.button:hover { border-color: var(--ink); }
.button.primary { background: var(--rust); border-color: var(--rust); color: var(--on-accent); }
.button.primary:hover { filter: brightness(1.08); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 1.6rem 0 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 1.4rem 0 2rem; }
.card {
  display: block;
  padding: 18px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}
a.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.card h3 { margin: 0 0 6px; font-size: 1rem; }
.card p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.card .eyebrow { margin-bottom: 8px; font-size: .68rem; }

/* Home page hero: copy on the left, a fleet readout on the right. */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 36px; align-items: center;
  padding: 8px 0 34px; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.hero h1 { font-size: clamp(2rem, 3.4vw, 2.8rem); margin-bottom: 16px; }
.hero h1 span { color: var(--rust); }
.readout {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sunken);
  font: .8rem/1.75 var(--font-mono);
  overflow: hidden;
}
.readout figcaption { padding: 7px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.readout pre { margin: 0; padding: 12px 14px 14px; overflow-x: auto; }
.readout .v { color: var(--patina); font-weight: 700; }
.readout .w { color: var(--amber); font-weight: 700; }
.readout .r { color: var(--rust); font-weight: 700; }
.readout .m { color: var(--muted); }

.facts { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 18px 0 0; padding: 0; list-style: none; font: .78rem var(--font-mono); color: var(--muted); }
.facts li { margin: 0; }
.facts li::before { content: "\2713\00a0"; color: var(--patina); }

.steps { counter-reset: step; list-style: none; padding: 0 !important; }
.steps > li { counter-increment: step; position: relative; padding-left: 44px; margin: 0 0 18px; }
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; display: grid; place-items: center;
  font: 600 .8rem var(--font-mono);
  color: var(--rust); background: var(--rust-soft); border-radius: 50%;
}

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 1.2rem 0 2rem; }
.swatch { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.swatch i { display: block; height: 64px; border-bottom: 1px solid var(--line); }
.swatch b { display: block; padding: 8px 10px 0; font: 600 .78rem var(--font-mono); }
.swatch b code { padding: 0; border: 0; background: none; font-size: inherit; }
.swatch span { display: block; padding: 0 10px 8px; font: .72rem var(--font-mono); color: var(--muted); }

/* Configuration reference */
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 1.2rem 0 1.6rem; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.filter label { font-size: .85rem; color: var(--muted); }
.filter input[type="search"] { flex: 1 1 240px; height: 36px; padding: 0 12px; font: inherit; font-size: .9rem; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.filter .check { display: inline-flex; gap: 6px; align-items: center; }
.conf-section h2 { position: sticky; top: var(--masthead); z-index: 2; background: var(--paper); padding: 10px 0; margin-bottom: 4px; }
.conf-option { padding: 18px 0 16px; border-bottom: 1px solid var(--line); }
.conf-option header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.conf-option h3 { margin: 0; font: 650 1rem var(--font-mono); letter-spacing: 0; }
.conf-option h3 a { color: var(--ink); text-decoration: none; }
.conf-option h3 a:hover { color: var(--rust); }
.conf-values { font: .76rem var(--font-mono); color: var(--muted); }
.conf-summary { margin: 6px 0 4px; }
.conf-default { margin: 0 0 8px; font: .78rem var(--font-mono); color: var(--muted); }
.conf-option > p:not(.conf-summary):not(.conf-default) { font-size: .9rem; color: var(--muted); }
.conf-pre { margin: 0 0 1rem; padding: 10px 12px; font-size: .78rem; line-height: 1.6; white-space: pre-wrap; background: var(--sunken); border-radius: var(--radius-sm); color: var(--muted); }
.conf-option[hidden], .conf-section[hidden] { display: none; }

/* ------------------------------------------------------------ page foot */

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 3.4rem 0 0; }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); background: var(--surface); }
.pager a:hover { border-color: var(--line-strong); }
.pager span { display: block; font: .72rem var(--font-mono); color: var(--muted); }
.pager .next { text-align: right; grid-column: 2; }

.footer {
  display: flex; flex-wrap: wrap; gap: 8px 22px;
  margin: 40px 0 0; padding: 22px 0 30px;
  border-top: 1px solid var(--line);
  font-size: .8rem; color: var(--muted);
}
.footer a { color: var(--muted); }
.footer .built { margin-left: auto; font-family: var(--font-mono); font-size: .74rem; }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1280px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .search input { width: 200px; }
}

@media (max-width: 820px) {
  :root { --gutter: 16px; }
  .masthead { padding: 0 16px; gap: 12px; }
  .brand-tag, .masthead-link { display: none; }
  .search input { width: 100%; }
  .search { flex: 1; min-width: 0; }
  .search kbd { display: none; }
  .masthead-tools { flex: 1; justify-content: flex-end; min-width: 0; }
  .layout { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .navigation { position: static; max-height: none; padding: 0 16px; }
  .navigation > summary { display: flex; justify-content: space-between; padding: 12px 0; font-weight: 600; font-size: .9rem; cursor: pointer; list-style: none; }
  .navigation > summary::-webkit-details-marker { display: none; }
  .navigation > summary::after { content: "+"; font-family: var(--font-mono); color: var(--muted); }
  .navigation[open] > summary::after { content: "\2212"; }
  .navigation[open] { padding-bottom: 8px; }
  main { padding: 24px 16px 0; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .footer .built { margin-left: 0; }
  .table-wrap td code { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .masthead, .sidebar, .toc, .pager, .copy { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  a.ext::after { content: " (" attr(href) ")"; font-size: .8em; color: var(--muted); }
}

/* Settings pictures keep page previews short and open the complete capture. */
.settings-figure { margin: 1.4rem 0 2rem; }
.settings-shot {
  display: block;
  max-height: 28rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.settings-shot img { display: block; width: 100%; height: auto; }
.settings-shot:focus-visible { outline: 2px solid var(--rust); outline-offset: 4px; }
.settings-figure figcaption { margin-top: .55rem; color: var(--muted); font-size: .85rem; }

@media print {
  .settings-shot { max-height: none; overflow: visible; }
}
