/* latin-ext */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
/* latin-ext italic */
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/inter-latin-ext-italic.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin italic */
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/inter-latin-italic.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #050810;
  --sidebar-bg: #080d18;
  --surface: rgba(10, 15, 24, 0.6);
  --border: #101b2d;
  --border-glow: rgba(100, 175, 255, 0.08);
  --text: rgba(248, 250, 252, 0.85);
  --muted: #94a3b8;
  --heading: #f8fafc;
  --accent: #529cec;
  --accent-light: #64afff;
  --code-bg: rgba(13, 17, 23, 0.75);
  --code-border: #1a2a3d;
  --sidebar-w: 280px;
  --toc-w: 232px;
  --header-h: 60px;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    system-ui,
    sans-serif;
  font-weight: 400;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-light);
  text-decoration: underline;
}

/* ── Header ────────────────────────────────────────── */

.hdr {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: rgba(5, 8, 16, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glow);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
}

.hdr-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.hdr-logo:hover {
  text-decoration: none;
}

.hdr-logo-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hdr-logo-icon img {
  display: block;
  width: 40px;
  height: 40px;
}

.hdr-logo-brand {
  font-size: 24px;
  font-weight: 1000;
  color: var(--heading);
}

.hdr-logo-product {
  font-size: 24px;
  font-weight: 1000;
  background: linear-gradient(90deg, #64afff, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}


.hdr-back {
  margin-left: auto; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 18px; line-height: 1;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.hdr-back:hover { color: var(--heading); background: rgba(100, 175, 255, 0.06); text-decoration: none; }

/* ── Layout ────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--header-h);
}

/* ── Left sidebar ──────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 20px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.nav-section {
  margin-bottom: 6px;
}

.nav-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 16px 20px 6px;
}

.nav-link {
  display: block;
  padding: 6px 20px;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition:
    color 0.15s,
    background 0.15s,
    border-color 0.15s;
  line-height: 1.4;
}
.nav-link:hover {
  color: var(--heading);
  background: rgba(100, 175, 255, 0.04);
  text-decoration: none;
}
.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(82, 156, 236, 0.08);
}

.lang-select {
  display: block;
  width: calc(100% - 40px);
  margin: 4px 20px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: "Inter", sans-serif;
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.lang-select:focus {
  outline: none;
  border-color: var(--accent);
}
.lang-select option {
  background: #0d1117;
  color: var(--text);
  font-weight: 500;
}

/* ── Main area (content + right TOC) ──────────────── */

.main {
  flex: 1;
  display: flex;
  margin-left: var(--sidebar-w);
  min-width: 0;
}

/* ── Content ───────────────────────────────────────── */

.content {
  flex: 1;
  min-width: 0;
  padding: 52px 56px 96px;
}

/* ── Right TOC ─────────────────────────────────────── */

.toc {
  width: var(--toc-w);
  flex-shrink: 0;
  padding: 52px 0 96px 8px;
  display: none; /* shown via JS when items exist */
}

.toc-inner {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.toc-header {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 10px;
  padding-left: 12px;
}

#toc-list {
  list-style: none;
  border-left: 1px solid var(--border);
}

.toc-item a {
  display: block;
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.45;
  transition: color 0.15s;
  border-left: 2px solid transparent;
  margin-left: -1px;
}
.toc-item a:hover {
  color: var(--heading);
  text-decoration: none;
}
.toc-item a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}
.toc-item--3 a {
  padding-left: 24px;
  font-size: 12px;
}

/* ── Prose ─────────────────────────────────────────── */

.prose {
  max-width: 760px;
}

.prose h1 {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.prose h2 {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.3;
  margin: 48px 0 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.prose h2:first-child {
  margin-top: 0;
  border-top: none;
}
.prose h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--heading);
  margin: 28px 0 8px;
  line-height: 1.35;
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.prose h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--heading);
  margin: 20px 0 6px;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.prose .anchor {
  color: var(--muted);
  margin-left: 8px;
  opacity: 0;
  text-decoration: none;
  font-weight: 400;
  transition: opacity 0.15s;
}
.prose h2:hover .anchor,
.prose h3:hover .anchor,
.prose h4:hover .anchor {
  opacity: 1;
}

.prose p {
  margin: 10px 0;
}
.prose ul,
.prose ol {
  margin: 10px 0 10px 24px;
}
.prose li {
  margin: 4px 0;
}
.prose li > p {
  margin: 3px 0;
}
.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}
.prose strong {
  color: var(--heading);
  font-weight: 600;
}
.prose em {
  font-style: italic;
}

.prose code {
  font-family:
    "SF Mono", "Fira Code", "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: 0.84em;
  background: rgba(146, 151, 179, 0.12);
  color: #b6c1d2;
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
  line-height: 1.6;
  font-size: 0.875rem;
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: #c9d5e8;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.875rem;
}
.prose th {
  background: var(--surface);
  color: var(--heading);
  font-weight: 600;
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.prose td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.prose tr:nth-child(even) td {
  background: rgba(100, 175, 255, 0.02);
}

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  margin: 16px 0;
  color: var(--muted);
  background: rgba(82, 156, 236, 0.06);
  border-radius: 0 4px 4px 0;
}

/* ── Index page ─────────────────────────────────────── */

.page-intro {
  font-size: 1.05rem;
  color: var(--text);
  margin: 14px 0 40px;
  line-height: 1.75;
  max-width: 580px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  text-decoration: none;
  display: block;
  transition:
    border-color 0.2s,
    transform 0.2s,
    box-shadow 0.2s;
}
.card:hover {
  border-color: rgba(82, 156, 236, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(82, 156, 236, 0.12);
  text-decoration: none;
}
.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 6px;
}
.card-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Pagination ─────────────────────────────────────── */

.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  gap: 16px;
}
.pagination-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  min-width: 180px;
  max-width: 260px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition:
    border-color 0.2s,
    background 0.2s;
  flex: 1;
}
.pagination-link:hover {
  border-color: rgba(82, 156, 236, 0.4);
  background: rgba(82, 156, 236, 0.04);
  text-decoration: none;
  color: var(--text);
}
.pagination-link--next {
  align-items: flex-end;
  margin-left: auto;
}
.pagination-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.pagination-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--heading);
}

/* ── Syntax highlighting (Material theme) ───────────── */

.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in {
  color: #c792ea;
}
.hljs-string {
  color: #c3e88d;
}
.hljs-attr {
  color: #ffcb6b;
}
.hljs-number,
.hljs-literal {
  color: #f78c6c;
}
.hljs-comment {
  color: #546e7a;
  font-style: italic;
}
.hljs-function,
.hljs-title,
.hljs-title.function_ {
  color: #82aaff;
}
.hljs-params {
  color: #d6deeb;
}
.hljs-type,
.hljs-class {
  color: #ffcb6b;
}
.hljs-meta {
  color: #89ddff;
}
.hljs-variable {
  color: #f07178;
}
.hljs-operator,
.hljs-punctuation {
  color: #89ddff;
}
.hljs-property {
  color: #80cbc4;
}
.hljs-tag {
  color: #f07178;
}
.hljs-deletion {
  color: #ef5350;
}
.hljs-addition {
  color: #c3e88d;
}
.hljs-section {
  color: #82aaff;
  font-weight: 600;
}
.hljs-bullet {
  color: #f78c6c;
}
.hljs-link {
  color: #80cbc4;
}

/* ── Platform Tabs ──────────────────────────────────── */

.ptabs { margin: 20px 0; }

.ptabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.ptabs-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.ptabs-btn:hover { color: var(--text); }
.ptabs-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.ptabs-pane { display: none; }
.ptabs-pane.active { display: block; }

.ptabs-body p { margin: 12px 0 4px; }
.ptabs-body p:first-child { margin-top: 12px; }

/* ── Snippet Pack Pills + Copy ──────────────────────── */

.snippet-tabs { margin: 20px 0; }

.snippet-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.snippet-tab-btn {
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.snippet-tab-btn:hover {
  color: var(--heading);
  border-color: var(--accent);
}
.snippet-tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.snippet-tab-pane { display: none; }
.snippet-tab-pane.active { display: block; }

.snippet-copy-wrap { position: relative; }

.snippet-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  padding: 4px 10px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.snippet-copy-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.snippet-copy-btn.copied { background: var(--accent); color: #fff; border-color: var(--accent); }

.snippet-copy-wrap pre { margin-top: 0; max-height: 480px; overflow: auto; }

/* ── Hamburger button ───────────────────────────────── */

.hdr-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  margin-right: 4px;
  flex-shrink: 0;
  transition: background-color 0.15s;
}
.hdr-menu-btn:hover {
  background: rgba(100, 175, 255, 0.06);
}
.hdr-menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background-color: var(--text);
  border-radius: 2px;
  transition: background-color 0.15s;
}
.hdr-menu-btn:hover span {
  background: var(--heading);
}

/* ── Sidebar overlay ────────────────────────────────── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 98;
}
.sidebar-overlay.active {
  display: block;
}

/* ── Mobile ─────────────────────────────────────────── */

@media (max-width: 1200px) {
  .toc {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .hdr-menu-btn {
    display: flex;
  }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 99;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .content {
    padding: 32px 20px 64px;
  }
  .prose h1 {
    font-size: 1.5rem;
  }
  .pagination {
    flex-direction: column;
  }
  .pagination-link {
    max-width: 100%;
  }
}
