/* ============================================================
   PerfLens docs site — vanilla CSS, dark + light themes.
   Design tokens mirror the app UI for consistency.
   ============================================================ */

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

:root,
[data-theme="dark"] {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;

    --bg-base:       #0f1117;
    --bg-surface:    #181a20;
    --bg-surface-2:  #1e2028;
    --bg-elevated:   #262830;

    --border-subtle:  rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.10);
    --border-strong:  rgba(255, 255, 255, 0.16);

    --text-primary:   #f0f0f3;
    --text-secondary: #9ca3af;
    --text-tertiary:  #6b7280;

    --accent:         #38bdf8;
    --accent-hover:   #7dd3fc;
    --accent-muted:   rgba(56, 189, 248, 0.12);

    --success:        #34d399;
    --warning:        #fbbf24;
    --error:          #f87171;
    --magenta:        #c084fc;

    --shadow-sm:  0 1px 2px rgba(0,0,0,0.4);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg:  0 8px 30px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 60px rgba(56, 189, 248, 0.10);

    --code-bg:    rgba(56, 189, 248, 0.10);
    --code-text:  var(--accent);

    --grad-accent: linear-gradient(135deg, #38bdf8 0%, #a78bfa 100%);
    --grad-hero:   radial-gradient(ellipse 80% 60% at 50% 0%, rgba(56,189,248,0.08), transparent 60%),
                   radial-gradient(ellipse 60% 40% at 90% 10%, rgba(192,132,252,0.06), transparent 60%);
}

[data-theme="light"] {
    --bg-base:       #f7f8fa;
    --bg-surface:    #ffffff;
    --bg-surface-2:  #f0f2f5;
    --bg-elevated:   #ffffff;

    --border-subtle:  rgba(0, 0, 0, 0.06);
    --border-default: rgba(0, 0, 0, 0.10);
    --border-strong:  rgba(0, 0, 0, 0.16);

    --text-primary:   #0f172a;
    --text-secondary: #475569;
    --text-tertiary:  #64748b;

    --accent:         #0284c7;
    --accent-hover:   #0369a1;
    --accent-muted:   rgba(2, 132, 199, 0.10);

    --shadow-sm:  0 1px 2px rgba(0,0,0,0.06);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:  0 8px 30px rgba(0,0,0,0.12);
    --shadow-glow: 0 0 60px rgba(2,132,199,0.10);

    --code-bg:    rgba(2, 132, 199, 0.10);
    --code-text:  var(--accent);

    --grad-hero:  radial-gradient(ellipse 80% 60% at 50% 0%, rgba(2,132,199,0.10), transparent 60%),
                  radial-gradient(ellipse 60% 40% at 90% 10%, rgba(168,85,247,0.06), transparent 60%);
}

html { scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color 120ms ease; }
a:hover { color: var(--accent-hover); }

/* ---------- Top navigation ---------- */
.topnav {
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--bg-base) 80%, transparent);
    border-bottom: 1px solid var(--border-subtle);
}
.topnav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex; align-items: center; gap: 28px;
}
.brand {
    font-weight: 700; font-size: 19px; letter-spacing: -0.01em;
    color: var(--text-primary);
}
.brand .a { color: var(--accent); }
.topnav-links { display: flex; gap: 24px; flex: 1; }
.topnav-links a {
    color: var(--text-secondary);
    font-size: 14px; font-weight: 500;
}
.topnav-links a:hover, .topnav-links a.active { color: var(--text-primary); }
.topnav-right { display: flex; gap: 10px; align-items: center; }
.topnav-right a.btn { font-size: 13px; }
.theme-btn {
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    color: var(--text-secondary);
    width: 36px; height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 140ms ease;
}
.theme-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }
.theme-btn svg { width: 16px; height: 16px; }

/* ---------- Layout primitives ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.section { padding: 80px 0; }
.section-narrow { max-width: 880px; margin: 0 auto; padding: 0 24px; }

.eyebrow {
    display: inline-block;
    font-size: 12px; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-muted);
    padding: 6px 12px; border-radius: 999px;
    margin-bottom: 20px;
}

h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
h1 { font-size: clamp(40px, 6vw, 64px); line-height: 1.05; }
h2 { font-size: clamp(28px, 3.6vw, 40px); line-height: 1.15; margin-bottom: 16px; }
h3 { font-size: 20px; line-height: 1.3; margin-bottom: 8px; }
p.lead { font-size: 18px; color: var(--text-secondary); max-width: 720px; }
.section-sub {
    font-size: 17px; color: var(--text-secondary);
    max-width: 720px; margin-bottom: 48px;
}

code, pre, kbd {
    font-family: var(--font-mono);
}
code:not(pre code) {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.875em;
    border: 1px solid var(--border-subtle);
}
pre {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 18px 20px;
    overflow-x: auto;
    font-size: 13.5px;
    line-height: 1.65;
    box-shadow: var(--shadow-sm);
    position: relative;
}
pre code { background: none; padding: 0; color: var(--text-primary); border: none; }

.copy-btn {
    position: absolute; top: 10px; right: 10px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-default);
    color: var(--text-tertiary);
    font-size: 11px;
    padding: 4px 9px;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0; transition: opacity 120ms ease, color 120ms ease;
    font-family: var(--font-sans);
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.copy-btn.copied { color: var(--success); border-color: var(--success); }

/* ---------- Hero ---------- */
.hero {
    padding: 100px 0 60px;
    background: var(--grad-hero);
    position: relative;
    overflow: hidden;
}
.hero-inner {
    max-width: 1200px; margin: 0 auto; padding: 0 24px;
    display: grid; grid-template-columns: 1fr; gap: 48px;
    text-align: center;
}
.hero h1 { margin-bottom: 20px; }
.hero h1 .grad {
    background: var(--grad-accent);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero-lede {
    font-size: clamp(17px, 2.2vw, 21px);
    color: var(--text-secondary);
    max-width: 760px; margin: 0 auto 32px;
}
.hero-actions {
    display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
    margin-bottom: 48px;
}
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 22px;
    border-radius: 10px;
    font-weight: 600; font-size: 14.5px;
    transition: all 140ms ease;
    border: 1px solid transparent;
    cursor: pointer;
}
.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15), 0 0 0 1px var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.30);
}
.btn-ghost {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-default);
}
.btn-ghost:hover {
    border-color: var(--border-strong);
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

.hero-badges {
    display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
    margin-bottom: 36px;
}
.hero-badges img { height: 22px; }

.hero-shot {
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    background: var(--bg-surface);
    max-width: 1100px;
    margin: 0 auto;
}
.hero-shot img { display: block; width: 100%; height: auto; }

/* ---------- Feature grid ---------- */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}
.feature {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 26px 24px;
    transition: border-color 140ms ease, transform 140ms ease;
}
.feature:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
}
.feature-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--accent-muted);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
    font-size: 18px;
}
.feature h3 { font-size: 16.5px; margin-bottom: 6px; }
.feature p { font-size: 14px; color: var(--text-secondary); line-height: 1.55; }

/* ---------- Screenshot strip ---------- */
.shots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
}
.shot {
    border-radius: 12px;
    border: 1px solid var(--border-default);
    overflow: hidden;
    background: var(--bg-surface);
    box-shadow: var(--shadow-md);
    transition: transform 200ms ease, box-shadow 200ms ease;
}
.shot:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.shot img { display: block; width: 100%; height: auto; }
.shot-caption {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface-2);
}
.shot-caption strong { color: var(--text-primary); display: block; margin-bottom: 2px; font-size: 13.5px; font-weight: 600; }

/* ---------- Quickstart steps ---------- */
.steps {
    display: grid;
    gap: 20px;
}
.step {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 22px 24px;
}
.step-num {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent-muted);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 15px;
}
.step-body h3 { margin-bottom: 4px; }
.step-body p { color: var(--text-secondary); font-size: 14.5px; margin-bottom: 12px; }
.step-body pre { margin-top: 6px; }

/* ---------- Tables ---------- */
table.ref {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
}
table.ref th, table.ref td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}
table.ref th {
    background: var(--bg-surface-2);
    font-weight: 600;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}
table.ref tbody tr:last-child td { border-bottom: none; }
table.ref tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
table.ref td code { font-size: 12.5px; white-space: nowrap; }

/* ---------- Callouts ---------- */
.note {
    border-left: 3px solid var(--accent);
    background: var(--accent-muted);
    padding: 14px 18px;
    border-radius: 0 8px 8px 0;
    font-size: 14.5px;
    color: var(--text-primary);
    margin: 16px 0;
}
.note.warn { border-color: var(--warning); background: rgba(251, 191, 36, 0.08); }
.note.warn strong { color: var(--warning); }
.note strong { color: var(--accent); }

/* ---------- Diagram blocks ---------- */
.diagram {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 28px;
    margin: 24px 0;
    text-align: center;
}
.diagram img { max-width: 100%; height: auto; }
.diagram-caption { color: var(--text-tertiary); font-size: 13px; margin-top: 14px; }

/* ---------- Prose ---------- */
.prose h2 { margin-top: 56px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: 32px; }
.prose p { color: var(--text-secondary); margin-bottom: 14px; font-size: 15.5px; }
.prose p strong { color: var(--text-primary); }
.prose ul, .prose ol { color: var(--text-secondary); padding-left: 22px; margin-bottom: 14px; }
.prose ul li, .prose ol li { margin-bottom: 6px; font-size: 15.5px; }
.prose ul li strong, .prose ol li strong { color: var(--text-primary); }
.prose pre { margin-bottom: 18px; }

/* ---------- TOC sidebar ---------- */
.layout-with-toc {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 56px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 56px 24px;
}
.toc {
    position: sticky; top: 100px;
    align-self: start;
    font-size: 13.5px;
    border-left: 1px solid var(--border-subtle);
    padding-left: 18px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}
.toc-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}
.toc ul { list-style: none; padding: 0; }
.toc li { margin-bottom: 6px; }
.toc a {
    color: var(--text-secondary);
    display: block;
    padding: 4px 0;
    border-radius: 4px;
    transition: color 120ms ease;
}
.toc a:hover, .toc a.active { color: var(--accent); }
@media (max-width: 960px) {
    .layout-with-toc { grid-template-columns: 1fr; }
    .toc { display: none; }
}

/* ---------- Footer ---------- */
footer {
    border-top: 1px solid var(--border-subtle);
    padding: 40px 24px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13.5px;
    margin-top: 60px;
}
footer a { color: var(--text-secondary); }
footer a:hover { color: var(--text-primary); }
footer .foot-row { display: flex; justify-content: center; gap: 22px; margin-bottom: 12px; flex-wrap: wrap; }

/* ---------- Tabs ---------- */
.tabs {
    border-bottom: 1px solid var(--border-default);
    display: flex; gap: 2px;
    margin-bottom: 18px;
}
.tab-btn {
    background: none; border: none; cursor: pointer;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-tertiary);
    border-bottom: 2px solid transparent;
    transition: color 140ms ease, border-color 140ms ease;
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Misc ---------- */
.kv {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 8px 24px;
    font-size: 14.5px;
}
.kv dt { color: var(--text-secondary); }
.kv dd { color: var(--text-primary); }

.split-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}
