/* syntaqlite docs */

/* ------------------------------------------------------------------ */
/* Variables                                                          */
/* ------------------------------------------------------------------ */

:root, [data-theme="dark"] {
  /* Colors */
  --c-bg: #1a1d1e;
  --c-surface: #232729;
  --c-fg: #d4d8d6;
  --c-muted: #8a8f8c;
  --c-accent: #d4826a;
  --c-accent-hover: #c0715a;
  --c-border: #353a3c;
  --c-border-strong: #4a5052;
  --c-code-bg: #1c2021;

  /* Diagnostics */
  --c-diag-error: #e06c60;
  --c-diag-warn: #d4a656;
  --c-diag-help: #6ab0a3;

  /* Syntax highlighting (Prism token overrides) */
  --c-syn-comment: #6a737d;
  --c-syn-keyword: #c792ea;
  --c-syn-string: #a3be8c;
  --c-syn-number: #f78c6c;
  --c-syn-function: #82aaff;
  --c-syn-operator: #89ddff;
  --c-syn-punctuation: #8a8f8c;
  --c-syn-builtin: #ffcb6b;

  /* Typography */
  --text-xs: 0.75rem;
  --text-sm: 0.85rem;
  --text-base: 0.9rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.75rem;
  --text-code: 0.875em;
  --text-pre: 0.85rem;

  /* Font stacks */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "Fira Code", monospace;

  /* Spacing */
  --sp-xs: 0.25rem;
  --sp-sm: 0.5rem;
  --sp-md: 0.75rem;
  --sp-lg: 1rem;
  --sp-xl: 1.5rem;
  --sp-2xl: 2rem;

  /* Layout */
  --sidebar-w: 220px;
  --nav-h: 52px;
  --max-w: 1200px;
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 8px;
}

[data-theme="light"] {
  --c-bg: #fff;
  --c-surface: #f3f4f6;
  --c-fg: #1a1a1a;
  --c-muted: #666;
  --c-accent: #c0715a;
  --c-accent-hover: #a8614d;
  --c-border: #e5e7eb;
  --c-border-strong: #d1d5db;
  --c-code-bg: #f7f7f8;

  --c-syn-comment: #6a737d;
  --c-syn-keyword: #d73a49;
  --c-syn-string: #22863a;
  --c-syn-number: #005cc5;
  --c-syn-function: #6f42c1;
  --c-syn-operator: #d73a49;
  --c-syn-punctuation: #666;
  --c-syn-builtin: #e36209;
}

/* ------------------------------------------------------------------ */
/* Reset                                                              */
/* ------------------------------------------------------------------ */

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

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--c-fg);
  background: var(--c-bg);
}

/* ------------------------------------------------------------------ */
/* Content — shared styles for .home and article                      */
/* ------------------------------------------------------------------ */

.home h1, article h1 { font-size: var(--text-xl); font-weight: 700; margin-bottom: var(--sp-xl); }
.home h2, article h2 { font-size: var(--text-lg); font-weight: 600; margin: var(--sp-2xl) 0 var(--sp-md); }
.home h3, article h3 { font-size: var(--text-md); font-weight: 600; margin: var(--sp-xl) 0 var(--sp-sm); }

.home p,  article p  { margin-bottom: var(--sp-lg); }
.home ul, article ul,
.home ol, article ol { margin: 0 0 var(--sp-lg) var(--sp-xl); }
.home li, article li { margin-bottom: var(--sp-xs); }

.home strong, article strong { color: var(--c-fg); }

.home a,  article a  { color: var(--c-accent); text-decoration: none; }
.home a:hover, article a:hover { color: var(--c-accent-hover); }

.home code, article code {
  font-family: var(--font-mono);
  font-size: var(--text-code);
  background: var(--c-surface);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  color: var(--c-fg);
}

.home pre, article pre {
  background: var(--c-code-bg);
  color: var(--c-fg);
  border: 1px solid var(--c-border);
  padding: var(--sp-lg) var(--sp-xl);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: var(--sp-lg);
  font-size: var(--text-pre);
  font-family: var(--font-mono);
  line-height: 1.5;
}

.home pre code, article pre code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
  font-size: inherit;
}

.home li { margin-bottom: var(--sp-sm); }

article table { width: 100%; border-collapse: collapse; margin-bottom: var(--sp-lg); font-size: var(--text-base); }
article th, article td { text-align: left; padding: var(--sp-sm) var(--sp-md); border-bottom: 1px solid var(--c-border); }
article th { font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--c-muted); }
article td code { font-size: var(--text-code); }

article hr { border: none; border-top: 1px solid var(--c-border); margin: var(--sp-2xl) 0; }
article blockquote { border-left: 3px solid var(--c-border-strong); padding-left: var(--sp-lg); color: var(--c-muted); margin-bottom: var(--sp-lg); }

/* ------------------------------------------------------------------ */
/* Label — reusable uppercase muted caption                           */
/* ------------------------------------------------------------------ */

.label,
.home-example__label,
aside h3,
article th,
.mobile-section-header {
  font-family: var(--font);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
}

/* ------------------------------------------------------------------ */
/* Card — reusable bordered link block                                */
/* ------------------------------------------------------------------ */

.entry-card,
.section-page-link {
  display: block;
  padding: var(--sp-lg) var(--sp-xl);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--c-fg);
  transition: border-color 0.15s;
}

.entry-card:hover,
.section-page-link:hover { border-color: var(--c-accent); }

.entry-card__title,
.section-page-link__title {
  display: block;
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: var(--sp-xs);
}

.entry-card__desc,
.section-page-link__desc {
  display: block;
  font-size: var(--text-sm);
  color: var(--c-muted);
  line-height: 1.4;
}

.section-page-link { border-radius: var(--radius); }
.section-page-link__desc { margin-top: 0.15rem; }

/* ------------------------------------------------------------------ */
/* Nav header                                                         */
/* ------------------------------------------------------------------ */

header {
  position: sticky;
  top: 0;
  height: var(--nav-h);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg);
  z-index: 10;
}

header nav {
  display: flex;
  align-items: center;
  gap: var(--sp-2xl);
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--sp-xl);
  height: 100%;
}

.site-title {
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--c-fg);
  text-decoration: none;
}

header nav ul {
  display: flex;
  gap: var(--sp-xl);
  list-style: none;
  flex: 1;
}

header nav ul a {
  color: var(--c-muted);
  text-decoration: none;
  font-size: var(--text-base);
}

header nav ul a:hover { color: var(--c-fg); }

/* ------------------------------------------------------------------ */
/* Nav icons                                                          */
/* ------------------------------------------------------------------ */

.nav-icons {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-left: auto;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  color: var(--c-muted);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.nav-icon:hover { color: var(--c-fg); background: var(--c-surface); }

.nav-icon--labeled {
  width: auto;
  gap: 0.35rem;
  padding: 0 var(--sp-sm);
  font-size: var(--text-sm);
}

/* ------------------------------------------------------------------ */
/* Version switcher                                                   */
/* ------------------------------------------------------------------ */

.version-switcher { position: relative; }

.version-switcher__btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: var(--sp-xs) 0.6rem;
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--c-muted);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.version-switcher__btn:hover { color: var(--c-fg); border-color: var(--c-border-strong); }

.version-switcher__menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 120px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--sp-xs) 0;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.version-switcher__menu.open { display: block; }

.version-switcher__menu a {
  display: block;
  padding: 0.35rem var(--sp-md);
  font-size: var(--text-sm);
  color: var(--c-muted);
  text-decoration: none;
  transition: color 0.1s, background 0.1s;
}

.version-switcher__menu a:hover { color: var(--c-fg); background: var(--c-bg); }
.version-switcher__menu a.active { color: var(--c-accent); font-weight: 500; }

/* Theme toggle */
[data-theme="dark"]  .icon-sun  { display: block; }
[data-theme="dark"]  .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ------------------------------------------------------------------ */
/* Layout                                                             */
/* ------------------------------------------------------------------ */

.layout {
  display: flex;
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: calc(100vh - var(--nav-h));
}

aside {
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: var(--sp-2xl) var(--sp-lg) var(--sp-2xl) var(--sp-xl);
  border-right: 1px solid var(--c-border);
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}

aside h3 { margin-bottom: var(--sp-md); }
aside h3 a { color: inherit; text-decoration: none; }
aside h3 a:hover { color: var(--c-fg); }

aside ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

aside ul a {
  display: block;
  padding: 0.3rem var(--sp-sm);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--c-muted);
  text-decoration: none;
}

aside ul a:hover { color: var(--c-fg); background: var(--c-surface); }
aside ul a.active { color: var(--c-accent); font-weight: 500; }

main {
  flex: 1;
  padding: 2.5rem 3rem;
  min-width: 0;
}

/* ------------------------------------------------------------------ */
/* Home — example columns                                             */
/* ------------------------------------------------------------------ */

.home-example {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-md);
  margin: var(--sp-xl) 0;
}

.home-example__col { min-width: 0; }
.home-example__label { margin-bottom: 0.4rem; }

.home-example__note {
  font-size: var(--text-sm);
  color: var(--c-muted);
  margin-top: var(--sp-sm);
}

/* ------------------------------------------------------------------ */
/* Home — feature blocks                                              */
/* ------------------------------------------------------------------ */

.home-feature {
  margin: var(--sp-md) 0;
  padding: var(--sp-xl);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  min-width: 0;
  overflow: hidden;
}

.home-feature h3 { margin: 0 0 var(--sp-sm); }
.home-feature p { margin-bottom: 0; }
.home-feature p + pre { margin-top: var(--sp-lg); }
.home-feature pre { margin: 0; }

.home-feature ul {
  margin: var(--sp-lg) 0 0 var(--sp-xl);
  color: var(--c-muted);
  font-size: var(--text-base);
}

.home-feature .home-example,
.home-feature .home-diagnostic {
  margin-top: var(--sp-lg);
  margin-bottom: 0;
}

.home-feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-md);
  margin: var(--sp-md) 0 var(--sp-2xl);
}

/* ------------------------------------------------------------------ */
/* Home — diagnostics                                                 */
/* ------------------------------------------------------------------ */

.home-diagnostic { margin: var(--sp-2xl) 0; }
.home-diagnostic pre + pre { margin-top: var(--sp-md); }
.home-diagnostic__output { background: var(--c-code-bg); }

.diag-error     { color: var(--c-diag-error); font-weight: 600; }
.diag-warning   { color: var(--c-diag-warn);  font-weight: 600; }
.diag-underline { color: var(--c-diag-error); }
.diag-help      { color: var(--c-diag-help); }

/* ------------------------------------------------------------------ */
/* Home — entry card grid                                             */
/* ------------------------------------------------------------------ */

.entry-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}

.entry-card--playground { grid-column: 1 / -1; border-color: var(--c-accent); }
.entry-card--playground .entry-card__title { color: var(--c-accent); }

.home h2:last-of-type { margin-top: 2.5rem; }

/* ------------------------------------------------------------------ */
/* Home — tag badge                                                   */
/* ------------------------------------------------------------------ */

.home-tag {
  font-size: 0.65em;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--c-accent);
  color: #fff;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

/* ------------------------------------------------------------------ */
/* Section overview                                                   */
/* ------------------------------------------------------------------ */

.section-pages {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  margin-top: var(--sp-xl);
}

/* ------------------------------------------------------------------ */
/* Tabs                                                               */
/* ------------------------------------------------------------------ */

.tabs { margin-bottom: var(--sp-lg); }

.tab-buttons {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--c-border);
}

.tab-buttons button {
  font-family: var(--font);
  font-size: var(--text-sm);
  padding: var(--sp-sm) var(--sp-lg);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--c-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab-buttons button:hover { color: var(--c-fg); }
.tab-buttons button.active { color: var(--c-accent); border-bottom-color: var(--c-accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel pre { border-top-left-radius: 0; border-top-right-radius: 0; margin-top: 0; }

/* ------------------------------------------------------------------ */
/* Hamburger (mobile only)                                            */
/* ------------------------------------------------------------------ */

.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: var(--c-fg);
  cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Syntax highlighting — Prism token colors                           */
/* ------------------------------------------------------------------ */

pre[class*="language-"],
code[class*="language-"] {
  background: var(--c-code-bg);
  color: var(--c-fg);
}

.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--c-syn-comment); }
.token.punctuation { color: var(--c-syn-punctuation); }
.token.keyword, .token.tag, .token.boolean, .token.constant { color: var(--c-syn-keyword); }
.token.string, .token.char, .token.attr-value { color: var(--c-syn-string); }
.token.number { color: var(--c-syn-number); }
.token.function { color: var(--c-syn-function); }
.token.operator, .token.entity, .token.url { color: var(--c-syn-operator); }
.token.builtin, .token.class-name { color: var(--c-syn-builtin); }
.token.variable { color: var(--c-fg); }

/* ------------------------------------------------------------------ */
/* Scrollbar                                                          */
/* ------------------------------------------------------------------ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-muted); }

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

@media (max-width: 768px) {
  body { overflow-x: hidden; }

  .hamburger { display: flex; }

  header nav { gap: var(--sp-md); padding: 0 var(--sp-lg); }

  header nav ul {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    padding: var(--sp-md) var(--sp-xl);
    gap: var(--sp-xs);
    z-index: 15;
  }

  header nav ul.open { display: flex; }
  header nav ul a { font-size: var(--text-base); padding: 0.4rem 0; }
  header nav ul a.active { color: var(--c-accent); }

  .mobile-section-divider {
    border-top: 1px solid var(--c-border);
    margin: var(--sp-sm) 0;
    list-style: none;
  }

  .mobile-section-header {
    padding: 0.4rem 0 0.2rem;
    list-style: none;
  }

  .version-switcher { display: none; }
  .nav-icon--labeled span { display: none; }

  aside { display: none; }

  main { padding: var(--sp-xl) var(--sp-lg); min-width: 0; }

  .home h1, article h1 { font-size: 1.35rem; }
  .home h2, article h2 { font-size: 1.1rem; }

  .home-example,
  .home-feature-grid,
  .entry-cards { grid-template-columns: 1fr; }

  .home-feature { padding: var(--sp-lg); }

  .home-example__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .home pre, article pre {
    padding: var(--sp-md) var(--sp-lg);
    font-size: 0.8rem;
  }

  article table { display: block; overflow-x: auto; }

  .entry-card, .section-page-link { padding: var(--sp-md) var(--sp-lg); }
}
