/* BYOW · Build Your Own Workflow
   Layout concept: a docs site drawn like a delivery pipeline. Ink-blue lines are the
   pipeline, amber diamonds are security gates; each page has a "pipeline rail" TOC
   whose stations are the page's sections. */
:root {
  /* color */
  --paper: #f3f5f8;
  --surface: #ffffff;
  --sunken: #e9edf3;
  --ink: #131a2c;
  --ink-2: #4f5870;
  --line: #d6dce6;
  --accent: #2b3fbe;          /* pipeline ink-blue: links, rails, focus */
  --accent-soft: #e4e8fb;
  --gate: #b86e00;            /* security gate amber (text-safe on paper) */
  --gate-fill: #f0a520;       /* gate diamond fill */
  --gate-soft: #fbf0d9;
  --pass: #1d7a46;
  --pass-soft: #def2e6;
  --fail: #b8322a;
  --fail-soft: #f9e3e1;
  --pf-gh: #24292f;
  --pf-ado: #0a66c2;
  --pf-gl: #e24329;
  /* code surface is dark in both themes */
  --code-bg: #121829;
  --code-head: #1b2338;
  --code-fg: #e3e7f1;
  --code-dim: #8a93ab;
  --tok-key: #8fb3ff;
  --tok-str: #f2c879;
  --tok-num: #ff9f8a;
  --tok-com: #7d869d;
  --tok-kw: #c7a3ff;
  --tok-var: #7fd8c4;

  /* type */
  --f-display: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --t-xs: 0.78rem;
  --t-sm: 0.88rem;
  --t-base: 1.02rem;
  --t-md: 1.2rem;
  --t-lg: 1.55rem;
  --t-xl: 2.1rem;
  --t-2xl: clamp(2.2rem, 5vw, 3.4rem);

  /* layout */
  --maxw: 1200px;
  --rail: 236px;
  --measure: 70ch;
  --gutter: 20px;
  --radius: 6px;

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1220;
    --surface: #151b2d;
    --sunken: #1b2236;
    --ink: #e5e9f3;
    --ink-2: #a0a9bf;
    --line: #2a3349;
    --accent: #95a4ff;
    --accent-soft: #232c52;
    --gate: #f4b443;
    --gate-fill: #f4b443;
    --gate-soft: #33280f;
    --pass: #5ccf91;
    --pass-soft: #14301f;
    --fail: #ff8579;
    --fail-soft: #3a1a17;
    --pf-gh: #c9d1d9;
    --pf-ado: #5ea8f2;
    --pf-gl: #ff8a65;
    --code-bg: #0a0e19;
    --code-head: #121829;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1220;
  --surface: #151b2d;
  --sunken: #1b2236;
  --ink: #e5e9f3;
  --ink-2: #a0a9bf;
  --line: #2a3349;
  --accent: #95a4ff;
  --accent-soft: #232c52;
  --gate: #f4b443;
  --gate-fill: #f4b443;
  --gate-soft: #33280f;
  --pass: #5ccf91;
  --pass-soft: #14301f;
  --fail: #ff8579;
  --fail-soft: #3a1a17;
  --pf-gh: #c9d1d9;
  --pf-ado: #5ea8f2;
  --pf-gl: #ff8a65;
  --code-bg: #0a0e19;
  --code-head: #121829;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: var(--t-base);
  line-height: 1.62;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; margin: 0; color: var(--ink); }
h1 { font-size: var(--t-2xl); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.012em; }
h3 { font-size: var(--t-md); font-weight: 700; }
h4 { font-size: var(--t-base); font-weight: 700; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.25em; }
li + li { margin-top: 0.3em; }
strong { font-weight: 700; }
code { font-family: var(--f-mono); font-size: 0.86em; }
:not(pre) > code {
  background: var(--sunken);
  padding: 0.1em 0.36em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: var(--gutter); }
.eyebrow {
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.lede { font-size: var(--t-md); color: var(--ink-2); max-width: 60ch; }
.muted { color: var(--ink-2); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- header ---------- */
.site-head {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.head-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: var(--gutter);
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}
.brand svg { width: 34px; height: 18px; flex-shrink: 0; }
.brand-name { font-family: var(--f-display); font-weight: 800; font-size: 1.1rem; letter-spacing: 0.04em; }
.brand-sub { font-size: var(--t-sm); color: var(--ink-2); }
.site-nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  padding: 7px 11px;
  border-radius: var(--radius);
  font-size: var(--t-sm);
  color: var(--ink-2);
  text-decoration: none;
}
.site-nav a:hover { color: var(--ink); background: var(--sunken); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-weight: 700; }
.pf { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.pf.gh { background: var(--pf-gh); }
.pf.ado { background: var(--pf-ado); }
.pf.gl { background: var(--pf-gl); }
@media (max-width: 860px) {
  .brand-sub { display: none; }
  .head-inner { gap: 12px; }
}
@media (max-width: 600px) {
  .site-nav a:first-child { display: none; }  /* the brand already links home */
}

/* ---------- footer ---------- */
.site-foot { border-top: 1px solid var(--line); margin-top: 72px; }
.foot-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px var(--gutter) 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  justify-content: space-between;
  font-size: var(--t-sm);
  color: var(--ink-2);
}
.foot-inner nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* ---------- page hero (inner pages) ---------- */
.page-hero { padding-block: 44px 28px; border-bottom: 1px solid var(--line); background: var(--surface); }
.page-hero .wrap { display: grid; gap: 14px; }
.page-hero h1 { font-size: clamp(2rem, 4.4vw, 2.9rem); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--sunken);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip.gate { background: var(--gate-soft); color: var(--gate); }
.chip.pass { background: var(--pass-soft); color: var(--pass); }
.chip.fail { background: var(--fail-soft); color: var(--fail); }
.chip.info { background: var(--accent-soft); color: var(--accent); }

/* ---------- doc layout with pipeline rail ---------- */
.doc {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: var(--gutter);
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 48px;
  padding-block: 36px 0;
}
.rail { position: relative; }
.rail details { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 84px); }
.rail summary {
  display: none;
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.rail .rail-title { margin-bottom: 12px; }
.rail ol { list-style: none; padding: 0; margin: 0; position: relative; }
.rail ol::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--line);
}
.rail li { margin: 0; position: relative; }
.rail a {
  display: block;
  padding: 5px 0 5px 24px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: var(--t-sm);
  line-height: 1.35;
  position: relative;
}
.rail a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--line);
}
.rail a.is-gate::before {
  border-radius: 1px;
  transform: rotate(45deg) scale(0.85);
  border-color: var(--gate-fill);
}
.rail a:hover { color: var(--ink); }
.rail a[aria-current="true"] { color: var(--ink); font-weight: 700; }
.rail a[aria-current="true"]::before { background: var(--accent); border-color: var(--accent); }
.rail a.is-gate[aria-current="true"]::before { background: var(--gate-fill); border-color: var(--gate-fill); }

.content { min-width: 0; display: grid; gap: 56px; }
.section { display: grid; gap: 18px; min-width: 0; }
.section > *, .tabs > *, .panel > *, .prose > * { min-width: 0; }
.section > p, .section > ul, .section > ol, .section > .prose { max-width: var(--measure); }
.section h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.step-tag {
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.section h3 { margin-top: 10px; }
.prose { display: grid; gap: 14px; }

@media (max-width: 1000px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 20px; }
  .rail details {
    position: static;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
  }
  .rail summary { display: list-item; }
  .rail details[open] summary { margin-bottom: 10px; }
  .rail .rail-title { display: none; }
}

/* ---------- breadcrumb path for settings ---------- */
.path {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-family: var(--f-mono);
  font-size: 0.8rem;
  line-height: 1.4;
  vertical-align: baseline;
}
.path span {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--ink);
}
.path i { font-style: normal; color: var(--ink-2); }

/* ---------- callouts ---------- */
.callout {
  max-width: var(--measure);
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  display: grid;
  gap: 8px;
}
.callout .label {
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.callout.warn { background: var(--gate-soft); }
.callout.warn .label { color: var(--gate); }
.callout.incident { background: var(--fail-soft); }
.callout.incident .label { color: var(--fail); }
.callout.ok { background: var(--pass-soft); }
.callout.ok .label { color: var(--pass); }
.callout p, .callout ul { margin: 0; }

/* ---------- code blocks ---------- */
.code {
  margin: 0;
  background: var(--code-bg);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
  max-width: 100%;
}
.code figcaption {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 14px;
  background: var(--code-head);
  color: var(--code-dim);
  font-family: var(--f-mono);
  font-size: var(--t-xs);
}
.code figcaption .file { color: var(--code-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.code figcaption .lang { margin-left: auto; text-transform: uppercase; letter-spacing: 0.08em; }
.code .copy {
  font: inherit;
  color: var(--code-fg);
  background: transparent;
  border: 1px solid #ffffff2e;
  border-radius: 4px;
  padding: 3px 9px;
  cursor: pointer;
}
.code .copy:hover { background: #ffffff14; }
.code pre {
  margin: 0;
  padding: 14px 16px 16px;
  overflow-x: auto;
  font-family: var(--f-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--code-fg);
  tab-size: 2;
}
.code pre code { font-size: inherit; background: none; padding: 0; }
.code.bad figcaption { box-shadow: inset 3px 0 0 var(--fail); }
.code.good figcaption { box-shadow: inset 3px 0 0 var(--pass); }
.code figcaption .verdict { font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.code.bad .verdict { color: #ff9d93; }
.code.good .verdict { color: #7fe0a9; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 760px) { .pair { grid-template-columns: minmax(0, 1fr); } }

/* highlight.js tokens */
.hljs-attr, .hljs-name, .hljs-section { color: var(--tok-key); }
.hljs-string, .hljs-symbol { color: var(--tok-str); }
.hljs-number, .hljs-literal { color: var(--tok-num); }
.hljs-comment, .hljs-quote { color: var(--tok-com); font-style: italic; }
.hljs-keyword, .hljs-built_in, .hljs-selector-tag, .hljs-meta { color: var(--tok-kw); }
.hljs-variable, .hljs-template-variable, .hljs-subst, .hljs-bullet, .hljs-type { color: var(--tok-var); }

/* ---------- tabs ---------- */
.tabs { display: grid; gap: 0; min-width: 0; }
.tablist { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tablist button {
  font-family: var(--f-mono);
  font-size: var(--t-sm);
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.tablist button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: var(--t-sm); line-height: 1.5; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th {
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 600;
  background: var(--sunken);
  white-space: nowrap;
}
td:first-child { font-weight: 700; }
table.wide { min-width: 780px; }
td .chip { margin: 1px 0; }

/* ---------- file tree ---------- */
.tree {
  margin: 0;
  font-family: var(--f-mono);
  font-size: 0.84rem;
  line-height: 1.7;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  overflow-x: auto;
  color: var(--ink);
}
.tree .c { color: var(--ink-2); }

/* ---------- generic grids & cards ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
}
.panel h3 { margin: 0; }
.panel p, .panel li { font-size: var(--t-sm); }
.panel .eyebrow { margin-bottom: -4px; }

/* settings checklist rows */
.settings { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.setting { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting .what { font-weight: 700; }
.setting .where { display: block; }
.setting .why { color: var(--ink-2); font-size: var(--t-sm); max-width: var(--measure); }

/* numbered flow (only where order is real) */
.flow { list-style: none; padding: 0; margin: 0; counter-reset: flow; display: grid; gap: 0; max-width: var(--measure); }
.flow > li { counter-increment: flow; position: relative; padding: 0 0 18px 44px; margin: 0; }
.flow > li::before {
  content: counter(flow);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--f-mono);
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--accent);
  background: var(--surface);
  border: 2px solid var(--accent);
}
.flow > li::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 30px;
  bottom: 2px;
  width: 2px;
  background: var(--line);
}
.flow > li:last-child::after { display: none; }
.flow > li:last-child { padding-bottom: 0; }
.flow strong { display: block; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
