/* ── Design Tokens ── */
:root {
    --surface: #161922;
    --surface-raised: #1c2030;
    --background: #0f1117;
    --accent: #6c63ff;
    --accent-hover: #5a52e0;
    --accent-glow: rgba(108, 99, 255, 0.25);
    --accent-subtle: rgba(108, 99, 255, 0.08);
    --text: #e4e4e7;
    --text-muted: #8b8b9e;
    --border: #2a2d3a;
    --nav-bg: #12141c;
    --nav-border: #1e2130;
    --pink: #ff0082;
    --cyan: #009dd9;
    --sidebar-w: 260px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

body::before {
    content: '';
    position: fixed;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(108, 99, 255, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(99, 179, 255, 0.03) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

/* ── Navigation ── */
.top-nav {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 200;
    backdrop-filter: blur(12px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-right: 2rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.nav-brand:hover { text-decoration: none; }
.nav-brand-icon { display: flex; align-items: center; }
.nav-brand-icon svg { width: 32px; height: auto; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s, background 0.2s;
}

.nav-links a:hover { color: var(--text); background: var(--accent-subtle); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: var(--accent-subtle); }

.spacer { flex: 1; }

.nav-github {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.35rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.nav-github:hover { background: var(--accent-subtle); border-color: var(--accent); color: var(--text); text-decoration: none; }

.mobile-nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    margin-right: 0.75rem;
}

/* ── Typography ── */
h1 {
    color: var(--text);
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
}

h2 {
    color: var(--text);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

h2:first-child, .docs-content > h2:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }

h3 {
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 600;
    margin-top: 1.75rem;
    margin-bottom: 0.5rem;
}

.docs-content > p:first-of-type {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

p { color: var(--text-muted); margin-bottom: 1rem; font-size: 0.925rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

ul, ol { color: var(--text-muted); padding-left: 1.25rem; margin-bottom: 1rem; }
li { margin-bottom: 0.4rem; font-size: 0.925rem; }
li::marker { color: var(--accent); }

code {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.825rem;
    color: #c4b5fd;
}

pre {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    overflow-x: auto;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

pre code { background: none; border: none; padding: 0; font-size: 0.825rem; }

/* ── Copy button ── */
.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s, border-color 0.2s;
}

pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── Callouts ── */
.callout {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    border-left: 3px solid;
}

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

.callout-info { background: rgba(99, 179, 255, 0.06); border-color: #63b3ff; color: #93c5fd; }
.callout-warning { background: rgba(251, 191, 36, 0.06); border-color: #fbbf24; color: #fcd34d; }
.callout-tip { background: rgba(52, 211, 153, 0.06); border-color: #34d399; color: #6ee7b7; }

/* ── Tables ── */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
}

th {
    text-align: left;
    padding: 0.625rem 0.75rem;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

tr:hover td { background: rgba(108, 99, 255, 0.03); }

/* ── Buttons ── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-accent {
    background: var(--accent-subtle);
    color: var(--accent);
    border: 1px solid rgba(108, 99, 255, 0.2);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s, box-shadow 0.2s, transform 0.1s;
    text-decoration: none;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #5a52e0);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover { opacity: 0.92; box-shadow: 0 4px 20px var(--accent-glow); }

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-lg {
    padding: 0.7rem 1.5rem;
    font-size: 0.925rem;
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 56px; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--nav-bg);
    border-right: 1px solid var(--nav-border);
    overflow-y: auto;
    padding: 1.25rem 0;
    z-index: 100;
}

.sidebar-section {
    padding: 0 1rem;
    margin-bottom: 1.25rem;
}

.sidebar-heading {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 0.75rem;
    margin-bottom: 0.4rem;
}

.sidebar a {
    display: block;
    padding: 0.35rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    margin-bottom: 1px;
}

.sidebar a:hover { color: var(--text); background: var(--accent-subtle); text-decoration: none; }
.sidebar a.active { color: var(--accent); background: var(--accent-subtle); font-weight: 500; }

/* ── Docs Main Content ── */
.docs-main {
    margin-left: var(--sidebar-w);
    min-height: calc(100vh - 56px);
}

.docs-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 2.5rem 3rem;
}

.docs-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

/* ── Prev/Next Nav ── */
.docs-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.docs-nav a {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    transition: border-color 0.2s, background 0.2s;
    min-width: 0;
}

.docs-nav a:hover { border-color: var(--accent); background: var(--accent-subtle); text-decoration: none; }
.docs-nav .nav-label { font-size: 0.75rem; color: var(--text-muted); }
.docs-nav .nav-title { font-size: 0.9rem; color: var(--accent); font-weight: 500; }
.docs-nav .next { text-align: right; margin-left: auto; }

/* ── Footer ── */
.site-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

.site-footer a { color: var(--accent); }
.site-footer a:hover { text-decoration: underline; }

/* ── Hero ── */
.hero {
    text-align: center;
    padding: 4.5rem 2rem 3rem;
    position: relative;
    overflow: hidden;
}

.hero > * { position: relative; z-index: 1; }

.hero-glow {
    position: absolute;
    top: -120px;
    left: 50%;
    transform: translateX(-50%);
    width: 700px;
    height: 450px;
    background: radial-gradient(ellipse, rgba(108, 99, 255, 0.1) 0%, rgba(0, 157, 217, 0.04) 50%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.hero-icon { width: 88px; margin: 0 auto 1.75rem; }
.hero-icon svg { width: 100%; height: auto; }

.hero h1 {
    font-size: 2.75rem;
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.15;
    margin-bottom: 1.25rem;
    background: linear-gradient(135deg, var(--text) 30%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    border-top: none;
    padding-top: 0;
}

.hero-sub {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.hero-version {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
}

/* ── Features Section ── */
.features-section {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem 2rem 3.5rem;
}

.section-heading {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    color: var(--text);
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.section-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 520px;
    margin: 0 auto 2rem;
}

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.feature-card:hover {
    border-color: rgba(108, 99, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.feature-card:nth-child(1) { border-top: 2px solid #ff0082; }
.feature-card:nth-child(2) { border-top: 2px solid #009dd9; }
.feature-card:nth-child(3) { border-top: 2px solid var(--accent); }
.feature-card:nth-child(4) { border-top: 2px solid #34d399; }
.feature-card:nth-child(5) { border-top: 2px solid #fbbf24; }
.feature-card:nth-child(6) { border-top: 2px solid #c084fc; }
.feature-card:nth-child(7) { border-top: 2px solid #f97316; }
.feature-card:nth-child(8) { border-top: 2px solid #ec4899; }
.feature-card:nth-child(9) { border-top: 2px solid #14b8a6; }

.feature-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.feature-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
}

/* ── Code Window ── */
.code-section {
    max-width: 720px;
    margin: 0 auto;
    padding: 1rem 2rem 3.5rem;
}

.code-window {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.code-chrome {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.code-dot { width: 10px; height: 10px; border-radius: 50%; }
.code-dot-red { background: #ff5f57; }
.code-dot-yellow { background: #febc2e; }
.code-dot-green { background: #28c840; }

.code-filename {
    margin-left: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
}

.code-window pre {
    margin: 0;
    border: none;
    border-radius: 0;
    padding: 1.5rem;
    line-height: 1.6;
}

.code-window pre code { font-size: 0.825rem; }

/* ── Architecture ── */
.arch-section {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem 2rem 3.5rem;
}

.arch-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 2rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.arch-step {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    transition: border-color 0.2s;
}

.arch-step:hover { border-color: var(--accent); }

.arch-arrow {
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 600;
}

/* ── CTA ── */
.cta-section {
    text-align: center;
    padding: 2.5rem 2rem 3.5rem;
    max-width: 640px;
    margin: 0 auto;
}

.cta-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    border-top: none;
    padding-top: 0;
}

.cta-links {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Dogfood Badge ── */
.dogfood-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.dogfood-badge strong { color: var(--accent); }

/* ── Ecosystem Section ── */
.ecosystem-section {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1rem 2rem 3.5rem;
}

.ecosystem-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.ecosystem-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    transition: border-color 0.2s;
}

.ecosystem-card:hover { border-color: rgba(108, 99, 255, 0.3); }

.ecosystem-card h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.ecosystem-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

/* ── Tutorial Cards ── */
.tutorial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.tutorial-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    text-decoration: none;
    transition: border-color 0.2s, transform 0.15s;
    display: block;
}

.tutorial-card:hover {
    border-color: rgba(108, 99, 255, 0.3);
    transform: translateY(-2px);
    text-decoration: none;
}

.tutorial-card h3 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.4rem;
    margin-top: 0;
}

.tutorial-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
}

.tutorial-card .difficulty {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    display: inline-block;
}

.difficulty-beginner { background: rgba(52, 211, 153, 0.1); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.2); }
.difficulty-intermediate { background: rgba(251, 191, 36, 0.1); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.2); }
.difficulty-advanced { background: rgba(248, 113, 113, 0.1); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.2); }

/* ── Why Melodic ── */
.comparison-table {
    width: 100%;
    margin-bottom: 1.5rem;
}

.comparison-table th:first-child { text-align: left; }
.comparison-table th { text-align: center; }
.comparison-table td:not(:first-child) { text-align: center; }

.check { color: #34d399; }
.cross { color: #f87171; }
.partial { color: #fbbf24; }

/* ── Doc Index Grid ── */
.doc-index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.doc-index-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    text-decoration: none;
    transition: border-color 0.2s;
    display: block;
}

.doc-index-card:hover { border-color: rgba(108, 99, 255, 0.3); text-decoration: none; }
.doc-index-card h4 { font-size: 0.9rem; color: var(--text); margin-bottom: 0.3rem; }
.doc-index-card p { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

/* ── Responsive ── */
@media (max-width: 900px) {
    .sidebar { display: none; }
    .sidebar.open { display: block; }
    .docs-main { margin-left: 0; }
    .mobile-nav-toggle { display: block; }
    .features { grid-template-columns: repeat(2, 1fr); }
    .ecosystem-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .hero h1 { font-size: 1.75rem; }
    .features { grid-template-columns: 1fr; }
    .arch-flow { flex-direction: column; }
    .arch-arrow { transform: rotate(90deg); }
    .docs-container { padding: 1.5rem 1rem; }
    .docs-content { padding: 1.5rem; }
}

@media (max-width: 480px) {
    .hero { padding: 3rem 1.25rem 2rem; }
    .hero h1 { font-size: 1.5rem; }
    .hero-actions { flex-direction: column; align-items: center; }
    .cta-links { flex-direction: column; align-items: center; }
    .top-nav { padding: 0 1rem; }
}
