/* ============================================================
   DESIGN TOKENS — dark-first, light-mode via media query
   ============================================================ */
:root {
    --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

    /* Dark mode (default) */
    --bg: #0a0a0b;
    --bg-elevated: #121214;
    --bg-subtle: #1a1a1d;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text-primary: #ededed;
    --text-secondary: #a0a0a5;
    --text-tertiary: #6a6a6f;
    --accent: #7ba3ff;
    --accent-soft: rgba(123, 163, 255, 0.10);
    --accent-border: rgba(123, 163, 255, 0.35);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --sidebar-width: 260px;
    --content-max: 820px;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #ffffff;
        --bg-elevated: #fafafa;
        --bg-subtle: #f2f2f3;
        --border: rgba(0, 0, 0, 0.08);
        --border-strong: rgba(0, 0, 0, 0.16);
        --text-primary: #0a0a0a;
        --text-secondary: #585860;
        --text-tertiary: #8a8a90;
        --accent: #2f5fe0;
        --accent-soft: rgba(47, 95, 224, 0.06);
        --accent-border: rgba(47, 95, 224, 0.28);
    }
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
}
img { max-width: 100%; display: block; }
a { color: inherit; }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3 {
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.011em;
    margin: 0 0 12px;
}
h1 { font-size: 2.25rem; line-height: 1.12; letter-spacing: -0.025em; }
h2 { font-size: 1.375rem; line-height: 1.3; }
h3 { font-size: 1rem; line-height: 1.4; }
p { margin: 0 0 14px; color: var(--text-secondary); }

.meta-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0 0 14px;
}
.meta-label-small {
    font-size: 11px;
    margin: 22px 0 10px;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 32px 24px;
    border-right: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 28px;
    overflow-y: auto;
}

.main-content {
    flex: 1;
    min-width: 0;
    padding: 56px 64px 80px;
    max-width: calc(var(--content-max) + 128px);
}

.section {
    padding: 44px 0;
    border-top: 1px solid var(--border);
}
.section:first-of-type {
    border-top: none;
    padding-top: 8px;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar-top {
    display: flex;
    align-items: center;
    gap: 12px;
}
.profile-pic {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}
.sidebar-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}
.sidebar-role {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 2px 0 0;
    line-height: 1.2;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-nav a {
    display: block;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    transition: color 0.15s, background 0.15s;
}
.sidebar-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-subtle);
}
.sidebar-nav a.active {
    color: var(--text-primary);
    background: var(--bg-subtle);
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-links a {
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: color 0.15s;
}
.sidebar-links a:hover { color: var(--text-primary); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary, .btn-secondary {
    display: inline-block;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-primary {
    background: var(--text-primary);
    color: var(--bg);
    border: 1px solid var(--text-primary);
}
.btn-primary:hover { opacity: 0.88; }
.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
    border-color: var(--text-primary);
    background: var(--bg-subtle);
}
.btn-sidebar {
    display: block;
    padding: 8px 12px;
    font-size: 13px;
    text-align: center;
}

/* ============================================================
   HERO
   ============================================================ */
.hero .hero-name {
    font-size: 2.5rem;
    font-weight: 500;
    margin: 0 0 16px;
    letter-spacing: -0.028em;
    line-height: 1.08;
}
.hero .hero-tagline {
    font-size: 1.0625rem;
    color: var(--text-secondary);
    max-width: 580px;
    margin: 0 0 24px;
    line-height: 1.55;
}
.hero-ctas {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============================================================
   METRICS GRID
   ============================================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 36px;
}
.metric-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}
.metric-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0 0 4px;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.metric-value {
    font-size: 1.375rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.015em;
    line-height: 1.2;
}

/* ============================================================
   THREAD / POSITIONING
   ============================================================ */
.thread-text {
    font-size: 1.375rem;
    font-weight: 400;
    line-height: 1.45;
    color: var(--text-primary);
    max-width: 640px;
    margin: 0;
    letter-spacing: -0.012em;
}

/* ============================================================
   PILLARS (CORE EXPERTISE)
   ============================================================ */
.pillars-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 22px;
}
.pillar-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color 0.2s, transform 0.2s;
}
.pillar-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}
.pillar-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.pillar-title {
    font-size: 0.9375rem;
    font-weight: 500;
    margin: 0 0 6px;
    color: var(--text-primary);
}
.pillar-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.55;
}

/* ============================================================
   TECH TAGS
   ============================================================ */
.tech-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.tech-tag {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    border: 1px solid var(--border);
    font-weight: 400;
}

/* ============================================================
   PROJECTS
   ============================================================ */
.project {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 26px;
    margin-bottom: 14px;
    transition: border-color 0.2s;
}
.project:hover { border-color: var(--border-strong); }
.project.featured {
    border-color: var(--accent-border);
    background:
        linear-gradient(180deg, var(--accent-soft) 0%, transparent 40%),
        var(--bg-elevated);
}
.project.featured:hover { border-color: var(--accent); }

.badge {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 500;
    margin-bottom: 14px;
    letter-spacing: 0.02em;
    border: 1px solid var(--accent-border);
}

.project-title {
    font-size: 1.0625rem;
    font-weight: 500;
    margin: 0 0 8px;
    color: var(--text-primary);
    letter-spacing: -0.011em;
    line-height: 1.35;
}
.project-desc {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin: 0 0 18px;
    line-height: 1.55;
}

.project-diagram {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 0 0 16px;
}
.project-diagram svg {
    width: 100%;
    height: auto;
    display: block;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}
.result-grid.three-col { grid-template-columns: repeat(3, 1fr); }
.result-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
}
.result-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0 0 3px;
    letter-spacing: 0.02em;
}
.result-value {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    font-family: var(--font-mono);
}

.project-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 14px;
    transition: opacity 0.15s;
}
.project-link:hover { opacity: 0.7; }

.compact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}
.project-compact {
    margin-bottom: 0;
    padding: 22px;
}
.project-compact .project-title { font-size: 0.9375rem; }
.project-compact .project-desc { font-size: 0.8125rem; margin-bottom: 14px; }

/* ============================================================
   PUBLICATIONS & EDUCATION
   ============================================================ */
.publications-list, .education-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.publications-list li {
    padding: 18px 0;
    border-top: 1px solid var(--border);
}
.publications-list li:first-child {
    border-top: none;
    padding-top: 0;
}
.pub-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.15s;
}
.pub-title:hover { color: var(--accent); }
.pub-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin: 6px 0 8px;
    font-family: var(--font-mono);
}
.pub-desc {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.55;
}

.education-list li {
    padding: 16px 0;
    border-top: 1px solid var(--border);
}
.education-list li:first-child { border-top: none; padding-top: 0; }
.edu-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 4px;
}
.edu-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin: 0 0 6px;
    font-family: var(--font-mono);
}
.edu-desc {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin: 0;
}
.edu-desc a {
    color: var(--accent);
    text-decoration: none;
}
.edu-desc a:hover { text-decoration: underline; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    margin-top: 40px;
    padding: 28px 0 0;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ============================================================
   FOCUS STATES (accessibility)
   ============================================================ */
a:focus-visible, button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 960px) {
    .container { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 24px 20px;
        gap: 20px;
    }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .sidebar-nav a { padding: 6px 10px; }
    .sidebar-footer { margin-top: 0; }
    .sidebar-links { flex-direction: row; gap: 6px; }

    .main-content { padding: 32px 24px 60px; }
    .hero .hero-name { font-size: 2rem; }
    .hero .hero-tagline { font-size: 1rem; }
    .thread-text { font-size: 1.1875rem; }

    .pillars-grid { grid-template-columns: 1fr; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .compact-grid { grid-template-columns: 1fr; }
    .result-grid, .result-grid.three-col { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    h1 { font-size: 1.75rem; }
    .result-grid.three-col { grid-template-columns: 1fr; }
    .project, .project-compact { padding: 20px; }
}

/* ============================================================
   THEMED BACKGROUND MOTIFS
   ============================================================ */

/* Containers that host motifs need positioning + overflow clip */
.pillar-card,
.section-publications {
    position: relative;
    overflow: hidden;
}

/* Content layers above motifs */
.pillar-card > .pillar-icon,
.pillar-card > .pillar-title,
.pillar-card > .pillar-desc,
.section-publications > h2,
.section-publications > .publications-list {
    position: relative;
    z-index: 1;
}

/* Generic motif container */
.motif-bg {
    position: absolute;
    pointer-events: none;
    opacity: 0.32;
    z-index: 0;
}

@media (prefers-color-scheme: light) {
    .motif-bg { opacity: 0.22; }
}

/* Per-motif positioning (amplified) */
.motif-classification {
    top: 8px;
    right: -20px;
    width: 190px;
    height: 100px;
}
.motif-llm {
    top: 12px;
    right: -14px;
    width: 210px;
    height: 62px;
}
.motif-scrna {
    top: 20px;
    right: -10px;
    width: 360px;
    height: 170px;
    opacity: 0.26;
}
.motif-hero {
    top: 24px;
    right: 18px;
    width: 190px;
    height: 105px;
    opacity: 0.24;
}
.motif-production {
    top: 14px;
    right: -10px;
    width: 180px;
    height: 76px;
}

/* Keyframes (subtle, slow) */
@keyframes motif-pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}
@keyframes motif-token {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}
@keyframes motif-breathe {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}
@keyframes motif-flow {
    to { stroke-dashoffset: -14; }
}
@keyframes arch-glow {
    0%, 100% { opacity: 0.88; }
    50% { opacity: 1; }
}

/* Classification: cluster points pulsing with staggered delays */
.motif-classification .pt {
    animation: motif-pulse 3.8s ease-in-out infinite;
}
.motif-classification .pt:nth-child(3n)   { animation-duration: 4.2s; animation-delay: -0.4s; }
.motif-classification .pt:nth-child(3n+1) { animation-duration: 3.6s; animation-delay: -1.1s; }
.motif-classification .pt:nth-child(3n+2) { animation-duration: 4.5s; animation-delay: -1.9s; }

/* LLM: tokens cascading left to right */
.motif-llm .tok {
    animation: motif-token 3s ease-in-out infinite;
}
.motif-llm .tok:nth-child(1) { animation-delay: 0s; }
.motif-llm .tok:nth-child(2) { animation-delay: 0.3s; }
.motif-llm .tok:nth-child(3) { animation-delay: 0.6s; }
.motif-llm .tok:nth-child(4) { animation-delay: 0.9s; }
.motif-llm .tok:nth-child(5) { animation-delay: 1.2s; }
.motif-llm .tok:nth-child(6) { animation-delay: 1.5s; }
.motif-llm .tok:nth-child(7) { animation-delay: 1.8s; }

/* scRNA-seq: cells breathing within clusters */
.motif-scrna .cell {
    animation: motif-breathe 4.3s ease-in-out infinite;
}
.motif-scrna .cell:nth-child(4n)   { animation-duration: 4.7s; animation-delay: -0.8s; }
.motif-scrna .cell:nth-child(4n+1) { animation-duration: 3.9s; animation-delay: -1.5s; }
.motif-scrna .cell:nth-child(4n+2) { animation-duration: 4.5s; animation-delay: -2.1s; }
.motif-scrna .cell:nth-child(4n+3) { animation-duration: 4.1s; animation-delay: -0.3s; }

/* KAN RL architecture diagram: flowing arrows + judge glow */
.arch-flow {
    stroke-dasharray: 4 3;
    animation: motif-flow 2.8s linear infinite;
}
.arch-loop {
    animation: motif-flow 3.4s linear infinite;
}
.arch-pulse {
    animation: arch-glow 3.2s ease-in-out infinite;
    transform-origin: center;
}

/* Reduced motion: hide decorative motifs, freeze arch diagram */
@media (prefers-reduced-motion: reduce) {
    .motif-bg { display: none; }
    .arch-flow { animation: none; stroke-dasharray: 0; }
    .arch-loop { animation: none; }
    .arch-pulse { animation: none; }
}

/* Mobile: reduce or hide motifs that compete with content */
@media (max-width: 480px) {
    .motif-classification, .motif-llm { opacity: 0.16; }
    .motif-scrna { opacity: 0.12; }
    .motif-hero, .motif-production { opacity: 0.14; }
}

/* ============================================================
   HERO CONTAINER FOR MOTIF
   ============================================================ */
.hero {
    position: relative;
    overflow: hidden;
}
.hero > *:not(.motif-bg) {
    position: relative;
    z-index: 1;
}

/* Hero motif: neural network */
.motif-hero .node {
    animation: motif-pulse 4s ease-in-out infinite;
}
.motif-hero .node:nth-child(3n)   { animation-duration: 4.4s; animation-delay: -0.5s; }
.motif-hero .node:nth-child(3n+1) { animation-duration: 3.7s; animation-delay: -1.2s; }
.motif-hero .node:nth-child(3n+2) { animation-duration: 4.6s; animation-delay: -2s; }

/* Production pillar motif: pipeline flow */
@keyframes pipe-flow {
    to { stroke-dashoffset: -14; }
}
.motif-production .pipe-line {
    stroke-dasharray: 4 3;
    animation: pipe-flow 3s linear infinite;
}
.motif-production .pipe-line:nth-child(2) { animation-duration: 3.6s; animation-delay: -0.5s; }
.motif-production .pipe-line:nth-child(3) { animation-duration: 2.8s; animation-delay: -1s; }
.motif-production .pipe-line:nth-child(4) { animation-duration: 3.4s; animation-delay: -0.3s; }
.motif-production .pipe-line:nth-child(5) { animation-duration: 3.2s; animation-delay: -0.8s; }

/* Extend LLM token cascade for 9 tokens */
.motif-llm .tok:nth-child(8) { animation-delay: 2.1s; }
.motif-llm .tok:nth-child(9) { animation-delay: 2.4s; }

/* ============================================================
   PROJECT VISUAL COMPONENTS (benchmark + pipeline)
   ============================================================ */
.project-visual {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin: 0 0 18px;
}
.project-visual svg {
    width: 100%;
    height: auto;
    display: block;
}

.project-result-tagline {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 4px 0 12px;
    line-height: 1.45;
    letter-spacing: -0.005em;
}

.project-impact {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: -6px 0 16px;
    line-height: 1.5;
    letter-spacing: -0.005em;
}

.looking-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
}
.looking-list li {
    position: relative;
    padding: 10px 0 10px 22px;
    font-size: 0.9375rem;
    color: var(--text-primary);
    border-top: 1px solid var(--border);
    line-height: 1.5;
}
.looking-list li:first-child { border-top: none; }
.looking-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 500;
}

.result-meaning {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 16px 0 18px;
    line-height: 1.55;
    font-style: italic;
    padding: 10px 14px;
    border-left: 2px solid var(--accent-border);
    background: var(--accent-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Benchmark bar pulse animations */
@keyframes bench-pulse-slow {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}
@keyframes bench-pulse-fast {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}
.bench-bar-slow { animation: bench-pulse-slow 3.4s ease-in-out infinite; }
.bench-bar-fast { animation: bench-pulse-fast 1.5s ease-in-out infinite; }

/* Pipeline visual animations */
.pipe-arrow {
    stroke-dasharray: 4 3;
    animation: pipe-flow 2.8s linear infinite;
}
@keyframes pipe-boundary-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.95; }
}
.pipe-boundary {
    animation: pipe-boundary-pulse 5s ease-in-out infinite;
}

/* Reduced motion: stop all new animations */
@media (prefers-reduced-motion: reduce) {
    .bench-bar-slow, .bench-bar-fast,
    .pipe-arrow, .pipe-boundary,
    .motif-production .pipe-line,
    .motif-hero .node {
        animation: none;
    }
    .pipe-arrow { stroke-dasharray: 0; }
    .motif-production .pipe-line { stroke-dasharray: 0; }
}
