/* ═══════════════════════════════════════════════════════════
   LP24 Protocol Docs — Stylesheet
   Dark theme, accent-driven, docs.uniswap.org-inspired layout
   ═══════════════════════════════════════════════════════════ */

:root {
    --accent: #00D4AA;
    --accent-dark: #00B894;
    --accent-rgb: 0, 212, 170;
    --bg-primary: #0A0B0F;
    --bg-secondary: #0F1117;
    --bg-tertiary: #141620;
    --bg-code: #161822;
    --border: rgba(255, 255, 255, 0.07);
    --border-active: rgba(0, 212, 170, 0.3);
    --text-primary: #E8E9ED;
    --text-secondary: rgba(255, 255, 255, 0.55);
    --text-muted: rgba(255, 255, 255, 0.35);
    --sidebar-width: 260px;
    --toc-width: 200px;
    --nav-height: 56px;
    --yellow: #FBBF24;
    --red: #FF6B6B;
    --blue: #60A5FA;
    --purple: #A78BFA;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Top Nav ─────────────────────────────────────────────── */
.top-nav {
    background: rgba(10, 11, 15, 0.97);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    height: var(--nav-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-link {
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.brand-accent { color: var(--accent); }
.brand-suffix { color: var(--text-secondary); font-weight: 500; font-size: 0.9em; margin-left: 1px; }

.nav-chain-badges {
    display: flex;
    gap: 6px;
}

.chain-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chain-badge.base { background: rgba(0, 82, 255, 0.15); color: #3B82F6; border: 1px solid rgba(0, 82, 255, 0.2); }
.chain-badge.bsc { background: rgba(243, 186, 47, 0.12); color: #F3BA2F; border: 1px solid rgba(243, 186, 47, 0.2); }

.nav-right { display: flex; align-items: center; gap: 12px; }

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: all 0.15s ease;
}
.nav-link:hover { color: var(--accent); border-color: var(--border-active); }
.chain-link-base { color: #3B82F6; border-color: rgba(0, 82, 255, 0.2); }
.chain-link-base:hover { color: #60A5FA; border-color: rgba(59, 130, 246, 0.4); }
.chain-link-bsc { color: #F3BA2F; border-color: rgba(243, 186, 47, 0.2); }
.chain-link-bsc:hover { color: #FBBF24; border-color: rgba(243, 186, 47, 0.4); }

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

/* ── Layout ──────────────────────────────────────────────── */
.docs-layout {
    display: flex;
    margin-top: var(--nav-height);
    min-height: calc(100vh - var(--nav-height));
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: fixed;
    top: var(--nav-height);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--bg-secondary);
    z-index: 50;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.sidebar-nav { padding: 16px 0; }

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

.sidebar-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 12px 20px 6px;
}

.sidebar-link {
    display: block;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 20px 6px 24px;
    border-left: 2px solid transparent;
    transition: all 0.12s ease;
    line-height: 1.5;
}
.sidebar-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}
.sidebar-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.06);
    font-weight: 500;
}

/* ── Content ─────────────────────────────────────────────── */
.docs-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    margin-right: var(--toc-width);
    padding: 40px 48px 80px;
    max-width: 820px;
}

.docs-article { line-height: 1.75; }

/* ── Table of Contents ───────────────────────────────────── */
.toc-sidebar {
    width: var(--toc-width);
    position: fixed;
    top: var(--nav-height);
    right: 0;
    bottom: 0;
    padding: 24px 16px;
    overflow-y: auto;
    border-left: 1px solid var(--border);
}

.toc-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.toc-nav a {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 3px 0 3px 10px;
    border-left: 1px solid transparent;
    transition: all 0.12s ease;
    line-height: 1.6;
}
.toc-nav a:hover { color: var(--text-secondary); }
.toc-nav a.active { color: var(--accent); border-left-color: var(--accent); }
.toc-nav a.depth-3 { padding-left: 20px; }

/* ── Typography ──────────────────────────────────────────── */
.docs-article h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
    color: #fff;
    line-height: 1.2;
}

.docs-article h2 {
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 48px 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    color: #fff;
    scroll-margin-top: calc(var(--nav-height) + 24px);
}

.docs-article h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 32px 0 12px;
    color: #fff;
    scroll-margin-top: calc(var(--nav-height) + 24px);
}

.docs-article h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 24px 0 8px;
    color: var(--text-primary);
    scroll-margin-top: calc(var(--nav-height) + 24px);
}

.docs-article p {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.docs-article a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.docs-article a:hover { text-decoration: underline; }

.page-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

/* ── Code blocks ─────────────────────────────────────────── */
.docs-article code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125em;
    background: var(--bg-code);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.docs-article pre {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px 24px;
    overflow-x: auto;
    margin: 16px 0 24px;
    line-height: 1.65;
}

.docs-article pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.8125rem;
    color: var(--text-primary);
}

/* Syntax colors */
.kw { color: var(--purple); }
.fn { color: var(--blue); }
.str { color: var(--yellow); }
.cm { color: var(--text-muted); font-style: italic; }
.num { color: #F472B6; }
.type { color: #34D399; }
.op { color: var(--text-secondary); }

/* ── Tables ──────────────────────────────────────────────── */
.docs-table-wrap { overflow-x: auto; margin: 16px 0 24px; }

.docs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8375rem;
}

.docs-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

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

.docs-table td code {
    font-size: 0.78em;
    white-space: nowrap;
}

/* ── Callouts ────────────────────────────────────────────── */
.callout {
    padding: 16px 20px;
    border-radius: 10px;
    margin: 20px 0;
    font-size: 0.875rem;
    line-height: 1.65;
    border-left: 3px solid;
}

.callout p { margin-bottom: 8px; color: inherit; }
.callout p:last-child { margin-bottom: 0; }

.callout-title {
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.callout.info {
    background: rgba(96, 165, 250, 0.08);
    border-color: var(--blue);
    color: rgba(255,255,255,0.7);
}
.callout.info .callout-title { color: var(--blue); }

.callout.warning {
    background: rgba(251, 191, 36, 0.08);
    border-color: var(--yellow);
    color: rgba(255,255,255,0.7);
}
.callout.warning .callout-title { color: var(--yellow); }

.callout.danger {
    background: rgba(255, 107, 107, 0.08);
    border-color: var(--red);
    color: rgba(255,255,255,0.7);
}
.callout.danger .callout-title { color: var(--red); }

.callout.tip {
    background: rgba(var(--accent-rgb), 0.08);
    border-color: var(--accent);
    color: rgba(255,255,255,0.7);
}
.callout.tip .callout-title { color: var(--accent); }

/* ── Function Reference Card ─────────────────────────────── */
.fn-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 24px 0;
    overflow: hidden;
}

.fn-card-header {
    background: var(--bg-tertiary);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}

.fn-card-header code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    background: none;
    border: none;
    padding: 0;
}

.fn-badge {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 7px;
    border-radius: 4px;
}
.fn-badge.payable { background: rgba(var(--accent-rgb), 0.15); color: var(--accent); }
.fn-badge.view { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.fn-badge.external { background: rgba(167, 139, 250, 0.15); color: var(--purple); }
.fn-badge.nonreentrant { background: rgba(251, 191, 36, 0.15); color: var(--yellow); }

.fn-card-body { padding: 16px 20px; }
.fn-card-body p { font-size: 0.875rem; }

.fn-params-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 16px 0 8px;
}

/* ── Landing cards ───────────────────────────────────────── */
.landing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.landing-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    text-decoration: none;
    transition: all 0.15s ease;
}
.landing-card:hover {
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.landing-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
}

.landing-card-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ── Page navigation footer ──────────────────────────────── */
.docs-footer {
    margin-top: 64px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

.page-nav-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    gap: 4px;
}
.page-nav-link:hover .page-nav-title { color: var(--accent); }

.page-nav-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.page-nav-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.12s ease;
}

.page-nav-link.next { text-align: right; margin-left: auto; }

/* ── Sidebar Overlay ─────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 40;
}

/* ── Lists ────────────────────────────────────────────────── */
.docs-article ul, .docs-article ol {
    padding-left: 24px;
    margin: 12px 0 20px;
}

.docs-article li {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.65;
}

.docs-article li code { font-size: 0.78em; }

/* ── Diagram / Flow ──────────────────────────────────────── */
.flow-steps {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 24px 0;
}

.flow-step {
    display: flex;
    gap: 16px;
    position: relative;
}

.flow-step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.flow-step-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
    z-index: 1;
}

.flow-step-line {
    width: 2px;
    flex: 1;
    background: var(--border);
    min-height: 20px;
}

.flow-step:last-child .flow-step-line { display: none; }

.flow-step-content {
    padding-bottom: 24px;
}

.flow-step-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.flow-step-desc {
    font-size: 0.8375rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ── Chain Diff Table ────────────────────────────────────── */
.chain-diff-row td:nth-child(2) { color: #3B82F6; }
.chain-diff-row td:nth-child(3) { color: #F3BA2F; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
    .toc-sidebar { display: none; }
    .docs-content { margin-right: 0; }
}

@media (max-width: 860px) {
    .mobile-menu-btn { display: block; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.visible { display: block; }

    .docs-content {
        margin-left: 0;
        padding: 28px 20px 60px;
    }

    .docs-article h1 { font-size: 1.6rem; }
    .docs-article h2 { font-size: 1.2rem; }

    .landing-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .nav-chain-badges { display: none; }
    .docs-article pre { padding: 14px 16px; font-size: 0.75rem; }
}
