/* ============================================================
   mobile.css — phone and small-tablet layer.

   Loaded LAST so it only ever overrides. Everything that changes
   appearance lives inside @media (max-width: 900px), which is the
   same breakpoint legacy.css already used to hide the navigation
   entirely. Desktop rendering is untouched by construction.
   ============================================================ */

/* The mark sits in the top bar at every width. */
.topbar-mark { width: 26px; height: 26px; display: block; flex-shrink: 0; }

/* Drawer controls exist in the markup at all widths but only appear small. */
.nav-toggle-btn { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {

  /* ── Top bar: keep the mark, the name and the way out ───────── */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-left { gap: 9px; min-width: 0; }
  .topbar-divider,
  .topbar-title,
  .topbar-badge.confidential { display: none; }
  .wordmark { font-size: 14px; white-space: nowrap; }
  .topbar-mark { width: 24px; height: 24px; }
  .topbar-lock { height: 28px; padding: 0 11px; font-size: 9px; letter-spacing: .08em; }

  .nav-toggle-btn {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px; height: 34px;
    padding: 0 8px;
    background: transparent;
    border: 1px solid var(--ivory-4);
    border-radius: var(--r);
    flex-shrink: 0;
  }
  .nav-toggle-btn span {
    display: block; height: 1.5px; width: 100%;
    background: var(--ink-2); border-radius: 2px;
    transition: transform var(--ease), opacity var(--ease);
  }
  body.nav-open .nav-toggle-btn span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
  body.nav-open .nav-toggle-btn span:nth-child(2) { opacity: 0; }
  body.nav-open .nav-toggle-btn span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

  /* ── Document sidebar becomes an off-canvas drawer ──────────── */
  .sidebar {
    display: flex !important;          /* legacy.css hides it at this width */
    position: fixed;
    top: var(--topbar-h); bottom: 0; left: 0;
    width: min(300px, 84vw);
    z-index: 120;
    transform: translateX(-102%);
    transition: transform .26s cubic-bezier(.2,.7,.3,1);
    box-shadow: 2px 0 24px rgba(26,24,20,.10);
  }
  body.nav-open .sidebar { transform: none; }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(26,24,20,.42);
    opacity: 0; pointer-events: none;
    transition: opacity .26s;
    z-index: 110;
  }
  body.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

  /* ── Page contents pane collapses to a bar at the top ───────── */
  .doc-layout { flex-direction: column; }
  .doc-toc {
    display: block !important;         /* legacy.css hides it at this width */
    position: static;
    width: auto; height: auto; max-height: 52vh;
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid var(--ivory-3);
  }
  .doc-toc .toc-hdr { display: none; }
  .toc-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 13px 16px;
    background: var(--ivory-2); border: 0;
    font-size: 9px; font-weight: 700;
    letter-spacing: .26em; text-transform: uppercase;
    color: var(--ink-3); text-align: left;
  }
  .toc-toggle svg { width: 11px; height: 11px; transition: transform var(--ease); }
  .doc-toc.is-open .toc-toggle svg { transform: rotate(180deg); }
  .doc-toc.is-open { overflow-y: auto; }
  .doc-toc:not(.is-open) { max-height: none; overflow: hidden; }
  .doc-toc:not(.is-open) .toc-link { display: none; }
  .doc-toc .toc-link { padding: 8px 16px; font-size: 12px; }
  .doc-toc .toc-link.l2 { padding-left: 28px; font-size: 11.5px; }
  .doc-toc .toc-link.l3 { padding-left: 38px; font-size: 11px; }

  /* ── Reading column ─────────────────────────────────────────── */
  .doc-body { padding: 26px 16px 64px; max-width: none; }
  .doc-body h1 { font-size: 25px; line-height: 1.25; }
  .doc-body h2 { font-size: 18px; }
  .doc-body h3 { font-size: 14px; }
  .doc-body p, .doc-body li { font-size: 13.5px; line-height: 1.72; }

  /* ── Anything that is wider than a phone scrolls sideways ───── */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrapper table { min-width: 560px; }
  .doc-body pre { overflow-x: auto; -webkit-overflow-scrolling: touch; font-size: 11px; }
  .mermaid { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .mermaid svg { max-width: none; }

  /* Long identifiers and URLs should wrap instead of stretching the page. */
  .doc-body { overflow-wrap: anywhere; }
  .doc-body code { overflow-wrap: anywhere; }
}

/* Very narrow phones: drop the wordmark text, the mark carries it. */
@media (max-width: 380px) {
  .wordmark span { display: none; }
}
