/* SBOMFlow docs — self-hosted, CSP-safe. Themes via [data-theme] on <html>.
   Default follows the OS via prefers-color-scheme (works with JS disabled). */

:root {
  --bg: #ffffff;
  --fg: #1c2024;
  --muted: #5b6570;
  --panel: #f6f8fa;
  --border: #d8dee4;
  --link: #0757ba;
  --accent: #0969da;
  --code-bg: #f6f8fa;
  --note: #0969da;
  --warn: #9a6700;
  --offline: #1a7f37;
  --network: #8250df;
  --maxw: 46rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="hc"]) {
    --bg: #0d1117; --fg: #e6edf3; --muted: #9aa5b1; --panel: #161b22;
    --border: #30363d; --link: #4aa3ff; --accent: #58a6ff; --code-bg: #161b22;
    --note: #58a6ff; --warn: #d4a72c; --offline: #3fb950; --network: #bc8cff;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --fg: #e6edf3; --muted: #9aa5b1; --panel: #161b22;
  --border: #30363d; --link: #4aa3ff; --accent: #58a6ff; --code-bg: #161b22;
  --note: #58a6ff; --warn: #d4a72c; --offline: #3fb950; --network: #bc8cff;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
/* High-contrast / colorblind-safe palette */
:root[data-theme="hc"] {
  --bg: #ffffff; --fg: #000000; --muted: #1a1a1a; --panel: #f2f2f2;
  --border: #000000; --link: #0000cc; --accent: #0000cc; --code-bg: #f2f2f2;
  --note: #0000cc; --warn: #7a3d00; --offline: #005a2a; --network: #4b0082;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }

body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.65;
}
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff;
  padding: 8px 14px; z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

.masthead {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.site-switcher { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.site-return {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px;
  border-radius: 6px; color: var(--muted); font-size: 14px; font-weight: 600;
  text-decoration: none;
}
.site-return:hover { color: var(--fg); background: var(--panel); }
.site-divider { color: var(--border); }
.brand { font-weight: 700; text-decoration: none; color: var(--fg); font-size: 16px; }
.masthead .search-trigger { margin-left: auto; }
.masthead button {
  background: var(--panel); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.masthead kbd {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  padding: 0 4px; font-size: 11px; margin-left: 3px;
}
.nav-toggle { display: none; }

.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px; max-width: 1400px; margin: 0 auto; }
nav.side { border-right: 1px solid var(--border); padding: 20px 14px; }
nav.side .nav-group { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 6px; }
nav.side ul { list-style: none; margin: 0; padding: 0; }
nav.side li { margin: 1px 0; }
nav.side a { display: block; padding: 5px 10px; border-radius: 6px; text-decoration: none; color: var(--fg); font-size: 14px; }
nav.side a:hover { background: var(--panel); }
nav.side a.active { background: var(--panel); color: var(--accent); font-weight: 600; border-left: 3px solid var(--accent); }

main { padding: 26px 40px; min-width: 0; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.breadcrumb a { color: var(--muted); }
.content { max-width: var(--maxw); }
.content h1 { font-size: 30px; margin: 0 0 14px; line-height: 1.2; }
.content h2 { font-size: 22px; margin: 30px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); scroll-margin-top: 70px; }
.content h3 { font-size: 17px; margin: 22px 0 8px; scroll-margin-top: 70px; }
.content p, .content li { font-size: 15.5px; }
.content code { background: var(--code-bg); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; font-size: 90%; }

.codeblock { position: relative; margin: 14px 0; }
.codeblock .code-lang { position: absolute; top: 6px; left: 10px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.codeblock pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 30px 14px 14px; overflow: auto; }
.codeblock pre code { background: none; border: none; padding: 0; }
.copy-btn { position: absolute; top: 6px; right: 8px; font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; cursor: pointer; color: var(--fg); }
.copy-btn:hover { background: var(--panel); }

.table-wrap { overflow-x: auto; margin: 14px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
th { background: var(--panel); }
blockquote { border-left: 4px solid var(--border); margin: 14px 0; padding: 4px 14px; color: var(--muted); }
hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }

.callout { border: 1px solid var(--border); border-left-width: 4px; border-radius: 8px; padding: 10px 14px; margin: 16px 0; background: var(--panel); }
.callout-title { font-weight: 700; margin: 0 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
.callout p:last-child { margin-bottom: 0; }
.callout-note { border-left-color: var(--note); } .callout-note .callout-title { color: var(--note); }
.callout-tip { border-left-color: var(--offline); } .callout-tip .callout-title { color: var(--offline); }
.callout-important { border-left-color: var(--accent); } .callout-important .callout-title { color: var(--accent); }
.callout-warning { border-left-color: var(--warn); } .callout-warning .callout-title { color: var(--warn); }
.callout-offline { border-left-color: var(--offline); } .callout-offline .callout-title { color: var(--offline); }
.callout-network { border-left-color: var(--network); } .callout-network .callout-title { color: var(--network); }

.prevnext { display: flex; justify-content: space-between; gap: 16px; margin: 34px 0 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.prevnext a { text-decoration: none; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 14px; max-width: 48%; }
.prevnext a:hover { background: var(--panel); }
.footer { color: var(--muted); font-size: 12px; margin-top: 30px; border-top: 1px solid var(--border); padding-top: 12px; max-width: var(--maxw); }

aside.outline { padding: 26px 14px; font-size: 13px; position: sticky; top: 52px; align-self: start; max-height: calc(100vh - 60px); overflow: auto; }
.outline-title { text-transform: uppercase; letter-spacing: .05em; font-size: 11px; color: var(--muted); margin: 0 0 8px; }
aside.outline ul { list-style: none; margin: 0; padding: 0; }
aside.outline a { color: var(--muted); text-decoration: none; display: block; padding: 2px 0; }
aside.outline a:hover { color: var(--accent); }
aside.outline .lvl-3 { padding-left: 12px; }

.search-modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; z-index: 50; }
.search-modal[hidden] { display: none; }
.search-box { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; width: min(90vw, 560px); padding: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.search-input { width: 100%; padding: 10px 12px; font-size: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--fg); }
.search-results { list-style: none; margin: 10px 0 0; padding: 0; max-height: 50vh; overflow: auto; }
.search-results li { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.search-results li:hover, .search-results li[aria-selected="true"] { background: var(--panel); }
.search-results a { text-decoration: none; color: var(--fg); display: block; }
.search-results .r-group { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.search-hint { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  aside.outline { display: none; }
  .nav-toggle { display: inline-block; }
  nav.side { position: fixed; left: 0; top: 49px; bottom: 0; width: 280px; background: var(--bg); border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform .15s ease; z-index: 30; overflow: auto; }
  nav.side.open { transform: translateX(0); }
  main { padding: 20px 18px; }
}

@media (max-width: 600px) {
  .masthead { gap: 6px; padding: 8px; }
  .site-switcher { gap: 4px; }
  .site-return { gap: 3px; padding: 3px 2px; font-size: 13px; }
  .brand { font-size: 14px; }
  .masthead button { padding: 5px 7px; }
  .masthead .search-trigger kbd { display: none; }
  .masthead .theme-toggle { font-size: 0; }
  .masthead .theme-toggle::before { content: "Theme"; font-size: 12px; }
}

@media print {
  .masthead, nav.side, aside.outline, .prevnext, .search-modal, .copy-btn { display: none !important; }
  .layout { display: block; } main { padding: 0; } a { color: #000; text-decoration: underline; }
}
