/* ============================================
   BOS Enterprise Docs — site.css (CHROME ONLY)
   Header, sidebar nav, breadcrumb, footer, layout, tokens.
   Do not put documentation-content styling here — see content.css.
   ============================================ */

/* ============================================
   1. TOKENS — locked monochrome spec
   ============================================ */
:root {
  --gray-950: #050505;
  --gray-900: #0c0c0c;
  --gray-800: #262626;
  --gray-700: #404040;
  --gray-600: #525252;
  --gray-500: #6b6b6b;
  --gray-400: #a3a3a3;
  --gray-300: #d4d4d4;
  --gray-200: #e5e5e5;
  --gray-100: #f0f0f0;
  --gray-50: #f7f7f7;

  --background: #ffffff;
  --background-alt: var(--gray-50);
  --foreground: var(--gray-900);
  --muted: var(--gray-50);
  --muted-foreground: var(--gray-500);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --primary: var(--gray-900);
  --primary-dark: var(--gray-950);
  --primary-foreground: #ffffff;

  --destructive: #b91c1c;
  --destructive-bg: rgba(220, 38, 38, 0.1);
  --destructive-foreground: #ffffff;

  --font-body: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Consolas", "Liberation Mono", Menlo, monospace;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 3rem;

  --breakpoint-md: 768px;
  --header-height: 3.5rem;
  --sidebar-width: 17rem;
}

:root[data-theme="dark"] {
  --dark-elevated: #1c1c1c;
  --background: var(--gray-950);
  --background-alt: var(--dark-elevated);
  --foreground: var(--gray-50);
  --muted: var(--dark-elevated);
  --muted-foreground: var(--gray-400);
  --border: var(--gray-800);
  --border-strong: var(--gray-700);
  --primary: var(--gray-50);
  --primary-dark: #ffffff;
  --primary-foreground: var(--gray-950);

  --destructive: #f87171;
  --destructive-bg: rgba(248, 113, 113, 0.14);
  --destructive-foreground: var(--gray-950);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --dark-elevated: #1c1c1c;
    --background: var(--gray-950);
    --background-alt: var(--dark-elevated);
    --foreground: var(--gray-50);
    --muted: var(--dark-elevated);
    --muted-foreground: var(--gray-400);
    --border: var(--gray-800);
    --border-strong: var(--gray-700);
    --primary: var(--gray-50);
    --primary-dark: #ffffff;
    --primary-foreground: var(--gray-950);
    --destructive: #f87171;
    --destructive-bg: rgba(248, 113, 113, 0.14);
    --destructive-foreground: var(--gray-950);
  }
}

@font-face {
  font-family: "Roboto";
  src: url("/assets/fonts/roboto-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Roboto";
  src: url("/assets/fonts/roboto-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ============================================
   2. RESET / BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: var(--space-md); }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--background);
}
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p { margin: 0 0 var(--space-md); }
a { color: inherit; }

/* ============================================
   3. LAYOUT
   ============================================ */
.container {
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--space-md);
}

.site-body {
  display: flex;
  flex-direction: column;
  max-width: 1280px;
  margin-inline: auto;
}

.doc-layout {
  display: block;
  padding-inline: var(--space-md);
  padding-block: var(--space-lg);
}

.doc-content-wrapper {
  min-width: 0;
  max-width: 48rem;
}

@media (min-width: 768px) {
  .doc-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: var(--space-lg);
    align-items: start;
  }
}

/* ============================================
   4. COMPONENTS
   ============================================ */

/* --- Skip link --- */
.skip-link {
  position: absolute;
  top: -3rem;
  left: var(--space-sm);
  background: var(--primary);
  color: var(--primary-foreground);
  padding: var(--space-sm) var(--space-md);
  z-index: 100;
  border-radius: 4px;
}
.skip-link:focus { top: var(--space-sm); }

/* --- Header --- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  height: var(--header-height);
  padding-inline: var(--space-md);
  max-width: 1280px;
  margin-inline: auto;
}
.site-header__logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}
.site-header__logo img { height: 1.75rem; width: auto; }

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--foreground);
}
.nav-toggle__icon,
.nav-toggle__icon::before,
.nav-toggle__icon::after {
  display: block;
  width: 1.25rem;
  height: 2px;
  background: currentColor;
}
.nav-toggle__icon::before,
.nav-toggle__icon::after { content: ""; margin-block: 4px; }

/* --- Theme toggle ---
   Manual override of the automatic prefers-color-scheme default. Shows the
   icon for the mode you'd switch TO. No stored preference = follows the
   OS/browser setting (handled by the same media query as every other
   token); clicking sets an explicit data-theme and remembers it. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--foreground);
  flex-shrink: 0;
}
.theme-toggle svg { width: 1.25rem; height: 1.25rem; }
.theme-toggle__icon--dark { display: block; }
.theme-toggle__icon--light { display: none; }

:root[data-theme="dark"] .theme-toggle__icon--dark { display: none; }
:root[data-theme="dark"] .theme-toggle__icon--light { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__icon--dark { display: none; }
  :root:not([data-theme="light"]) .theme-toggle__icon--light { display: block; }
}

/* --- Sidebar tree nav --- */
.sidebar {
  display: none;
}
.sidebar--open { display: block; }
.sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar__group { margin-bottom: var(--space-xs); }
.sidebar__group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  color: var(--foreground);
  border-radius: 4px;
}
.sidebar__group-toggle:hover,
.sidebar__group-toggle:focus-visible { background: var(--muted); }
.sidebar__group-toggle-icon {
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid var(--muted-foreground);
  border-bottom: 2px solid var(--muted-foreground);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.sidebar__group[data-open="true"] .sidebar__group-toggle-icon {
  transform: rotate(-135deg);
}
.sidebar__sublist {
  list-style: none;
  margin: 0;
  padding: 0 0 var(--space-sm) var(--space-md);
  display: none;
}
.sidebar__group[data-open="true"] .sidebar__sublist { display: block; }
.sidebar__link {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  text-decoration: none;
  color: var(--muted-foreground);
  border-radius: 4px;
  font-size: 0.9375rem;
}
.sidebar__link:hover,
.sidebar__link:focus-visible { background: var(--muted); color: var(--foreground); }
/* Top-level single-page categories (no children, so no group-toggle button)
   sit directly in .sidebar__list, not a .sidebar__sublist - match the
   group-toggle buttons' weight so they read as peers, not sub-items. */
.sidebar__list > li > .sidebar__link {
  color: var(--foreground);
  font-weight: 600;
}
.sidebar__link[aria-current="page"] {
  color: var(--foreground);
  font-weight: 600;
  background: var(--muted);
}

@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .sidebar { display: block; position: sticky; top: calc(var(--header-height) + var(--space-lg)); }
}

/* --- Breadcrumb --- */
.breadcrumb {
  margin-bottom: var(--space-md);
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
.breadcrumb__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
.breadcrumb__list li:not(:last-child)::after {
  content: "/";
  margin-left: var(--space-xs);
  color: var(--border-strong);
}
.breadcrumb__list a { text-decoration: none; }
.breadcrumb__list a:hover { text-decoration: underline; }

/* --- Search --- */
.site-search { position: relative; flex: 1; min-width: 0; max-width: 20rem; }
.site-search__input {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--background);
  color: var(--foreground);
  font: inherit;
}
.site-search__results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--background);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  max-height: 20rem;
  overflow-y: auto;
  z-index: 30;
}
.site-search__results:empty { display: none; }
.site-search__result { display: block; padding: var(--space-sm); text-decoration: none; border-bottom: 1px solid var(--border); }
.site-search__result:last-child { border-bottom: 0; }
.site-search__result:hover, .site-search__result:focus-visible { background: var(--muted); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-weight: 600;
  font-family: var(--font-body);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--foreground); }
.btn-outline:hover { border-color: var(--primary); }

/* --- Footer --- */
.site-footer {
  background: var(--background-alt);
  margin-top: var(--space-xl);
  border-top: 1px solid var(--border);
}
.site-footer__inner {
  display: grid;
  gap: var(--space-lg);
  padding-block: var(--space-lg);
  grid-template-columns: 1fr;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--space-md);
}
.site-footer__col { min-width: 0; }
.site-footer__heading { font-weight: 600; margin-bottom: var(--space-sm); }
.site-footer__list { list-style: none; margin: 0; padding: 0; }
.site-footer__list a { text-decoration: none; color: var(--muted-foreground); }
.site-footer__list a:hover { color: var(--foreground); }
.site-footer__bottom {
  border-top: 1px solid var(--border);
  padding-block: var(--space-sm);
  padding-inline: var(--space-md);
  font-size: 0.875rem;
  color: var(--muted-foreground);
  max-width: 1280px;
  margin-inline: auto;
}

@media (min-width: 768px) {
  .site-footer__inner { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================
   5. UTILITIES
   ============================================ */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.text-center { text-align: center; }
