:root {
    /* Soft Brutalist Systems Lab Palette */
    --paper: #f2ece4;
    --paper-strong: #fffdf9;
    --ink: #1c1a17;
    --ink-soft: #5e5954;
    --ink-faint: #99938b;
    --line: rgba(28, 26, 23, 0.12);
    --line-strong: rgba(28, 26, 23, 1);
    
    /* Accents - Used extremely sparingly */
    --accent-mint: #b5c29c;
    --accent-rose: #d7a9ae;
    --accent-yellow: #d8c488;
    
    --font-display: 'Fraunces', serif;
    --font-body: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Reveal ease */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    /* Full viewport scroll snapping */
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    background-color: var(--ink); /* For overscroll bounce */
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* Background Systems Grid */
.bg-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: 
        linear-gradient(to right, var(--line) 1px, transparent 1px),
        linear-gradient(to bottom, var(--line) 1px, transparent 1px);
    background-size: 4vw 4vw;
    opacity: 0.4;
    mask-image: radial-gradient(ellipse at center, white 20%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse at center, white 20%, transparent 80%);
}

/* Global Navigation (Fixed) */
.fixed-nav {
    position: fixed;
    top: 2vw;
    left: 2vw;
    right: 2vw;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none; /* Let clicks pass through empty areas */
}

.brand-block, .nav-links {
    pointer-events: auto; /* Re-enable clicks to links */
}

.brand-block {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    color: var(--ink);
    text-decoration: none;
    line-height: 1;
}

.brand-sys {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-top: 0.25rem;
    letter-spacing: 0.05em;
}

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

.nav-link {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink);
    position: relative;
    overflow: hidden;
    padding-bottom: 2px;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--ink);
    transform: translateX(-101%);
    transition: transform 0.4s var(--ease-out-expo);
}

.nav-link:hover::after {
    transform: translateX(0);
}

/* Progress Indicator */
.scroll-progress {
    position: fixed;
    right: 2vw;
    bottom: 2vw;
    z-index: 100;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-line {
    width: 40px;
    height: 1px;
    background: var(--line);
    position: relative;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--ink);
    width: 0%;
    transition: width 0.3s ease-out;
}

/* Sections */
.section-slide {
    position: relative;
    width: 100vw;
    height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 5vw;
}

/* Split Layout */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4vw;
    align-items: center;
    height: 100%;
    position: relative;
    z-index: 10;
}

/* Typography elements */
.display-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 8rem);
    line-height: 0.85;
    letter-spacing: -0.04em;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 2rem;
}

.display-title span {
    display: block;
    overflow: hidden;
}

.display-title span i {
    font-style: italic;
    font-weight: 400;
}

.body-lead {
    font-size: clamp(1rem, 1.5vw, 1.5rem);
    color: var(--ink-soft);
    max-width: 40ch;
    margin-bottom: 2rem;
    line-height: 1.4;
}

.meta-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-faint);
    margin-bottom: 1rem;
    display: block;
}

/* Brutalist details */
.sys-line {
    width: 100%;
    height: 1px;
    background-color: var(--line-strong);
    margin: 2rem 0;
}

.sys-box {
    border: 1px solid var(--line-strong);
    padding: 2rem;
    background: rgba(242, 236, 228, 0.5);
    backdrop-filter: blur(10px);
}

/* Cards & Lists */
.work-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--line-strong);
}

.work-item {
    display: block;
    padding: 0;
    border-bottom: 1px solid var(--line-strong);
    color: var(--ink);
    transition: background 0.4s var(--ease-out-expo), color 0.4s var(--ease-out-expo);
    position: relative;
    overflow: hidden;
}

.work-item.is-expanded {
    background: var(--ink);
    color: var(--paper);
}

.work-item::before {
    /* Kept for subtle background layering if needed, but background color swap handles it */
    content: none; 
}

.work-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 0;
    cursor: pointer;
    transition: padding 0.4s var(--ease-out-expo);
}

.work-header:hover {
    padding: 2rem 1rem;
}

.work-item.is-expanded .work-header {
    padding: 2rem 1rem;
}

.work-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 3.5vw, 4rem);
    line-height: 1;
    letter-spacing: -0.02em;
}

.work-meta {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: color 0.4s var(--ease-out-expo);
}

.work-toggle {
    font-size: 1.5rem;
    font-weight: 400;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 24px;
    transition: transform 0.4s var(--ease-out-expo);
}

.work-item.is-expanded .work-toggle {
    transform: rotate(45deg);
}

.work-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.5s var(--ease-out-expo);
}

.work-item.is-expanded .work-body {
    grid-template-rows: 1fr;
}

.work-inner {
    overflow: hidden;
    opacity: 0;
    padding: 0 1rem;
    transition: opacity 0.4s ease, padding 0.4s var(--ease-out-expo);
}

.work-item.is-expanded .work-inner {
    opacity: 1;
    padding: 0 1rem 2.5rem 1rem;
}

.work-item.is-expanded .btn-brutal {
    border-color: var(--paper);
    color: var(--paper);
}

.work-item.is-expanded .btn-brutal:hover {
    background: var(--paper);
    color: var(--ink);
}

.btn-brutal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-brutal:hover {
    background: var(--ink);
    color: var(--paper);
}

/* Animations Triggered by Classes */
.reveal-text {
    transform: translateY(100%);
    opacity: 0;
    transition: transform 1.2s var(--ease-out-expo), opacity 1.2s var(--ease-out-expo);
}

.is-inview .reveal-text {
    transform: translateY(0);
    opacity: 1;
}

/* Staggering reveals */
.is-inview .delay-1 { transition-delay: 0.1s; }
.is-inview .delay-2 { transition-delay: 0.2s; }
.is-inview .delay-3 { transition-delay: 0.3s; }
.is-inview .delay-4 { transition-delay: 0.4s; }

.reveal-fade {
    opacity: 0;
    filter: blur(10px);
    transition: opacity 1s ease, filter 1s ease;
}

.is-inview .reveal-fade {
    opacity: 1;
    filter: blur(0);
}

/* Image mask reveal */
.img-reveal {
    position: relative;
    overflow: hidden;
}

.img-reveal img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.1);
    transition: transform 1.5s var(--ease-out-expo);
}

.is-inview .img-reveal img {
    transform: scale(1);
}

.img-reveal::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--paper);
    transform-origin: top;
    transition: transform 1s var(--ease-out-expo);
    transition-delay: 0.2s;
}

.is-inview .img-reveal::after {
    transform: scaleY(0);
}

/* Dark Section Mode */
.section-dark {
    background: var(--ink);
    color: var(--paper);
}

.section-dark .display-title,
.section-dark .body-lead,
.section-dark .brand-name,
.section-dark .nav-link,
.section-dark .footer-link {
    color: var(--paper);
}

.section-dark .meta-label {
    color: rgba(255, 253, 249, 0.5);
}

.section-dark .line,
.section-dark .sys-line,
.section-dark .work-item {
    border-color: rgba(255, 253, 249, 0.2);
}

.section-dark .nav-link::after {
    background: var(--paper);
}

/* Footer / Contact */
.footer-links {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-family: var(--font-display);
    font-size: clamp(3rem, 6vw, 6rem);
    line-height: 0.9;
}

.footer-link {
    text-decoration: none;
    color: var(--ink);
    transition: opacity 0.3s ease;
}

.footer-link:hover {
    opacity: 0.5;
    font-style: italic;
}

@media (max-width: 900px) {
    .split-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    .work-meta {
        flex-direction: column;
        gap: 0.2rem;
        align-items: flex-end;
    }
}

/* ========================================
   MOBILE & RESPONSIVE SYSTEMS LAB
   ======================================== */
@media (max-width: 768px) {
    html {
        /* Re-enabling strict snapping on mobile layout per user request */
        scroll-snap-type: y mandatory; 
    }

    .section-slide {
        height: 100dvh;
        min-height: 100vh;
        scroll-snap-align: start;
        scroll-snap-stop: always;
        padding: 6rem 5vw 8rem 5vw; /* Extra padding top/bottom for nav clearance */
    }

    /* Typography Overrides */
    .display-title {
        font-size: clamp(2rem, 10vw, 3.5rem);
        margin-bottom: 1rem;
    }

    .body-lead {
        font-size: 0.95rem;
        margin-bottom: 1rem;
        max-width: 100%;
    }

    /* Mobile Navigation (Repositioned to Top & Bottom) */
    .fixed-nav {
        top: 0;
        left: 0;
        right: 0;
        background: rgba(242, 236, 228, 0.9);
        backdrop-filter: blur(10px);
        padding: 0.75rem 5vw;
        border-bottom: 1px solid var(--line-strong);
        justify-content: center;
        transition: background 0.3s ease, border-color 0.3s ease;
    }

    .brand-block {
        align-items: center;
        text-align: center;
    }

    .nav-links {
        /* Move standard links to a fixed bottom dock on mobile */
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(242, 236, 228, 0.9);
        backdrop-filter: blur(10px);
        padding: 0.75rem 5vw;
        border-top: 1px solid var(--line-strong);
        justify-content: space-between;
        gap: 0.5rem;
        z-index: 100;
        pointer-events: auto;
        transition: background 0.3s ease, border-color 0.3s ease;
    }

    .nav-link {
        font-size: 0.65rem;
    }

    /* Progress Hide */
    .scroll-progress {
        display: none;
    }

    /* Layout Constraints */
    .split-layout {
        gap: 1.5rem;
    }

    /* Accordion / Cards adjustment */
    .work-title {
        font-size: clamp(1.5rem, 7vw, 2.2rem);
    }

    .work-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 1.25rem 0;
    }

    .work-header:hover, .work-item.is-expanded .work-header {
        padding: 1.25rem 0.5rem;
    }

    .work-item.is-expanded .work-inner {
        padding: 0 1rem 4rem 1rem; /* Extra bottom padding on mobile so buttons aren't cut by screen bottom */
    }

    .work-meta {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.75rem;
    }

    /* Section Dark Theme Fixes for Mobile Fixed Elements */
    .section-dark .fixed-nav,
    .section-dark .nav-links {
        background: rgba(28, 26, 23, 0.9);
        border-color: rgba(255, 253, 249, 0.2);
    }

    /* Project List Fixes */
    .work-list {
        width: 100%;
        max-width: 100vw;
    }

    /* Wrap long nav links across lines if necessary */
    .nav-links {
        flex-wrap: wrap;
        width: 100%;
        box-sizing: border-box;
    }

    /* Snappy motion for mobile swiping */
    .reveal-text {
        transition-duration: 0.8s;
    }
}

/* ========================================
   BLOG / JOURNAL — Soft Brutalist Systems
   ======================================== */

/* Blog feed section — scrollable, not scroll-snap locked */
.section-blog-feed {
    position: relative;
    width: 100vw;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 8rem 5vw 6rem 5vw;
}

.blog-feed-inner {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

/* Blog Feed Container */
.blog-feed {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--line-strong);
}

/* Individual Post Card */
.blog-post-card {
    border-bottom: 1px solid var(--line-strong);
    cursor: pointer;
    transition: background 0.4s var(--ease-out-expo);
    position: relative;
    overflow: hidden;
}

.blog-post-card:hover {
    background: rgba(28, 26, 23, 0.03);
}

/* Post Header (always visible) */
.blog-post-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    padding: 1.75rem 0;
    transition: padding 0.3s var(--ease-out-expo);
}

.blog-post-card:hover .blog-post-header,
.blog-post-card.expanded .blog-post-header {
    padding: 1.75rem 1rem;
}

.blog-post-header-left {
    display: grid;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

/* Date */
.blog-post-date {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-faint);
}

/* Title */
.blog-post-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 2.8vw, 2.4rem);
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--ink);
}

/* Tags */
.blog-post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.2rem;
}

.blog-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--line-strong);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    background: transparent;
    transition: border-color 0.3s ease, color 0.3s ease;
}

/* Expand icon */
.blog-expand-icon {
    width: 32px;
    height: 32px;
    border: 1px solid var(--line-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-soft);
    flex-shrink: 0;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    transition: transform 0.4s var(--ease-out-expo), border-color 0.3s ease, color 0.3s ease;
}

.blog-post-card.expanded .blog-expand-icon {
    transform: rotate(180deg);
    border-color: rgba(246, 241, 232, 0.35);
    color: rgba(246, 241, 232, 0.65);
}

/* Expanded state — warm dark stone background */
.blog-post-card.expanded {
    background: #3d3830;
    color: var(--paper);
}

.blog-post-card.expanded .blog-post-title,
.blog-post-card.expanded .blog-post-date {
    color: var(--paper);
}

.blog-post-card.expanded .blog-tag {
    border-color: rgba(246, 241, 232, 0.3);
    color: rgba(246, 241, 232, 0.6);
}

/* Post Body (collapsible via grid-template-rows trick) */
.blog-post-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.5s var(--ease-out-expo);
}

.blog-post-card.expanded .blog-post-body {
    grid-template-rows: 1fr;
}

.blog-post-body-inner {
    overflow: hidden;
    opacity: 0;
    padding: 0 1rem;
    transition: opacity 0.35s ease, padding 0.4s var(--ease-out-expo);
}

.blog-post-card.expanded .blog-post-body-inner {
    opacity: 1;
    padding: 0 1rem 2.5rem 1rem;
}

/* Summary text */
.blog-post-summary {
    border-top: 1px solid rgba(246, 241, 232, 0.18);
    padding-top: 1rem;
    margin-bottom: 1rem;
}

.blog-post-summary p {
    color: rgba(246, 241, 232, 0.82);
    font-size: 1rem;
    line-height: 1.55;
    max-width: 64ch;
}

.blog-post-summary p + p {
    margin-top: 0.72rem;
}

/* Commit section */
.blog-post-commits {
    margin-top: 1.25rem;
}

.blog-post-commits-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(246, 241, 232, 0.5);
    margin-bottom: 0.6rem;
}

.blog-commit-list {
    list-style: none;
    display: grid;
    gap: 0.4rem;
}

.blog-commit-item {
    border: 1px solid rgba(246, 241, 232, 0.15);
    background: rgba(246, 241, 232, 0.05);
    padding: 0.45rem 0.7rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: rgba(246, 241, 232, 0.7);
}

/* Loading & Empty states */
.blog-loading,
.blog-empty {
    min-height: 160px;
    display: grid;
    place-items: center;
    text-align: center;
    gap: 0.6rem;
    padding: 2rem;
    color: var(--ink-faint);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.blog-empty h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    color: var(--ink);
    text-transform: none;
}

.blog-loading-spinner {
    width: 24px;
    height: 24px;
    border: 1px solid var(--line);
    border-top-color: var(--ink);
    animation: spin 0.9s linear infinite;
}

/* Blog-specific mobile overrides */
@media (max-width: 768px) {
    .section-blog-feed {
        padding: 6rem 5vw 4rem 5vw;
    }

    .blog-post-title {
        font-size: clamp(1.3rem, 6vw, 1.8rem);
    }

    .blog-post-header {
        gap: 1rem;
        padding: 1.25rem 0;
    }

    .blog-post-card:hover .blog-post-header,
    .blog-post-card.expanded .blog-post-header {
        padding: 1.25rem 0.5rem;
    }

    .blog-post-card.expanded .blog-post-body-inner {
        padding: 0 0.5rem 4rem 0.5rem;
    }
}
