/* The guides under /docs/: a sidebar of guides beside one article. Loaded
   after theme.css and the site/ stylesheets, which give the header, footer and buttons. */
@layer layout {
  .docs-layout {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    column-gap: 56px;
    align-items: start;
    padding-block: 48px 96px;
  }

  .docs-sidebar {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    scrollbar-width: thin;
  }

  .docs-article {
    max-width: 760px;
    min-width: 0;
  }
}

@layer components {
  .desktop-nav a[aria-current="page"] {
    color: var(--text-primary);
    background: var(--nav-selected);
    border-color: var(--border-warm);
  }

  /* Sidebar: groups of guides, the current one with its sections. */
  .docs-nav-group + .docs-nav-group {
    margin-top: 22px;
  }

  .docs-nav-label {
    padding-left: 12px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--text-muted);
  }

  .docs-nav ul {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
  }

  .docs-nav-link {
    display: flex;
    gap: 11px;
    align-items: center;
    min-height: 42px;
    margin-block: 3px;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 7px;
  }

  .docs-nav-link .ui-icon {
    color: var(--accent);
  }

  .docs-nav-link:hover {
    background: var(--nav-hover);
    color: var(--text-primary);
  }

  .docs-nav-link[aria-current="page"] {
    background: var(--nav-selected);
    color: var(--accent);
    border-color: var(--border-warm);
  }

  .docs-toc {
    margin: 4px 0 10px 21px !important;
    border-left: 1px solid var(--border);
  }

  .docs-toc a {
    display: block;
    padding: 6px 12px;
    margin-left: -1px;
    font-size: 12px;
    color: var(--text-muted);
    border-left: 1px solid transparent;
  }

  .docs-toc a:hover {
    color: var(--text-primary);
    border-left-color: var(--accent);
  }

  .docs-help {
    margin-top: 28px;
    padding: 14px 12px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: var(--bg-warm);
    border: 1px solid var(--border-warm);
    border-radius: 9px;
  }

  .docs-help strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-primary);
  }

  .docs-help a {
    color: var(--accent);
  }

  /* Article. */
  .docs-article h1 {
    margin-top: 14px;
    font-size: 34px;
    letter-spacing: -0.8px;
    line-height: 1.18;
  }

  .docs-lead {
    margin-top: 14px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-secondary);
  }

  .docs-article section {
    margin-top: 44px;
    padding-top: 36px;
    border-top: 1px solid var(--border);
    scroll-margin-top: 24px;
  }

  .docs-article h2 {
    font-size: 22px;
    letter-spacing: -0.3px;
  }

  .docs-article h3 {
    margin-top: 26px;
    font-size: 15px;
  }

  .docs-article section > p,
  .docs-article section > ul,
  .docs-article section > ol,
  .docs-article li > p {
    margin-top: 12px;
    line-height: 1.75;
    color: var(--text-secondary);
  }

  .docs-article li > p:first-child {
    margin-top: 0;
  }

  .docs-article section > ul:not(.docs-cards),
  .docs-article section > ol:not(.docs-steps) {
    padding-left: 20px;
  }

  .docs-article li + li {
    margin-top: 6px;
  }

  .docs-article strong {
    font-weight: 600;
    color: var(--text-primary);
  }

  .docs-article p a,
  .docs-article li a:not(.docs-card),
  .docs-article td a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: var(--accent-border);
    text-underline-offset: 3px;
  }

  .docs-article p a:hover,
  .docs-article li a:not(.docs-card):hover,
  .docs-article td a:hover {
    color: var(--accent-hover);
  }

  .docs-article code {
    padding: 1px 6px;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.92em;
    color: var(--text-warm);
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: 5px;
    overflow-wrap: anywhere;
  }

  /* Numbered steps with copper counters. */
  .docs-steps {
    list-style: none;
    margin: 18px 0 0;
    padding: 0;
    counter-reset: step;
  }

  .docs-steps > li {
    position: relative;
    min-height: 30px;
    padding-left: 46px;
    line-height: 1.75;
    color: var(--text-secondary);
    counter-increment: step;
  }

  .docs-steps > li + li {
    margin-top: 16px;
  }

  .docs-steps > li::before {
    content: counter(step);
    position: absolute;
    top: 0;
    left: 0;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: var(--nav-selected);
    border: 1px solid var(--border-warm);
    border-radius: 50%;
  }

  .docs-steps ul {
    margin-top: 8px;
    padding-left: 18px;
  }

  /* A note set apart from the text. */
  .docs-note {
    display: flex;
    gap: 12px;
    margin-top: 18px;
    padding: 14px 16px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary);
    background: var(--bg-warm);
    border: 1px solid var(--border-warm);
    border-radius: 9px;
  }

  .docs-note .ui-icon {
    margin-top: 2px;
    color: var(--accent);
  }

  .docs-note.is-warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
  }

  .docs-note.is-warning .ui-icon {
    color: var(--warning);
  }

  /* Reference tables; they scroll sideways on narrow screens. */
  .docs-table-wrap {
    margin-top: 16px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 9px;
  }

  .docs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    line-height: 1.6;
  }

  .docs-table th,
  .docs-table td {
    padding: 10px 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
  }

  .docs-table tr:last-child > * {
    border-bottom: 0;
  }

  .docs-table thead th {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg-secondary);
  }

  .docs-table tbody th {
    font-weight: 600;
    white-space: nowrap;
  }

  .docs-table td {
    color: var(--text-secondary);
  }

  /* Guide cards on the overview. */
  .docs-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 20px;
    padding: 0;
    list-style: none;
  }

  .docs-cards li + li {
    margin-top: 0;
  }

  .docs-card {
    display: flex;
    gap: 14px;
    height: 100%;
    padding: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 150ms ease;
  }

  .docs-card:hover {
    border-color: var(--accent-border);
  }

  .docs-card strong {
    display: block;
    font-size: 14px;
  }

  .docs-card span:not(.feature-icon) {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
  }

  .docs-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
  }

  /* Previous and next guide. */
  .docs-pager {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 56px;
  }

  .docs-pager a {
    display: block;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 9px;
    transition: border-color 150ms ease;
  }

  .docs-pager a:hover {
    border-color: var(--accent-border);
  }

  .docs-pager small {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
  }

  .docs-pager strong {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: var(--accent);
  }

  .docs-pager .is-next {
    grid-column: 2;
    text-align: right;
  }
}

@layer responsive {
  @media (max-width: 900px) {
    .docs-layout {
      grid-template-columns: minmax(0, 1fr);
      padding-block: 0 72px;
    }

    /* The guides become a row of chips that scrolls sideways under the header. */
    .docs-sidebar {
      position: static;
      max-height: none;
      overflow: visible;
      margin-inline: -24px;
      padding: 12px 24px;
      border-bottom: 1px solid var(--border);
    }

    .docs-nav {
      display: flex;
      gap: 6px;
      overflow-x: auto;
      scrollbar-width: none;
    }

    .docs-nav-group,
    .docs-nav-group + .docs-nav-group {
      display: contents;
    }

    .docs-nav ul {
      display: contents;
    }

    .docs-nav-label,
    .docs-nav .docs-toc,
    .docs-help {
      display: none;
    }

    .docs-nav-link {
      margin: 0;
      white-space: nowrap;
      border-color: var(--border);
    }

    .docs-article {
      padding-top: 32px;
    }
  }

  @media (max-width: 1100px) and (min-width: 901px) {
    .docs-layout {
      column-gap: 40px;
    }
  }

  /* Out to the edge of .container's gutter (site/base.css). */
  @media (max-width: 800px) {
    .docs-sidebar {
      margin-inline: -20px;
      padding-inline: 20px;
    }
  }

  @media (max-width: 760px) {
    .docs-sidebar {
      margin-inline: -16px;
      padding-inline: 16px;
    }
  }

  @media (max-width: 600px) {
    .docs-article h1 {
      font-size: 28px;
    }

    .docs-table tbody th {
      white-space: normal;
    }

    .docs-table th,
    .docs-table td {
      padding-inline: 12px;
    }

    .docs-cards,
    .docs-pager {
      grid-template-columns: minmax(0, 1fr);
    }

    .docs-pager .is-next {
      grid-column: auto;
    }
  }
}
