/* ==========================================================================
   Documentation. Inherits every token from /styles/index.css.
   ========================================================================== */

body { overflow-wrap: break-word; }

.docs-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 190px;
  gap: 0 3rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 28px;
  align-items: start;
}

/* ---------- Left rail ---------------------------------------------------- */

.sidebar {
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 1.8rem 0 3rem;
  scrollbar-width: thin;
  scrollbar-color: #33373d transparent;
}

.sidebar__group { margin-bottom: 1.5rem; }

.sidebar__label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin: 0 0 0.5rem;
  padding-left: 0.85rem;
}

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

.sidebar__list a {
  display: block;
  padding: 0.33rem 0.85rem;
  border-left: 2px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.895rem;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.sidebar__list a:hover { color: var(--text); border-left-color: var(--line); }

.sidebar__list a.is-active {
  color: var(--orange);
  border-left-color: var(--orange);
  background: var(--orange-wash);
}

/* ---------- Right rail --------------------------------------------------- */

.toc {
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 1.8rem 0 3rem;
}

.toc__label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin: 0 0 0.6rem;
}

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

.toc__list a {
  display: block;
  padding: 0.22rem 0;
  color: var(--faint);
  font-size: 0.83rem;
  line-height: 1.4;
}
.toc__list a:hover { color: var(--text-soft); }
.toc__list a.is-active { color: var(--orange); }

/* ---------- Content ------------------------------------------------------ */

.doc-content { padding: 1.8rem 0 6rem; min-width: 0; }

.doc-section { padding-top: 1.6rem; margin-bottom: 3.5rem; scroll-margin-top: 80px; }

.doc-section > h2 {
  font-size: 1.95rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line-soft);
  max-width: none;
}

.doc-section h3 {
  font-size: 1.16rem;
  margin: 2.4rem 0 0.7rem;
  scroll-margin-top: 80px;
}

.doc-section h4 {
  font-size: 0.99rem;
  color: var(--text-soft);
  margin: 1.6rem 0 0.5rem;
  font-weight: 600;
}

.doc-content p { color: var(--muted); max-width: 74ch; margin-bottom: 1rem; }
.doc-content p strong { color: var(--text-soft); font-weight: 600; }

.doc-content ul, .doc-content ol { color: var(--muted); max-width: 74ch; padding-left: 1.3rem; margin: 0 0 1.1rem; }
.doc-content li { margin-bottom: 0.4rem; }
.doc-content li::marker { color: var(--faint); }

.lede {
  font-size: 1.06rem;
  color: var(--text-soft) !important;
  margin-bottom: 1.6rem !important;
}

/* ---------- Snippets ----------------------------------------------------- */

.snippet {
  margin: 0 0 1.4rem;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.snippet__bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 0.7rem 0.5rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
}

.snippet__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.snippet__body {
  margin: 0;
  padding: 1rem 1.2rem;
  font-family: var(--mono);
  font-size: 0.805rem;
  line-height: 1.7;
  color: var(--text-soft);
  overflow-x: auto;
  white-space: pre;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  scrollbar-width: thin;
  scrollbar-color: #33373d transparent;
}

.snippet--out .snippet__body { color: var(--muted); }

.snippet__body::-webkit-scrollbar { height: 9px; }
.snippet__body::-webkit-scrollbar-track { background: transparent; }
.snippet__body::-webkit-scrollbar-thumb { background: #33373d; border-radius: 6px; }

/* ---------- Callouts ----------------------------------------------------- */

.callout {
  margin: 0 0 1.4rem;
  padding: 0.95rem 1.2rem;
  border-left: 2px solid var(--orange-quiet);
  background: rgba(255, 255, 255, 0.018);
  border-radius: 0 6px 6px 0;
}

.callout p { margin-bottom: 0.5rem; color: var(--text-soft); font-size: 0.945rem; }
.callout p:last-child { margin-bottom: 0; }

.callout__tag {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--orange);
  margin-bottom: 0.35rem;
}

.callout--warn { border-left-color: #d98a3a; }
.callout--warn .callout__tag { color: #e0a45e; }

.callout--trap { border-left-color: #cf5f45; }
.callout--trap .callout__tag { color: #e07a62; }

/* ---------- Tables ------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 1.4rem;
  scrollbar-width: thin;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.895rem;
  min-width: 460px;
}

.doc-table th {
  text-align: left;
  padding: 0.7rem 1rem;
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.doc-table td {
  padding: 0.7rem 1rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.doc-table tr:last-child td { border-bottom: 0; }
.doc-table td:first-child { color: var(--text-soft); white-space: nowrap; }
.doc-table td code, .doc-table th code { background: none; padding: 0; }

/* ---------- Search ------------------------------------------------------- */

.search-trigger {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  appearance: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  margin-bottom: 1.5rem;
  font-family: var(--sans);
  font-size: 0.87rem;
  color: var(--faint);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.search-trigger:hover { border-color: var(--orange-quiet); color: var(--muted); }
.search-trigger kbd {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.08rem 0.32rem;
}

.search-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  padding: 10vh 1rem 1rem;
  background: rgba(8, 9, 10, 0.72);
  backdrop-filter: blur(3px);
}
.search-modal[open], .search-modal.is-open { display: block; }

.search-panel {
  max-width: 640px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.search-input {
  width: 100%;
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.2rem;
  font-family: var(--sans);
  font-size: 1.02rem;
  color: var(--text);
}
.search-input::placeholder { color: var(--faint); }
.search-input:focus { outline: none; }

.search-results {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  max-height: 58vh;
  overflow-y: auto;
  scrollbar-width: thin;
}

.search-results li { margin: 0; }

.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  background: none;
  border: 0;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  font-family: var(--sans);
}
.search-hit:hover, .search-hit.is-active { background: var(--orange-wash); }
.search-hit.is-active { outline: 1px solid var(--orange-quiet); }

.search-hit__crumb {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--faint);
  margin-bottom: 0.15rem;
}

.search-hit__title { display: block; color: var(--text); font-size: 0.95rem; font-weight: 500; }

.search-hit__snip {
  display: block;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.45;
  margin-top: 0.2rem;
}

.search-hit mark { background: none; color: var(--orange); font-weight: 600; }

.search-empty { padding: 1.5rem 1.2rem; color: var(--faint); font-size: 0.9rem; text-align: center; }

.search-foot {
  display: flex;
  gap: 1.2rem;
  padding: 0.55rem 1.2rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--faint);
}

/* ---------- Mobile ------------------------------------------------------- */

.nav-toggle { display: none; }

@media (max-width: 1180px) {
  .docs-layout { grid-template-columns: 240px minmax(0, 1fr); gap: 0 2.5rem; }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .docs-layout { grid-template-columns: minmax(0, 1fr); padding: 0 20px; }

  .nav-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    appearance: none;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.55rem 0.9rem;
    margin: 1.2rem 0 0;
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-soft);
    cursor: pointer;
  }

  .sidebar {
    position: static;
    max-height: none;
    padding: 1rem 0 0;
    display: none;
  }
  .sidebar.is-open { display: block; }
  .doc-content { padding-top: 1.2rem; }
  .doc-section > h2 { font-size: 1.6rem; }
  .search-modal { padding: 4vh 0.75rem 1rem; }
}

/* ---------- Page heading -------------------------------------------------- */

.doc-intro {
  padding: 1.4rem 0 0.4rem;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 1rem;
}

.doc-intro h1 {
  font-size: clamp(1.9rem, 3.4vw, 2.5rem);
  letter-spacing: -0.035em;
  margin-bottom: 0.8rem;
}

.doc-intro p {
  color: var(--muted);
  max-width: 68ch;
}

.doc-intro__hint {
  font-size: 0.93rem;
  color: var(--faint) !important;
  padding-left: 1rem;
  border-left: 2px solid var(--orange-quiet);
  margin-bottom: 1.6rem !important;
}
