/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-muted: #5a5a7a;
    --color-accent: #9b1b30;
    --color-accent-light: #c4354d;
    --color-gold: #ffcc00;
    --color-border: #e8e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --radius: 12px;
    --max-width: 1100px;
}

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* ===== Navigation ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: blur(12px);
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-accent);
}

.nav-links { display: flex; gap: 0.25rem; }

.nav-links a {
    text-decoration: none;
    color: var(--color-text-muted);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--color-accent);
    background: rgba(155, 27, 48, 0.06);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text);
}

/* ===== Hero ===== */
.hero {
    background: linear-gradient(135deg, var(--color-accent) 0%, #6b1525 100%);
    color: white;
    padding: 5rem 2rem 4rem;
    text-align: center;
}

.hero-content { max-width: var(--max-width); margin: 0 auto; }

.hero h1 {
    font-size: 2.75rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: 1.15rem;
    opacity: 0.9;
    margin-bottom: 1rem;
    font-weight: 500;
}

.hero-description {
    font-size: 1rem;
    opacity: 0.75;
    max-width: 600px;
    margin: 0 auto;
}

/* ===== Page Hero (project pages) ===== */
.page-hero {
    background: linear-gradient(135deg, var(--color-accent) 0%, #6b1525 100%);
    color: white;
    padding: 3.5rem 2rem 3rem;
}

.page-hero-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}

.page-hero .badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

.page-hero h1 {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.page-hero p {
    font-size: 1.05rem;
    opacity: 0.85;
    max-width: 700px;
    line-height: 1.6;
}

/* ===== Container ===== */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* ===== Project Cards (home) ===== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.project-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    transition: all 0.3s ease;
    position: relative;
}

.project-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: var(--color-accent);
}

.card-badge {
    display: inline-block;
    background: var(--color-accent);
    color: white;
    padding: 0.2rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: 0.04em;
}

.project-card h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.card-desc {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
    line-height: 1.6;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.card-tags span {
    background: rgba(155, 27, 48, 0.08);
    color: var(--color-accent);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
}

/* ===== About Section ===== */
.about-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
}

.about-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.about-section p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.about-section p:last-child { margin-bottom: 0; }

/* ===== Project Page Content ===== */
.project-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2.5rem 2rem 4rem;
}

/* Section blocks */
.section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.section h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    color: var(--color-text);
}

.section p, .section li {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
}

.section ul, .section ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.section li { margin-bottom: 0.4rem; }

/* Highlight box */
.highlight-box {
    background: rgba(155, 27, 48, 0.05);
    border-left: 4px solid var(--color-accent);
    padding: 1.25rem 1.5rem;
    border-radius: 0 8px 8px 0;
    margin: 1.25rem 0;
}

.highlight-box p {
    color: var(--color-text) !important;
    font-weight: 500;
}

/* Data pipeline steps */
.pipeline {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.25rem 0;
}

.pipeline-step {
    flex: 1;
    min-width: 180px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
    position: relative;
}

.pipeline-step .step-num {
    display: inline-block;
    width: 28px;
    height: 28px;
    line-height: 28px;
    background: var(--color-accent);
    color: white;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.pipeline-step h4 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.pipeline-step p {
    font-size: 0.8rem !important;
    line-height: 1.5 !important;
}

/* Visualization grid */
.viz-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

.viz-item {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
}

.viz-item img {
    width: 100%;
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
}

.viz-item img:hover { transform: scale(1.01); }

.viz-caption {
    padding: 1rem 1.25rem;
}

.viz-caption h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.viz-caption p {
    font-size: 0.85rem !important;
    line-height: 1.5 !important;
}

.viz-grid-2col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin: 1.25rem 0;
}

.stat-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-accent);
    display: block;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
    display: block;
}

/* Code block */
.code-block {
    background: #1e1e2e;
    color: #cdd6f4;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    overflow-x: auto;
    margin: 1rem 0;
}

.code-block .comment { color: #6c7086; }
.code-block .keyword { color: #cba6f7; }
.code-block .string { color: #a6e3a1; }
.code-block .func { color: #89b4fa; }

/* Table of contents */
.toc {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.toc h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.toc ol {
    padding-left: 1.25rem;
    margin: 0;
}

.toc li {
    margin-bottom: 0.35rem;
}

.toc a {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.toc a:hover { text-decoration: underline; }

/* Map images */
.map-container {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    margin: 1rem 0;
}

.map-container img {
    width: 100%;
    display: block;
}

.map-caption {
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

/* ===== Lightbox ===== */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    padding: 2rem;
}

.lightbox.active { display: flex; }

.lightbox img {
    max-width: 95%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--color-border);
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--color-surface);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow-md);
    }

    .nav-links.open { display: flex; }
    .nav-toggle { display: block; }

    .hero h1 { font-size: 2rem; }
    .hero { padding: 3.5rem 1.5rem 3rem; }
    .page-hero h1 { font-size: 1.75rem; }
    .projects-grid { grid-template-columns: 1fr; }
    .pipeline { flex-direction: column; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .viz-grid-2col { grid-template-columns: 1fr; }
    .container, .project-content { padding: 1.5rem 1rem; }
    .section { padding: 1.5rem; }
}
