/* ==========================================================================
   better-seo.js docs — professional foss doc site
   Monospace · griddy · sharp · mobile-first · dark/light theme
   Zero deps. Zero build. Pure static.
   ========================================================================== */

/* --- Font loading --- */
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700;800&display=swap");

/* --- CSS custom properties: DARK (default) --- */
:root {
  --bg: #0a0a0a;
  --bg-secondary: #111;
  --bg-card: #141414;
  --bg-card-hover: #1e1e1e;
  --bg-code: #0d0d0d;
  --bg-nav: rgba(10, 10, 10, 0.85);
  --bg-inline-code: #1a1a1a;
  --bg-copy-btn: #222;

  --border: #2a2a2a;
  --border-light: #333;
  --accent: #00ff9d;
  --accent-dim: #00cc7d;
  --accent-bg: rgba(0, 255, 157, 0.06);

  --text: #e5e5e5;
  --text-secondary: #b0b0b0;
  --text-dim: #888;
  --text-muted: #555;
  --text-heading: #fff;

  --mono: "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --sidebar-w: 280px;
  --header-h: 60px;

  /* Syntax highlighting (dark) */
  --syn-keyword: #ff79c6;
  --syn-string: #50fa7b;
  --syn-comment: #6272a4;
  --syn-function: #8be9fd;
  --syn-number: #bd93f9;
  --syn-type: #8be9fd;
  --syn-operator: #ff79c6;
  --syn-punctuation: #f8f8f2;
  --syn-property: #50fa7b;
  --syn-tag: #ff79c6;
  --syn-attr: #50fa7b;
  --syn-value: #f1fa8c;
  --syn-decorator: #ffb86c;
  --syn-regex: #ff5555;
  --syn-builtin: #8be9fd;
  --syn-variable: #f8f8f2;
  --syn-boolean: #bd93f9;
  --syn-null: #ff79c6;
}

/* --- LIGHT theme --- */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-secondary: #f7f7f7;
  --bg-card: #fafafa;
  --bg-card-hover: #f0f0f0;
  --bg-code: #f6f8fa;
  --bg-nav: rgba(255, 255, 255, 0.9);
  --bg-inline-code: #f0f0f0;
  --bg-copy-btn: #e0e0e0;

  --border: #e0e0e0;
  --border-light: #d0d0d0;
  --accent: #00b36b;
  --accent-dim: #009960;
  --accent-bg: rgba(0, 179, 107, 0.06);

  --text: #1a1a1a;
  --text-secondary: #444;
  --text-dim: #666;
  --text-muted: #999;
  --text-heading: #000;

  /* Syntax highlighting (light) */
  --syn-keyword: #d73a49;
  --syn-string: #032f62;
  --syn-comment: #6a737d;
  --syn-function: #6f42c1;
  --syn-number: #005cc5;
  --syn-type: #d73a49;
  --syn-operator: #d73a49;
  --syn-punctuation: #24292e;
  --syn-property: #005cc5;
  --syn-tag: #22863a;
  --syn-attr: #005cc5;
  --syn-value: #032f62;
  --syn-decorator: #e36209;
  --syn-regex: #e36209;
  --syn-builtin: #005cc5;
  --syn-variable: #24292e;
  --syn-boolean: #005cc5;
  --syn-null: #d73a49;
}

/* --- Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-radius: 0 !important;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--mono);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

/* --- Background grid --- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(128, 128, 128, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(128, 128, 128, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

/* --- Links --- */
a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}
a:hover {
  border-bottom-color: var(--accent);
}

/* --- Selection --- */
::selection {
  background: var(--accent);
  color: var(--bg);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   LAYOUT
   ========================================================================== */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.site-logo {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-heading);
  letter-spacing: -0.02em;
  border-bottom: none;
}
.site-logo:hover {
  border-bottom-color: transparent;
}
.site-logo span {
  color: var(--accent);
}

.header-right {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}
.header-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}
.header-links a {
  font-size: 0.875rem;
  color: var(--text-dim);
  border-bottom: none;
  font-weight: 500;
}
.header-links a:hover {
  color: var(--accent);
  border-bottom-color: transparent;
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

/* Mobile menu button */
.menu-toggle {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  font-family: var(--mono);
}
.menu-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.25rem 0;
  z-index: 50;
  transition: transform 0.2s ease;
}

.sidebar-section {
  margin-bottom: 0.25rem;
}

.sidebar-heading {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0.75rem 1.25rem 0.35rem;
}

.sidebar-link {
  display: block;
  padding: 0.4rem 1.25rem 0.4rem 1.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  border-bottom: none;
  line-height: 1.4;
}
.sidebar-link:hover {
  background: var(--accent-bg);
  color: var(--accent);
  border-left-color: var(--accent);
}
.sidebar-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
  background: var(--accent-bg);
}

/* --- Main content --- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2.5rem 3rem 5rem;
  max-width: 960px;
  min-width: 0;
}

/* --- Typography --- */
h1,
h2,
h3,
h4 {
  font-family: var(--sans);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.025em;
  color: var(--text-heading);
}
h1 {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  margin-bottom: 1rem;
}
h2 {
  font-size: clamp(1.375rem, 3.5vw, 1.75rem);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin: 2.5rem 0 1rem;
}
h3 {
  font-size: clamp(1.125rem, 2.5vw, 1.375rem);
  margin: 2rem 0 0.75rem;
}
h4 {
  font-size: 1.0625rem;
  margin: 1.5rem 0 0.5rem;
}

p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}
strong {
  color: var(--text);
  font-weight: 600;
}

/* --- Inline code --- */
code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--bg-inline-code);
  border: 1px solid var(--border);
  padding: 0.15em 0.4em;
  color: var(--accent-dim);
}

/* --- Code blocks --- */
.code-block-wrapper {
  position: relative;
  margin-bottom: 1.5rem;
}
pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.7;
  font-family: var(--mono);
  color: var(--text);
}
pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Syntax highlighting */
pre .token-keyword {
  color: var(--syn-keyword);
}
pre .token-string {
  color: var(--syn-string);
}
pre .token-comment {
  color: var(--syn-comment);
  font-style: italic;
}
pre .token-function {
  color: var(--syn-function);
}
pre .token-number {
  color: var(--syn-number);
}
pre .token-type {
  color: var(--syn-type);
}
pre .token-operator {
  color: var(--syn-operator);
}
pre .token-punctuation {
  color: var(--syn-punctuation);
}
pre .token-property {
  color: var(--syn-property);
}
pre .token-tag {
  color: var(--syn-tag);
}
pre .token-attr-name {
  color: var(--syn-attr);
}
pre .token-attr-value {
  color: var(--syn-value);
}
pre .token-decorator {
  color: var(--syn-decorator);
}
pre .token-regex {
  color: var(--syn-regex);
}
pre .token-builtin {
  color: var(--syn-builtin);
}
pre .token-variable {
  color: var(--syn-variable);
}
pre .token-boolean {
  color: var(--syn-boolean);
}
pre .token-null {
  color: var(--syn-null);
}

/* Copy button */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-copy-btn);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
  z-index: 2;
}
.code-block-wrapper:hover .copy-btn {
  opacity: 1;
}
.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.copy-btn.copied {
  color: var(--accent);
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 1.5rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}
th,
td {
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  text-align: left;
}
th {
  background: var(--bg-card);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
td {
  background: var(--bg-card);
}
tr:hover td {
  background: var(--bg-card-hover);
}

/* --- Blockquote --- */
blockquote {
  border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  background: var(--accent-bg);
  color: var(--text-secondary);
  font-style: italic;
}

/* --- Lists --- */
ul,
ol {
  padding-left: 1.75rem;
  margin-bottom: 1.25rem;
}
li {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  line-height: 1.6;
}

/* --- Feature grid (landing page) --- */
.feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 2rem;
}
.feature-card {
  background: var(--bg-card);
  padding: 1.5rem;
  transition: background 0.15s ease;
}
.feature-card:hover {
  background: var(--bg-card-hover);
}
.feature-card h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text-heading);
}
.feature-card p {
  font-size: 0.9375rem;
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
}
.feature-card .tag {
  display: inline-block;
  font-size: 0.6875rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.15rem 0.5rem;
  margin-top: 0.75rem;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.breadcrumbs a {
  color: var(--text-muted);
  font-size: 0.8125rem;
}
.breadcrumbs a:hover {
  color: var(--accent);
}
.breadcrumbs span {
  margin: 0 0.375rem;
  opacity: 0.5;
}

/* --- Hero stats (landing) --- */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.hero-stat {
  background: var(--bg-card);
  padding: 1.25rem 1rem;
  text-align: center;
}
.hero-stat strong {
  display: block;
  font-size: 1.75rem;
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
}
.hero-stat small {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-top: 0.25rem;
}

/* --- Next/prev navigation --- */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.page-nav a {
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  max-width: 48%;
}
.page-nav a:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}
.page-nav a.next {
  text-align: right;
  margin-left: auto;
}
.page-nav .nav-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.page-nav .nav-title {
  color: var(--accent);
  font-weight: 600;
}

/* --- Footer --- */
.site-footer {
  margin-left: var(--sidebar-w);
  border-top: 1px solid var(--border);
  padding: 2rem 3rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.site-footer a {
  color: var(--text-dim);
  font-size: 0.8125rem;
}
.site-footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

/* ==========================================================================
   MOBILE-FIRST RESPONSIVE
   ========================================================================== */

@media (max-width: 767px) {
  :root {
    --header-h: 56px;
    --sidebar-w: 0px;
  }
  html {
    font-size: 16px;
  }

  .menu-toggle {
    display: block;
  }
  .header-links {
    display: none;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 300px;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-h);
    background: rgba(0, 0, 0, 0.6);
    z-index: 40;
  }
  .sidebar-overlay.visible {
    display: block;
  }

  .main-content {
    padding: 1.5rem 1.25rem 3rem;
    max-width: 100%;
  }
  .site-footer {
    margin-left: 0;
    padding: 1.5rem 1.25rem;
  }

  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .feature-grid {
    grid-template-columns: 1fr;
  }
  .page-nav {
    flex-direction: column;
  }
  .page-nav a {
    max-width: 100%;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  pre {
    font-size: 0.8125rem;
    padding: 1rem;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .main-content {
    padding: 2rem 2rem 4rem;
  }
}

@media (min-width: 1024px) {
  .feature-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --- Focus visible --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Print --- */
@media print {
  body::before,
  .sidebar,
  .site-header,
  .site-footer,
  .copy-btn {
    display: none;
  }
  .main-content {
    margin-left: 0;
    max-width: none;
  }
  a {
    color: var(--text);
  }
  pre {
    white-space: pre-wrap;
    word-break: break-word;
  }
}
