/*
  Docs + Blog responsive boundary
  ---------------------------------------------------------------------------
  This file is intentionally loaded after style.css by docs.html and blog.html.
  The original stylesheet contains legacy Docs rules and newer rules in separate
  sections. Keeping the responsive layout here prevents a later generic rule
  from accidentally undoing the off-canvas sidebar or mobile reading layout.
*/

.docs-page {
  overflow-x: hidden;
}

.docs-page .docs-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: calc(100vh - 80px);
  max-width: 1440px;
  margin: 0 auto;
}

.docs-page .docs-sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
  width: auto;
  height: calc(100vh - 80px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.docs-page .docs-content {
  width: min(100%, 820px);
  min-width: 0;
  max-width: 820px;
  margin: 0 auto;
  padding: 30px 64px 100px;
}

.docs-page .portal-hero,
.docs-page .docs-toolbar,
.docs-page .docs-nav-buttons,
.docs-page .markdown-body {
  min-width: 0;
}

.docs-page .markdown-body {
  max-width: 68ch;
  margin-right: auto;
  margin-left: auto;
  overflow-wrap: anywhere;
}

.docs-page .markdown-body :is(img, video) {
  display: block;
  max-width: 100%;
  height: auto;
}

.docs-page .markdown-body :is(pre, .table-scroll) {
  max-width: 100%;
}

.docs-page .markdown-body pre {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.docs-page .markdown-body :is(a, code) {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.docs-page .markdown-body pre code {
  white-space: pre;
}

.docs-page .docs-menu-toggle,
.docs-page .docs-sidebar-close {
  display: none;
}

.docs-page .docs-backdrop {
  display: none;
}

/* Tablet and phone: sidebar becomes an off-canvas menu, never a normal-flow row. */
@media (max-width: 992px) {
  .docs-page .nav-links,
  .docs-page .nav-actions > .btn {
    display: none;
  }

  .docs-page .docs-menu-toggle {
    display: grid;
    place-items: center;
  }

  .docs-page .docs-layout {
    display: block;
    min-height: calc(100vh - 68px);
    max-width: none;
  }

  .docs-page .docs-sidebar {
    position: fixed;
    z-index: 210;
    top: 0;
    left: 0;
    width: min(360px, 88vw);
    height: 100dvh;
    min-height: 100vh;
    margin: 0;
    padding: 28px 22px 48px;
    border: 0;
    transform: translateX(-110%);
    transition: transform 0.25s ease;
    box-shadow: 20px 0 60px rgba(47, 27, 12, 0.18);
  }

  .docs-page .docs-sidebar.is-open {
    transform: translateX(0);
  }

  .docs-page .docs-sidebar-close {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
  }

  .docs-page .docs-backdrop {
    position: fixed;
    z-index: 200;
    inset: 0;
    display: block;
    width: 100%;
    height: 100dvh;
    margin: 0;
    border: 0;
    background: rgba(35, 21, 12, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .docs-page.docs-menu-open {
    overflow: hidden;
  }

  .docs-page.docs-menu-open .docs-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .docs-page .docs-content {
    width: min(100%, 820px);
    max-width: 820px;
    padding: 28px 32px 80px;
  }

  .docs-page .docs-menu-item a {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
}

/* Phone: preserve space for the menu, language toggle, and theme toggle. */
@media (max-width: 700px) {
  .docs-page .nav-container {
    height: 64px;
    gap: 10px;
    padding: 0 12px;
  }

  .docs-page .logo {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 150px;
    overflow: hidden;
    white-space: nowrap;
    font-size: 16px;
  }

  .docs-page .logo::before {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    font-size: 13px;
  }

  .docs-page .nav-actions {
    flex: 0 0 auto;
    gap: 4px;
  }

  .docs-page .docs-menu-toggle,
  .docs-page .theme-toggle {
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
  }

  .docs-page .lang-switcher {
    gap: 2px;
  }

  .docs-page .lang-btn {
    min-width: 34px;
    min-height: 32px;
    padding: 4px 7px;
    font-size: 12px;
  }

  .docs-page .docs-layout {
    min-height: calc(100vh - 64px);
  }

  .docs-page .docs-content {
    width: 100%;
    max-width: none;
    padding: 18px 14px 56px;
  }

  .docs-page .portal-hero {
    height: 128px;
    margin-bottom: 16px;
    border-radius: 16px;
  }

  .docs-page.is-reading .portal-hero {
    display: none;
  }

  .docs-page .docs-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 24px;
    padding-bottom: 14px;
  }

  .docs-page .docs-breadcrumb {
    align-items: flex-start;
    gap: 6px;
    line-height: 1.45;
  }

  .docs-page .static-badge {
    width: fit-content;
    max-width: 100%;
  }

  .docs-page .markdown-body {
    max-width: none;
  }

  .docs-page .markdown-body h1 {
    margin-bottom: 18px;
    padding-bottom: 10px;
    font-size: clamp(28px, 8.2vw, 34px);
    line-height: 1.18;
  }

  .docs-page .markdown-body h2 {
    margin-top: 34px;
    font-size: clamp(22px, 6.2vw, 26px);
    line-height: 1.25;
  }

  .docs-page .markdown-body h3 {
    font-size: 19px;
    line-height: 1.35;
  }

  .docs-page .markdown-body :is(p, ul, ol) {
    font-size: 15.5px;
    line-height: 1.78;
  }

  .docs-page .markdown-body :is(ul, ol) {
    padding-left: 20px;
  }

  .docs-page .markdown-body blockquote {
    margin: 20px 0;
    padding: 12px 14px;
  }

  .docs-page .markdown-body pre {
    margin: 20px 0;
    padding: 16px;
    border-radius: 14px;
  }

  /* Wide Markdown tables remain scrollable inside their own container.
     This is safer than converting every table to cards and avoids page-wide overflow. */
  .docs-page .markdown-body .table-scroll {
    display: block;
    width: 100%;
    margin: 20px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-color);
    border-radius: 12px;
  }

  .docs-page .markdown-body .table-scroll table {
    display: table;
    width: max-content;
    min-width: 640px;
    margin: 0;
    border-collapse: collapse;
  }

  .docs-page .markdown-body .table-scroll thead {
    display: table-header-group;
  }

  .docs-page .markdown-body .table-scroll tbody {
    display: table-row-group;
  }

  .docs-page .markdown-body .table-scroll tr {
    display: table-row;
    margin: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .docs-page .markdown-body .table-scroll :is(th, td) {
    display: table-cell;
    width: auto;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    font-size: 14px;
  }

  .docs-page .markdown-body .table-scroll td::before {
    display: none;
  }

  .docs-page .docs-sidebar {
    width: min(340px, 86vw);
    padding: 22px 18px 44px;
  }

  .docs-page .docs-nav-buttons {
    flex-direction: column;
    gap: 12px;
    margin-top: 36px;
    padding-top: 18px;
  }

  .docs-page .docs-nav-btn,
  .docs-page .docs-nav-btn.next {
    width: 100%;
    max-width: none;
    align-items: flex-start;
    padding: 14px 16px;
    text-align: left;
  }

  .docs-page .docs-nav-btn-title {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.35;
  }
}

@media (max-width: 420px) {
  .docs-page .nav-container {
    padding: 0 10px;
  }

  .docs-page .logo {
    max-width: 120px;
    font-size: 15px;
  }

  .docs-page .nav-actions {
    gap: 2px;
  }

  .docs-page .docs-menu-toggle,
  .docs-page .theme-toggle {
    width: 32px;
    min-width: 32px;
    height: 32px;
  }

  .docs-page .lang-btn {
    min-width: 31px;
    min-height: 30px;
    padding: 3px 6px;
  }

  .docs-page .docs-content {
    padding-right: 12px;
    padding-left: 12px;
  }

  .docs-page .portal-hero {
    height: 112px;
  }
}
