* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Rethemed onto the Thruline foundation. thruline.css loads first and owns
     the real palette: --color-bg/-bg-soft/-surface, --color-text/-secondary/
     -muted, --color-border, --font-body/-mono, radii, shadows, and the
     light/dark flip via [data-theme]. The aliases below remap the old docs
     tokens onto Thruline brand tokens, so every existing docs rule re-themes
     without being touched. */
  --font-fira: var(--font-body);   /* headings/UI → Switzer */
  --font-noto: var(--font-body);   /* body copy → Switzer */

  --color-primary: var(--color-accent);        /* links / accents → blue-grey */
  --color-primary-alt: var(--color-accent-hover);
  --color-red: var(--color-cta);               /* emphasis / callouts → terracotta */
  --color-red-dark: var(--color-cta-hover);
  --color-red-deep: var(--color-cta-hover);

  --color-light: var(--color-bg-soft);
  --color-dark: var(--color-text);
  --color-white: var(--color-surface);         /* elevated surface */
  --color-off-white: var(--color-bg);          /* page canvas */

  --color-border-solid: var(--color-border-strong);
}

body {
  font-family: var(--font-fira);
  background: rgb(255, 253, 248);
  color: var(--color-text);
  min-height: 100vh;
}
/* The light-mode canvas above is a hardcoded cream (= --color-surface in light).
   Dark mode flips it to the surface token so the body matches the topbar/sidebar/
   content (all --color-surface, #16292e in dark) instead of staying near-white. */
:root[data-theme="dark"] body { background: var(--color-surface); }

a { color: var(--color-red); text-decoration: none; }
a:hover { color: var(--color-primary-alt); text-decoration: underline; }

/* Top bar */
.docs-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4rem;
  margin: 0 auto;
  height: 64px;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  max-width: 1280px;
}

.docs-brand {
  display: flex;
  font-size: 1rem;
  align-items: center;
  gap: 8px;
  color: var(--color-dark);
  text-decoration: none;
  font-family: var(--font-fira);
}

.docs-brand strong {
  line-height: 25.6px;
  letter-spacing: -.32px;
}

.docs-brand img {
  width: 45px;
  /* height: 45px; */
}
.docs-brand:hover { color: var(--color-dark); text-decoration: none; }

.docs-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary);
  background: rgba(41, 88, 130, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.docs-topbar-right {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: auto;
}

.docs-topbar-links {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 0.85rem;
}

.docs-topbar-links a { color: var(--color-text-secondary); }
.docs-topbar-links a:hover { color: var(--color-primary); text-decoration: none; }

/* Search */
.docs-search {
  position: relative;
  width: 200px;
  height: 38px;
  flex-shrink: 0;
}

.docs-search-input {
  position: absolute;
  top: 0;
  right: 0;
  width: 200px;
  height: 38px;
  padding: 0 14px 0 34px;
  font-family: var(--font-noto);
  font-size: 0.85rem;
  color: var(--color-text);
  /* Magnifier icon anchored to the input's left edge so it stays put as the
     input expands (a background image tracks the input, not the topbar slot). */
  background-color: var(--color-bg-soft);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%238E9196' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='6'/%3E%3Cline x1='14' y1='14' x2='18' y2='18'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 16px;
  border: 1px solid var(--color-border-solid);
  border-radius: var(--radius-sm);
  outline: none;
  transition: width 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.docs-search-input::placeholder { color: var(--color-text-muted); }
.docs-search-input:focus {
  width: 380px;
  background-color: var(--color-white);
  border-color: var(--color-primary-alt);
  box-shadow: 0 0 0 3px rgba(81, 154, 205, 0.15), var(--shadow-md);
}

.docs-search-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--color-white);
  border: 1px solid var(--color-border-solid);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 200;
}
.docs-search-panel[hidden] { display: none; }

.docs-search-results { list-style: none; margin: 0; padding: 0; }

.docs-search-result {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
}
.docs-search-result:hover,
.docs-search-result.active {
  background: var(--color-bg-soft);
  text-decoration: none;
}

.docs-search-result-title {
  display: block;
  font-family: var(--font-fira);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
}

.docs-search-result-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-family: var(--font-noto);
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--color-text-secondary);
}

.docs-search-result mark {
  background: rgba(255, 74, 55, 0.18);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.docs-search-hint,
.docs-search-empty {
  margin: 0;
  padding: 12px;
  font-family: var(--font-noto);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.docs-search-hint[hidden],
.docs-search-empty[hidden] { display: none; }

.docs-nav-toggle {
  display: none;
  margin-left: auto;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-dark);
  background: var(--color-white);
  border: 1px solid var(--color-border-solid);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
}

.docs-nav-toggle-chevron {
  display: inline-block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 4px 0 4px;
  border-color: var(--color-dark) transparent transparent transparent;
  transition: transform 0.15s ease;
}
.docs-nav-toggle[aria-expanded="true"] .docs-nav-toggle-chevron { transform: rotate(180deg); }

/* Layout */
.docs-layout {
  display: flex;
  min-height: calc(100vh - 64px);
  max-width: 1280px;
  margin: 0 auto;
}

/* Sidebar */
.docs-sidebar {
  width: 260px;
  flex-shrink: 0;
  padding: 32px 20px;
  background: var(--color-white);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
}

.docs-nav-section { margin-bottom: 24px; }

.docs-nav-section h4 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  padding-left: 12px;
}

.docs-nav-section a {
  display: block;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.docs-nav-section a:hover {
  background: var(--color-bg-soft);
  color: var(--color-primary);
  text-decoration: none;
}

.docs-nav-section a.active {
  background: rgba(41, 88, 130, 0.08);
  color: var(--color-primary);
  font-weight: 700;
}

/* Content */
.docs-content {
  flex: 1;
  /* Flex items default to min-width:auto, so a <pre> with a long unbroken line
     forces this column wider than its share and pushes past .docs-layout. min-
     width:0 lets it shrink to its flex basis so the pre's own overflow-x scrolls
     instead of the whole page widening. */
  min-width: 0;
  padding: 48px 60px;
  background-color: var(--color-white);
}

.docs-content h1 {
  font-family: var(--font-display);   /* League Spartan */
  text-transform: uppercase;
  font-size: clamp(2rem, 4vw, 2.625rem);   /* ~42px */
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin-bottom: 8px;
  color: var(--color-text);
}

.docs-content .docs-subtitle {
  font-family: var(--font-noto);
  font-size: 1.0625rem;
  color: var(--color-text-secondary);
  margin-bottom: 32px;
  line-height: 1.7;
}

.docs-content h2 {
  font-family: var(--font-body);   /* Switzer Bold */
  font-size: 1.75rem;              /* 28px */
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 40px;
  margin-bottom: 12px;
  color: var(--color-text);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border-solid);
}

.docs-content h3 {
  font-family: var(--font-body);   /* Switzer Medium */
  font-size: 1.25rem;
  font-weight: 500;
  margin-top: 28px;
  margin-bottom: 8px;
  color: var(--color-text);
}

/* Brand emblem in the topbar: swap light/dark variant with the theme. */
.brand-emblem-dark { display: none; }
:root[data-theme="dark"] .brand-emblem-light { display: none; }
:root[data-theme="dark"] .brand-emblem-dark { display: inline-block; }

.docs-content p {
  font-family: var(--font-noto);
  line-height: 1.7;
  margin-bottom: 16px;
  color: var(--color-text-secondary);
}

.docs-content ul, .docs-content ol {
  font-family: var(--font-noto);
  margin: 0 0 16px 24px;
  line-height: 1.7;
  color: var(--color-text-secondary);
}

.docs-content li { margin-bottom: 6px; }
.docs-content strong { color: var(--color-text); }

.docs-content table {
  /* `display: block` + overflow keeps a wide table scrolling inside the article
     rather than widening the whole page on a phone. */
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-family: var(--font-noto);
  font-size: 0.9rem;
}

.docs-content th {
  text-align: left;
  border: 1px solid var(--color-border-solid);
  padding: 8px 12px;
  background: var(--color-bg-soft);
  color: var(--color-text);
}

.docs-content td {
  border: 1px solid var(--color-border-solid);
  padding: 8px 12px;
  color: var(--color-text-secondary);
  vertical-align: top;
}

.docs-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-bg-soft);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--color-red-deep);
}

.docs-content pre {
  background: var(--color-dark);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  max-width: 100%;      /* pin to the column; the scroll lives inside the block */
  overflow-x: auto;
  margin-bottom: 20px;
}

.docs-content pre code {
  background: none;
  padding: 0;
  color: var(--color-light);
  font-size: 0.85rem;
  line-height: 1.6;
}

.docs-callout {
  background: var(--color-bg-soft);
  border-left: 4px solid var(--color-red);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.docs-callout p { color: var(--color-text); margin-bottom: 0; }
.docs-callout p + p { margin-top: 8px; }
.docs-callout strong { color: var(--color-red-dark); }

/* Dark-mode contrast: inline code and callout emphasis stay terracotta (not the
   gold that --color-cta became) — a fixed #e0704f reaches ~5:1 on the dark code
   surface, vs 4.11:1 for the deeper #d65a3b. Light mode is unchanged. */
:root[data-theme="dark"] .docs-content code,
:root[data-theme="dark"] .docs-callout strong { color: #e0704f; }

.docs-step {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.docs-step-number {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary);
  color: var(--color-white);
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 50%;
  margin-top: 2px;
}

/* Take the space beside the step number and — crucially — min-width:0 so a wide
   <pre> scrolls inside the step instead of stretching it past the column. Without
   this the step content defaults to min-width:auto and overflows to the right. */
.docs-step-content { flex: 1; min-width: 0; }
.docs-step-content h3 { margin-top: 0; }
.docs-step-content pre { max-width: 100%; }

/* Mobile dropdown nav */
/* The sidebar-drawer theme toggle is desktop-hidden (the topbar .docs-theme-toggle
   shows there); the mobile block below swaps them at the drawer breakpoint. */
.docs-sidebar-toggle { display: none; }

@media (max-width: 770px) {
  .docs-topbar { padding: 0 16px; height: 56px; }
  .docs-topbar-links { display: none; }

  /* Mobile topbar order: [emblem] Thruline — space — [Menu] [search]. The theme
     toggle moves out of the topbar and into the sidebar drawer (see below), so
     the Menu button carries the `margin-left:auto` gap and search stays rightmost.
     The search input is right-anchored so its focus-expand grows LEFT into the gap. */
  .docs-nav-toggle { display: inline-flex; order: 1; margin-left: auto; }
  .docs-theme-toggle { display: none; }
  .docs-topbar-right { order: 3; margin-left: 0; }

  /* Theme toggle at the top-right of the open sidebar drawer. */
  .docs-sidebar-toggle { display: flex; justify-content: flex-end; margin-bottom: 12px; }

  /* Collapse the search to an icon that grows on focus so it fits the topbar.
     z-index lifts the expanded input above the Menu/theme controls it slides over. */
  .docs-search { width: 40px; z-index: 10; }
  .docs-search-input { width: 40px; padding: 0 8px 0 32px; }
  .docs-search-input:focus { width: min(76vw, 320px); }
  .docs-search-panel { width: min(84vw, 340px); }

  .docs-layout { flex-direction: column; max-width: 100%; }

  .docs-sidebar {
    display: none;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 56px);
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    z-index: 99;
    padding: 20px;
  }

  .docs-sidebar.open { display: block; }

  .docs-content { padding: 28px 20px; max-width: 100%; }
}

/* ----- Phone ----- */
@media (max-width: 560px) {
  .docs-topbar { gap: 8px; padding: 0 12px; }
  .docs-brand { font-size: 0.95rem; gap: 6px; }
  .docs-brand img { width: 36px; }
  .docs-badge { display: none; }          /* the wordmark already says where you are */
  .docs-content { padding: 22px 14px; }
  .docs-content h1 { font-size: 1.875rem; margin-top: .45rem; }
  .docs-content h2 { font-size: 1.35rem; }
  .docs-content pre { padding: 12px 14px; }
  /* 16px inputs stop iOS from zooming the page on focus. */
  .docs-search-input { font-size: 16px; }
}
