/* ============================================================
   Navigation — desktop sidebar
   (mobile drawer is the next pass; the @media block below is
   the original behaviour, left intact for now)
   ============================================================ */

/* Sidebar width. Referenced again by toc.css, which has to pin the same value
   as a flex-basis so the rail cannot squeeze the nav — keep it a variable so
   the two cannot drift apart. */
:root {
  --nav-width: 400px;
  --page-margin: 100px;
  /* One divider colour for the layout: the sidebar's trailing edge and the two
     page-frame rules. */
  --rule-color: rgb(217, 217, 217);

  /* Selected-state pair for the sidebar, per design 2026-08-19. The previous
     #006ddf on #d6e8fb measured 3.95:1 — under the 4.5:1 AA floor for 14px
     text. This pair measures 7.02:1 (AA and AAA), and #0F45A2 on white is
     8.77:1, so the same ink is safe on both backgrounds. */
  --nav-selected-ink: #0f45a2;
  --nav-selected-fill: #dae7fa;

  /* Selected-item accent rule. Shared with the "On this page" rail in toc.css
     so the sidebar and the rail mark the current item identically — declared
     once here rather than as a literal in each file, so they cannot drift.
     4px is Procore's AnchorSection value (core 12.49.0). */
  --selected-rule-width: 4px;
}

/* Page frame — a gutter at each screen edge with the rule on its INNER edge,
   so the line sits against the content rather than out at the page boundary.
   Borders live on <body> (the flex row holding nav + article), which puts them
   exactly at the margin/content boundary and runs them the full content
   height. */
body {
  margin-left: var(--page-margin);
  margin-right: var(--page-margin);
  border-left: 1px solid var(--rule-color);
  border-right: 1px solid var(--rule-color);
}

/* Column gaps, measured from docs.stripe.com at a 1600px viewport: left nav →
   prose 113px and a 128px right margin. The nav→prose gap is the source of
   truth for column spacing — prose → TOC matches it via --toc-gap in toc.css.
   The left value carries that gap now that the content card is gone and there
   is no panel to centre. */
article {
  padding: 48px 128px 48px 113px;
}

/* ---------------- Responsive ladder ----------------
   The content column is the focal point and is protected for as long as
   possible: it is not reduced until mobile, when there is nothing left to
   spend. Everything else is sacrificed first, in this order:

     1. The page frame  — margins + rules. Genuinely wide monitors only; below
        that it is dead space, so it goes first and goes completely.
     2. The column gutters — collapsed in steps, which walks the content left
        toward the nav rather than narrowing it.
     3. The rail — the first whole column to go, once no whitespace is left.
     4. The nav — off-canvas at the mobile breakpoint, last of all.

   --toc-gap steps in lockstep with the left gutter (see toc.css) so the
   nav→prose and prose→rail gaps stay equal the whole way down. */

/* The frame earns its keep only on a genuinely wide monitor. */
@media (max-width: 2100px) {
  :root {
    --page-margin: 0px;
  }

  body {
    border-left: 0;
    border-right: 0;
  }
}

/* Whitespace next — pull the content left instead of narrowing it. */
@media (max-width: 1700px) {
  article {
    padding: 48px 64px;
  }
}

@media (max-width: 1400px) {
  article {
    padding: 48px 32px;
  }
}

/* :not(.toc) — the "On this page" rail is also a <nav>, and without this it
   inherits the sidebar's width, 100vh height, 32px/20px padding and
   right border. */
nav:not(.toc) {
  width: var(--nav-width);
  box-sizing: border-box;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: 32px 20px;
  border-right: 1px solid var(--rule-color);
  font-size: 14px;
  line-height: 1.4;
}

.trigger:hover {
  cursor: pointer;
}

/* ---------------- Search ---------------- */

#search-input {
  width: 100%;
  box-sizing: border-box;
  height: 38px;
  margin-bottom: 4px;
  padding: 0 34px 0 36px;
  border: 1px solid #acb5b9;
  border-radius: 8px;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 15px 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23232729' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  color: #232729;
  font-size: 14px;
  transition: border-color 0.15s ease;
}

#search-input::placeholder {
  color: #5e696e;
}

#search-input:focus {
  outline: none;
  border: 2px solid #006ddf;
}

.search-clear {
  position: absolute;
  top: 0;
  right: 0;
  height: 38px;
  width: 34px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: #8a9099;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.search-clear.visible {
  display: flex;
}

.search-clear:hover {
  color: #232729;
}

.search-wrap {
  position: relative;
}

#results-container {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  list-style: none;
  margin: 0;
  padding: 0;
}

#results-container:not(:empty) {
  padding: 6px;
  background-color: #fff;
  border: 1px solid #e3e6ea;
  border-radius: 10px;
  box-shadow: 0 10px 28px -8px rgba(34, 40, 42, 0.28);
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}

#results-container:not(:empty)::before {
  content: "Search Results";
  display: block;
  padding: 4px 8px 6px;
  font-size: 12px;
  font-weight: 600;
  color: #8a9099;
}

#results-container li {
  list-style: none;
}

#results-container a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: #232729;
  text-decoration: none;
}

#results-container a:hover {
  background-color: #f4f5f6;
  text-decoration: none;
}

#results-container .no-results {
  list-style: none;
  padding: 6px 10px 8px;
  color: #6b7280;
  font-size: 14px;
  font-style: italic;
}

/* ---------------- Section triggers ---------------- */

nav dl {
  margin: 0;
}

dl.collapsible {
  margin-bottom: 2px;
}

nav dt {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
  color: #232729;
  transition: background-color 0.12s ease, color 0.12s ease;
}

nav dt:hover {
  background-color: #e6e8eb;
}

nav dt.active {
  color: var(--nav-selected-ink);
}

nav dt .icon {
  flex: 0 0 auto;
  font-size: 13px;
  color: #232729;
  transition: transform 0.2s ease, color 0.12s ease;
}

nav dt .icon.open {
  transform: rotate(90deg);
}

nav dt.active .icon {
  color: var(--nav-selected-ink);
}

/* ---------------- Section items ---------------- */

dl.col_content {
  margin: 2px 0 6px;
  padding-left: 11px;
}

nav dd {
  margin: 0;
  padding: 0;
  /* Transparent rather than removed: the expanded-section rail is gone, but the
     width is still reserved so items don't shift horizontally, and the current
     page keeps its accent via `nav dd.active` below. */
  border-left: var(--selected-rule-width) solid transparent;
}

nav dd a {
  display: block;
  padding: 7px 14px;
  /* Same black as the section titles (nav dt) so both levels of the sidebar
     read at the same colour weight. */
  color: #232729;
  text-decoration: none;
  border-radius: 0 6px 6px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.12s ease, color 0.12s ease;
}

nav dd a:hover {
  background-color: #e6e8eb;
  color: #232729;
}

nav dd.active {
  border-left-color: var(--nav-selected-ink);
}

nav dd.active a {
  color: var(--nav-selected-ink);
  background-color: var(--nav-selected-fill);
  font-weight: 500;
}

/* ============================================================
   Mobile — UNCHANGED (rebuild is the next pass)
   ============================================================ */

/* Menu button — a dark text pill (mobile only) */
.hamburger {
  display: none;
  position: static;
  padding: 10px 18px;
  border: none;
  border-radius: 4px;
  background: #232729;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.hamburger:hover {
  background: #3a3f43;
}

/* hideNav() strips the desktop gutters for the embedded view. Those gutters
   used to be optional because the white content card supplied its own inset
   against the grey page; now that the page is a single white surface, zeroing
   the padding would run body text flush into the iframe edge. Keep a modest
   symmetric inset instead — the host page supplies the outer chrome. */
article.no-padding {
  padding: 24px 48px;
}

section.full-width {
  max-width: 100%;
  min-width: 100%;
  width: 100%;
}

/* Drawer chrome — hidden on desktop, shown at the mobile breakpoint */
.nav-backdrop {
  display: none;
}

.nav-close {
  display: none;
}

.nav-close:hover {
  color: #232729;
}

html.nav-locked {
  overflow: hidden;
}

@media only screen and (max-width: 1100px) {
  .hamburger {
    display: inline-flex;
    align-items: center;
    margin-bottom: 20px;
  }

  /* Stack the Browse Docs button above the title, left-aligned with it */
  article h1 {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
  }

  article {
    padding: 0;
  }

  /* The page frame costs 200px of width — too much once the nav is a drawer. */
  body {
    margin-left: 0;
    margin-right: 0;
    border-left: 0;
    border-right: 0;
  }

  /* Mobile: cancel the desktop page-centering offset — content is full-width in the drawer layout */
  article section {
    margin-left: 0;
  }

  /* Nav becomes a left slide-in drawer */
  nav:not(.toc) {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 82vw);
    height: 100%;
    z-index: 1200;
    padding: 20px;
    background-color: #ffffff;
    border-right: none;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
  }

  nav.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.18);
  }

  .nav-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: -4px -4px 8px auto;
    padding: 0;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1150;
    background-color: rgba(20, 24, 28, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
  }

  .nav-backdrop.open {
    opacity: 1;
    visibility: visible;
  }
}
