/* ============================================
   Carl Luo — Personal Homepage
   Design inspired by steipete.me
   ============================================ */

/* --- CSS Variables / Design Tokens --- */
:root {
    /* Light theme */
    --bg-primary: #fdfdfd;
    --bg-secondary: #f5f5f5;
    --text-primary: #1a1a2e;
    --text-secondary: #555770;
    --text-muted: #8888a0;
    --accent: #006cac;
    --accent-hover: #0088d4;
    --border: #e2e2ea;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
    --header-bg: rgba(253, 253, 253, 0.85);
    --transition-speed: 0.3s;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --border: #334155;
    --card-bg: #1e293b;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.15);
    --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.3);
    --header-bg: rgba(15, 23, 42, 0.85);
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color var(--transition-speed) ease,
                color var(--transition-speed) ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

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

/* --- Cursor Blink Animation --- */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.cursor-blink {
    animation: blink 1s step-end infinite;
    color: var(--accent);
    font-weight: 700;
}

/* --- Fade-in Animation --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.6s ease-out forwards;
}

/* --- Header --- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-speed) ease,
                border-color var(--transition-speed) ease;
}

.header-inner {
    max-width: 768px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
    transition: color var(--transition-speed) ease;
}

.site-name:hover {
    color: var(--accent);
}

.nav {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    position: relative;
    padding-bottom: 2px;
    transition: color var(--transition-speed) ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width var(--transition-speed) ease;
    border-radius: 1px;
}

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

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

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-speed) ease,
                background var(--transition-speed) ease;
}

.icon-btn:hover {
    color: var(--accent);
    background: var(--bg-secondary);
}

/* Theme toggle icon visibility */
[data-theme="light"] .moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }

/* --- Main Content --- */
.main {
    max-width: 768px;
    margin: 0 auto;
    padding: 0 24px;
}

/* --- Hero Section --- */
.hero {
    padding: 56px 0 40px;
    border-bottom: 1px solid var(--border);
    animation: fadeInUp 0.6s ease-out;
}

.hero-inner {
    display: flex;
    align-items: flex-start;
    gap: 28px;
}

.avatar-wrapper {
    flex-shrink: 0;
}

.avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    transition: border-color var(--transition-speed) ease,
                transform var(--transition-speed) ease,
                box-shadow var(--transition-speed) ease;
}

.avatar:hover {
    border-color: var(--accent);
    transform: scale(1.05);
    box-shadow: 0 0 0 4px rgba(0, 108, 172, 0.15);
}

[data-theme="dark"] .avatar:hover {
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.15);
}

.hero-content {
    flex: 1;
    min-width: 0;
}

.hero-title {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.highlight {
    color: var(--accent);
}

.hero-bio {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 16px;
}

.social-links {
    display: flex;
    gap: 12px;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: var(--text-secondary);
    transition: color var(--transition-speed) ease,
                background var(--transition-speed) ease,
                transform var(--transition-speed) ease;
}

.social-link:hover {
    color: var(--accent);
    background: var(--bg-secondary);
    transform: rotate(6deg) scale(1.1);
}

/* --- Posts Section --- */
.posts-section {
    padding: 48px 0;
}

.posts-list {
    display: flex;
    flex-direction: column;
}

.post-card {
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
    animation: fadeInUp 0.6s ease-out;
    animation-fill-mode: both;
    transition: border-color var(--transition-speed) ease;
}

.post-card:nth-child(1) { animation-delay: 0.1s; }
.post-card:nth-child(2) { animation-delay: 0.2s; }
.post-card:nth-child(3) { animation-delay: 0.3s; }
.post-card:nth-child(4) { animation-delay: 0.4s; }
.post-card:nth-child(5) { animation-delay: 0.5s; }

.post-card:last-child {
    border-bottom: none;
}

.post-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    line-height: 1.4;
    transition: color var(--transition-speed) ease;
    display: inline-block;
    position: relative;
}

.post-title::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1.5px;
    background: var(--accent-hover);
    transition: width 0.4s ease;
}

.post-title:hover {
    color: var(--accent-hover);
}

.post-title:hover::after {
    width: 100%;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.post-date {
    display: flex;
    align-items: center;
    gap: 5px;
}

.post-date svg {
    opacity: 0.7;
}

.post-reading-time {
    font-style: italic;
}

.post-excerpt {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* --- About Section --- */
.about-section {
    padding: 48px 0 64px;
    border-top: 1px solid var(--border);
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
    letter-spacing: -0.3px;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 40px;
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
}

.about-text p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 16px;
}

.about-text p:last-child {
    margin-bottom: 0;
}

.about-subtitle {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 18px 0 8px;
    letter-spacing: -0.2px;
}

.about-list {
    margin: 0 0 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.about-list li {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.about-list li strong {
    color: var(--text-primary);
}

/* --- Education --- */
.education {
    margin-top: 28px;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: background var(--transition-speed) ease,
                border-color var(--transition-speed) ease;
}

.education-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    letter-spacing: -0.2px;
}

.education-title svg {
    color: var(--accent);
    flex-shrink: 0;
}

.education-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.education-degree {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
}

.education-school {
    font-size: 13px;
    color: var(--text-secondary);
}

.about-links {
    margin-top: 28px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.about-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all var(--transition-speed) ease;
}

.about-link:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
}

/* --- Footer --- */
.footer {
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
    transition: background var(--transition-speed) ease,
                border-color var(--transition-speed) ease;
}

.footer-inner {
    max-width: 768px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-text {
    font-size: 13px;
    color: var(--text-muted);
}

.footer-social {
    display: flex;
    gap: 12px;
}

.social-link-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 6px;
    transition: color var(--transition-speed) ease,
                transform var(--transition-speed) ease;
}

.social-link-sm:hover {
    color: var(--accent);
    transform: rotate(6deg);
}

/* --- Responsive Design --- */
@media (max-width: 640px) {
    .header-inner {
        padding: 12px 16px;
    }

    .nav {
        gap: 16px;
    }

    .main {
        padding: 0 16px;
    }

    .hero {
        padding: 32px 0 28px;
    }

    .hero-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 20px;
    }

    .hero-title {
        font-size: 20px;
    }

    .social-links {
        justify-content: center;
    }

    .avatar {
        width: 100px;
        height: 100px;
    }

    .post-card {
        padding: 20px 0;
    }

    .post-title {
        font-size: 15px;
    }

    .about-links {
        flex-direction: column;
    }

    .footer-inner {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}

/* --- Scroll reveal on posts --- */
@media (prefers-reduced-motion: no-preference) {
    .post-card {
        opacity: 0;
    }
}

/* --- Selection Styling --- */
::selection {
    background: var(--accent);
    color: #ffffff;
}

/* --- Scrollbar Styling (webkit) --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
