/* FieldWrench Pro Docs — GitHub Docs-like layout, brand navy + safety orange */

:root {
  --fw-navy: oklch(0.28 0.063 252);
  --fw-orange: oklch(0.682 0.186 44.8);
  --radius: 0.5rem;
  --header-h: 56px;
  --sidebar-w: 272px;
  --toc-w: 220px;
  --content-max: 52rem;

  --background: oklch(1 0 0);
  --surface: oklch(0.968 0.018 240);
  --foreground: oklch(0.28 0.063 252);
  --muted: oklch(0.96 0.015 240);
  --muted-foreground: oklch(0.45 0.035 260);
  --border: oklch(0.9 0.018 245);
  --card: oklch(1 0 0);
  --link: oklch(0.48 0.14 255);
  --link-hover: oklch(0.4 0.15 255);
  --primary: var(--fw-orange);
  --primary-foreground: oklch(0.28 0.063 252);
  --accent: oklch(0.95 0.045 60);
  --accent-foreground: oklch(0.42 0.13 45);
  --destructive: oklch(0.58 0.22 27);
  --warning-bg: oklch(0.97 0.03 80);
  --warning-border: oklch(0.75 0.15 80);
  --header-bg: oklch(0.28 0.063 252);
  --header-fg: oklch(0.98 0.01 240);
  --header-muted: oklch(0.78 0.03 255);
  --sidebar-bg: oklch(0.985 0.008 240);
  --sidebar-hover: oklch(0.95 0.015 240);
  --sidebar-active: oklch(0.95 0.04 50);
  --sidebar-active-fg: oklch(0.38 0.12 45);
  --shadow-pop: 0 8px 24px oklch(0.2 0.02 260 / 0.16);
  --code-bg: oklch(0.96 0.012 240);
  --input-bg: oklch(1 0 0 / 0.12);
  --ring: var(--fw-orange);
}

html.dark {
  --background: oklch(0.17 0.035 266);
  --surface: oklch(0.2 0.038 265);
  --foreground: oklch(0.95 0.01 240);
  --muted: oklch(0.26 0.04 265);
  --muted-foreground: oklch(0.7 0.03 250);
  --border: oklch(1 0 0 / 14%);
  --card: oklch(0.215 0.04 265);
  --link: oklch(0.78 0.12 250);
  --link-hover: oklch(0.85 0.1 250);
  --primary: oklch(0.72 0.186 46);
  --primary-foreground: oklch(0.18 0.04 266);
  --accent: oklch(0.32 0.07 50);
  --accent-foreground: oklch(0.9 0.08 60);
  --destructive: oklch(0.65 0.2 25);
  --warning-bg: oklch(0.28 0.05 70);
  --warning-border: oklch(0.72 0.14 75);
  --header-bg: oklch(0.14 0.04 252);
  --header-fg: oklch(0.96 0.01 240);
  --header-muted: oklch(0.74 0.03 255);
  --sidebar-bg: oklch(0.19 0.036 265);
  --sidebar-hover: oklch(0.24 0.04 265);
  --sidebar-active: oklch(0.3 0.06 50);
  --sidebar-active-fg: oklch(0.9 0.08 60);
  --shadow-pop: 0 8px 24px oklch(0 0 0 / 0.45);
  --code-bg: oklch(0.24 0.03 265);
  --input-bg: oklch(1 0 0 / 0.1);
  --ring: oklch(0.72 0.186 46);
}

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

html, body { margin: 0; padding: 0; }

html {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

html.dark { color-scheme: dark; }

body {
  background: var(--background);
  color: var(--foreground);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* ----- Header ----- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: var(--header-bg);
  color: var(--header-fg);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 2px solid var(--fw-orange);
}

.menu-btn {
  display: none;
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.menu-btn:hover { background: oklch(1 0 0 / 0.1); }
.menu-btn svg { width: 20px; height: 20px; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand:hover { color: inherit; text-decoration: none; }
.brand-mark {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.brand-docs {
  font-weight: 400;
  color: var(--header-muted);
  margin-left: 2px;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin-left: 8px;
}
.search-wrap input {
  width: 100%;
  height: 34px;
  border: 1px solid oklch(1 0 0 / 0.16);
  background: var(--input-bg);
  color: var(--header-fg);
  border-radius: 6px;
  padding: 0 12px 0 32px;
  font: inherit;
  font-size: 13.5px;
  outline: none;
}
.search-wrap input::placeholder { color: var(--header-muted); }
.search-wrap input:focus {
  border-color: var(--fw-orange);
  box-shadow: 0 0 0 2px oklch(0.682 0.186 44.8 / 0.35);
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--header-muted);
  pointer-events: none;
}
.search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--header-muted);
  border: 1px solid oklch(1 0 0 / 0.2);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 18px;
  pointer-events: none;
}

.search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(70vh, 420px);
  overflow: auto;
  background: var(--card);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
  z-index: 50;
}
.search-results.open { display: block; }
.search-hit {
  display: block;
  padding: 8px 12px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.search-hit:last-child { border-bottom: 0; }
.search-hit:hover,
.search-hit.active { background: var(--sidebar-active); text-decoration: none; }
.search-hit-title { font-weight: 600; font-size: 13.5px; }
.search-hit-meta { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; }
.search-empty { padding: 14px 12px; color: var(--muted-foreground); font-size: 13.5px; }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--header-fg);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: oklch(1 0 0 / 0.1); }
.icon-btn svg { width: 18px; height: 18px; }
html.dark .icon-sun { display: none; }
html:not(.dark) .icon-moon { display: none; }

/* ----- Shell ----- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 16px 10px 32px;
  font-size: 13.5px;
}

.sidebar-section + .sidebar-section { margin-top: 4px; }

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--foreground);
  font: inherit;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 8px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.section-toggle:hover { background: var(--sidebar-hover); }
.chevron {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  transition: transform 0.12s ease;
  color: var(--muted-foreground);
}
.sidebar-section.collapsed .chevron { transform: rotate(-90deg); }
.sidebar-section.collapsed .section-items { display: none; }

.section-items { list-style: none; margin: 0 0 6px; padding: 0 0 0 4px; }
.section-items a {
  display: block;
  color: var(--foreground);
  text-decoration: none;
  padding: 4px 8px 4px 16px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  line-height: 1.35;
}
.section-items a:hover {
  background: var(--sidebar-hover);
  text-decoration: none;
  color: var(--foreground);
}
.section-items a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-fg);
  font-weight: 600;
  border-left-color: var(--fw-orange);
}

.backdrop {
  display: none;
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: oklch(0.15 0.03 260 / 0.45);
  z-index: 29;
}

.main-col {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--toc-w);
  gap: 0;
}

.content {
  min-width: 0;
  padding: 24px 36px 64px;
  max-width: calc(var(--content-max) + 72px);
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted-foreground);
  margin: 0 0 14px;
}
.breadcrumbs a { color: var(--muted-foreground); }
.breadcrumbs a:hover { color: var(--link); }
.crumb-sep { opacity: 0.55; }

.article-title {
  margin: 0 0 6px;
  font-size: 1.85rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.article-lead {
  margin: 0 0 20px;
  color: var(--muted-foreground);
  font-size: 1.02rem;
  line-height: 1.5;
}

.mobile-toc { display: none; margin: 0 0 20px; }
.mobile-toc summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 0;
}
.mobile-toc ol { margin: 0; padding: 0 0 4px 18px; }
.mobile-toc a { font-size: 13.5px; }

.article h2 {
  margin: 1.6em 0 0.55em;
  padding-top: 0.4em;
  border-top: 1px solid var(--border);
  font-size: 1.2rem;
  letter-spacing: -0.015em;
}
.article h2:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.article h3 {
  margin: 1.25em 0 0.4em;
  font-size: 1.02rem;
}
.article p { margin: 0.65em 0; }
.article strong { font-weight: 600; }
.article ol, .article ul { margin: 0.5em 0 0.8em; padding-left: 1.4em; }
.article li { margin: 0.28em 0; }
.article li > ul, .article li > ol { margin: 0.2em 0; }

.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 0.8em 0 1.1em;
}
.article th, .article td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.article th { background: var(--muted); font-weight: 600; }

.article code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}
.article pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow: auto;
  font-size: 13px;
}
.article pre code { background: none; padding: 0; }

.article blockquote {
  margin: 0.9em 0;
  padding: 10px 14px;
  border-left: 3px solid var(--border);
  background: var(--muted);
  border-radius: 0 6px 6px 0;
}
.article blockquote p { margin: 0.3em 0; }
.article blockquote.alert-warning {
  border-left-color: var(--warning-border);
  background: var(--warning-bg);
}

.toc {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  align-self: start;
  padding: 24px 16px 32px 0;
  font-size: 12.5px;
}
.toc-title {
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin: 0 0 8px;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block;
  color: var(--muted-foreground);
  text-decoration: none;
  padding: 3px 0 3px 10px;
  border-left: 2px solid var(--border);
  line-height: 1.35;
}
.toc a:hover { color: var(--foreground); text-decoration: none; }
.toc a.active {
  color: var(--foreground);
  border-left-color: var(--fw-orange);
  font-weight: 600;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin: 8px 0 24px;
}
.home-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
}
.home-card:hover {
  border-color: var(--fw-orange);
  text-decoration: none;
  color: inherit;
}
.home-card h2 {
  margin: 0 0 4px;
  font-size: 0.98rem;
  border: 0;
  padding: 0;
}
.home-card p {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 13px;
}
.home-card ul {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.home-card li { margin: 3px 0; font-size: 13px; }

.site-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted-foreground);
}

/* ----- Mobile (GitHub Docs-style drawer) ----- */
@media (max-width: 1010px) {
  .main-col { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .mobile-toc { display: block; }
}

@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .shell { display: block; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: min(86vw, 320px);
    z-index: 30;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow-pop);
    height: auto;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .backdrop { display: block; }
  .content { padding: 18px 16px 48px; }
  .search-wrap { max-width: none; }
  .search-kbd { display: none; }
  .brand-name { display: none; }
}

.home-card h2 a { color: inherit; text-decoration: none; }
.home-card h2 a:hover { color: var(--link); text-decoration: none; }
