/* The Watership family chrome on Furo. watership-tokens.css loads first: it holds the fonts, the color
   tokens for both themes, and the shared header, footer, menu, and pill classes. This file fits Furo's own
   markup to them. Furo's variables are mapped to the tokens in conf.py. */

/* ---------- Page ---------- */
html { scroll-padding-top: calc(var(--ws-header-h) + 16px); scrollbar-gutter: stable; }
/* Furo sets html and body to height: 100%, so body is one window tall and the sticky header, a child of body,
   would scroll away after the first screen. The body grows with its content instead, and the header stays at
   the top of the window all the way down the page. */
html, body { height: auto; }
body { min-height: 100%; }
/* The page behind an open drawer doesn't scroll (sg-ui.js sets the class while a drawer is open). */
html.sg-drawer-open { overflow: hidden; }
/* The scroll padding keeps focused page content clear of the header, but a control inside the sticky header
   is always in view: without this, focusing Menu or search would scroll the page up by the header's height. */
.ws-header, .ws-header * { scroll-margin-top: calc(-1 * (var(--ws-header-h) + 16px)); }
.sidebar-scroll, .toc-scroll { overscroll-behavior: contain; }
/* The wide-screen search field sits at the top of the sticky sidebar, inside the scroll padding's zone, so
   focusing it, and the caret moving as the reader types, would scroll the page up. While it has focus the
   padding is off (no in-page target needs it then), and the field's own margin cancels the padding as the
   header's controls do. */
html:has(.sidebar-search:focus) { scroll-padding-top: 0; }
.sidebar-search-container, .sidebar-search-container * { scroll-margin-top: calc(-1 * (var(--ws-header-h) + 16px)); }
/* Furo enlarges the root to 110% from 97em (1552px), which would push every rem size up 10% on wide screens.
   The family keeps a 16px root at every width. */
@media (min-width: 97em) { html { font-size: 100%; } }
/* Furo's sizes all come from these variables; each one names a step of the family type scale. */
body {
  --header-height: var(--ws-header-h);
  --font-size--normal: var(--ws-text-base);
  --font-size--small: var(--ws-text-md);
  --font-size--small--2: var(--ws-text-sm);
  --font-size--small--3: var(--ws-text-sm);
  --font-size--small--4: var(--ws-text-sm);
  --sidebar-item-font-size: var(--ws-text-sm);
  --sidebar-item-line-height: var(--ws-leading-ui);
  --sidebar-caption-font-size: var(--ws-text-sm);
  --sidebar-search-input-font-size: var(--ws-text-base);
  --toc-font-size: var(--ws-text-sm);
  --toc-title-font-size: var(--ws-text-sm);
  --admonition-font-size: var(--ws-text-base);
  --admonition-title-font-size: var(--ws-text-sm);
  --code-font-size: var(--ws-text-sm);
  background: var(--ws-paper);
  font-feature-settings: "kern", "liga";
}
/* The padding on html already clears the header, so Furo's own margins on targets would double it. */
:target, section > span:target { scroll-margin-top: 0; }
.page { min-height: 0; }
:focus-visible { outline: 2px solid var(--ws-accent); outline-offset: 2px; }

/* The skip link comes first, before the header, and takes the family's .ws-skip look from the tokens file;
   Furo's own (after the header) is hidden. */
.ws-header ~ .skip-to-content { display: none; }

/* ---------- Header (design spec 4 and 5) ---------- */
/* Furo's phone header is replaced by the shared header at every width. */
.mobile-header { display: none !important; }
.content-icon-container { display: none; }
.sg-header .ws-header__nav { gap: 4px; }
/* Furo sizes every image by its width; the wordmark is sized by its height. */
.ws-brand__home img, .ws-footer__lead img { width: auto; max-width: none; height: 20px; }
@media (max-width: 480px) { .ws-brand__home img { height: 18px; } }
.sg-header .ws-menu > summary { gap: 6px; }
.sg-chevron { color: var(--ws-faint); }
.ws-menu[open] .sg-chevron { transform: rotate(180deg); }
.sg-menu-short { display: none; }
@media (max-width: 1100px) { .sg-menu-long { display: none; } .sg-menu-short { display: inline; } }
.sg-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--ws-radius); background: transparent; color: var(--ws-soft); cursor: pointer; }
.sg-iconbtn:hover { background: var(--ws-wash); color: var(--ws-ink); }
/* One header icon set across the family: 18px outline icons, 1.75 stroke, round caps (the theme toggle's style). */
.sg-iconbtn svg { width: 18px; height: 18px; color: inherit; }
.sg-icon-close { display: none; }
.sg-nav-toggle[aria-expanded="true"] .sg-icon-menu { display: none; }
.sg-nav-toggle[aria-expanded="true"] .sg-icon-close { display: block; }
/* The day/night button is a full 44px target (the 360px rule below narrows it with the other icons). */
.sg-header .theme-toggle { display: inline-flex; width: var(--ws-target); height: var(--ws-target); }
.sg-search-toggle, .sg-toc-toggle, .sg-nav-toggle { display: none; }
.sg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 82em) { .sg-toc-toggle { display: inline-flex; } }
/* The family's phone header: the brand at the left, then search, the theme button, and Menu at the right edge.
   Under Furo's phone breakpoint the Content Model menu and rules.json move to the drawer, and "On this page" moves
   to the bar under the header. */
@media (max-width: 63em) {
  .sg-search-toggle, .sg-nav-toggle { display: inline-flex; }
  .sg-toc-toggle, .sg-wide { display: none; }
}
/* The full site name and the divider show on the narrowest phones: the gaps between the brand, the name, and
   the icon buttons close up, so nothing in the header is cut off or needs an ellipsis down to 320px. */
@media (max-width: 400px) {
  .sg-header .ws-header__inner { gap: 6px; }
  .sg-header .ws-brand__site { flex-shrink: 0; overflow: visible; }
  .sg-header .ws-header__nav { gap: 0; }
}
/* At 320 the gutter stays 16px; the buttons narrow and the brand's gaps close, so at least 8px separates the
   site name from the search icon. */
@media (max-width: 360px) {
  .sg-header .sg-iconbtn { width: 32px; }
  .sg-header .ws-brand { gap: 6px; }
  .sg-header .ws-brand__home img { height: 17px; }
}

/* "On this page" on phones, in the UX writing look: a bar pinned under the header with a bordered chip ("On this
   page" and a right chevron), then the current section in ink. The whole bar is the button, so its name starts
   with "On this page". Page targets clear both bars, and the bar's own button doesn't scroll the page when focused. */
.sg-subnav { display: none; }
@media (max-width: 63em) {
  .sg-subnav { position: sticky; top: var(--ws-header-h); z-index: 15; display: flex; align-items: center; min-height: 48px; padding: 0 16px; border-bottom: 1px solid var(--ws-rule); background: var(--ws-header-bg); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); }
  html:has(.sg-subnav) { scroll-padding-top: calc(var(--ws-header-h) + 48px + 16px); }
  html:has(.sg-subnav) :is(.ws-header, .ws-header *, .sg-subnav, .sg-subnav *) { scroll-margin-top: calc(-1 * (var(--ws-header-h) + 48px + 16px)); }
  html:has(.sg-subnav) .back-to-top { top: calc(var(--ws-header-h) + 48px + .5rem); }
}
.sg-subnav__button { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; min-height: 44px; padding: 0; border: 0; border-radius: var(--ws-radius); background: transparent; color: var(--ws-ink); font: var(--ws-type-ui); text-align: left; cursor: pointer; }
.sg-subnav__chip { display: inline-flex; flex: none; align-items: center; gap: 16px; padding: 8px 8px 8px 12px; border: 1px solid var(--ws-rule); border-radius: 8px; background: var(--ws-paper); color: var(--ws-body); font: var(--ws-type-label); }
.sg-subnav__button:hover .sg-subnav__chip { background: var(--ws-wash); color: var(--ws-ink); }
.sg-subnav__chip svg { width: 16px; height: 16px; flex: none; }
.sg-subnav__button[aria-expanded="true"] .sg-subnav__chip svg { transform: rotate(90deg); }
.sg-subnav__current { min-width: 0; overflow: hidden; color: var(--ws-ink); font: var(--ws-type-ui); white-space: nowrap; text-overflow: ellipsis; }

/* The sticky panels and the drawers sit under the header. */
.sidebar-sticky, .toc-sticky { top: var(--ws-header-h); height: calc(100vh - var(--ws-header-h)); }
.back-to-top { top: calc(var(--ws-header-h) + .5rem); font-family: var(--ws-font-ui); font-size: var(--ws-text-sm); }
@media (max-width: 82em) {
  .toc-drawer { top: var(--ws-header-h); height: calc(100vh - var(--ws-header-h)); background: var(--ws-paper); border-left: 1px solid var(--ws-rule); }
}
/* The phone menu, as on the other family sites: the navigation drawer opens under the header at full width,
   with no slide, and "Menu" stays live in the header as its close button. */
@media (max-width: 63em) {
  .sidebar-drawer { top: var(--ws-header-h); left: 0; width: 100%; height: calc(100vh - var(--ws-header-h)); height: calc(100dvh - var(--ws-header-h)); border-right: 0; transition: none; }
  .sidebar-container { width: 100%; }
  .sidebar-sticky { top: 0; height: 100%; }
  .sidebar-overlay { display: none; }
  /* Room under the last link, so it and its focus ring show in full when it's scrolled into view. */
  .sidebar-scroll { padding-bottom: 16px; scroll-padding-block: 8px; }
}

/* ---------- Sidebar (design spec 10.6) ---------- */
.sidebar-drawer { border-right: 1px solid var(--ws-rule); }
@media (max-width: 63em) { .sidebar-drawer { border-right: 0; } }
/* The drawer's scroll box would clip a focus ring drawn outside the link. */
.sidebar-tree a:focus-visible, .sidebar-tree .family-current:focus-visible { outline-offset: -2px; }
.sidebar-container { padding-top: 12px; }
.sidebar-search-container { margin: 4px 12px 12px; border: 1px solid var(--ws-rule); border-radius: var(--ws-radius); background: var(--ws-wash); }
.sidebar-search-container::before { left: 10px; background-color: var(--ws-faint); }
/* The search field's 16px magnifier is the family icon (1.75 stroke, round caps), not Furo's. */
.sidebar-search-container { --icon-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
/* The field you type into is 17px Inter: under 16px, iOS Safari zooms the page when it is tapped. */
.sidebar-search { padding: 7px 10px 7px 34px; border: 0; border-radius: var(--ws-radius); background: transparent; color: var(--ws-ink); font: var(--ws-weight-regular) var(--ws-text-base)/1.4 var(--ws-font-text); }
.sidebar-search::placeholder { color: var(--ws-faint); opacity: 1; }
.sidebar-search:focus-visible { outline: 2px solid var(--ws-accent); outline-offset: 2px; }
.sidebar-tree { margin: 0; font-family: var(--ws-font-ui); font-size: var(--ws-text-sm); }
.sidebar-tree ul { margin: 0 8px; }
.sidebar-tree li > a, .sidebar-tree .family-current { display: flex; align-items: center; min-height: 32px; padding: 4px 10px; border-radius: var(--ws-radius); color: var(--ws-soft); font-weight: var(--ws-weight-regular); line-height: var(--ws-leading-ui); text-decoration: none; }
.sidebar-tree li > a:hover { background: var(--ws-wash); color: var(--ws-ink); }
/* The current site in the family list is a span; give it the inset Furo gives the links around it. */
.sidebar-tree .family-current { padding-left: var(--sidebar-item-spacing-horizontal); padding-right: var(--sidebar-item-spacing-horizontal); }
.sidebar-tree .current-page > a.reference, .sidebar-tree li > a.current.reference, .sidebar-tree .family-current { background: var(--ws-wash); color: var(--ws-ink); font-weight: var(--ws-weight-strong); box-shadow: inset 2px 0 0 var(--ws-accent); border-radius: 0 var(--ws-radius) var(--ws-radius) 0; }
.sidebar-tree .reference.external::after { display: none; }
.sidebar-tree .caption, .sidebar-tree :not(.caption) > .caption-text { margin: 20px 18px 6px; padding: 0; color: var(--ws-faint); font: var(--ws-type-label); text-transform: none; }
.sidebar-tree .caption-text { margin: 0; }

/* ---------- On this page (design spec 10.6) ---------- */
.toc-title-container { padding-top: 24px; }
.toc-title { color: var(--ws-faint); font: var(--ws-type-label); text-transform: none; }
.toc-tree { border-left: 1px solid var(--ws-rule); font: var(--ws-type-ui); }
.toc-tree li { margin: 0; }
.toc-tree a.reference { display: block; margin-left: -1px; padding: 5px 0 5px 12px; border-left: 2px solid transparent; color: var(--ws-soft); text-decoration: none; }
.toc-tree a.reference:hover { color: var(--ws-ink); }
.toc-tree li.scroll-current > .reference { border-left-color: var(--ws-accent); color: var(--ws-ink); font-weight: var(--ws-weight-regular); }
.toc-tree .rule-badge { display: none; }

/* ---------- Content (design spec 3, type scale 5) ---------- */
.content { width: min(100%, var(--ws-content-w)); }
article[role=main] { color: var(--ws-body); font: var(--ws-type-body); }
article[role=main] h1, article[role=main] h2, article[role=main] h3, article[role=main] h4, article[role=main] h5, article[role=main] h6 { color: var(--ws-ink); }
/* The family rhythm (type scale section 5): 20px under blocks, 4px between list items, and fixed space above
   and below each heading level. */
article[role=main] h1 { margin-top: 2.2rem; margin-bottom: var(--ws-space-3); font: var(--ws-type-h1); letter-spacing: var(--ws-tracking-head); }
article[role=main] h2 { margin-top: var(--ws-space-12); margin-bottom: var(--ws-space-3); font: var(--ws-type-h2); letter-spacing: var(--ws-tracking-head); }
article[role=main] h3 { margin-top: var(--ws-space-8); margin-bottom: var(--ws-space-2); font: var(--ws-type-h3); }
article[role=main] :is(h4, h5, h6) { margin-top: var(--ws-space-6); margin-bottom: var(--ws-space-2); font: var(--ws-type-h4); }
article[role=main] :is(p, ul, ol, dl, blockquote, figure) { margin-top: 0; margin-bottom: var(--ws-space-5); }
article[role=main] li { margin-bottom: var(--ws-space-1); }
article[role=main] li > :is(p, ul, ol) { margin-bottom: var(--ws-space-1); }
article[role=main] section > :last-child { margin-bottom: 0; }
article[role=main] :is(strong, b) { color: var(--ws-ink); font-weight: var(--ws-weight-strong); }
article[role=main] h1 + p { color: var(--ws-body); }
/* Heading anchor glyph: the family label role (13px JetBrains Mono 600), whatever the heading's size. Furo
   sets it at weight 100. */
.headerlink { color: var(--ws-faint); font: var(--ws-type-label); letter-spacing: normal; }

/* Links in prose: ink, with an accent (blue) underline. */
article[role=main] a { color: var(--ws-ink); text-decoration: underline 1px color-mix(in srgb, var(--ws-accent) 70%, transparent); text-underline-offset: .2em; }
article[role=main] a:hover { color: var(--ws-ink); text-decoration-color: var(--ws-accent); text-decoration-thickness: 2px; }
article[role=main] a.headerlink { text-decoration: none; }

/* Inline code and code blocks (design spec 10.4). */
code.literal, .highlight pre, pre { font-family: var(--ws-font-mono); }
/* Inline code is one step below the text around it: 15 in prose, 13 in tables and chrome, the heading's own
   size in a heading. */
code.literal { padding: .1em .35em; border: 0; border-radius: var(--ws-radius-sm); background: var(--ws-wash); color: var(--ws-ink); font-size: var(--ws-text-md); }
code.literal .pre { font-size: inherit; }
:is(table, .sidebar-drawer, .toc-drawer, .related-pages, .rule-badge) code.literal { font-size: var(--ws-text-sm); }
:is(h1, h2, h3, h4, h5, h6) code.literal { font-size: inherit; }
div[class*="highlight-"] { margin: 0 0 var(--ws-space-5); }
.highlight { border: 1px solid var(--ws-rule); border-radius: var(--ws-radius); background: var(--ws-code-bg); }
.highlight pre { padding: 16px 18px; font: var(--ws-type-code); background: transparent; }

/* Tables (design spec 10.5). */
.table-scroll, .table-wrapper { border: 1px solid var(--ws-rule); border-radius: var(--ws-radius); background: var(--ws-sheet); }
article[role=main] table.docutils { width: 100%; border: 0; border-collapse: collapse; border-radius: 0; box-shadow: none; }
article[role=main] table.docutils th { padding: 10px 14px; border: 0; border-bottom: 1px solid var(--ws-rule); background: var(--ws-wash); color: var(--ws-faint); font: var(--ws-type-label); text-align: left; text-transform: none; }
article[role=main] table.docutils td { padding: 10px 14px; border: 0; border-bottom: 1px solid var(--ws-rule); font: var(--ws-type-small); }
article[role=main] table.docutils tbody tr:last-child td { border-bottom: 0; }
article[role=main] table.docutils td p { margin: 0; }
article[role=main] table.docutils th p { margin: 0; }

/* Previous and next (design spec 10.6): two cards. */
.related-pages { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 48px; padding: 0; border: 0; }
.related-pages a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--ws-rule); border-radius: var(--ws-radius); background: var(--ws-sheet); color: var(--ws-ink); text-decoration: none; }
.related-pages a:hover { border-color: var(--ws-ink); color: var(--ws-ink); }
.related-pages a.prev-page { grid-column: 1; grid-row: 1; }
.related-pages a.next-page { grid-column: 2; justify-content: flex-end; text-align: right; }
.related-pages .page-info .context { color: var(--ws-faint); font: var(--ws-type-ui); text-transform: none; }
.related-pages .page-info .title { color: var(--ws-ink); font: var(--ws-type-h4); }
.related-pages .furo-related-icon { color: var(--ws-faint); }
@media (max-width: 480px) {
  .related-pages { grid-template-columns: 1fr; }
  .related-pages a.next-page { grid-column: 1; grid-row: auto; }
}
.sg-related { display: flex; flex-direction: column; margin-top: 2rem; padding-bottom: var(--ws-space-12); font: var(--ws-type-ui); }

/* ---------- Footer (design spec 9) ---------- */
.ws-footer { margin-top: 0; }
.ws-footer [aria-current] { display: inline; }

/* Furo pads its table wrapper for a scroll shadow; the family wrapper is a hairline box with no padding. */
.table-wrapper.container { margin: 0 0 var(--ws-space-5); padding: 0; }
.table-wrapper.container > table.docutils { margin: 0; }

/* Furo floats the previous and next links; the grid above places them instead. */
.related-pages a.next-page, .related-pages a.prev-page { float: none; max-width: none; }

/* Furo opens the drawers at the top of the window; open them under the header instead. */
@media (max-width: 82em) {
  #__toc:checked ~ .page .toc-drawer { top: var(--ws-header-h); }
}
@media (max-width: 63em) {
  #__navigation:checked ~ .page .sidebar-drawer { top: var(--ws-header-h); left: 0; }
}

/* A closed drawer is only moved off screen, so its links would stay in the Tab order and the accessibility
   tree. Hide it while closed; for "On this page" the visibility change waits for the slide-out to finish (the
   phone navigation drawer doesn't slide). */
@media (max-width: 82em) {
  #__toc:not(:checked) ~ .page .toc-drawer { visibility: hidden; transition: right .25s ease-in-out, visibility 0s .25s; }
}
@media (max-width: 63em) {
  #__navigation:not(:checked) ~ .page .sidebar-drawer { visibility: hidden; }
}

/* ---------- Search results ---------- */
/* One role for a search result on every family site: the title as the 17px Inter 600 card title, the
   excerpt as 15px small text, and the status line as 13px mono chrome. */
#search-results h2 { margin-top: var(--ws-space-8); font: var(--ws-type-h2); }
#search-results .search-summary { color: var(--ws-soft); font: var(--ws-type-ui); }
#search-results ul.search { margin: 0; padding: 0; border-bottom: 1px solid var(--ws-rule); }
#search-results ul.search li { margin: 0; padding: 14px 0; border: 0; border-top: 1px solid var(--ws-rule); background: none; }
#search-results ul.search li > a { font: var(--ws-weight-strong) var(--ws-text-base)/1.3 var(--ws-font-text); }
#search-results ul.search li > span { color: var(--ws-faint); font: var(--ws-type-ui); }
#search-results ul.search li p.context { margin: 4px 0 0; color: var(--ws-body); font: var(--ws-type-small); }
