/* Tesoro documentation.
 *
 * Self-contained on purpose: no CDN, no webfont, no analytics, nothing that phones out. The
 * package ships an HTML report with the same rule, tested by grepping the rendered bytes -- a
 * documentation site that violated it while the product asserted it would be an odd look.
 *
 * Layout is a persistent left sidebar with the current page's sections nested under it, which is
 * what a developer reading reference material actually wants: knowing where you are, and what else
 * is here, without going back to an index.
 */

:root {
  --bg: #fbfbfa;
  --panel: #ffffff;
  --sidebar: #f6f6f3;
  --ink: #16161a;
  --dim: #5f5f68;
  --faint: #8c8c95;
  --line: #e3e3df;
  --line-soft: #eeeeea;
  --accent: #2b4c7e;
  --accent-soft: #eaf0f8;
  --ok: #1f7a4d;
  --warn: #9a6a00;
  --esc: #a8480c;
  --bad: #a81c1c;
  --code-bg: #f4f4f1;
  --sidebar-w: 268px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15151a;
    --panel: #1d1d23;
    --sidebar: #191920;
    --ink: #e9e9e6;
    --dim: #a0a0a9;
    --faint: #75757e;
    --line: #2e2e36;
    --line-soft: #24242b;
    --accent: #8fb3e0;
    --accent-soft: #1e2a3a;
    --ok: #4bbf85;
    --warn: #d9a534;
    --esc: #e0834a;
    --bad: #e8635f;
    --code-bg: #23232a;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- topbar ------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand .v { color: var(--faint); font-weight: 400; font-size: 0.8rem; }

.topbar .links { margin-left: auto; display: flex; gap: 1.1rem; font-size: 0.86rem; }
.topbar .links a { color: var(--dim); text-decoration: none; }
.topbar .links a:hover { color: var(--accent); }

/* The sidebar toggle only exists on narrow screens. A checkbox rather than script: the whole
 * site works with JavaScript disabled, which is easier to promise when there is none. */
#menu { display: none; }
.menu-btn {
  display: none;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
  color: var(--dim);
  user-select: none;
}

/* --- shell -------------------------------------------------------------- */

.shell { display: flex; align-items: flex-start; }

aside.nav {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 49px;
  height: calc(100vh - 49px);
  overflow-y: auto;
  padding: 1.4rem 0 3rem;
}

aside.nav .group {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  font-weight: 600;
  padding: 1.2rem 1.4rem 0.35rem;
}
aside.nav .group:first-child { padding-top: 0; }

aside.nav a.page {
  display: block;
  padding: 0.32rem 1.4rem;
  color: var(--dim);
  text-decoration: none;
  font-size: 0.91rem;
  border-left: 2px solid transparent;
}
aside.nav a.page:hover { color: var(--accent); }
aside.nav a.page[aria-current="page"] {
  color: var(--ink);
  font-weight: 650;
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

/* The current page's own sections, nested. Only rendered on that page, so the sidebar shows
 * depth where you are and stays flat everywhere else. */
aside.nav ul.sub {
  list-style: none;
  margin: 0.15rem 0 0.5rem;
  padding: 0 0 0 1.4rem;
  border-left: 2px solid var(--accent-soft);
  margin-left: 0;
}
aside.nav ul.sub li { margin: 0; }
aside.nav ul.sub a {
  display: block;
  padding: 0.2rem 0.9rem 0.2rem 0.5rem;
  color: var(--dim);
  text-decoration: none;
  font-size: 0.855rem;
  line-height: 1.45;
}
aside.nav ul.sub a:hover { color: var(--accent); }

main {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 860px;
  padding: 2.6rem 2.4rem 6rem;
}

@media (max-width: 900px) {
  .menu-btn { display: inline-block; }
  aside.nav {
    display: none;
    position: fixed;
    top: 49px;
    left: 0;
    z-index: 15;
    width: 300px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  }
  #menu:checked ~ .shell aside.nav { display: block; }
  main { padding: 2rem 1.25rem 5rem; }
}

/* --- type --------------------------------------------------------------- */

h1 { font-size: 2.05rem; line-height: 1.2; letter-spacing: -0.022em; margin: 0 0 0.5rem; }
.lede { font-size: 1.1rem; color: var(--dim); margin: 0 0 2.4rem; max-width: 62ch; }

h2 {
  font-size: 1.34rem;
  letter-spacing: -0.015em;
  margin: 3rem 0 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 70px;
}
h3 { font-size: 1.04rem; margin: 1.9rem 0 0.55rem; scroll-margin-top: 70px; }
h4 { font-size: 0.93rem; margin: 1.4rem 0 0.35rem; color: var(--dim); }

p, li { max-width: 74ch; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

code, kbd, pre { font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace; }
code { background: var(--code-bg); padding: 0.1em 0.32em; border-radius: 4px; font-size: 0.88em; }
pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.9rem 1.05rem;
  overflow-x: auto;
  font-size: 0.845rem;
  line-height: 1.55;
}
pre code { background: none; padding: 0; font-size: inherit; }
pre .c { color: var(--faint); }
pre .k { color: var(--accent); }
pre .s { color: var(--ok); }

/* --- tables ------------------------------------------------------------- */

.scroll { overflow-x: auto; margin: 1.15rem 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.895rem; }
th {
  text-align: left;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  border-bottom: 1px solid var(--line);
  padding: 0 0.75rem 0.45rem 0;
  white-space: nowrap;
}
td { padding: 0.5rem 0.75rem 0.5rem 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td code { white-space: nowrap; }

/* --- callouts ----------------------------------------------------------- */

.note, .warn-box, .key {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 0.85rem 1.05rem;
  border-radius: 0 6px 6px 0;
  margin: 1.35rem 0;
  font-size: 0.94rem;
}
.note p, .warn-box p, .key p { max-width: none; }
.note p:last-child, .warn-box p:last-child, .key p:last-child { margin-bottom: 0; }
.note p:first-child, .warn-box p:first-child, .key p:first-child { margin-top: 0; }
.warn-box { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 9%, transparent); }
.key { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, transparent); }

.cards { display: grid; gap: 0.95rem; grid-template-columns: repeat(auto-fit, minmax(224px, 1fr)); margin: 1.4rem 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.1rem; }
.card h3 { margin: 0 0 0.3rem; font-size: 0.98rem; }
.card p { margin: 0 0 0.4rem; font-size: 0.885rem; color: var(--dim); max-width: none; }
.card a { font-size: 0.87rem; }

/* --- verdicts ----------------------------------------------------------- */

.v-tag {
  display: inline-block;
  padding: 0.1rem 0.44rem;
  border-radius: 4px;
  font-size: 0.755rem;
  font-weight: 700;
  font-family: ui-monospace, Consolas, monospace;
}
.v-tag.approve { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.v-tag.review { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.v-tag.escalate { color: var(--esc); background: color-mix(in srgb, var(--esc) 16%, transparent); }
.v-tag.reject { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }

/* --- diagrams ----------------------------------------------------------- */

figure { margin: 1.7rem 0; }
figure svg { max-width: 100%; height: auto; display: block; }
figcaption { font-size: 0.855rem; color: var(--dim); margin-top: 0.65rem; max-width: 74ch; }

svg .box { fill: var(--panel); stroke: var(--line); stroke-width: 1.5; }
svg .box-accent { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
svg .label { fill: var(--ink); font: 12px ui-sans-serif, system-ui, sans-serif; }
svg .label-sm { fill: var(--dim); font: 10.5px ui-sans-serif, system-ui, sans-serif; }
svg .label-mono { fill: var(--ink); font: 11px ui-monospace, Consolas, monospace; }
svg .flow { stroke: var(--dim); stroke-width: 1.5; fill: none; }
svg .flow-strong { stroke: var(--accent); stroke-width: 2; fill: none; }
svg .flow-bad { stroke: var(--bad); stroke-width: 1.5; fill: none; }
svg .fill-ok { fill: var(--ok); }
svg .fill-bad { fill: var(--bad); }
svg .fill-warn { fill: var(--warn); }
svg .fill-dim { fill: var(--dim); }

/* --- misc --------------------------------------------------------------- */

.gap-list li { margin-bottom: 0.5rem; }
hr { border: none; border-top: 1px solid var(--line); margin: 2.8rem 0; }
.small { font-size: 0.87rem; color: var(--dim); }
.pill {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.08rem 0.5rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}
.next {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}
.next a { text-decoration: none; }
.next .lbl { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); }
footer.page { margin-top: 3rem; color: var(--faint); font-size: 0.82rem; }

/* The mark on the landing page. Inlined SVG rather than an <img>, so the page still makes no
   outbound request; `currentColor` and the palette variables make it follow the theme. */
svg.mark {
  display: block;
  margin: 0 0 1.1rem;
  color: var(--ink);
}

/* The mark in the topbar. Sized down and thickened: the landing-page version is 72px, and its
   4px strokes disappear at 22px. `aria-hidden` because the brand link beside it already says
   "tesoro" -- announcing it twice is worse for a screen reader than not announcing it at all. */
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
svg.mark-sm {
  flex: 0 0 auto;
  color: var(--ink);
}
