:root {
    --bg: #ffffff;
    --fg: #000000;
    --border: #e5e5e5;
    --muted: #666666;
    --accent: #000000;
}

/* Load Google Fonts */
/* @import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&family=Roboto+Mono:wght@400;700&display=swap'); */

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.6;
    margin-top: 40px;
    font-size: 16px;
}

.mono {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9em;
}

/* =========================================
   REFINED MINIMALIST NAVIGATION
   ========================================= */

nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    /* Slight transparency */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    padding: 24px 0;
}

.nav-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 30px;
    display: grid;
    /* This grid matches your home-grid (0.8fr 1.2fr) */
    grid-template-columns: 0.8fr 1.2fr;
}

.nav-links {
    grid-column: 2;
    /* Forces links to start where the work section starts */
    display: flex;
    gap: 32px;
}

.nav-links a {
    text-decoration: none;
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: lowercase;
    /* Matching your new bio style */
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--fg);
}

/* Mobile Nav adjustment */
@media (max-width: 768px) {
    .nav-content {
        display: block;
        /* Stack on mobile */
        text-align: right;
    }

    nav {
        padding: 15px 0;
    }

    .nav-links {
        justify-content: flex-end;
        gap: 20px;
    }

    .nav-links a {
        font-size: 0.9rem;
    }
}

/* Layout */
.container {
    max-width: 800px;
    margin: 80px auto 60px;
    padding: 0 30px;
}

.wide-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 30px;
}

/* Typography */
h1,
h2,
h3 {
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    line-height: 1.2;
}

h2 {
    font-size: 1.5rem;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

a {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-color: var(--border);
    transition: all 0.2s;
}

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

/* --- New Personal Intro Styles --- */

.intro-name {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    margin-bottom: 4px !important;
    text-transform: lowercase;
    /* Ted-style lowercase */
}

.intro-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 24px;
    text-transform: lowercase;
}

.home-intro .about-snippet p {
    font-size: 1.05rem;
    line-height: 1.5;
    margin-bottom: 16px;
    color: var(--fg);
    opacity: 0.85;
}

.archive-link {
    font-size: 0.8rem;
    margin-top: 20px;
    display: inline-block;
    opacity: 0.5;
    text-decoration: none;
}

.archive-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Cards & Grids (Default / Archive Views) */
.posts-grid {
    display: grid;
    gap: 40px;
}

.post-card,
.featured-card {
    display: block;
    text-decoration: none;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    background: var(--bg);
}

.post-card:hover,
.featured-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
    text-decoration: none;
}

.card-title {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
}

.post-title {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.card-meta {
    color: var(--muted);
    font-size: 0.85em;
    margin-bottom: 12px;
}

#blog-header .card-meta {
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 400;
    letter-spacing: 0.01em;
}

#blog-header .post-tags {
    margin-top: 20px;
    margin-bottom: 48px;
}

#blog-header .tag {
    background: transparent;
    border: 1px solid var(--border);
    padding: 4px 10px;
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.card-description,
.post-excerpt {
    color: var(--fg);
    font-size: 1rem;
    margin-bottom: 16px;
    opacity: 0.9;
}

.featured-label {
    display: inline-block;
    background: var(--fg);
    color: var(--bg);
    padding: 4px 8px;
    font-size: 0.75em;
    border-radius: 4px;
    margin-bottom: 16px;
}

.post-tags {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    color: var(--muted);
}

.cta-button {
    display: inline-block;
    margin-top: 20px;
    color: var(--fg);
    font-weight: 600;
    text-decoration: none;
}

.cta-button:hover {
    text-decoration: underline;
}

/* Footer */
footer {
    border-top: 1px solid var(--border);
    padding: 40px 30px;
    margin-top: 80px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9em;
}

/* Blog Content */
.blog-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 100px 30px 60px;
    display: grid;
    grid-template-columns: 1fr minmax(0, 720px) 1fr;
    gap: 60px;
}

.blog-content {
    grid-column: 2;
    min-width: 0;
}

.toc-sidebar {
    position: sticky;
    top: 100px;
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-left: 24px;
    border-left: 1px solid var(--border);
    display: block;
}

.toc-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 20px;
    color: var(--muted);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin-bottom: 10px;
}

.toc-list a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.85rem;
    display: block;
    line-height: 1.5;
    transition: all 0.2s;
    font-weight: 400;
    text-transform: lowercase;
    font-family: 'Roboto Mono', monospace;
}

.toc-list a.toc-h3 {
    padding-left: 16px;
    font-size: 0.85em;
}

.toc-list a:hover {
    color: var(--fg);
}

.toc-list a.active {
    color: var(--fg);
    font-weight: 700;
    position: relative;
}

.toc-list a.active::before {
    content: "→";
    position: absolute;
    left: -16px;
    color: var(--fg);
}

.blog-breadcrumb {
    font-size: 1.2rem;
    text-transform: lowercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 8px;
    font-weight: 500;
}

#blog-header h1 {
    font-size: 2.25rem;
    line-height: 1.2;
    margin-bottom: 16px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

#blog-content h2 {
    margin-top: 2.5rem;
}

#blog-content h3 {
    margin-top: 2rem;
}

#blog-content p {
    margin-bottom: 1.5rem;
}

#blog-content img {
    max-width: 100%;
    border-radius: 8px;
    margin: 20px 0;
}

#blog-content pre {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
}

#blog-content .math-display,
#blog-content .MathJax_Display,
#blog-content .katex-display,
#blog-content mjx-container[display="true"],
#blog-content .math {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    padding: 10px 0;
}

#blog-content mjx-container,
#blog-content .katex {
    max-width: 100%;
    overflow-x: auto;
}

#blog-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9em;
}

#blog-content pre code {
    background: none;
    padding: 0;
}

#blog-content blockquote {
    border-left: 4px solid var(--fg);
    margin: 20px 0;
    padding-left: 20px;
    font-style: italic;
    color: var(--muted);
}

/* Scroll Top Button */
.scroll-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 48px;
    height: 48px;
    background: var(--fg);
    color: var(--bg);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-top.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-top:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1024px) {
    .blog-container {
        grid-template-columns: 1fr;
        padding: 100px 40px 60px;
        gap: 40px;
    }

    .toc-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .blog-container {
        padding: 80px 16px 40px;
        gap: 0px;
    }

    .blog-content {
        padding: 0 4px;
    }

    .blog-breadcrumb {
        font-size: 0.95rem;
    }

    #blog-header h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }

    #blog-header .card-meta {
        font-size: 0.8rem;
    }

    #blog-content h2 {
        font-size: 1.3rem;
    }

    #blog-content h3 {
        font-size: 1.1rem;
    }

    #blog-content p {
        font-size: 0.95rem;
    }

    #blog-content pre {
        padding: 12px;
        font-size: 0.85rem;
    }

    #blog-content code {
        font-size: 0.85rem;
    }
}

/* =========================================
   NEW HOME LAYOUT (Refined Alignment)
   ========================================= */

.home-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 60px;
    max-width: 1100px;
    margin: 100px auto 60px;
    padding: 0 30px;
    margin-top: 140px;
}

@media (min-width: 768px) {
    .home-grid {
        grid-template-columns: 0.8fr 1.2fr;
        align-items: start;
    }

    .home-intro {
        position: sticky;
        top: 100px;
        /* Adjusted to sit comfortably below nav */
    }
}

/* --- Alignment Fixes (A) --- */
.home-intro h1 {
    font-size: 2rem;
    line-height: 1.1;
    /* Tighter line height for alignment */
    margin-top: 0 !important;
    /* Force start at the very top */
    margin-bottom: 24px;
    letter-spacing: -0.03em;
}

/* Alignment & Spacing Fix (Point A) */
.home-section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-top: 0 !important;
    padding-top: 4px;
    /* Optical alignment for the first header */
    margin-bottom: 24px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    display: block;
}

/* Add space above "Recent Writing" without affecting "Selected Work" */
.home-content-block+.home-content-block .home-section-title {
    margin-top: 60px !important;
    padding-top: 0;
    /* Remove the alignment padding for secondary headers */
}

/* Ensure the whole card feels clickable (Point B) */
.home-grid .featured-card {
    cursor: pointer;
    position: relative;
}

/* --- Restored Tags & Links (B & C) --- */

.home-grid .post-card,
.home-grid .featured-card {
    display: block;
    padding: 20px 0;
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: opacity 0.2s;
    text-decoration: none;
}

.home-grid .post-card:hover,
.home-grid .featured-card:hover {
    transform: none;
    box-shadow: none;
    opacity: 0.7;
}

.home-grid .card-title,
.home-grid .post-title {
    font-size: 1.15rem;
    margin: 0 0 4px 0;
    font-weight: 600;
    color: var(--fg);
}

.home-grid .card-meta {
    font-size: 0.8rem;
    margin-bottom: 8px;
    color: var(--muted);
}

.home-grid .card-description,
.home-grid .post-excerpt {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Home Tags Styling */
.home-grid .post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.home-grid .tag {
    background: transparent;
    border: 1px solid var(--border);
    padding: 2px 6px;
    font-size: 0.65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Home Links Styling (Try Maira Free, etc.) */
.home-grid .card-link {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--fg);
    text-decoration: none;
    border: 1px solid var(--fg);
    padding: 4px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}

.home-grid .card-link:hover {
    background: var(--fg);
    color: var(--bg);
}

/* Keep previous intro links styles */
.home-intro .tagline {
    color: var(--muted);
    margin-bottom: 32px;
}

.home-intro .links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.home-intro .links a {
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9em;
}

/* =========================================
   ARCHIVE PAGE (Matching New Home Style)
   ========================================= */

/* The main container uses the same grid as Home */
.archive-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 60px;
    max-width: 1100px;
    margin: 140px auto 60px;
    /* Space for fixed nav */
    padding: 0 30px;
}

@media (min-width: 768px) {
    .archive-layout {
        grid-template-columns: 0.8fr 1.2fr;
        align-items: start;
    }
}

/* Header styling (Left Column) */
.archive-layout .intro-name {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    margin-bottom: 4px !important;
    text-transform: lowercase;
}

.archive-layout .intro-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: lowercase;
}

/* The List (Right Column) */
.archive-layout #all-posts .post-card,
.archive-layout #all-posts .featured-card {
    display: block;
    border: none !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
    /* Subtle divider */
    border-radius: 0 !important;
    padding: 32px 0 !important;
    margin-bottom: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

/* Hover state for the whole list item */
.archive-layout #all-posts a:hover {
    opacity: 0.6;
    transform: none !important;
}

/* Typography inside the list */
.archive-layout .post-title,
.archive-layout .card-title {
    font-size: 1.1rem !important;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 8px;
}

.archive-layout .post-excerpt,
.archive-layout .card-description {
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.5;
    margin-bottom: 12px;
    max-width: 90%;
}

/* Tags in Archive */
.archive-layout .post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.archive-layout .tag {
    background: transparent;
    border: 1px solid var(--border);
    padding: 2px 6px;
    font-size: 0.65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* "Read More" link style */
.archive-layout .card-link {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--fg);
    text-transform: lowercase;
}

/* Remove border from the very last item */
.archive-layout #all-posts a:last-child .post-card,
.archive-layout #all-posts a:last-child .featured-card {
    border-bottom: none !important;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .archive-layout {
        margin-top: 100px;
        gap: 40px;
    }
}

/* =========================================
   RESUME PAGE STYLES (High Density)
   ========================================= */

.resume-layout {
    margin-top: 140px;
}

/* Sidebar TOC */
.resume-toc {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 40px;
}

.resume-toc a {
    font-size: 0.75rem;
    text-transform: lowercase;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s;
}

.resume-toc a:hover {
    color: var(--fg);
}

/* Content Styling */
.resume-markdown h1 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-top: 60px;
    margin-bottom: 24px;
}

.resume-markdown h1:first-of-type {
    margin-top: 0;
    /* Align with left column */
    padding-top: 4px;
    /* Visual balance with intro-name */
}

.resume-markdown h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 4px;
    text-transform: lowercase;
}

.resume-markdown p strong {
    font-size: 0.8rem;
    color: var(--muted);
    display: block;
    margin-bottom: 12px;
}

.resume-markdown ul {
    list-style: none;
    padding-left: 0;
}

.resume-markdown li {
    font-size: 0.95rem;
    margin-bottom: 10px;
    line-height: 1.5;
    position: relative;
    padding-left: 18px;
}

/* Minimalist bullet points */
.resume-markdown li::before {
    content: "—";
    position: absolute;
    left: 0;
    color: var(--border);
}

.resume-markdown hr {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    margin: 40px 0;
}

/* Skills section styling */
.resume-markdown li strong {
    color: var(--fg);
    display: inline;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .resume-toc {
        display: none;
        /* Hide TOC on small screens to save space */
    }
}

/* --- Pastel Highlights --- */
.hlt-y {
    background-color: #fff1b7;
    padding: 0 2px;
    border-radius: 2px;
}

/* Pastel Yellow */
.hlt-b {
    background-color: #cceaff;
    padding: 0 2px;
    border-radius: 2px;
}

/* Pastel Blue */
.hlt-p {
    background-color: #fce7f3;
    padding: 0 2px;
    border-radius: 2px;
}

/* Pastel Green */
.hlt-g {
    background-color: #85ffb0;
    padding: 0 2px;
    border-radius: 2px;
}

/* Pastel Red */
.hlt-r {
    background-color: #ff9494;
    padding: 0 2px;
    border-radius: 2px;
}

/* Pastel Pink */

/* --- Skills-as-Tags --- */
.skills-tag-container {
    list-style: none !important;
    padding-left: 0 !important;
}

.skills-tag-container li {
    padding-left: 0 !important;
    margin-bottom: 20px !important;
}

.skills-tag-container li::before {
    content: "" !important;
    /* Remove the dash for skills */
}

/* This turns the comma-separated text into a tag-cloud look */
.skills-tag-container li {
    font-size: 0.85rem;
    color: var(--muted);
}

.skills-tag-container strong {
    display: block;
    color: var(--fg);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

/* Adjust project links in resume */
.resume-markdown a[href*="http"] {
    font-size: 0.9rem;
    text-transform: lowercase;
    text-decoration: none;
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    color: var(--muted);
}

.resume-markdown a[href*="http"]:hover {
    border-color: var(--fg);
    color: var(--fg);
}

/* =========================================
   BLOG TABLE STYLES
   ========================================= */

#blog-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 0.95rem;
}

#blog-content thead {
    background: #f5f5f5;
}

#blog-content th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    border: 1px solid var(--border);
    font-size: 0.9rem;
}

#blog-content td {
    padding: 10px 16px;
    border: 1px solid var(--border);
    line-height: 1.5;
}

#blog-content tbody tr:hover {
    background: #fafafa;
}

/* Center align specific columns if needed */
#blog-content td:first-child,
#blog-content th:first-child {
    text-align: left;
}

/* Mobile responsiveness for tables */
@media (max-width: 768px) {
    #blog-content table {
        font-size: 0.85rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    #blog-content th,
    #blog-content td {
        padding: 8px 12px;
    }
}