/* Forward Deployed Engineering knowledge base
   One stylesheet for every page. Colors are tokens on :root; dark mode follows the visitor's system. */

:root {
  --bg: #ffffff;
  --bg-soft: #f3f8f8;
  --bg-tint: #e0f0f2;
  --text: #14272b;
  --muted: #4b6064;
  --line: #d3e1e3;
  --accent: #0a6672;
  --accent-hover: #074d56;
  --accent-ink: #ffffff;
  --logo-ink: #ffffff;
  --note: #e8f3f5;
  --tip: #e9f5ec;
  --tip-line: #2f7d4a;
  --warn: #fdf1e3;
  --warn-line: #b45f06;
  --shadow: 0 1px 2px rgba(20, 39, 43, 0.06), 0 4px 14px rgba(20, 39, 43, 0.06);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1a1c;
    --bg-soft: #14262a;
    --bg-tint: #1a3a40;
    --text: #e4eef0;
    --muted: #a8bec2;
    --line: #28403f;
    --accent: #62c6d2;
    --accent-hover: #8fdbe4;
    --accent-ink: #04222a;
    --logo-ink: #04222a;
    --note: #14303a;
    --tip: #14301f;
    --tip-line: #5cc27f;
    --warn: #35260f;
    --warn-line: #f0a24b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: 16px; }
@media (min-width: 700px) { html { scroll-padding-top: 88px; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem; /* 17px */
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}
@media (min-width: 700px) { body { font-size: 1.125rem; } } /* 18px */

h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 1.1em; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 8px;
}
.skip:focus { top: 12px; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 780px; }
@media (min-width: 700px) { .wrap { padding: 0 24px; } }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); position: relative; z-index: 50; }
@media (min-width: 700px) { .site-header { position: sticky; top: 0; } }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 68px; padding-top: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--accent); text-decoration: none; min-height: 44px; }
.brand:hover { color: var(--accent-hover); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 1rem; color: var(--text); }
.brand-sub { font-size: 0.8125rem; color: var(--muted); }
.site-header .search { margin-left: auto; flex: 1 1 260px; max-width: 420px; }

/* ---------- search ---------- */
.search { position: relative; }
.search input[type="search"] {
  width: 100%; height: 48px; padding: 0 14px 0 44px; font: inherit; font-size: 1rem;
  color: var(--text); background: var(--bg); border: 2px solid var(--line); border-radius: 10px;
  appearance: none; -webkit-appearance: none;
}
.search input[type="search"]::placeholder { color: var(--muted); opacity: 1; }
.search input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.search-icon { position: absolute; left: 13px; top: 13px; color: var(--muted); pointer-events: none; }
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 60;
  max-height: min(70vh, 480px); overflow-y: auto; text-align: left;
}
.search-results li { margin: 0; }
.search-results a {
  display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); line-height: 1.4;
}
.search-results a:hover, .search-results [aria-selected="true"] a { background: var(--bg-tint); }
.search-results .r-title { display: block; font-weight: 650; font-size: 1rem; }
.search-results .r-cat { display: block; font-size: 0.8125rem; color: var(--accent); font-weight: 600; margin-top: 2px; }
.search-results .r-sum { display: block; font-size: 0.9375rem; color: var(--muted); margin-top: 2px; }
.search-results .r-none { padding: 12px; color: var(--muted); font-size: 1rem; }
.search mark { background: none; color: inherit; font-weight: 800; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }

.search-big { max-width: 720px; margin: 28px auto 0; display: flex; gap: 10px; flex-wrap: wrap; }
.search-big .search-icon { top: 20px; left: 18px; }
.search-big input[type="search"] { height: 64px; font-size: 1.125rem; padding-left: 52px; border-radius: 14px; flex: 1 1 280px; width: auto; }
.search-big .search-btn {
  height: 64px; padding: 0 28px; font: inherit; font-weight: 650; font-size: 1.0625rem; color: var(--accent-ink);
  background: var(--accent); border: 0; border-radius: 14px; cursor: pointer; flex: 0 0 auto;
}
.search-big .search-btn:hover { background: var(--accent-hover); }
.search-big .search-results { top: 70px; }
@media (max-width: 520px) { .search-big .search-btn { width: 100%; } .search-big .search-results { top: 70px; } }

/* ---------- home ---------- */
.hero { background: var(--bg-soft); border-bottom: 1px solid var(--line); padding: 56px 0 64px; text-align: center; }
.hero h1 { font-size: clamp(2.125rem, 6vw, 3.5rem); font-weight: 750; }
.hero-sub { max-width: 34em; margin: 14px auto 0; font-size: 1.1875rem; color: var(--muted); }
.hero-note { color: var(--muted); font-size: 1rem; margin-top: 14px; }

.topics, .popular { padding-top: 48px; padding-bottom: 8px; }
.topics h2, .popular h2 { font-size: 1.5rem; margin-bottom: 22px; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 22px; text-decoration: none; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); line-height: 1.45;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); color: var(--text); }
.tile-icon {
  display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 12px;
  background: var(--bg-tint); color: var(--accent); margin-bottom: 8px;
}
.tile-title { font-weight: 700; font-size: 1.1875rem; }
.tile-desc { color: var(--muted); font-size: 1rem; }
.tile-count { margin-top: auto; padding-top: 8px; font-size: 0.875rem; color: var(--accent); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } .tile:hover { transform: none; } }

/* ---------- lists of articles ---------- */
.article-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.article-list li { border-bottom: 1px solid var(--line); }
.article-link { display: block; padding: 18px 4px; text-decoration: none; color: var(--text); }
.article-link:hover .article-link-title { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 4px; }
.article-link-title { display: block; font-weight: 700; font-size: 1.1875rem; color: var(--accent); line-height: 1.35; }
.article-link-summary { display: block; margin-top: 4px; color: var(--muted); font-size: 1rem; line-height: 1.5; }

/* ---------- headings on plain pages ---------- */
.narrow > h1 { font-size: clamp(2rem, 5vw, 2.75rem); margin: 8px 0 14px; }
.lead { font-size: 1.25rem; color: var(--muted); margin-bottom: 32px; max-width: 38em; }
.narrow { padding-bottom: 72px; }
.narrow .article-list { margin-top: 8px; }

/* ---------- breadcrumb ---------- */
.breadcrumb { margin: 28px 0 8px; font-size: 0.9375rem; }
.breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: nowrap; color: var(--muted); }
.breadcrumb li { flex: 0 0 auto; white-space: nowrap; }
.breadcrumb li + li::before { content: "/"; margin: 0 10px; color: var(--muted); opacity: 0.6; }
.breadcrumb li[aria-current] { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb li[aria-current]::before { display: inline-block; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb [aria-current] { color: var(--text); }

/* ---------- article layout ---------- */
.layout { display: flex; flex-direction: column; padding-bottom: 64px; }
.toc { display: none; }
.article { min-width: 0; order: 1; }
.side { order: 2; margin-top: 8px; }
.article h1 { font-size: clamp(1.875rem, 5vw, 2.5rem); font-weight: 750; margin-bottom: 10px; }
.meta { color: var(--muted); font-size: 0.9375rem; margin-bottom: 20px; }

.side-details > summary {
  cursor: pointer; font-weight: 650; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-top: 16px;
  min-height: 44px; list-style-position: inside;
}
.side-details[open] > summary { margin-bottom: 8px; }
.side-title { display: none; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a {
  display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--text);
  font-size: 0.975rem; line-height: 1.4; border-left: 3px solid transparent;
}
.side li a:hover { background: var(--bg-soft); }
.side li a[aria-current="page"] { background: var(--bg-tint); border-left-color: var(--accent); font-weight: 650; color: var(--text); }

.toc-mobile { margin: 0 0 28px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); }
.toc-mobile summary { cursor: pointer; padding: 12px 14px; font-weight: 650; min-height: 44px; }
.toc-mobile ol { margin: 0; padding: 0 14px 12px 14px; list-style: none; }
.toc-mobile a { display: block; padding: 7px 0; font-size: 1rem; text-decoration: none; }
.toc-mobile .toc-l3 { padding-left: 16px; }

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); column-gap: 48px; }
  .side, .article { order: 0; }
  .side { display: block; margin-top: 0; position: sticky; top: 92px; align-self: start; max-height: calc(100vh - 110px); overflow-y: auto; padding-top: 28px; }
  .side-details > summary { display: none; }
  .side-title { display: block; font-weight: 750; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 10px 12px; }
  .side-title a { color: var(--muted); text-decoration: none; }
  .side-title a:hover { color: var(--accent); }
}
@media (min-width: 1200px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr) 230px; column-gap: 44px; }
  .toc { display: block; position: sticky; top: 92px; align-self: start; max-height: calc(100vh - 110px); overflow-y: auto; padding-top: 28px; }
  .toc-mobile { display: none; }
  .toc-title { font-weight: 750; font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 10px; color: var(--muted); }
  .toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
  .toc a {
    display: block; padding: 5px 0 5px 14px; margin-left: -2px; border-left: 2px solid transparent; text-decoration: none;
    color: var(--muted); font-size: 0.9375rem; line-height: 1.4;
  }
  .toc a:hover { color: var(--text); }
  .toc a[aria-current="true"] { color: var(--accent); border-left-color: var(--accent); font-weight: 650; }
  .toc .toc-l3 a { padding-left: 28px; font-size: 0.875rem; }
}

/* ---------- article text ---------- */
.prose { max-width: 70ch; }
.prose h2 { font-size: 1.625rem; margin: 2.1em 0 0.6em; font-weight: 720; }
.prose h3 { font-size: 1.25rem; margin: 1.7em 0 0.5em; font-weight: 700; }
.prose > :first-child { margin-top: 0; }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.5em; }
.prose li { margin-bottom: 0.45em; padding-left: 0.2em; }
.prose li::marker { color: var(--accent); }
.prose strong { font-weight: 700; }
.prose code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-soft); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.prose pre {
  margin: 0 0 1.3em; padding: 16px 18px; overflow-x: auto; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; font-size: 0.9375rem; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.prose blockquote { margin: 0 0 1.3em; padding: 2px 0 2px 18px; border-left: 4px solid var(--accent); color: var(--muted); }
.prose blockquote p { margin-bottom: 0.6em; }

.table-wrap { overflow-x: auto; margin: 0 0 1.4em; border: 1px solid var(--line); border-radius: 10px; -webkit-overflow-scrolling: touch; }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.975rem; line-height: 1.5; min-width: 520px; }
.prose th, .prose td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose thead th { background: var(--bg-soft); font-weight: 700; }
.prose tbody tr:last-child th, .prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody th { font-weight: 650; }

.callout { margin: 0 0 1.4em; padding: 14px 18px; border-radius: 10px; border-left: 4px solid var(--accent); background: var(--note); }
.callout p:last-child, .callout ul:last-child, .callout ol:last-child { margin-bottom: 0; }
.callout-title { font-weight: 750; margin-bottom: 0.3em !important; }
.callout-tip { background: var(--tip); border-left-color: var(--tip-line); }
.callout-warning { background: var(--warn); border-left-color: var(--warn-line); }

.checklist { list-style: none; padding-left: 0 !important; }
.checklist li { padding-left: 0; }
.checklist label { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; padding: 4px 0; }
.checklist input { width: 22px; height: 22px; margin: 4px 0 0; flex: 0 0 auto; accent-color: var(--accent); }

.diagram, .shot { margin: 1.8em 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); }
.diagram svg { display: block; width: 100%; max-width: 520px; height: auto; margin: 0 auto; }
.shot img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 6px; }
figcaption { margin-top: 12px; font-size: 0.9375rem; color: var(--muted); text-align: center; line-height: 1.5; }

/* diagram parts (used inside the inline SVGs) */
.d-box { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.d-box-strong { fill: var(--bg-tint); stroke: var(--accent); stroke-width: 2.5; }
.d-box-soft { fill: var(--bg); stroke: var(--line); stroke-width: 2; }
.d-line { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.d-head { fill: var(--accent); }
.d-text { fill: var(--text); font: 700 18px var(--font); }
.d-sub { fill: var(--muted); font: 400 15px var(--font); }
.d-axis { fill: var(--muted); font: 600 15px var(--font); }
.d-grid { stroke: var(--line); stroke-width: 2; }

/* ---------- feedback and related ---------- */
.helpful { margin: 56px 0 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); max-width: 70ch; }
.helpful h2 { font-size: 1.25rem; margin-bottom: 14px; }
.helpful-buttons { display: flex; gap: 12px; }
.helpful button {
  min-width: 96px; min-height: 48px; padding: 0 22px; font: inherit; font-weight: 650; font-size: 1rem; color: var(--accent);
  background: var(--bg); border: 2px solid var(--accent); border-radius: 10px; cursor: pointer;
}
.helpful button:hover { background: var(--accent); color: var(--accent-ink); }
.helpful-thanks { margin: 14px 0 0; }

.related { margin-top: 56px; }
.related h2 { font-size: 1.375rem; margin-bottom: 16px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.card {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 18px; text-decoration: none; color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); line-height: 1.45;
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); color: var(--text); }
.card-cat { font-size: 0.8125rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.card-title { font-weight: 700; font-size: 1.0625rem; }
.card-summary { font-size: 0.9375rem; color: var(--muted); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: 0.9375rem; }
.site-footer p { margin: 0 0 6px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }
.footer-small { font-size: 0.875rem; }

/* ---------- print (templates and worksheets) ---------- */
@media print {
  :root { --bg: #fff; --text: #000; --muted: #333; --line: #999; --bg-soft: #fff; --bg-tint: #fff; --accent: #000; }
  body { font-size: 12pt; }
  .site-header, .site-footer, .side, .toc, .toc-mobile, .helpful, .related, .skip, .breadcrumb { display: none !important; }
  .layout { display: block; }
  .prose { max-width: none; }
  a { color: #000; text-decoration: none; }
  h2, h3 { break-after: avoid; }
  .callout, .diagram, table, pre { break-inside: avoid; }
}
