/* Documentation layout. Sidebar, content column, on this page rail.
   Every colour is a token from theme.css. */

body {
  overflow-y: scroll;
}

/* The base theme turns selection off, which is right for an app and wrong
   for documentation. */
.article, .article * {
  -webkit-user-select: text;
  user-select: text;
}

/* ---- topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface-strong);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--surface-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  background: var(--brand-fill);
  color: var(--on-brand);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-name { font-size: 1rem; color: var(--brand-ink); }
.brand-tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-fill-strong);
  color: var(--on-brand);
}

.topbar-spacer { flex: 1; }

/* ---- search ---- */
.search { position: relative; width: min(360px, 42vw); }
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
}
.search-field svg { width: 16px; height: 16px; color: var(--muted-strong); }
.search-field input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  color: var(--ink);
  font-size: 0.88rem;
  outline: none;
}
.search-field input::placeholder { color: var(--muted-strong); opacity: 1; }
.search-field:focus-within { border-color: var(--brand-ink); }
.search-hint {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  color: var(--muted-strong);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface-strong);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow);
  z-index: 40;
}
.search-results.hidden { display: none; }

.search-hit {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.15s ease;
}
.search-hit:hover { background: var(--brand-fill); }
.search-hit:hover .search-hit-title,
.search-hit:hover .search-hit-section,
.search-hit:hover .search-hit-excerpt { color: var(--on-brand); }
.search-hit-title { display: block; font-size: 0.88rem; color: var(--ink); }
.search-hit-section { display: block; font-size: 0.72rem; color: var(--brand-ink); }
.search-hit-excerpt {
  display: block;
  font-size: 0.76rem;
  color: var(--muted-strong);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.search-empty { padding: 10px; font-size: 0.84rem; color: var(--muted-strong); }

/* ---- shell ---- */
.shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 210px;
  gap: 24px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 16px;
  align-items: start;
}

/* ---- sidebar ---- */
.sidebar {
  position: sticky;
  top: 61px;
  max-height: calc(100vh - 61px);
  overflow-y: auto;
  padding: 20px 4px 40px;
}
.nav-section { margin-bottom: 18px; }
.nav-section-title {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 6px;
}
.nav-link {
  display: block;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 0.88rem;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--surface); }
.nav-link.active {
  background: var(--brand-fill);
  color: var(--on-brand);
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(10, 15, 12, 0.35);
}
.sidebar-scrim.hidden { display: none; }

/* ---- content ---- */
.content { padding: 24px 0 48px; min-width: 0; }

.breadcrumb {
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.article { min-width: 0; }
.article h1 {
  font-size: 1.75rem;
  color: var(--brand-ink);
  margin-bottom: 14px;
  line-height: 1.25;
}
.article h2 {
  font-size: 1.22rem;
  color: var(--brand-ink);
  margin: 30px 0 10px;
  padding-top: 8px;
  border-top: 1px solid var(--surface-border);
}
.article h3 { font-size: 1.02rem; color: var(--ink); margin: 22px 0 8px; }
.article h4 { font-size: 0.94rem; color: var(--ink); margin: 18px 0 6px; }

.article p { font-size: 0.94rem; line-height: 1.7; color: var(--ink); margin-bottom: 14px; }
.article ul, .article ol { margin: 0 0 14px 20px; }
.article li { font-size: 0.94rem; line-height: 1.7; margin-bottom: 5px; }
.article a { color: var(--brand-ink); }
.article strong { color: var(--ink); }
.article hr { border: none; border-top: 1px solid var(--surface-border); margin: 26px 0; }
.article img { max-width: 100%; border-radius: 14px; }

.article .anchor {
  margin-left: 8px;
  font-size: 0.8em;
  color: var(--muted-strong);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.article h2:hover .anchor,
.article h3:hover .anchor,
.article h4:hover .anchor { opacity: 1; }

.article code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  font-size: 0.86em;
  word-break: break-word;
}

.article pre.code {
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  overflow-x: auto;
  user-select: text;
}
.article pre.code code {
  padding: 0;
  border: none;
  background: none;
  font-size: 0.84rem;
  line-height: 1.6;
  white-space: pre;
  color: var(--ink);
}

.article blockquote {
  padding: 2px 0 2px 14px;
  margin-bottom: 14px;
  border-left: 3px solid var(--brand-fill-strong);
}
.article blockquote p { color: var(--muted); margin-bottom: 6px; }

/* ---- tables ---- */
.table-scroll { overflow-x: auto; margin-bottom: 16px; }
.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 420px;
}
.article th, .article td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--surface-border);
  vertical-align: top;
}
.article th { color: var(--brand-ink); white-space: nowrap; }
.article td { color: var(--ink); }

/* ---- callouts ---- */
.callout {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 14px;
}
.callout-icon svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.callout-body p:last-child { margin-bottom: 0; }
.callout-label { font-size: 0.9rem; }
.callout p, .callout li { font-size: 0.9rem; }

.callout.note { background: color-mix(in srgb, var(--busy) 14%, transparent); }
.callout.note .callout-icon, .callout.note .callout-label { color: var(--busy); }
.callout.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.callout.warn .callout-icon, .callout.warn .callout-label { color: var(--warn); }
.callout.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); }
.callout.ok .callout-icon, .callout.ok .callout-label { color: var(--ok); }

/* ---- pager ---- */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--surface-border);
}
.pager-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  text-decoration: none;
  max-width: 48%;
  transition: transform 0.15s ease, background 0.15s ease;
}
.pager-link:hover { transform: translateY(-1px); background: var(--surface-strong); }
.pager-link svg { width: 17px; height: 17px; color: var(--brand-ink); flex-shrink: 0; }
.pager-link.next { margin-left: auto; text-align: right; }
.pager-body { display: flex; flex-direction: column; min-width: 0; }
.pager-label { font-size: 0.72rem; color: var(--muted); }
.pager-title { font-size: 0.88rem; color: var(--ink); }

/* ---- on this page ---- */
.toc {
  position: sticky;
  top: 61px;
  max-height: calc(100vh - 61px);
  overflow-y: auto;
  padding: 24px 0 40px;
}
.toc.empty { display: none; }
.toc-title {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.toc-link {
  display: block;
  padding: 5px 0 5px 10px;
  border-left: 2px solid var(--surface-border);
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.toc-link:hover { color: var(--brand-ink); border-color: var(--brand-ink); }
.toc-link.level-3 { padding-left: 20px; font-size: 0.78rem; }

/* ---- footer ---- */
.docs-footer {
  padding: 20px 16px 32px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}
.docs-footer .heart { color: #34c759; }
.docs-footer svg { width: 13px; height: 13px; vertical-align: -2px; }

/* ---- chip button, the coffee link ---- */
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--brand-fill);
  border: 1px solid var(--surface-border);
  color: var(--on-brand);
  font-size: 0.83rem;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.15s ease;
}
.chip-btn:link, .chip-btn:visited { color: var(--on-brand); }
.chip-btn:hover { transform: translateY(-1px); background: var(--brand-fill-strong); }
.chip-btn svg { width: 17px; height: 17px; }

#menuBtn { display: none; }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  #menuBtn { display: inline-flex; }
  .shell { grid-template-columns: minmax(0, 1fr); padding: 0 14px; }
  .brand-tag { display: none; }
  .search { width: auto; flex: 1; }
  .search-hint { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 25;
    width: 272px;
    max-height: none;
    padding: 16px 10px 40px;
    background: var(--surface-strong);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border-right: 1px solid var(--surface-border);
    transform: translateX(-100%);
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .sidebar.open { transform: translateX(0); }
}

@media (max-width: 480px) {
  .chip-btn .chip-label { display: none; }
  .chip-btn { padding: 0 11px; }
  .article h1 { font-size: 1.45rem; }
  .pager-link { max-width: 100%; }
  .pager { flex-direction: column; }
  .pager-link.next { margin-left: 0; }
}
