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

:root {
    --bg: #0d1117;
    --bg-surface: #161b22;
    --bg-surface-hover: #1c2333;
    --border: #30363d;
    --border-light: #21262d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --text-dim: #484f58;
    --accent-blue: #388bfd;
    --accent-green: #3fb950;
    --accent-orange: #e3b341;
    --accent-purple: #bc8cff;
    --accent-red: #f85149;
    --accent-teal: #39d2c0;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Navbar === */
.navbar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 2rem;
}
.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    white-space: nowrap;
}
.nav-brand:hover { text-decoration: none; color: var(--accent-blue); }
.nav-links { display: flex; align-items: center; gap: 0.25rem; }
.nav-link {
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
}
.nav-link:hover { color: var(--text); background: var(--bg-surface-hover); text-decoration: none; }
.nav-dropdown { position: relative; }
.nav-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 240px;
    max-height: 70vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    z-index: 200;
}
.nav-dropdown:hover .nav-dropdown-content { display: block; }
.nav-dropdown-content a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}
.nav-dropdown-content a:hover {
    background: var(--bg-surface-hover);
    color: var(--text);
    text-decoration: none;
}

/* === Container === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    flex: 1;
    width: 100%;
}

/* === Hero === */
.hero {
    text-align: center;
    padding: 3rem 0 2rem;
}
.hero h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.hero-sub { color: var(--text-muted); font-size: 1.1rem; max-width: 600px; margin: 0 auto 2rem; }
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 2rem;
}
.stat { text-align: center; }
.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-blue);
}
.stat-label { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: #4d9afe; }
.btn-secondary { background: var(--bg-surface); color: var(--text-muted); border-color: var(--border); }
.btn-secondary:hover { color: var(--text); border-color: var(--text-muted); }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.8rem; }

/* === Chips / Badges === */
.chip {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.chip-lg { font-size: 0.8rem; padding: 0.25rem 0.7rem; }
.chip-asset { background: rgba(56,139,253,0.15); color: var(--accent-blue); border: 1px solid rgba(56,139,253,0.3); }
.chip-category { background: rgba(188,140,255,0.15); color: var(--accent-purple); border: 1px solid rgba(188,140,255,0.3); }

.impl-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.impl-options_factory { background: rgba(56,139,253,0.2); color: var(--accent-blue); }
.impl-python_plugin { background: rgba(63,185,80,0.2); color: var(--accent-green); }
.impl-json_config { background: rgba(227,179,65,0.2); color: var(--accent-orange); }

/* === Chapter Grid === */
.chapters-section { margin: 3rem 0; }
.chapters-section h2, .quick-links h2 { margin-bottom: 1.25rem; font-size: 1.3rem; }
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.chapter-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all 0.15s;
    display: block;
    color: var(--text);
}
.chapter-card:hover {
    border-color: var(--accent-blue);
    background: var(--bg-surface-hover);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.chapter-number { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.chapter-name { font-size: 1.05rem; font-weight: 600; margin: 0.25rem 0; }
.chapter-count { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.5rem; }
.chapter-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; }

/* === Tag Cloud === */
.quick-links { margin: 2.5rem 0; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* === Catalog Layout === */
.catalog-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 2rem;
    align-items: start;
}
.sidebar {
    position: sticky;
    top: 72px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.sidebar-section { margin-bottom: 1.25rem; }
.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.search-input, .filter-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--font);
}
.search-input:focus, .filter-select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(56,139,253,0.2);
}
.filter-select { cursor: pointer; }
.filter-select option { background: var(--bg-surface); }

/* === Catalog Header === */
.catalog-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.catalog-header h1 { font-size: 1.5rem; }
.result-count { color: var(--text-muted); font-size: 0.85rem; }

/* === Card Grid === */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.strategy-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: all 0.15s;
    color: var(--text);
}
.strategy-card:hover {
    border-color: var(--accent-blue);
    background: var(--bg-surface-hover);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.strategy-id {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}
.strategy-id-lg { font-size: 1.1rem; }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; line-height: 1.3; }
.card-desc {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
    flex: 1;
    margin-bottom: 0.75rem;
}
.card-footer { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* === Detail Layout === */
.detail-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    align-items: start;
}
.breadcrumb {
    display: flex;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent-blue); }
.detail-header { margin-bottom: 2rem; }
.detail-header h1 { font-size: 1.8rem; margin: 0.5rem 0; }
.detail-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.detail-section { margin-bottom: 2rem; }
.detail-section h2 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}
.detail-description { font-size: 1rem; line-height: 1.7; }
.docstring {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-wrap;
}
.code-block {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
    color: var(--accent-green);
}

/* === Params Table === */
.params-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.params-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.params-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
}
.param-name { font-family: var(--font-mono); color: var(--accent-teal); font-weight: 500; }
.param-value { font-family: var(--font-mono); color: var(--accent-orange); }
.param-type { color: var(--text-dim); font-size: 0.8rem; }

/* === Detail Sidebar === */
.detail-sidebar { position: sticky; top: 72px; }
.sidebar-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.sidebar-card h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.meta-list { font-size: 0.85rem; }
.meta-list dt { color: var(--text-dim); font-size: 0.75rem; margin-top: 0.5rem; text-transform: uppercase; letter-spacing: 0.03em; }
.meta-list dd { color: var(--text); margin-left: 0; }
.meta-list dd code { font-family: var(--font-mono); color: var(--accent-green); font-size: 0.85rem; }
.nav-card .prev-next {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}
.empty-state p { margin-bottom: 1rem; }

/* === Footer === */
.footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    margin-top: 3rem;
}
.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
}

/* === Responsive === */
@media (max-width: 900px) {
    .catalog-layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .detail-layout { grid-template-columns: 1fr; }
    .detail-sidebar { position: static; }
    .stats-bar { gap: 1.5rem; }
    .stat-value { font-size: 1.5rem; }
    .hero h1 { font-size: 1.8rem; }
}
@media (max-width: 600px) {
    .card-grid { grid-template-columns: 1fr; }
    .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .stats-bar { flex-wrap: wrap; gap: 1rem; }
}
