/* ==========================================================================
   BugCatch — documentation
   Loaded after styles.css by the five docs-*.html pages. Tokens all come from
   there; nothing is redefined here. Layout only, plus the three things prose
   pages need and the marketing page never did: code blocks, numbered steps and
   parameter tables.

   Responsive rules live at the bottom, after everything they override.
   ========================================================================== */

/* ------------------------------ HERO ------------------------------ */

.docs-hero {
  position: relative;
  padding: 62px 0 34px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  overflow: hidden;
}
.docs-hero::before {
  content: ''; position: absolute; inset: -40% 30% auto -10%; height: 420px;
  background: radial-gradient(closest-side, rgba(124, 108, 255, 0.16), transparent);
  pointer-events: none;
}
.docs-hero-in { position: relative; z-index: 2; }
.docs-hero .h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
.docs-hero .sub { max-width: 660px; margin-top: 14px; color: var(--ink-dim); }

/* Breadcrumb. A docs page reached from a search result has to say where it
   sits before it says anything else. */
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.84rem; color: var(--ink-faint); margin-bottom: 14px; }
.crumbs a { color: var(--ink-faint); }
.crumbs a:hover { color: var(--accent-2); }
/* --line-bright is a border colour and lands at 1.85:1 here, which is a
   separator nobody can see. --ink-faint is the dimmest ink that still clears
   AA on this background. */
.crumbs span[aria-hidden] { color: var(--ink-faint); }

.docs-meta {
  display: flex; flex-wrap: wrap; gap: 8px 22px;
  margin-top: 22px; font-size: 0.85rem; color: var(--ink-faint);
}
.docs-meta b { color: var(--ink-dim); font-weight: 560; }

/* ------------------------------ SHELL ------------------------------ */

.docs-body {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 54px;
  padding-top: 44px;
  padding-bottom: 90px;
  align-items: start;
}

.docs-nav { position: sticky; top: 92px; max-height: calc(100vh - 112px); overflow-y: auto; }
.docs-nav h2 {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--ink-faint); font-weight: 620; margin: 0 0 10px;
}
.docs-nav h2 + ul { margin-bottom: 26px; }
.docs-nav a {
  display: block; padding: 5px 0 5px 12px; font-size: 0.88rem; color: var(--ink-faint);
  border-left: 2px solid var(--line); line-height: 1.45;
}
.docs-nav a:hover { color: var(--ink); border-left-color: var(--line-bright); }
.docs-nav a[aria-current="page"] {
  color: var(--accent-2); border-left-color: var(--accent); font-weight: 560;
}
/* The current page's own sections, nested under it. */
.docs-nav .sub-list { margin: 2px 0 4px; }
.docs-nav .sub-list a { padding-left: 24px; font-size: 0.85rem; }

/* ------------------------------ ARTICLE ------------------------------ */

.docs-main { min-width: 0; max-width: 78ch; }
.docs-main > section { scroll-margin-top: 92px; }
.docs-main > section + section { margin-top: 52px; padding-top: 6px; }

.docs-main h2 {
  font-size: 1.32rem; margin: 0 0 14px; color: var(--ink);
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.docs-main h3 { font-size: 1.02rem; margin: 30px 0 10px; color: var(--ink); }
.docs-main h4 { font-size: 0.92rem; margin: 22px 0 8px; color: var(--ink-dim); font-weight: 620; }
.docs-main p, .docs-main li { color: var(--ink-dim); font-size: 0.96rem; text-wrap: pretty; }
.docs-main p + p { margin-top: 13px; }
.docs-main a:not(.btn):not(.card-link) {
  color: var(--accent-2); text-decoration: underline; text-underline-offset: 3px;
}
.docs-main strong { color: var(--ink); font-weight: 600; }
.docs-main ul, .docs-main ol { margin: 13px 0; padding-left: 24px; }
.docs-main ul { list-style: disc; }
.docs-main ol { list-style: decimal; }
.docs-main li { margin: 7px 0; padding-left: 4px; }
.docs-main li::marker { color: var(--line-bright); }

/* Inline code. Not `.mono`, which is only a font swap — this needs a chip so a
   value inside a sentence reads as a value. */
.docs-main :not(pre) > code {
  font-family: var(--mono); font-size: 0.85em;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; color: var(--ink);
  overflow-wrap: break-word;
}

/* ------------------------------ CODE BLOCKS ------------------------------ */

.code {
  margin: 18px 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-2); overflow: hidden;
}
.code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.code-head span {
  font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint);
  letter-spacing: 0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Injected by script.js, so a page with no JS shows no button rather than a
   dead one. */
.code-copy {
  flex: none; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink-dim); font: inherit; font-size: 0.72rem; font-weight: 560;
  padding: 3px 10px; border-radius: 6px; cursor: pointer;
}
.code-copy:hover { color: var(--ink); border-color: var(--line-bright); }
.code-copy.done { color: var(--sev-low); border-color: rgba(89, 212, 153, 0.4); }

.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code code {
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.75;
  color: var(--ink-dim); white-space: pre;
}
/* The three things worth colouring in a snippet, marked up by hand — there is
   no highlighter on this site and a 40 kB one for six pages is not a trade
   worth making. */
.code .tk-c { color: var(--ink-faint); font-style: italic; }   /* comment */
.code .tk-s { color: var(--sev-low); }                          /* string */
.code .tk-k { color: var(--accent-2); }                         /* keyword */
.code .tk-v { color: var(--sev-medium); }                       /* value you replace */

/* ------------------------------ STEPS ------------------------------ */

.docs-steps { margin: 20px 0; padding: 0; list-style: none; counter-reset: step; }
.docs-steps > li {
  position: relative; margin: 0; padding: 0 0 26px 44px;
  border-left: 1px solid var(--line); counter-increment: step;
}
.docs-steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.docs-steps > li::before {
  content: counter(step);
  position: absolute; left: -14px; top: -3px;
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line-bright);
  color: var(--ink); font-size: 0.78rem; font-weight: 620;
  display: flex; align-items: center; justify-content: center;
}
.docs-steps > li > h3, .docs-steps > li > h3:first-child { margin-top: 0; margin-bottom: 8px; }
.docs-steps ul, .docs-steps ol { margin: 10px 0; }

/* ------------------------------ CALLOUTS ------------------------------ */

.callout {
  margin: 20px 0; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  border-left: 3px solid var(--line-bright);
}
.callout p { font-size: 0.92rem; }
.callout p + p { margin-top: 10px; }
.callout b:first-child { color: var(--ink); }
.callout-tip { border-left-color: var(--accent); background: rgba(124, 108, 255, 0.07); }
.callout-warn { border-left-color: var(--sev-high); background: rgba(255, 159, 67, 0.07); }
.callout-stop { border-left-color: var(--sev-critical); background: rgba(255, 84, 112, 0.07); }

/* ------------------------------ TABLES ------------------------------ */

.docs-table {
  overflow-x: auto; margin: 18px 0;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.docs-table table { width: 100%; border-collapse: collapse; min-width: 520px; font-size: 0.88rem; }
.docs-table th, .docs-table td {
  text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top;
}
.docs-table th { background: var(--surface); color: var(--ink); font-weight: 580; white-space: nowrap; }
.docs-table tbody tr:last-child td { border-bottom: 0; }
.docs-table td { color: var(--ink-dim); }
.docs-table code {
  font-family: var(--mono); font-size: 0.84em; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
}
.docs-table .req { color: var(--sev-high); font-size: 0.78rem; font-weight: 600; }

/* ------------------------------ TABS ------------------------------ */

/* Native radios in a fieldset, like the pricing toggle: the panels switch from
   arrow keys alone and the first one is visible with no JavaScript at all. */
.tabs {
  position: relative;   /* contains the visually-hidden radios */
  margin: 20px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2);
}
/* min-inline-size, not just min-width: a fieldset's default is min-content,
   which the <pre> inside makes enormous — so without this the whole tab block
   refuses to shrink and the page scrolls sideways on a phone. */
.tabs fieldset { border: 0; margin: 0; padding: 0; min-inline-size: 0; min-width: 0; }
.tabs legend {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; white-space: nowrap; border: 0; clip-path: inset(50%);
}
.tab-strip { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--surface); }
/* Hidden, but still real radios: the panel switching below is driven entirely
   by :checked, so the tabs work from the arrow keys and without JavaScript. */
.tabs input { position: absolute; top: 0; left: 0; opacity: 0; pointer-events: none; }
.tab-strip label {
  padding: 6px 13px; border-radius: 7px; font-size: 0.84rem; font-weight: 560;
  color: var(--ink-faint); cursor: pointer; white-space: nowrap;
}
.tab-strip label:hover { color: var(--ink); }
/* The radios are siblings of .tab-strip, not children of it, so the active and
   focused states are reached through the strip and matched on a shared class. */
.tabs input.t1:checked ~ .tab-strip label.t1,
.tabs input.t2:checked ~ .tab-strip label.t2,
.tabs input.t3:checked ~ .tab-strip label.t3,
.tabs input.t4:checked ~ .tab-strip label.t4,
.tabs input.t5:checked ~ .tab-strip label.t5,
.tabs input.t6:checked ~ .tab-strip label.t6 {
  background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-bright);
}
.tabs input.t1:focus-visible ~ .tab-strip label.t1,
.tabs input.t2:focus-visible ~ .tab-strip label.t2,
.tabs input.t3:focus-visible ~ .tab-strip label.t3,
.tabs input.t4:focus-visible ~ .tab-strip label.t4,
.tabs input.t5:focus-visible ~ .tab-strip label.t5,
.tabs input.t6:focus-visible ~ .tab-strip label.t6 {
  outline: 2px solid var(--accent-2); outline-offset: 2px;
}
.tab-panel { display: none; }
.tab-panel .code { margin: 0; border: 0; border-radius: 0; background: transparent; }
.tab-panel > p:first-child { padding: 14px 16px 0; font-size: 0.92rem; }
/* Each panel is shown by its own rule; a shared one would need :has(). */
.tabs input.t1:checked ~ .tab-panels > .tab-panel:nth-child(1),
.tabs input.t2:checked ~ .tab-panels > .tab-panel:nth-child(2),
.tabs input.t3:checked ~ .tab-panels > .tab-panel:nth-child(3),
.tabs input.t4:checked ~ .tab-panels > .tab-panel:nth-child(4),
.tabs input.t5:checked ~ .tab-panels > .tab-panel:nth-child(5),
.tabs input.t6:checked ~ .tab-panels > .tab-panel:nth-child(6) { display: block; }

/* ------------------------------ PATH CARDS ------------------------------ */

.paths { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 22px 0; }
.path {
  display: block; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); transition: border-color 0.18s, transform 0.18s;
}
.path:hover { border-color: var(--accent); transform: translateY(-2px); }
.path h3 { margin: 0 0 6px; font-size: 1rem; color: var(--ink); }
.path p { font-size: 0.89rem; color: var(--ink-dim); margin: 0; }
.path .path-who { display: block; margin-top: 10px; font-size: 0.78rem; color: var(--ink-faint); }
.path .path-icon { color: var(--accent-2); font-size: 1.25rem; margin-bottom: 10px; }

/* ------------------------------ CHECKLIST ------------------------------ */

.docs-check { margin: 18px 0; padding: 0; list-style: none; }
.docs-check li { position: relative; padding-left: 28px; margin: 9px 0; font-size: 0.94rem; }
.docs-check li::before {
  content: ''; position: absolute; left: 4px; top: 7px;
  width: 11px; height: 6px; border-left: 2px solid var(--sev-low); border-bottom: 2px solid var(--sev-low);
  transform: rotate(-45deg);
}

/* ------------------------------ NEXT / PREV ------------------------------ */

.docs-next {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
  margin-top: 56px; padding-top: 30px; border-top: 1px solid var(--line);
}
.docs-next a {
  display: block; padding: 15px 17px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
}
.docs-next a:hover { border-color: var(--accent); }
.docs-next b { display: block; color: var(--ink); font-size: 0.95rem; font-weight: 600; }
.docs-next span { display: block; font-size: 0.78rem; color: var(--ink-faint); margin-bottom: 4px; }
.docs-next .prev { text-align: left; }
.docs-next .next { text-align: right; }

.docs-help {
  margin-top: 40px; padding: 20px 22px; border: 1px solid var(--line);
  border-radius: var(--radius-lg); background: var(--surface);
}
.docs-help h2 { border: 0; padding: 0; margin-bottom: 8px; font-size: 1.05rem; }
.docs-help dl { margin: 12px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 0.92rem; }
.docs-help dt { color: var(--ink-faint); }
.docs-help dd { margin: 0; color: var(--ink-dim); }

/* ------------------------------ RESPONSIVE ------------------------------ */
/* Last, so these win the cascade against everything above. */

@media (max-width: 1000px) {
  .docs-body { grid-template-columns: 1fr; gap: 30px; }
  /* A sticky sidebar that has become a block at the top of the page would
     pin a list of every docs page over the content the reader came for. */
  .docs-nav {
    position: static; max-height: none; overflow: visible;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); padding: 16px 18px;
  }
  .docs-nav h2 + ul { margin-bottom: 18px; }
  .docs-nav .sub-list { display: none; }
  .docs-main { max-width: none; }
}

@media (max-width: 720px) {
  .docs-hero { padding: 44px 0 28px; }
  .paths, .docs-next { grid-template-columns: 1fr; }
  .docs-next .next { text-align: left; }
  .docs-help dl { grid-template-columns: 1fr; gap: 2px 0; }
  .docs-help dd { margin-bottom: 10px; }
  .code code { font-size: 0.75rem; }
  .docs-steps > li { padding-left: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .path { transition: none; }
  .path:hover { transform: none; }
}

/* Set by script.js as the reader scrolls. Placed after the responsive block on
   purpose: at ≤1000px the sub-list is display:none and this must not resurrect
   it, which it cannot — it only sets colour. */
.docs-nav .sub-list a.is-current { color: var(--ink); border-left-color: var(--line-bright); }
