/* The public handbook (#1213, layouts/handbook): a bar with brand, search and language; below it the
   navigation and the content (#2375). Running text keeps a readable measure while screenshots, tables
   and code use the content column's full width. Narrow screens (< 1024px) stack the navigation
   collapsed above the content. From 1024px the content column grows up to 960px; a page's contents
   move into a column on the right only from 1600px, where the content column still has its full
   960px, so the content never gets narrower as the window gets wider. */
.handbook__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  /* Its content lines up with the centred .handbook__frame below on very wide screens. */
  padding: 14px max(20px, calc((100% - 1600px) / 2 + 20px));
  border-bottom: var(--border);
  background: var(--nav);
  color: var(--nav-fg);
}

.handbook__brand {
  color: var(--white);
  font-family: var(--f-display);
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
}

.handbook__search {
  display: flex;
  flex: 1;
  gap: 8px;
  min-width: 200px;
  max-width: 420px;
}

.handbook__search input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
}

.handbook__search .btn {
  border-color: var(--nav-line);
  color: var(--white);
}

.handbook__languages {
  display: flex;
  gap: 12px;
  margin-left: auto;
}

.handbook__languages a {
  color: var(--nav-fg);
  text-decoration: none;
}

.handbook__languages a[aria-current] {
  color: var(--accent);
  font-weight: 600;
}

.handbook__frame {
  max-width: 1600px;
  margin: 0 auto;
}

.handbook__nav {
  border-bottom: var(--border);
}

/* The narrow screens' "Menu" and the expandable sections of a page open and close in height
   (#2376), so the page below does not jump. Browsers without ::details-content or interpolate-size
   open them at once, as before. From 1024px the menu is always shown (below). */
.handbook__nav,
.handbook__page details {
  interpolate-size: allow-keywords;
}

.handbook__nav::details-content,
.handbook__page details::details-content {
  block-size: 0;
  overflow: hidden;
  transition: block-size var(--duration-swap) var(--ease), content-visibility var(--duration-swap) allow-discrete;
}

.handbook__nav[open]::details-content,
.handbook__page details[open]::details-content {
  block-size: auto;
}

.handbook__nav summary {
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
}

.handbook__nav nav {
  padding: 0 20px 16px;
}

.handbook__nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.handbook__nav li {
  margin: 2px 0;
}

.handbook__nav a {
  display: block;
  padding: 4px 8px;
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease);
}

.handbook__nav a:hover {
  background: var(--surface);
}

.handbook__nav a[aria-current] {
  background: var(--surface);
  font-weight: 600;
}

.handbook__nav-area {
  font-weight: 600;
}

.handbook__nav li ul {
  margin: 2px 0 8px 8px;
  padding-left: 8px;
  border-left: var(--border);
  font-size: 14px;
}

.handbook__main {
  --measure: 70ch;
  --content-max: 960px;
  min-width: 0;
  padding: 32px 20px 64px;
  overflow-wrap: break-word;
}

.handbook__main > :not(.handbook__page, .handbook__areas),
.handbook__page > :not(.handbook__body),
.handbook__body > * {
  max-width: var(--measure);
}

.handbook__body > :is(p:has(img), table, pre) {
  max-width: none;
}

.handbook__body pre {
  overflow-x: auto;
}

.handbook__main h1 {
  margin: 0 0 12px;
  font-family: var(--f-display);
  font-size: 2.2rem;
  line-height: 1.1;
}

.handbook__main h2,
.handbook__main h3 {
  font-family: var(--f-display);
}

.handbook__main a {
  color: var(--blue);
}

.handbook__lead {
  color: var(--muted);
  font-size: 1.1rem;
}

.handbook__areas,
.handbook__pages {
  display: grid;
  gap: 12px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.handbook__areas {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  max-width: 72rem;
}

.handbook__areas li,
.handbook__pages li {
  padding: 16px 18px;
  border: var(--border);
  border-radius: var(--radius-lg);
}

.handbook__areas h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.handbook__areas p,
.handbook__pages p {
  margin: 4px 0 0;
  color: var(--muted);
}

.handbook__crumb {
  margin: 0 0 6px;
  font-size: 14px;
}

.handbook__toc {
  margin: 20px 0;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.handbook__toc h2 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.handbook__toc ol {
  margin: 0;
  padding-left: 20px;
}

.handbook__body img {
  max-width: 100%;
  height: auto;
  border: var(--border);
  border-radius: var(--radius);
}

.handbook__body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.handbook__body th,
.handbook__body td {
  padding: 6px 10px;
  border: var(--border);
  text-align: left;
}

.handbook__feedback {
  display: block;
  margin: 40px 0 0;
  padding: 16px 18px;
  border: var(--border);
  border-radius: var(--radius-lg);
}

.handbook__feedback fieldset {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.handbook__feedback legend {
  margin-bottom: 8px;
  font-family: var(--f-display);
  font-weight: 700;
}

.handbook__feedback .field {
  flex-basis: 100%;
  margin-bottom: 4px;
}

.handbook__feedback p {
  margin: 0;
}

.handbook__pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.handbook__pager a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
}

.handbook__pager a[rel="next"] {
  margin-left: auto;
  text-align: right;
}

.handbook__pager small {
  color: var(--muted);
}

@media (min-width: 1024px) {
  .handbook__frame {
    display: grid;
    grid-template-columns: 16rem minmax(0, 1fr);
    align-items: start;
  }

  .handbook__nav {
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
    border-right: var(--border);
    border-bottom: 0;
  }

  /* Shown whatever the open state, so a full page load does not flash a collapsed "Menu" before
     handbook_nav_controller.js opens it. */
  .handbook__nav summary {
    display: none;
  }

  .handbook__nav::details-content {
    display: block;
    block-size: auto;
    overflow: visible;
    content-visibility: visible;
    transition: none;
  }

  .handbook__nav nav {
    padding: 32px 16px 32px 12px;
  }

  .handbook__main {
    padding: 32px 40px 64px;
  }

  .handbook__page {
    max-width: var(--content-max);
  }
}

/* 1600px = 16rem nav + 1px border + 80px padding + 960px content + 48px gap + 15rem contents
   (1585px), rounded up; the frame stops growing at 1600px. */
@media (min-width: 1600px) {
  .handbook__page:has(> .handbook__toc) {
    display: grid;
    grid-template-columns: minmax(0, var(--content-max)) 15rem;
    column-gap: 48px;
    max-width: none;
  }

  .handbook__page > * {
    grid-column: 1;
  }

  .handbook__page > .handbook__toc {
    position: sticky;
    top: 24px;
    grid-row: 1 / span 3;
    grid-column: 2;
    align-self: start;
    margin: 0;
    font-size: 14px;
  }
}

@media (max-width: 600px) {
  .handbook__bar {
    padding: 12px;
  }

  .handbook__search {
    order: 3;
    max-width: none;
    flex-basis: 100%;
  }

  .handbook__nav summary {
    padding: 12px;
  }

  .handbook__nav nav {
    padding: 0 12px 12px;
  }

  .handbook__main {
    padding: 20px 12px 48px;
  }

  .handbook__main h1 {
    font-size: 1.7rem;
  }
}
