/* SWAIN marketing site stylesheet
   - Modern, responsive, accessible
   - Carefully tuned for readability and conversion
   - Consistent design system with standardized spacing, typography, and interactions
*/
*,
*::before,
*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
:root {
  /* Color System */
  --bg: #0b0f1a;
  --bg-elev: #101424;
  --surface: #0f172a;
  /* Slightly elevated surface for subtle hovers */
  --surface-2: color-mix(in srgb, var(--surface), white 6%);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #1f2937;
  --brand-1: #6EE7F9;
  --brand-2: #8B5CF6;
  --accent: #22d3ee;
  --bad: #ef4444;
  --good: #10b981;
  --warn: #f59e0b;

  /* Button contrast tuning (defaults for dark theme) */
  --btn-primary-bg1: color-mix(in srgb, var(--brand-1), black 28%);
  --btn-primary-bg2: color-mix(in srgb, var(--brand-2), black 24%);
  --btn-primary-fg: #ffffff;
  
  /* Code Block Colors */
  --code-bg: #0d1117;
  --code-text: #e6edf3;
  --code-comment: #8b949e;
  --code-keyword: #ff7b72;
  --code-string: #a5d6ff;
  --code-number: #79c0ff;
  --code-function: #d2a8ff;
  --code-operator: #ff7b72;
  --code-header-bg: rgba(13, 17, 23, 0.7);
  
  /* Spacing System */
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 20px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --space-4xl: 64px;
  
  /* Typography Scale */
  --font-xs: 12px;
  --font-sm: 14px;
  --font-base: 16px;
  --font-lg: 18px;
  --font-xl: 20px;
  --font-2xl: 24px;
  --font-3xl: 32px;
  --font-4xl: 48px;
  
  /* Consistent Values */
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --transition: 0.3s ease;
  --shadow-1: 0 10px 30px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.02);
  --shadow-2: 0 12px 40px rgba(0,0,0,.35);
  --shadow-focus: 0 0 0 3px rgba(110,231,249,.4);
  --maxw: 1160px;
  
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #f7f9fc;
  --surface: #f7f9fc;
  --surface-2: color-mix(in srgb, var(--surface), black 6%);
  --text: #0b1020;
  --muted: #4b5563;
  --border: #e5e7eb;
  --shadow-1: 0 10px 30px rgba(0,0,0,.06), inset 0 1px 0 rgba(255,255,255,.5);
  --shadow-2: 0 12px 40px rgba(0,0,0,.08);
  --shadow-focus: 0 0 0 3px rgba(139,92,246,.25);

  /* Button contrast tuning for light theme */
  /* Keep gradient vivid but switch to dark text for AA contrast */
  --btn-primary-bg1: color-mix(in srgb, var(--brand-1), white 0%);
  --btn-primary-bg2: color-mix(in srgb, var(--brand-2), white 0%);
  --btn-primary-fg: #0b1020;
  
  /* Code Block Colors for Light Theme */
  --code-bg: #f6f8fa;
  --code-text: #24292f;
  --code-comment: #6e7781;
  --code-keyword: #cf222e;
  --code-string: #0a3069;
  --code-number: #0550ae;
  --code-function: #8250df;
  --code-operator: #cf222e;
  --code-header-bg: rgba(246, 248, 250, 0.9);
  
  color-scheme: light;
}

@media (prefers-reduced-motion: no-preference) {
  :root { scroll-behavior: smooth; }
}

::selection { 
  background: rgba(139, 92, 246, .35); 
  color: var(--text); 
}

/* Base Styles */
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Arial, Noto Sans, Apple Color Emoji, Segoe UI Emoji;
  background: radial-gradient(1000px 600px at 80% -10%, rgba(110,231,249,.12), transparent 60%),
              radial-gradient(1100px 700px at -10% -20%, rgba(139,92,246,.12), transparent 50%),
              var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: var(--font-base);
}

/* Global link styling (content links) */
a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: color-mix(in srgb, var(--accent), white 12%);
  text-decoration-thickness: 2px;
  text-decoration-skip-ink: auto;
}

/* Container */
.container { 
  width: 100%; 
  max-width: var(--maxw); 
  margin-inline: auto; 
  padding-inline: var(--space-lg); 
}

/* Typography with Consistent Scale */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 700;
  margin-top: 0;
}

h1 { 
  font-size: clamp(var(--font-3xl), 4vw, 56px); 
  margin-bottom: var(--space-lg);
}

h2 { 
  font-size: clamp(var(--font-2xl), 3vw, 36px); 
  margin-bottom: var(--space-md);
}

h3 { 
  font-size: clamp(var(--font-lg), 2vw, var(--font-xl)); 
  margin-bottom: var(--space-sm);
}

p {
  margin-bottom: var(--space-md);
}

/* Header & Navigation */
.header {
  position: sticky; 
  top: 0; 
  z-index: 50;
  background: color-mix(in srgb, var(--bg), transparent 20%);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.header-inner { 
  display: flex; 
  align-items: center; 
  gap: var(--space-lg); 
  height: 68px; 
}

.brand { 
  display: inline-flex; 
  align-items: center; 
  gap: var(--space-sm); 
  text-decoration: none;
  transition: transform var(--transition);
}

.brand:hover {
  transform: translateX(2px);
}

.brand img { 
  width: 124px; 
  height: auto; 
  display: block; 
}

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

.nav a {
  color: var(--muted); 
  text-decoration: none; 
  padding: var(--space-xs) var(--space-sm); 
  border-radius: var(--radius);
  transition: all var(--transition);
  position: relative;
}

/* Nav item with submenu */
.nav .nav-item { 
  position: relative; 
  display: inline-flex; 
  align-items: center; 
  gap: 4px; 
}
.nav .nav-item .nav-link { padding-right: 6px; }
.nav .submenu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--muted);
  cursor: pointer;
}
.nav .submenu-toggle:hover { background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 10%); color: var(--text); }
.nav .submenu-toggle:focus { outline: none; box-shadow: var(--shadow-focus); }
.nav .submenu-toggle[aria-expanded="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent), var(--border) 60%); }

.nav .submenu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow-2);
  display: none;
  z-index: 60;
}
.nav .submenu a { display: block; padding: 8px 10px; border-radius: 8px; }
.nav .submenu a:hover { background: color-mix(in srgb, var(--surface), transparent 40%); }
.nav .submenu hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

/* Open submenu on desktop via hover or when toggled */
@media (min-width: 981px) {
  .nav .nav-item:hover > .submenu { display: block; }
  .nav .nav-item.open > .submenu { display: block; }
}

.nav a:hover { 
  color: var(--text); 
  background: color-mix(in srgb, var(--bg-elev), transparent 35%); 
  transform: translateY(-1px);
}

.nav a[aria-current="page"] { 
  color: var(--text); 
  background: color-mix(in srgb, var(--brand-1), transparent 90%);
  border: 1px solid color-mix(in srgb, var(--brand-1), transparent 70%);
}

.nav .cta { padding: var(--space-xs) var(--space-md); }

.nav .cta:hover { 
  transform: translateY(-2px); 
  box-shadow: var(--shadow-2);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--muted);
  border-radius: var(--radius); 
  padding: var(--space-xs) var(--space-sm); 
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle:hover {
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 10%);
  color: var(--text);
}

.theme-toggle:focus {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.menu-btn { 
  display: none; 
  align-items: center;
  gap: 8px;
}

/* Mobile Navigation Overlay */
@media (max-width: 980px) {
  .menu-btn { 
    display: inline-flex; 
    margin-left: auto; 
  }
  
  .nav { 
    position: fixed; 
    inset: 68px 12px auto 12px; 
    background: var(--bg-elev); 
    flex-wrap: wrap; 
    padding: var(--space-md); 
    border: 1px solid var(--border); 
    border-radius: var(--radius); 
    display: none;
    animation: slideDown 0.3s ease;
    box-shadow: var(--shadow-2);
  }
  
  .nav.open { 
    display: flex; 
  }
  
  /* Overlay backdrop */
  .nav.open::before {
    content: '';
    position: fixed;
    inset: 68px 0 0 0;
    background: rgba(0,0,0,0.5);
    z-index: -1;
    /* Allow clicks to pass through so document handler can close menu,
       while underlying content remains inert and non-interactive */
    pointer-events: none;
  }
  /* Mobile submenu: stack inside panel */
  .nav .nav-item { width: 100%; }
  .nav .submenu {
    position: static;
    display: none;
    width: 100%;
    margin-top: 6px;
    box-shadow: none;
    padding: 4px;
    background: color-mix(in srgb, var(--bg-elev), transparent 10%);
  }
  .nav .nav-item.open > .submenu { display: block; }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hero Section */
.hero { 
  padding: var(--space-4xl) 0 var(--space-3xl); 
}

.hero-grid { 
  display: grid; 
  grid-template-columns: 1.2fr 1fr; 
  gap: var(--space-2xl); 
  align-items: center; 
}

.hero h1 { 
  font-size: clamp(var(--font-3xl), 4vw, 56px); 
  line-height: 1.1; 
  margin: 0 0 var(--space-lg); 
}

.lead { 
  font-size: clamp(var(--font-base), 2vw, var(--font-xl)); 
  color: var(--muted); 
  max-width: 60ch; 
}

/* Buttons with Consistent Styling */
.btn {
  display: inline-flex; 
  align-items: center; 
  gap: var(--space-xs); 
  text-decoration: none;
  border: 1px solid var(--border); 
  padding: var(--space-sm) var(--space-lg); 
  border-radius: var(--radius); 
  color: var(--text);
  background: var(--bg-elev); 
  box-shadow: var(--shadow-1);
  transition: all var(--transition);
  cursor: pointer;
  font-size: var(--font-base);
}

.btn:hover { 
  transform: translateY(-2px); 
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 5%);
  box-shadow: var(--shadow-2);
}

.btn:focus {
  outline: none;
  box-shadow: var(--shadow-focus);
}


.btn-primary {
  background: linear-gradient(135deg, var(--btn-primary-bg1), var(--btn-primary-bg2));
  color: var(--btn-primary-fg);
  font-weight: 700;
  border: none;
}

.btn-primary:hover {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--btn-primary-bg1), white 10%),
    color-mix(in srgb, var(--btn-primary-bg2), white 10%)
  );
}

/* High-contrast secondary action */
.btn-contrast {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--bg-elev), var(--brand-1) 18%),
    color-mix(in srgb, var(--bg-elev), var(--brand-2) 18%)
  );
  border: 1px solid color-mix(in srgb, var(--brand-1), transparent 50%);
  color: var(--text);
  font-weight: 600;
}

.btn-contrast:hover {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--bg-elev), var(--brand-1) 26%),
    color-mix(in srgb, var(--bg-elev), var(--brand-2) 26%)
  );
  border-color: color-mix(in srgb, var(--brand-2), transparent 40%);
}

/* Light theme tuning for contrast button */
[data-theme="light"] .btn-contrast {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--bg-elev), var(--brand-1) 26%),
    color-mix(in srgb, var(--bg-elev), var(--brand-2) 26%)
  );
  border-color: color-mix(in srgb, var(--brand-1), transparent 40%);
}

[data-theme="light"] .btn-contrast:hover {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--bg-elev), var(--brand-1) 34%),
    color-mix(in srgb, var(--bg-elev), var(--brand-2) 34%)
  );
  border-color: color-mix(in srgb, var(--brand-2), transparent 30%);
}

.hero-cta { 
  display: flex; 
  gap: var(--space-sm); 
  flex-wrap: wrap; 
  margin-top: var(--space-xl); 
}

/* Microcopy under CTAs to clarify choices */
.cta-note {
  margin-top: var(--space-sm);
  font-size: var(--font-sm);
  color: var(--muted);
}

/* Code Cards with Enhanced Styling */
.code-card {
  background: var(--code-bg); 
  border: 1px solid var(--border); 
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2); 
  overflow: hidden; 
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  transition: all var(--transition);
}

.code-card:hover {
  box-shadow: 0 14px 45px rgba(0,0,0,.4);
  transform: translateY(-1px);
}

[data-theme="light"] .code-card:hover {
  box-shadow: 0 14px 45px rgba(0,0,0,.15);
}

.code-header { 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  padding: var(--space-sm) var(--space-md); 
  border-bottom: 1px solid var(--border); 
  color: var(--muted);
  background: var(--code-header-bg);
}
.code-header .spacer { margin-left: auto; }

.code-header .dot { 
  width: 10px; 
  height: 10px; 
  border-radius: 50%; 
  opacity: 0.8;
}

.code-header .dot:nth-child(1) { 
  background: #ff5f57; 
}
.code-header .dot:nth-child(2) { 
  background: #ffbd2e; 
}
.code-header .dot:nth-child(3) { 
  background: #28ca42; 
}

[data-theme="light"] .code-header .dot {
  opacity: 0.6;
}

.code-header .muted {
  margin-left: var(--space-xs);
  font-size: var(--font-sm);
  opacity: 0.7;
}

pre { 
  margin: 0; 
  overflow: auto; 
  padding: var(--space-lg); 
  background: transparent; 
  color: var(--code-text); 
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

pre::-webkit-scrollbar {
  height: 8px;
}

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

pre::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

pre::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

code { 
  font-size: var(--font-sm); 
  white-space: pre;
  color: var(--code-text);
}

/* Inline code */
p code, 
li code,
td code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--code-text);
  border: 1px solid var(--border);
}

/* Syntax Highlighting Classes */
/* Removed highlight.js selectors (.hljs-*) to avoid redundancy.
   The site uses Prism; keep Prism .token-* styles below. */

.copy { 
  margin-left: auto; 
  border: 1px solid color-mix(in srgb, var(--border), transparent 50%); 
  border-radius: var(--radius); 
  padding: 6px var(--space-sm); 
  background: color-mix(in srgb, var(--code-bg), var(--bg-elev) 30%); 
  color: var(--muted); 
  cursor: pointer;
  transition: all var(--transition);
  font-size: var(--font-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative; /* anchor for tooltip */
}

[data-theme="light"] .copy {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);
}

.copy svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition);
}

/* Copy tooltip */
.copy-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--font-xs);
  padding: 4px 8px;
  box-shadow: var(--shadow-1);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--transition), transform var(--transition);
  pointer-events: none;
  z-index: 20;
}
.copy-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

/* Prism.js Theme Overrides for Better Integration */
.code-card pre[class*="language-"],
.code-card code[class*="language-"] {
  color: var(--code-text);
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: var(--font-sm);
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  overflow-wrap: normal;
  line-height: 1.6;
  tab-size: 2;
  hyphens: none;
}

/* Override Prism's pre styles */
.code-card pre[class*="language-"] {
  padding: var(--space-lg);
  margin: 0;
  overflow: auto;
  background: transparent;
}

/* Token colors - Override Prism Tomorrow Night theme */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--code-comment);
  font-style: italic;
}

.token.punctuation {
  color: var(--code-text);
  opacity: 0.7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: var(--code-number);
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: var(--code-string);
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: var(--code-operator);
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: var(--code-keyword);
  font-weight: 500;
}

.token.function,
.token.class-name {
  color: var(--code-function);
}

.token.regex,
.token.important,
.token.variable {
  color: var(--code-variable);
}

/* Ensure selection colors work properly */
.token.important,
.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}

/* Remove any default Prism backgrounds */
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
  background: transparent;
}

/* Ensure proper contrast in light theme */

/* Prism.js Plugin Styles */

/* Line Numbers Plugin */
pre.line-numbers {
  position: relative;
  padding-left: 3.8em !important;
  counter-reset: linenumber;
}

pre.line-numbers > code {
  position: relative;
  white-space: inherit;
}

.line-numbers-rows {
  position: absolute;
  pointer-events: none;
  top: 0;
  font-size: 100%;
  left: -3.8em;
  width: 3em;
  letter-spacing: -1px;
  border-right: 1px solid var(--border);
  user-select: none;
}

.line-numbers-rows > span {
  display: block;
  counter-increment: linenumber;
}

.line-numbers-rows > span:before {
  content: counter(linenumber);
  color: var(--muted);
  display: block;
  padding-right: 0.8em;
  text-align: right;
}

/* Toolbar Plugin */
div.code-toolbar {
  position: relative;
}

div.code-toolbar > .toolbar {
  position: absolute;
  z-index: 10;
  top: 0.3em;
  right: 0.3em;
  transition: opacity 0.3s;
  opacity: 0;
}

div.code-toolbar:hover > .toolbar {
  opacity: 1;
}

div.code-toolbar > .toolbar > .toolbar-item {
  display: inline-block;
  margin-left: 0.5em;
}

div.code-toolbar > .toolbar > .toolbar-item > a,
div.code-toolbar > .toolbar > .toolbar-item > button,
div.code-toolbar > .toolbar > .toolbar-item > span {
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.25em 0.5em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

div.code-toolbar > .toolbar > .toolbar-item > a:hover,
div.code-toolbar > .toolbar > .toolbar-item > button:hover {
  color: var(--accent);
  background: var(--code-selection);
}

/* Command Line Plugin */
pre.command-line {
  position: relative;
  padding: 1em 1em 1em 3em;
}

pre.command-line:before {
  content: attr(data-prompt);
  position: absolute;
  left: 1em;
  color: var(--code-comment);
  pointer-events: none;
}

/* Code Tabs Component */
.code-tabs-container {
  margin: var(--space-md) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.code-tabs-header {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: thin;
  gap: 2px;
}

.code-tab {
  padding: var(--space-xs) var(--space-sm);
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  position: relative;
  border-bottom: 2px solid transparent;
}

.code-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.code-tab.active {
  color: var(--accent);
  background: var(--code-bg);
  border-bottom-color: var(--accent);
}

.code-tab:before {
  margin-right: 0.5em;
  opacity: 0.7;
  font-weight: 600;
}

.code-panels {
  position: relative;
  background: var(--code-bg);
}

.code-panels .code-panel {
  display: none;
}

.code-panels .code-panel.active {
  display: block;
}

.code-panel pre {
  margin: 0;
  border-radius: 0;
}

/* Language-specific icons */
.code-tab[data-lang="javascript"]:before { content: "JS"; }
.code-tab[data-lang="typescript"]:before { content: "TS"; }
.code-tab[data-lang="python"]:before { content: "PY"; }
.code-tab[data-lang="go"]:before { content: "GO"; }
.code-tab[data-lang="ruby"]:before { content: "RB"; }
.code-tab[data-lang="php"]:before { content: "PHP"; }
.code-tab[data-lang="java"]:before { content: "Java"; }
.code-tab[data-lang="csharp"]:before { content: "C#"; }
.code-tab[data-lang="swift"]:before { content: "Swift"; }
.code-tab[data-lang="kotlin"]:before { content: "KT"; }
.code-tab[data-lang="bash"]:before { content: "Bash"; }
.code-tab[data-lang="curl"]:before { content: "cURL"; }
[data-theme="light"] .token.comment {
  opacity: 0.8;
}

[data-theme="light"] .token.punctuation {
  opacity: 0.6;
}

/* Show Prism line numbers when enabled */
/* (no override; rely on Prism's default styles) */

/* Highlight active line if needed */
.line-highlight {
  background: color-mix(in srgb, var(--brand-2), transparent 95%);
  display: block;
  margin-right: calc(-1 * var(--space-lg));
  margin-left: calc(-1 * var(--space-lg));
  padding-left: var(--space-lg);
  padding-right: var(--space-lg);
}

.copy:hover {
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 10%);
  color: var(--text);
  border-color: color-mix(in srgb, var(--brand-1), transparent 70%);
}

.copy:hover svg {
  transform: scale(1.1);
}

.copy.success {
  background: color-mix(in srgb, var(--bg-elev), var(--good) 20%);
  color: var(--good);
  border-color: var(--good);
}

.copy:focus { 
  outline: none; 
  box-shadow: var(--shadow-focus); 
}

/* Trust Bar */
.trust { 
  display: grid; 
  grid-template-columns: repeat(4, 1fr); 
  gap: var(--space-lg); 
  margin: var(--space-2xl) 0 var(--space-sm); 
  padding: var(--space-lg);
  background: color-mix(in srgb, var(--surface), transparent 50%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.trust img { 
  width: 60px; 
  height: auto; 
  opacity: .9; 
  filter: saturate(90%);
  transition: all var(--transition);
}

.trust img:hover {
  opacity: 1;
  filter: saturate(100%);
  transform: scale(1.05);
}

/* Sections with Consistent Spacing */
.section { 
  padding: var(--space-4xl) 0; 
}

.section h2 { 
  font-size: clamp(var(--font-2xl), 3vw, 36px); 
  margin: 0 0 var(--space-md); 
}

.subtitle { 
  color: var(--muted); 
  margin-bottom: var(--space-2xl); 
  font-size: var(--font-lg);
}

/* Grid Layouts with Consistent Gaps */
.grid-3 { 
  display: grid; 
  grid-template-columns: repeat(3, 1fr); 
  gap: var(--space-lg); 
}

.grid-2 { 
  display: grid; 
  grid-template-columns: repeat(2, 1fr); 
  gap: var(--space-lg); 
}

/* Feature Group (collapsible sections on product page) */
.feature-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-elev), transparent 30%);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.feature-group summary {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  padding: var(--space-md) var(--space-lg);
  list-style: none;
  user-select: none;
}

/* Remove default marker and add custom caret */
.feature-group summary::-webkit-details-marker { display: none; }
.feature-group summary::marker { content: ''; }
.feature-group summary::after {
  content: '';
  width: 12px; height: 12px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  margin-left: 8px;
  transition: transform var(--transition), border-color var(--transition);
}
.feature-group[open] summary::after { transform: rotate(45deg); border-color: var(--accent); }

/* Make the summary interactivity more obvious */
.feature-group summary:hover {
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 6%);
}
.feature-group summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-lg);
}

/* Subtle hint label on the right */
.feature-group summary .summary-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--font-xs);
  font-weight: 600;
  background: color-mix(in srgb, var(--bg-elev), transparent 30%);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
}
.feature-group[open] summary .summary-hint { color: var(--accent); border-color: color-mix(in srgb, var(--border), var(--accent) 30%); }

.feature-group summary h2 {
  margin: 0;
}

.feature-group > .group-inner {
  padding: var(--space-lg);
  padding-top: 0;
}

/* Cards with Enhanced Visual Hierarchy */
.card {
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: var(--radius-lg); 
  padding: var(--space-lg);
  box-shadow: var(--shadow-1);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand-1), var(--brand-2), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  background: color-mix(in srgb, var(--surface), var(--brand-1) 2%);
}

.card:hover::before {
  opacity: 0.7;
}

.card h3 { 
  margin-top: var(--space-xs); 
  margin-bottom: var(--space-sm); 
  font-size: var(--font-lg); 
}

.card p { 
  color: var(--muted); 
}

.kicker { 
  font-size: var(--font-xs); 
  text-transform: uppercase; 
  letter-spacing: .14em; 
  color: var(--accent); 
  font-weight: 600;
}

/* Equal-height feature cards and content clamping */
/* Ensure cards inside grid layouts stretch uniformly and look aligned */
.grid-3 > .card,
.grid-2 > .card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Clamp headings to two lines for consistent heights */
.grid-3 > .card h3,
.grid-2 > .card h3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-height: calc(1.2em * 2); /* h3 line-height (1.2) × 2 lines */
}

/* Clamp body text to three lines for uniformity */
.grid-3 > .card p,
.grid-2 > .card p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4; /* Show full thoughts; reduce unnecessary clicks */
  overflow: hidden;
  min-height: calc(1.6em * 4); /* paragraph line-height (1.6) × 4 lines */
}

/* Feature cards: allow expand on hover/click (product page) */
.feature-card {
  position: relative;
}

/* Gradient fade to indicate more content when clamped */
.feature-card:not(.expanded)::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 42px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, color-mix(in srgb, var(--surface), transparent 0%) 40%, var(--surface) 100%);
  pointer-events: none;
  opacity: 0.85;
  transition: opacity var(--transition);
}

/* Remove clamping when hovered, focused, or explicitly expanded */
.feature-card:hover h3,
.feature-card:focus-within h3,
.feature-card.expanded h3,
.feature-card:hover p,
.feature-card:focus-within p,
.feature-card.expanded p {
  display: block;
  -webkit-line-clamp: unset;
  min-height: 0;
  overflow: visible;
}

.feature-card:hover::after,
.feature-card:focus-within::after,
.feature-card.expanded::after {
  opacity: 0;
}

.feature-card .card-actions {
  margin-top: auto;
}

.feature-card .card-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: color-mix(in srgb, var(--surface), var(--bg-elev) 20%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-weight: 600;
  padding: 6px 10px;
  margin-top: var(--space-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.feature-card .card-toggle::after {
  content: '';
  width: 10px; height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--transition);
}

.feature-card .card-toggle[aria-expanded="true"]::after {
  transform: rotate(45deg);
}

.feature-card .card-toggle:hover,
.feature-card .card-toggle:focus {
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 12%);
  border-color: color-mix(in srgb, var(--border), var(--brand-1) 40%);
  color: var(--text);
}

.feature-card .card-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* On small screens, allow full text and natural heights */
@media (max-width: 768px) {
  .grid-3 > .card,
  .grid-2 > .card {
    height: auto;
  }

  .grid-3 > .card h3,
  .grid-2 > .card h3,
  .grid-3 > .card p,
  .grid-2 > .card p {
    display: block;
    -webkit-line-clamp: unset;
    min-height: 0;
    overflow: visible;
  }

  /* On small screens, keep fade hidden and show full text when toggled */
  .feature-card::after { display: none; }
  .feature-card .card-toggle { display: none; }
}

/* Tables with Better Visual Design */
.table { 
  width: 100%; 
  border-collapse: collapse; 
  overflow: hidden; 
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.table th, 
.table td { 
  padding: var(--space-md); 
  border-bottom: 1px solid var(--border); 
  text-align: left; 
}

.table th { 
  color: var(--muted); 
  font-weight: 600; 
  background: color-mix(in srgb, var(--bg-elev), transparent 50%); 
  font-size: var(--font-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tr {
  transition: background var(--transition);
}

.table tr:hover td { 
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 5%); 
}

/* Code in tables */
.table code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--code-text);
  border: 1px solid var(--border);
  font-weight: 500;
}

/* Table scroll wrapper to prevent page overflow */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface), transparent 40%);
}
.table-wrap > .table { border: none; box-shadow: none; min-width: 640px; }

/* Stackable tables become card-like on narrow screens */
@media (max-width: 720px) {
  .table-wrap > .table.stackable { min-width: 0; }
  .table.stackable { border: 0; box-shadow: none; }
  .table.stackable thead { display: none; }
  .table.stackable,
  .table.stackable tbody,
  .table.stackable tr,
  .table.stackable td { display: block; width: 100%; }
  .table.stackable tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-1);
  }
  .table.stackable td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border);
  }
  .table.stackable td:last-child { border-bottom: 0; }
  .table.stackable td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    min-width: 36%;
    color: var(--muted);
    font-weight: 600;
    text-transform: none;
  }
}

/* Forms with Consistent Styling */
.input, 
select, 
textarea {
  width: 100%; 
  padding: var(--space-sm) var(--space-md); 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  background: var(--bg-elev);
  color: var(--text);
  font-size: var(--font-base);
  transition: all var(--transition);
}

.input:hover,
select:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--border), var(--brand-1) 30%);
}

.input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-1);
  box-shadow: var(--shadow-focus);
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 3%);
}

.input.invalid,
select.invalid,
textarea.invalid,
[aria-invalid="true"] {
  border-color: var(--bad) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad), transparent 70%);
}

label { 
  display: inline-block; 
  margin-bottom: var(--space-xs); 
  color: var(--muted);
  font-size: var(--font-sm);
  font-weight: 500;
}

/* Inline form message styling */
.msg.error { color: var(--bad); }

.form-row { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: var(--space-md); 
}

.form-actions { 
  display: flex; 
  gap: var(--space-sm); 
  margin-top: var(--space-lg); 
}

/* Pricing Cards with Enhanced Design */
.pricing { 
  display: grid; 
  grid-template-columns: repeat(3, 1fr); 
  gap: var(--space-lg); 
  align-items: stretch; 
}

.plan { 
  position: relative; 
  padding: var(--space-xl); 
  border-radius: var(--radius-lg); 
  border: 1px solid var(--border); 
  background: var(--surface);
  transition: all var(--transition);
}

.plan:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-2);
}

.plan.popular { 
  border-color: color-mix(in srgb, var(--brand-2), black 20%); 
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-2), transparent 60%);
  background: color-mix(in srgb, var(--surface), var(--brand-2) 5%);
}

.plan.popular::before {
  content: 'POPULAR';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #0b0f1a;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.price { 
  font-size: var(--font-3xl); 
  font-weight: 800; 
  margin: var(--space-xs) 0; 
}

.price small { 
  font-weight: 500; 
  color: var(--muted); 
  font-size: var(--font-base);
}

.price-note {
  color: var(--muted);
  font-size: var(--font-sm);
  margin-top: 2px;
}

/* Emphasize pricing when yearly billing is selected */
body[data-billing="yearly"] .plan.popular {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1), transparent 60%);
}

.feature-list { 
  list-style: none; 
  padding-left: 0; 
  margin: var(--space-lg) 0; 
}

.feature-list li { 
  display: flex; 
  align-items: baseline; 
  gap: var(--space-sm); 
  margin: var(--space-sm) 0; 
}

.feature-list li::before { 
  content: "✓"; 
  color: var(--good); 
  font-weight: 700;
}

/* Toggle Switch */
.toggle {
  display: inline-flex; 
  gap: var(--space-sm); 
  align-items: center; 
  border: 1px solid var(--border); 
  padding: var(--space-sm) var(--space-md); 
  border-radius: var(--radius-full); 
  background: var(--bg-elev);
}

.toggle input[type="checkbox"] {
  appearance: none;
  width: 48px;
  height: 24px;
  background: var(--border);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform var(--transition);
}

.toggle input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
}

.toggle input[type="checkbox"]:checked::after {
  transform: translateX(24px);
}

/* Footer with Improved Layout */
.footer { 
  border-top: 1px solid var(--border); 
  padding: var(--space-3xl) 0; 
  margin-top: var(--space-4xl);
  background: color-mix(in srgb, var(--bg), var(--surface) 30%);
}

.footer-grid { 
  display: grid; 
  grid-template-columns: 2fr repeat(4, 1fr); 
  gap: var(--space-2xl); 
}

.footer a { 
  color: var(--muted); 
  text-decoration: none;
  transition: color var(--transition);
  display: inline-block;
  padding: 2px 0;
}

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

.footer strong {
  color: var(--text);
  font-weight: 600;
  margin-bottom: var(--space-sm);
  display: block;
}

/* Footer social links */
#footer-social {
  margin-top: var(--space-md);
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.footer .social-label {
  display: inline;
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.footer .social-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--bg-elev), transparent 30%);
  color: var(--muted);
  text-decoration: none;
  transition: all var(--transition);
}

.footer .social-link:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--border), var(--brand-1) 30%);
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 8%);
  transform: translateY(-1px);
}

.footer .social-link .icon {
  width: 16px;
  height: 16px;
  opacity: 0.9;
}

/* Focus-visible for social links */
.footer .social-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1), transparent 60%);
}

.footer .social-link.twitter:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, #1DA1F2, transparent 60%);
  border-color: #1DA1F2;
}

.footer .social-link.linkedin:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, #0A66C2, transparent 60%);
  border-color: #0A66C2;
}

.footer .social-link.github:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, #6e7681, transparent 60%);
  border-color: #6e7681;
}

/* Platform-specific hovers */
.footer .social-link.twitter:hover {
  color: #1DA1F2;
  border-color: color-mix(in srgb, #1DA1F2, var(--border) 30%);
  background: color-mix(in srgb, var(--bg-elev), #1DA1F2 10%);
}

.footer .social-link.linkedin:hover {
  color: #0A66C2;
  border-color: color-mix(in srgb, #0A66C2, var(--border) 30%);
  background: color-mix(in srgb, var(--bg-elev), #0A66C2 10%);
}

.footer .social-link.github:hover {
  color: #c9d1d9;
  border-color: color-mix(in srgb, #6e7681, var(--border) 40%);
  background: color-mix(in srgb, var(--bg-elev), #6e7681 12%);
}

@media (max-width: 480px) {
  .footer .social-link .social-text { display: none; }
  .footer .social-link { padding: 10px; }
  #footer-social { gap: 8px; }
}

/* Accessibility helpers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  width: auto;
  height: auto;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  z-index: 1000;
  text-decoration: none;
}

/* Utility Classes */
.badge { 
  display: inline-flex; 
  align-items: center; 
  gap: 6px; 
  padding: 6px 12px; 
  background: color-mix(in srgb, var(--bg-elev), transparent 20%); 
  border: 1px solid var(--border); 
  border-radius: var(--radius-full); 
  color: var(--muted); 
  font-size: var(--font-xs);
  font-weight: 500;
  transition: all var(--transition);
}

.badge-hero {
  color: var(--text);
  /* Increase contrast over hero gradient */
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 18%);
  border-color: color-mix(in srgb, var(--border), var(--brand-1) 40%);
}

.badge-hero:hover {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--bg-elev), var(--brand-1) 26%),
    color-mix(in srgb, var(--bg-elev), var(--brand-2) 18%)
  );
  border-color: color-mix(in srgb, var(--border), var(--brand-2) 40%);
}

.badge:hover {
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 10%);
  border-color: color-mix(in srgb, var(--border), var(--brand-1) 30%);
}

/* Small inline help icon for tooltips/explanations */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  user-select: none;
  cursor: help;
}

.help-icon:hover, .help-icon:focus {
  outline: none;
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 12%);
  border-color: color-mix(in srgb, var(--border), var(--brand-1) 35%);
  color: var(--text);
}

.muted { 
  color: var(--muted); 
}

.center { 
  text-align: center; 
}

.stack { 
  display: flex; 
  flex-direction: column; 
  gap: var(--space-md); 
}

.row { 
  display: flex; 
  align-items: center; 
  gap: var(--space-sm); 
  flex-wrap: wrap; 
}

.hidden { 
  display: none !important; 
}

/* Reveal Animation with Improved Timing */
.reveal { 
  opacity: 0; 
  transform: translateY(20px); 
  transition: opacity 0.6s ease, transform 0.6s ease; 
}

.reveal.is-visible { 
  opacity: 1; 
  transform: translateY(0); 
}

/* Responsive Design with Better Breakpoints */
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .pricing { grid-template-columns: 1fr; }
  .trust { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--space-xl); }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .container {
    padding-inline: var(--space-md);
  }
  
  .grid-3 { 
    grid-template-columns: 1fr; 
    gap: var(--space-md);
  }
  
  .hero h1 {
    font-size: clamp(28px, 6vw, 40px);
  }
  
  .section {
    padding: var(--space-3xl) 0;
  }
  
  .trust {
    padding: var(--space-md);
  }
  
  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--space-2xl);
  }
}

@media (max-width: 480px) {
  .hero-cta {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .trust img {
    width: 48px;
  }
}

/* Focus Visible for Better Accessibility */
*:focus-visible {
  outline: 2px solid var(--brand-1);
  outline-offset: 2px;
}

/* Ensure clear focus states on key interactive elements */
.btn:focus-visible,
.theme-toggle:focus-visible,
.copy:focus-visible,
.nav a:focus-visible,
.brand:focus-visible,
.help-icon:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand-2), var(--brand-1) 50%);
  outline-offset: 2px;
}

/* Playground specific code styling */
#pg-json,
#pg-curl {
  color: var(--code-text);
  background: var(--code-bg);
}

/* 404 Page */
.notfound { 
  display: grid; 
  place-items: center; 
  min-height: 60vh; 
  text-align: center; 
}

/* Smooth Transitions for Theme Changes */
html, body, .btn, .input, select, textarea, .card, .nav a, .code-card, .badge {
  transition: background-color var(--transition), 
              border-color var(--transition),
              color var(--transition);
}

/* Reduce motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ---------------- Docs: Layout + TOC + Anchors ---------------- */
.docs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: var(--space-xl);
}

@media (max-width: 1099px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
}

.docs-toc {
  display: none;
}

@media (min-width: 1100px) {
  .docs-toc {
    display: block;
    position: sticky;
    top: 88px; /* header height + space */
    align-self: start;
    max-height: calc(100vh - 100px);
    overflow: auto;
  }
}

.docs-toc-inner {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--space-md);
}

.docs-toc-title {
  display: block;
  color: var(--muted);
  font-size: var(--font-sm);
  letter-spacing: 0.04em;
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
}

.docs-toc-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.docs-toc-nav li { margin: 2px 0; }
.docs-toc-nav li ul { margin-left: 12px; padding-left: 10px; border-left: 1px dashed var(--border); }

.docs-toc-nav a {
  display: block;
  text-decoration: none;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
  transition: background var(--transition), color var(--transition);
}

.docs-toc-nav a:hover { background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 6%); color: var(--text); }
.docs-toc-nav a.active {
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 16%);
  color: var(--text);
  font-weight: 600;
  border-left: 3px solid var(--accent);
}

/* Collapsible TOC subsections */
.docs-toc-nav li { position: relative; }
.docs-toc-nav li.has-children > ul { margin-top: 4px; }
.docs-toc-nav li.collapsed > ul { display: none; }
.docs-toc-nav .toc-toggle {
  background: none;
  border: none;
  padding: 4px;
  margin-right: 4px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
}
.docs-toc-nav .toc-toggle:hover { background: color-mix(in srgb, var(--surface), transparent 40%); color: var(--text); }
.docs-toc-nav .toc-toggle svg { width: 13px; height: 13px; transition: transform var(--transition); }
.docs-toc-nav .toc-toggle { min-width: 28px; min-height: 28px; display: inline-flex; align-items: center; justify-content: center; }
.docs-toc-nav .toc-toggle svg { width: 16px; height: 16px; }
.docs-toc-nav li:not(.collapsed) > .toc-toggle svg { transform: rotate(90deg); }

.docs-content { min-width: 0; }

/* Heading anchor links */
.has-anchor { position: relative; }
.anchor-link {
  margin-left: 8px;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
  font-size: 0.85em;
}

.has-anchor:hover .anchor-link,
.has-anchor:focus-within .anchor-link { opacity: 1; }
.anchor-link:hover { color: var(--accent); text-decoration: underline; }

/* Code collapse toggle */
.collapse-btn {
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  background: color-mix(in srgb, var(--code-bg), var(--bg-elev) 30%);
  color: var(--muted);
  cursor: pointer;
  font-size: var(--font-sm);
}
.collapse-btn:hover { background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 10%); color: var(--text); }

.code-card.collapsed pre {
  max-height: 320px;
  overflow: hidden;
  position: relative;
}

.code-card.collapsed pre::after {
  content: '';
  position: sticky;
  display: block;
  bottom: 0;
  height: 48px;
  margin-top: -48px; /* overlay starts before end */
  background: linear-gradient(to bottom, rgba(0,0,0,0), var(--code-bg));
}

/* Mobile TOC */
.docs-toc-mobile {
  display: block;
  position: sticky;
  top: 76px; /* below sticky header */
  z-index: 5;
  margin: 0 0 var(--space-md);
  background: color-mix(in srgb, var(--surface), transparent 20%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-sm);
}

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

/* Docs: TOC search spacing */
#docs-toc-search { margin-bottom: var(--space-sm); }

/* Mobile-friendly code wrapping: reduce horizontal scroll pain */
@media (max-width: 720px) {
  .code-card pre,
  .code-card code { 
    white-space: pre-wrap; 
    word-break: break-word; 
    overflow-wrap: anywhere; 
  }
}

/* Blog post typography */
.blog-post {
  max-width: 78ch;
}
.blog-post p { font-size: var(--font-lg); line-height: 1.75; }
.blog-post h2 { margin-top: var(--space-2xl); }
.blog-post h3 { margin-top: var(--space-xl); }
.blog-post ul, .blog-post ol { padding-left: 1.2rem; }
.blog-post li { margin: 6px 0; }
.blog-post a { text-decoration-thickness: 1.5px; }
.blog-post .code-card { margin: var(--space-lg) 0; }

/* Back-to-top button */
.back-to-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--bg-elev), var(--brand-1) 18%);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--border), var(--brand-1) 40%);
  box-shadow: var(--shadow-2);
}
.back-to-top.show { display: inline-flex; }
.back-to-top svg { width: 16px; height: 16px; }

/* Product: summary preview description */
.feature-group summary .summary-desc {
  color: var(--muted);
  font-weight: 500;
  font-size: var(--font-sm);
}
