/* ========================================
   Yuke Cai - Personal Academic Website
   Clean, minimal design with dark mode
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Light mode (default) */
    --bg: #fafafa;
    --bg-secondary: #ffffff;
    --bg-nav: rgba(255, 255, 255, 0.85);
    --text: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #888;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
    --tag-bg: #eef2ff;
    --tag-text: #3730a3;
    --code-bg: #f1f5f9;
    --footer-bg: #f8fafc;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --bg-nav: rgba(15, 23, 42, 0.9);
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #60a5fa;
    --accent-hover: #93bbfd;
    --border: #334155;
    --border-light: #1e293b;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
    --tag-bg: #1e293b;
    --tag-text: #93c5fd;
    --code-bg: #1e293b;
    --footer-bg: #0c1322;
}

/* Prevent transition flash on initial page load */
.no-transition,
.no-transition *,
.no-transition *::before,
.no-transition *::after {
    transition: none !important;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    line-height: 1.3;
    font-weight: 600;
}

h1 { font-size: 2rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.5rem; margin-top: 2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.25rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
}

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

ul, ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.35rem;
    color: var(--text-secondary);
}

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background-color: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: 4px;
}

pre {
    background-color: var(--code-bg);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

pre code {
    background: none;
    padding: 0;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

/* --- Navigation --- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-nav);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

nav {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.nav-inner {
    display: flex;
    align-items: center;
    height: 56px;
    gap: 1.5rem;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    white-space: nowrap;
    letter-spacing: -0.02em;
}

.nav-brand:hover {
    color: var(--accent);
}

.nav-links {
    display: flex;
    gap: 1.25rem;
    flex: 1;
}

.nav-links a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 450;
    padding: 0.25rem 0;
    position: relative;
}

.nav-links a:hover {
    color: var(--text);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--accent);
    transition: width 0.2s ease;
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-external {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-external a {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.nav-external a:hover {
    color: var(--accent);
}

/* --- Theme Toggle --- */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 34px;
    height: 34px;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.icon-moon { display: none; }
.icon-sun { display: block; }

[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: none; }

/* --- Hamburger --- */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.hamburger {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text);
    position: relative;
    transition: background-color 0.2s;
}

.hamburger::before,
.hamburger::after {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text);
    position: absolute;
    transition: transform 0.2s;
}

.hamburger::before { top: -6px; }
.hamburger::after { top: 6px; }

.nav-toggle.active .hamburger { background-color: transparent; }
.nav-toggle.active .hamburger::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle.active .hamburger::after { transform: translateY(-6px) rotate(-45deg); }

/* --- Main Content --- */
main {
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* --- Hero Section --- */
.hero {
    padding: 3rem 0 2rem;
    text-align: left;
}

.hero-avatar {
    margin-bottom: 1.5rem;
}

.hero-avatar img {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    box-shadow: var(--card-shadow);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hero-avatar img:hover {
    border-color: var(--accent);
    box-shadow: var(--card-shadow-hover);
}

.hero-name {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.hero-tagline {
    font-size: 1.15rem;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.hero-desc {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 600px;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.hero-links {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    color: #fff;
    background-color: var(--accent);
}

.btn:hover {
    background-color: var(--accent-hover);
    color: #fff;
}

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

.btn-outline:hover {
    background-color: var(--accent);
    color: #fff;
}

/* --- Home Section --- */
.home-section {
    padding: 1rem 0 2rem;
}

.home-section h2 {
    font-size: 1.35rem;
    margin-bottom: 1rem;
    color: var(--text);
}

/* --- Page Content --- */
.page-content {
    padding: 1rem 0 2rem;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

/* --- Cards for projects/experience --- */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: var(--card-shadow);
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
    border-color: var(--accent);
}

.card h3 {
    margin-top: 0;
    font-size: 1.1rem;
}

.card .meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.card ul {
    margin-bottom: 0;
}

/* --- Tags --- */
.tag {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.2em 0.6em;
    border-radius: 4px;
    background-color: var(--tag-bg);
    color: var(--tag-text);
    font-weight: 500;
    margin-right: 0.35rem;
    margin-bottom: 0.35rem;
}

/* --- Timeline --- */
.timeline-item {
    position: relative;
    padding-left: 1.5rem;
    padding-bottom: 1.5rem;
    border-left: 2px solid var(--border);
}

.timeline-item:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent);
}

.timeline-item h3 {
    margin-top: 0;
    font-size: 1.05rem;
}

.timeline-item .date {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

.timeline-item .org {
    font-size: 0.9rem;
    color: var(--accent);
    font-weight: 500;
}

/* --- Skills Grid --- */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

.skill-category h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    margin-top: 0;
}

/* --- Footer --- */
footer {
    background-color: var(--footer-bg);
    border-top: 1px solid var(--border);
    padding: 2rem 1.5rem;
    text-align: center;
    margin-top: auto;
}

.footer-inner p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-links a:hover {
    color: var(--accent);
}

.footer-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.footer-note a {
    color: var(--text-muted);
}

.footer-note a:hover {
    color: var(--accent);
}

/* --- Language Pills --- */
.lang-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-light);
}

.lang-item:last-child {
    border-bottom: none;
}

.lang-level {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
    }

    .nav-links,
    .nav-external {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background-color: var(--bg-nav);
        backdrop-filter: blur(12px);
        padding: 1rem 1.5rem;
        border-bottom: 1px solid var(--border);
        gap: 0.5rem;
    }

    .nav-links.open,
    .nav-external.open {
        display: flex;
    }

    .nav-external {
        top: auto;
        border-top: 1px solid var(--border);
        border-bottom: none;
    }

    .hero-name {
        font-size: 2rem;
    }

    .hero-avatar img {
        width: 130px;
        height: 130px;
    }

    .hero-tagline {
        font-size: 1rem;
    }

    .skills-grid {
        grid-template-columns: 1fr;
    }

    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.3rem; }
}

@media (max-width: 480px) {
    .hero-name {
        font-size: 1.75rem;
    }

    .hero-avatar img {
        width: 110px;
        height: 110px;
    }

    main {
        padding: 1.5rem 1rem;
    }

    .card {
        padding: 1rem;
    }
}
