/* ======================================================
   Astro Code Survey — Clean Best-of Style
   Dark, information-dense, GitHub-inspired
   ====================================================== */

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

:root {
    --bg: #0d1117;
    --bg-surface: #161b22;
    --bg-hover: #1c2129;
    --border: #30363d;
    --border-muted: #21262d;
    --text: #e6edf3;
    --text-2: #8b949e;
    --text-3: #6e7681;
    --link: #58a6ff;
    --link-hover: #79c0ff;
    --accent: #388bfd;
    --gold: #d29922;
    --silver: #8b949e;
    --bronze: #a0714f;
    --green: #3fb950;
    --ff: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
    --mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--ff);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: rgba(56, 139, 253, 0.3);
    color: var(--text);
}

a {
    color: var(--link);
    text-decoration: none;
}

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

/* === Layout === */
.wrapper {
    max-width: 920px;
    margin: 0 auto;
    padding: 40px 28px 60px;
}

/* === Header === */
.header {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-2);
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.header-btn:hover {
    color: var(--text);
    background: var(--bg-surface);
    border-color: var(--text-3);
    text-decoration: none;
}

.tagline {
    font-size: 0.95rem;
    color: var(--text-2);
    margin-bottom: 8px;
}

.tagline strong {
    color: var(--text);
}

.meta {
    font-size: 0.82rem;
    color: var(--text-3);
    line-height: 1.7;
}

/* === Stats Bar === */
.stats-bar {
    display: flex;
    gap: 6px;
    margin-top: 16px;
}

.stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 6px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
    gap: 2px;
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === Legend === */
.legend {
    margin-bottom: 24px;
    padding: 14px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.legend h2 {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-3);
    margin-bottom: 8px;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    font-size: 0.78rem;
    color: var(--text-2);
    align-items: center;
}

.rank-sample {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    color: #0d1117;
    margin-right: 3px;
}

.rank-sample.gold {
    background: var(--gold);
}

.rank-sample.silver {
    background: var(--silver);
}

.rank-sample.bronze {
    background: var(--bronze);
}

.lang-dot-sample {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 3px;
    vertical-align: middle;
}

/* === TOC === */
.contents {
    margin-bottom: 24px;
}

.contents h2 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.contents ul {
    columns: 2;
    column-gap: 28px;
    list-style: none;
}

.contents li {
    break-inside: avoid;
    padding: 3px 0;
    font-size: 0.84rem;
}

.contents a {
    color: var(--text-2);
    text-decoration: none;
}

.contents a:hover {
    color: var(--link);
}

.toc-count {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-3);
}

/* === Search === */
.search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.search-input-wrap {
    flex: 1;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}

#searchInput {
    width: 100%;
    padding: 9px 14px 9px 34px;
    font-family: var(--ff);
    font-size: 0.85rem;
    color: var(--text);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#searchInput::placeholder {
    color: var(--text-3);
}

#searchInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 139, 253, 0.12);
}

.search-count {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-3);
    white-space: nowrap;
}

/* === Category === */
.cat-section {
    margin-bottom: 36px;
}

.cat-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.cat-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.cat-count {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-3);
    background: var(--bg-surface);
    padding: 1px 7px;
    border-radius: 10px;
    border: 1px solid var(--border-muted);
}

.cat-desc {
    font-size: 0.8rem;
    color: var(--text-3);
    margin-bottom: 10px;
    padding-top: 4px;
}

/* === Project Entry === */
.project-entry {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-muted);
    transition: background 0.12s ease;
    align-items: flex-start;
}

.project-entry:last-child {
    border-bottom: none;
}

.project-entry:hover {
    background: var(--bg-hover);
    border-radius: 6px;
}

/* Rank badge */
.proj-rank {
    font-family: var(--mono);
    font-size: 0.68rem;
    font-weight: 700;
    min-width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 2px;
    color: #0d1117;
    background: var(--border);
}

.proj-rank.gold {
    background: var(--gold);
}

.proj-rank.silver {
    background: var(--silver);
}

.proj-rank.bronze {
    background: var(--bronze);
}

.proj-rank.normal {
    color: var(--text-3);
}

/* Entry body */
.proj-body {
    flex: 1;
    min-width: 0;
}

.proj-title-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}

.proj-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--link);
    text-decoration: none;
}

.proj-name:hover {
    text-decoration: underline;
}

.proj-stars {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--gold);
    white-space: nowrap;
}

.proj-lang {
    font-size: 0.7rem;
    color: var(--text-3);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.lang-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.proj-desc {
    font-size: 0.82rem;
    color: var(--text-2);
    line-height: 1.55;
}

/* Language colors */
.lang-python {
    background: #3572a5;
}

.lang-fortran {
    background: #734f96;
}

.lang-c {
    background: #555;
}

.lang-cpp {
    background: #f34b7d;
}

.lang-rust {
    background: #dea584;
}

.lang-julia {
    background: #a270ba;
}

.lang-markdown {
    background: #083fa1;
}

.lang-default {
    background: var(--text-3);
}

/* === No results === */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-3);
    font-size: 0.88rem;
}

/* === Back to top === */
.back-top {
    display: block;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-3);
    padding: 12px 0;
    text-decoration: none;
    border-top: 1px solid var(--border-muted);
    margin-top: 20px;
}

.back-top:hover {
    color: var(--link);
    text-decoration: none;
}

/* === Author Section === */
.author-section {
    margin-top: 40px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.author-section h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.author-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
}

.author-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.author-bio {
    font-size: 0.84rem;
    color: var(--text-2);
    line-height: 1.65;
    margin-bottom: 16px;
}

.author-bio em {
    color: var(--text);
    font-style: italic;
}

.author-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-2);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.social-link:hover {
    color: var(--link);
    border-color: var(--link);
    background: rgba(56, 139, 253, 0.06);
    text-decoration: none;
}

.social-link svg {
    flex-shrink: 0;
}

/* === Footer === */
.footer {
    margin-top: 8px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.footer-inner {
    text-align: center;
}

.footer-inner p {
    font-size: 0.78rem;
    color: var(--text-3);
}

/* === Responsive === */
@media (max-width: 640px) {
    .wrapper {
        padding: 24px 16px 40px;
    }

    .header h1 {
        font-size: 1.35rem;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .stats-bar {
        flex-wrap: wrap;
    }

    .stats-bar .stat {
        min-width: calc(33% - 6px);
    }

    .contents ul {
        columns: 1;
    }

    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-count {
        text-align: right;
    }

    .project-entry {
        gap: 8px;
        padding: 10px 8px;
    }

    .proj-title-row {
        gap: 6px;
    }

    .legend-items {
        gap: 4px 14px;
    }

    .author-card {
        padding: 16px;
    }

    .author-links {
        gap: 6px;
    }

    .social-link {
        padding: 5px 10px;
        font-size: 0.74rem;
    }
}