/* System Builder Manual — branding tokens.
   MIRROR of frontend/tailwind.config.cjs + frontend/src/main.css.
   If the tool rebrands, update this :root block AND that file together. */
:root {
  --sb-green: #34D399;        /* custom-green */
  --sb-green-strong: #059669; /* emerald-600 hover */
  --sb-green-dark: #006633;   /* green.700 (select accent) */
  --sb-header-bg: #166534;    /* header stripe */
  --sb-red: #DF696A;          /* custom-red */
  --sb-bg: #ffffff;
  --sb-bg-alt: #f8fafc;       /* slate-50 */
  --sb-border: #e2e8f0;       /* slate-200 */
  --sb-text: #334155;         /* slate-700 (body text in tool) */
  --sb-text-muted: #64748b;   /* slate-500 */
  --sb-heading: #0f172a;      /* slate-900 */
  /* Tailwind default font-sans stack — tool ships NO webfont. Do not add one. */
  --sb-font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
             "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
             sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --sb-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
             "Liberation Mono", "Courier New", monospace;
  color-scheme: light;
}

/* === Dark mode ===
   Two triggers, same token overrides:
   1. explicit user choice  -> :root[data-theme="dark"] (set via header toggle)
   2. OS preference, no choice -> @media + :root:not([data-theme])
   Header green stays; it reads well on both themes. */
:root[data-theme="dark"] {
  --sb-header-bg: #0d3b24;    /* slightly deeper green for dark surfaces */
  --sb-green-strong: #34D399; /* links pop on dark bg */
  --sb-bg: #1e293b;           /* slate-800 (matches tool dark bg) */
  --sb-bg-alt: #0f172a;       /* slate-900 */
  --sb-border: #334155;       /* slate-700 */
  --sb-text: #cbd5e1;         /* slate-300 */
  --sb-text-muted: #94a3b8;   /* slate-400 */
  --sb-heading: #f1f5f9;      /* slate-100 */
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --sb-header-bg: #0d3b24;
    --sb-green-strong: #34D399;
    --sb-bg: #1e293b;
    --sb-bg-alt: #0f172a;
    --sb-border: #334155;
    --sb-text: #cbd5e1;
    --sb-text-muted: #94a3b8;
    --sb-heading: #f1f5f9;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--sb-font);
  color: var(--sb-text);
  background: var(--sb-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* === Header ===
   Full-width green stripe. Inner flex row keeps the title left and the
   language switcher + theme toggle right, aligned to the content column. */
.sb-header {
  background: var(--sb-header-bg);
  color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.sb-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.sb-header__title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.sb-header__controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Language switcher — pill group sitting on the green header. */
.sb-lang {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 2px;
}
.sb-lang__opt {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  line-height: 1.4;
}
.sb-lang__opt:hover { color: #fff; }
.sb-lang__opt--active {
  background: #fff;
  color: var(--sb-header-bg);
  pointer-events: none;
  cursor: default;
}
.sb-lang__opt--active:hover {
  color: var(--sb-header-bg);
}

/* Theme toggle — one button, shows the icon for the mode you'll switch TO. */
.sb-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}
.sb-theme-toggle:hover { background: rgba(255, 255, 255, 0.24); }
/* Show the icon for the mode you'll switch TO:
   light mode -> moon (go dark), dark mode -> sun (go light). */
.sb-theme-toggle__sun  { display: none; }
.sb-theme-toggle__moon { display: inline; }
:root[data-theme="dark"] .sb-theme-toggle__sun  { display: inline; }
:root[data-theme="dark"] .sb-theme-toggle__moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .sb-theme-toggle__sun  { display: inline; }
  :root:not([data-theme]) .sb-theme-toggle__moon { display: none; }
}

.sb-manual {
  display: flex;
  min-height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
}

/* Hamburger button (mobile only) */
.sb-hamburger {
  display: none;
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  padding: 0;
  flex-direction: column;
  justify-content: space-around;
}
.sb-hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
  transition: all 150ms ease;
}

/* === Sidebar nav === */
.sb-nav {
  flex: 0 0 240px;
  border-right: 1px solid var(--sb-border);
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}
.sb-nav__group {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sb-text-muted);
  margin: 1rem 0 0.35rem;
}
.sb-nav__link {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: 0.375rem;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 0.9rem;
}
.sb-nav__link:hover { background: var(--sb-bg-alt); }
.sb-nav__link--active {
  background: var(--sb-bg-alt);
  color: var(--sb-green-strong);
  font-weight: 600;
}

/* === Content === */
.sb-content {
  flex: 1 1 auto;
  padding: 2rem 2.5rem;
  min-width: 0;
}
.sb-content h1, .sb-content h2, .sb-content h3 {
  color: var(--sb-heading);
  line-height: 1.25;
  margin-top: 1.75rem;
}
.sb-content h1 { font-size: 1.9rem; margin-top: 0; }
.sb-content h2 {
  font-size: 1.35rem;
  border-bottom: 1px solid var(--sb-border);
  padding-bottom: 0.3rem;
}
.sb-content h3 { font-size: 1.1rem; }
.sb-content a { color: var(--sb-green-strong); }
.sb-content code {
  font-family: var(--sb-mono);
  font-size: 0.85em;
  background: var(--sb-bg-alt);
  border: 1px solid var(--sb-border);
  border-radius: 0.25rem;
  padding: 0.1em 0.35em;
}
.sb-content pre {
  background: var(--sb-bg-alt);
  border: 1px solid var(--sb-border);
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
}
.sb-content pre code { background: none; border: none; padding: 0; }
.sb-content img {
  max-width: 100%;
  border: 1px solid var(--sb-border);
  border-radius: 0.5rem;
  display: block;
  margin: 1rem 0;
}
.sb-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.9rem;
}
.sb-content th, .sb-content td {
  border: 1px solid var(--sb-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.sb-content th { background: var(--sb-bg-alt); }
.sb-content blockquote {
  border-left: 3px solid var(--sb-green);
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  color: var(--sb-text-muted);
  background: var(--sb-bg-alt);
}

/* === Prev / next === */
.sb-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--sb-border);
}
.sb-pager a {
  text-decoration: none;
  color: var(--sb-green-strong);
  font-size: 0.9rem;
  font-weight: 600;
}
.sb-pager span { color: var(--sb-text-muted); }

/* === Index landing cards === */
.sb-index-card {
  display: block;
  border: 1px solid var(--sb-border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin: 0.75rem 0;
  text-decoration: none;
  color: var(--sb-text);
  transition: border-color 150ms ease;
}
.sb-index-card:hover { border-color: var(--sb-green); }
.sb-index-card__title { font-weight: 700; color: var(--sb-heading); }
.sb-index-card__desc { color: var(--sb-text-muted); font-size: 0.9rem; margin-top: 0.2rem; }

@media (max-width: 720px) {
  .sb-hamburger { display: flex; }
  .sb-header__inner { padding: 0.75rem 1.25rem; }
  .sb-lang { display: none; } /* Hide language switcher on mobile, leave only hamburger and theme toggle */
  .sb-manual { flex-direction: column; }
  .sb-nav {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    height: calc(100vh - 60px);
    max-height: none;
    border-right: none;
    border-bottom: none;
    background: var(--sb-bg);
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 150ms ease;
    overflow-y: auto;
    flex-basis: auto;
  }
  .sb-nav--open {
    transform: translateX(0);
  }
  .sb-content { padding: 1.5rem 1.25rem; }
}
