/* ========================================
   BRAIDS DOCS — SHARED STYLES
   Same design tokens as landing page.
   ======================================== */

/* ---------- Design Tokens (dark default) ---------- */
:root {
  --coral: #ff6b6b;
  --coral-light: #ff8e8e;
  --coral-dark: #e85555;
  --midnight: #0f1729;
  --slate: #1a2332;
  --slate-light: #1e2a3a;
  --ghost: #f7f8fa;
  --text: #e2e8f0;
  --text-dark: #1a202c;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.08);
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
  --transition: 0.2s ease;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --content-max: 780px;

  /* Page colors */
  --bg: var(--midnight);
  --bg-sidebar: #0c1220;
  --bg-code: var(--slate);
  --bg-table-stripe: rgba(255, 255, 255, 0.02);
  --text-body: var(--text);
  --text-heading: #fff;
  --text-link: var(--coral-light);
  --border-color: var(--border);
  --inline-code-bg: rgba(255, 107, 107, 0.1);
  --inline-code-text: var(--coral-light);
  --table-header-bg: rgba(255, 255, 255, 0.04);
}

/* ---------- Light theme ---------- */
[data-theme="light"] {
  --bg: #ffffff;
  --bg-sidebar: var(--ghost);
  --bg-code: #f1f5f9;
  --bg-table-stripe: rgba(0, 0, 0, 0.02);
  --text-body: #334155;
  --text-heading: var(--text-dark);
  --text-muted: #64748b;
  --text-link: var(--coral-dark);
  --border-color: #e2e8f0;
  --inline-code-bg: rgba(255, 107, 107, 0.08);
  --inline-code-text: var(--coral-dark);
  --table-header-bg: rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.92);
  border-bottom-color: var(--border-color);
}

[data-theme="light"] .sidebar {
  background: var(--bg-sidebar);
  border-right-color: var(--border-color);
}

[data-theme="light"] .sidebar-link.active {
  background: rgba(255, 107, 107, 0.08);
}

[data-theme="light"] .logo-text {
  color: var(--text-dark);
}

[data-theme="light"] .topbar-github svg {
  color: var(--text-dark);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 24px);
}

body {
  font-family: var(--font-sans);
  color: var(--text-body);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition);
}

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

/* ---------- Topbar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(15, 23, 41, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.topbar-logo svg {
  height: 22px;
  width: auto;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}

.logo-text span {
  color: var(--coral);
}

.logo-docs {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 2px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-left: 4px;
}

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

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  color: var(--coral);
  background: rgba(255, 107, 107, 0.08);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle .icon-sun {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: block;
}

.topbar-github {
  color: var(--text-muted);
  transition: color var(--transition);
  display: flex;
  align-items: center;
}

.topbar-github:hover {
  color: var(--coral);
}

.topbar-github svg {
  width: 22px;
  height: 22px;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
  background: none;
  border: none;
  cursor: pointer;
}

.hamburger span {
  width: 20px;
  height: 2px;
  background: var(--text-body);
  border-radius: 1px;
  transition: transform var(--transition), opacity var(--transition);
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 24px 0;
  z-index: 90;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.06) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-heading {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 24px 4px;
}

.sidebar-link {
  display: block;
  padding: 7px 24px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}

.sidebar-link:hover {
  color: var(--text-body);
  background: rgba(255, 255, 255, 0.03);
}

.sidebar-link.active {
  color: var(--coral);
  border-left-color: var(--coral);
  background: rgba(255, 107, 107, 0.05);
}

.sidebar-sub {
  padding-left: 16px;
}

.sidebar-sub .sidebar-link {
  font-size: 0.8125rem;
  padding-top: 5px;
  padding-bottom: 5px;
  color: var(--text-muted);
  opacity: 0.85;
}

/* ---------- Content ---------- */
.content {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 40px) 48px 80px;
  max-width: calc(var(--content-max) + var(--sidebar-w) + 96px);
  min-height: 100vh;
}

.content-inner {
  max-width: var(--content-max);
}

/* ---------- Typography ---------- */
h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-heading);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 16px;
}

h1 + .subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 40px;
  line-height: 1.7;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
  margin-top: 56px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

h2:first-child {
  margin-top: 0;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-top: 36px;
  margin-bottom: 12px;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-top: 28px;
  margin-bottom: 8px;
}

p {
  margin-bottom: 16px;
}

ul, ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

li {
  margin-bottom: 6px;
}

li > ul, li > ol {
  margin-top: 6px;
  margin-bottom: 8px;
}

strong {
  font-weight: 600;
  color: var(--text-heading);
}

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

/* ---------- Anchor links on headings ---------- */
h2[id]::before,
h3[id]::before {
  content: "";
  display: block;
  height: calc(var(--topbar-h) + 24px);
  margin-top: calc(-1 * (var(--topbar-h) + 24px));
  visibility: hidden;
  pointer-events: none;
}

.heading-anchor {
  color: var(--text-muted);
  opacity: 0;
  margin-left: 8px;
  font-weight: 400;
  transition: opacity var(--transition);
  text-decoration: none;
}

h2:hover .heading-anchor,
h3:hover .heading-anchor {
  opacity: 0.6;
}

.heading-anchor:hover {
  opacity: 1 !important;
  color: var(--coral);
}

/* ---------- Inline code ---------- */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
}

/* ---------- Code blocks ---------- */
pre {
  background: var(--bg-code);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  overflow-x: auto;
  border: 1px solid var(--border-color);
}

pre code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--text);
  background: none;
  padding: 0;
  border-radius: 0;
  white-space: pre;
}

/* Code block with filename label */
.code-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-bottom: none;
  padding: 6px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: -1px;
  position: relative;
  z-index: 1;
}

.code-label + pre {
  border-top-left-radius: 0;
}

/* Syntax highlighting classes (matching landing page) */
.yk { color: var(--coral); }        /* YAML key */
.yv { color: #7dd3fc; }             /* value */
.yc { color: #64748b; }             /* comment */
.ys { color: #a5f3ab; }             /* string */
.yn { color: #c4b5fd; }             /* number / bool */
.tg { color: #4ade80; }             /* terminal green */
.ty { color: #facc15; }             /* terminal yellow */
.td { color: #64748b; }             /* terminal dim */
.tc { color: var(--coral); }        /* terminal coral */
.tb { color: #7dd3fc; }             /* terminal blue */

/* Shell prompt styling */
.prompt { color: #64748b; user-select: none; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--table-header-bg);
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--text-heading);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}

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

tbody tr:nth-child(even) {
  background: var(--bg-table-stripe);
}

/* ---------- Quick links grid ---------- */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 32px 0;
}

.quick-link {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  background: var(--bg-code);
  text-decoration: none;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.quick-link:hover {
  border-color: var(--coral);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.quick-link-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--text-link);
}

.quick-link-icon svg {
  width: 100%;
  height: 100%;
}

.quick-link-text strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.quick-link-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ---------- Callout / Tip boxes ---------- */
.callout {
  border-left: 3px solid var(--coral);
  background: rgba(255, 107, 107, 0.05);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 20px;
  margin-bottom: 20px;
}

.callout-title {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--coral);
  margin-bottom: 6px;
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout-info {
  border-left-color: #7dd3fc;
  background: rgba(125, 211, 252, 0.05);
}

.callout-info .callout-title {
  color: #7dd3fc;
}

/* ---------- Footer ---------- */
.docs-footer {
  margin-left: var(--sidebar-w);
  padding: 40px 48px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: calc(var(--content-max) + var(--sidebar-w) + 96px);
}

.docs-footer-links {
  display: flex;
  gap: 24px;
}

.docs-footer-links a {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.docs-footer-links a:hover {
  color: var(--coral);
}

.docs-footer-copy {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Prev / Next nav ---------- */
.page-nav {
  display: flex;
  gap: 16px;
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border-color);
}

.page-nav a {
  flex: 1;
  display: block;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  text-decoration: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.page-nav a:hover {
  border-color: var(--coral);
  box-shadow: var(--shadow-sm);
}

.page-nav-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.page-nav-title {
  font-weight: 600;
  color: var(--text-heading);
}

.page-nav-next {
  text-align: right;
}

/* ---------- Badge / Tag ---------- */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 107, 107, 0.12);
  color: var(--coral);
  vertical-align: middle;
}

.badge-blue {
  background: rgba(125, 211, 252, 0.12);
  color: #7dd3fc;
}

.badge-green {
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
}

.badge-purple {
  background: rgba(196, 181, 253, 0.12);
  color: #c4b5fd;
}

/* ---------- Mobile (≤768px) ---------- */
@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 280px;
    z-index: 95;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-h);
    background: rgba(0, 0, 0, 0.5);
    z-index: 94;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .content {
    margin-left: 0;
    padding: calc(var(--topbar-h) + 24px) 20px 60px;
  }

  .docs-footer {
    margin-left: 0;
    padding: 32px 20px;
    flex-direction: column;
    text-align: center;
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  .quick-links {
    grid-template-columns: 1fr;
  }

  .page-nav {
    flex-direction: column;
  }

  .page-nav-next {
    text-align: left;
  }

  pre {
    padding: 16px;
    font-size: 0.8rem;
  }
}

/* ---------- Hamburger open state ---------- */
.hamburger.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.open span:nth-child(2) {
  opacity: 0;
}

.hamburger.open span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

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

pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

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

/* ---------- Category grouping (connectors page) ---------- */
.connector-category {
  margin-top: 32px;
  margin-bottom: 20px;
}

.connector-category h3 {
  margin-top: 0;
}

/* ---------- Flag table ---------- */
.flag-table td:first-child {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  color: var(--coral);
}

/* ---------- Pipeline diagram ---------- */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  margin: 32px 0;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--bg-code);
  border: 1px solid var(--border-color);
}

.pipeline-step {
  text-align: center;
  padding: 12px 20px;
  border-radius: 8px;
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.15);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-heading);
}

.pipeline-arrow {
  padding: 0 12px;
  color: var(--text-muted);
  font-size: 1.1rem;
}
