@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-subtle: #ecfdf5;
  --bg: #ffffff;
  --bg-surface: #f8fafc;
  --bg-code: #1e1e2e;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-code: #d4d4d8;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
  --topbar-height: 52px;
  --sidebar-width: 240px;
  --toc-width: 200px;
  --radius: 8px;
  --radius-sm: 6px;
}

html.dark {
  --primary: #34d399;
  --primary-hover: #6ee7b7;
  --primary-subtle: rgba(16, 185, 129, 0.1);
  --bg: #0a0a0a;
  --bg-surface: #141414;
  --bg-code: #161616;
  --text: #e5e5e5;
  --text-secondary: #a0a0a0;
  --text-code: #d4d4d8;
  --border: #262626;
  --border-subtle: #1a1a1a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-hover);
}

::selection {
  background: var(--primary);
  color: #fff;
}

/* ------------------------------------------------------------------ */
/* Top Bar                                                            */
/* ------------------------------------------------------------------ */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 1.25rem;
  z-index: 100;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1;
}

.topbar-btn:hover {
  color: var(--text);
  border-color: var(--primary);
  text-decoration: none;
}

.topbar-btn svg {
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ */
/* Sidebar                                                            */
/* ------------------------------------------------------------------ */

.sidebar {
  width: var(--sidebar-width);
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 50;
}

.sidebar-brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  padding: 0 0.5rem;
}

.sidebar nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar nav a {
  display: block;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.sidebar nav a:hover {
  color: var(--text);
  background: var(--border-subtle);
  text-decoration: none;
}

.sidebar nav a.active {
  color: var(--primary);
  background: var(--primary-subtle);
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Table of Contents (right sidebar)                                  */
/* ------------------------------------------------------------------ */

.toc {
  width: var(--toc-width);
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  bottom: 0;
  padding: 1.5rem 1rem 1.5rem 0;
  overflow-y: auto;
  z-index: 50;
}

.toc-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 0 0 0.6rem 0.75rem;
}

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

.toc a {
  display: block;
  padding: 0.25rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: all 0.15s ease;
  text-decoration: none;
}

.toc a:hover {
  color: var(--text);
}

.toc a.active {
  color: var(--primary);
  border-left-color: var(--primary);
}

/* ------------------------------------------------------------------ */
/* Main content                                                       */
/* ------------------------------------------------------------------ */

.content {
  margin-left: var(--sidebar-width);
  margin-right: var(--toc-width);
  max-width: 54rem;
  padding: calc(var(--topbar-height) + 2.5rem) 3rem 4rem;
}

/* ------------------------------------------------------------------ */
/* Typography                                                         */
/* ------------------------------------------------------------------ */

h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

h1 + p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-top: 3rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  scroll-margin-top: calc(var(--topbar-height) + 1.5rem);
}

h2 .anchor {
  color: var(--border);
  font-weight: 400;
  font-size: 1rem;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

h2:hover .anchor {
  opacity: 1;
  color: var(--primary);
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--topbar-height) + 1.5rem);
}

p {
  margin-bottom: 0.85rem;
}

ul,
ol {
  margin-left: 1.5rem;
  margin-bottom: 0.85rem;
}

li {
  margin-bottom: 0.35rem;
}

strong {
  font-weight: 600;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ------------------------------------------------------------------ */
/* Inline code                                                        */
/* ------------------------------------------------------------------ */

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-weight: 500;
}

/* ------------------------------------------------------------------ */
/* Code blocks                                                        */
/* ------------------------------------------------------------------ */

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-md);
  line-height: 1.6;
}

html.dark pre {
  border-color: #2a2a2a;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.84rem;
  color: var(--text-code);
  font-weight: 400;
}

/* Styled scrollbar for code blocks */
pre::-webkit-scrollbar {
  height: 6px;
}

pre::-webkit-scrollbar-track {
  background: transparent;
}

pre::-webkit-scrollbar-thumb {
  background: #4a4a5a;
  border-radius: 3px;
}

pre::-webkit-scrollbar-thumb:hover {
  background: #5a5a6a;
}

.method-sig::-webkit-scrollbar {
  height: 6px;
}

.method-sig::-webkit-scrollbar-track {
  background: transparent;
}

.method-sig::-webkit-scrollbar-thumb {
  background: #4a4a5a;
  border-radius: 3px;
}

/* Firefox scrollbar */
pre,
.method-sig {
  scrollbar-width: thin;
  scrollbar-color: #4a4a5a transparent;
}

/* ------------------------------------------------------------------ */
/* Highlight.js overrides                                             */
/* ------------------------------------------------------------------ */

pre code.hljs {
  background: transparent !important;
  padding: 0 !important;
}

.hljs {
  background: transparent !important;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

th,
td {
  padding: 0.65rem 1rem;
  text-align: left;
}

th {
  background: var(--bg-surface);
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  border-bottom: 1px solid var(--border-subtle);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg-surface);
}

/* ------------------------------------------------------------------ */
/* Callout                                                            */
/* ------------------------------------------------------------------ */

.callout {
  border-left: 3px solid var(--primary);
  background: var(--primary-subtle);
  padding: 0.85rem 1.15rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ------------------------------------------------------------------ */
/* Method signatures                                                  */
/* ------------------------------------------------------------------ */

.method-sig {
  background: var(--bg-code);
  color: var(--text-code);
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  margin-bottom: 0.75rem;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

html.dark .method-sig {
  border-color: #2a2a2a;
}

/* ------------------------------------------------------------------ */
/* Badges                                                             */
/* ------------------------------------------------------------------ */

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.badges img {
  height: 22px;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

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

  .content {
    margin-right: 0;
  }
}

@media (max-width: 860px) {
  .topbar {
    padding-left: 1.25rem;
  }

  .sidebar {
    position: static;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    gap: 0.75rem;
  }

  .sidebar nav ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .content {
    margin-left: 0;
    padding: calc(var(--topbar-height) + 1.5rem) 1.25rem 3rem;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.6rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  .content {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  pre {
    padding: 1rem;
    border-radius: var(--radius-sm);
  }

  table {
    font-size: 0.8rem;
  }

  th,
  td {
    padding: 0.5rem 0.6rem;
  }
}
