/* =========================================
   CORE VARIABLES & RESET
   ========================================= */
/* =========================================
   FONTS
   ========================================= */
@font-face {
    font-family: 'IBM Plex Mono';
    src: url('fonts/IBMPlexMono-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('fonts/IBMPlexMono-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('fonts/IBMPlexMono-SemiBold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('fonts/IBMPlexMono-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

/* =========================================
   CORE VARIABLES & RESET
   ========================================= */
:root {
    --bg-color: #ffffff;
    --text-color: #000000;
    --font-main: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', Courier, monospace;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    cursor: auto;
    /* Default system cursor */
}

::selection {
    background: #00FF00;
    /* Neon Green for Brutalist contrast */
    color: #000;
}

/* =========================================
   HEADER & NAVIGATION
   ========================================= */
header {
    padding: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 250;
    /* Topmost layer (except lightbox) */
    mix-blend-mode: difference;
    /* Invert colors over content */
    color: #fff;
    pointer-events: none;
    /* Let clicks pass through empty space */
}

/* Re-enable pointer events for interactive elements */
header * {
    pointer-events: auto;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: -0.02em;
    text-decoration: none;
    color: #fff;
    cursor: pointer;
}

nav a {
    color: #fff;
    text-decoration: none;
    margin-left: 30px;
    font-size: 0.9rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-weight: 600;
}

/* =========================================
   MAIN CONTENT & PROJECT LIST
   ========================================= */
main {
    padding: 160px 0;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.project-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
    z-index: 20;
    mix-blend-mode: difference;
    color: #fff;
}

/* Individual Project Row */
.project-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    /* Title | Date | Tags */
    align-items: center;
    gap: 40px;
    padding: 8px 15px;
    cursor: pointer;
    position: relative;
    border-bottom: 1px solid #fff;
    transition: padding 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.project-item:first-child {
    border-top: 1px solid #fff;
}

.project-item:hover {
    padding: 20px 35px;
}

/* Typography specifics */
.project-title {
    font-size: clamp(0.7rem, 1.25vw, 1.5rem);
    font-weight: 800;
    text-transform: none;
    line-height: 1;
    letter-spacing: -0.02em;
    pointer-events: none;
}

.project-date {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: uppercase;
    white-space: nowrap;
    min-width: 60px;
    text-align: left;
    color: rgba(255, 255, 255, 0.6);
    /* Reduced contrast for hierarchy */
}

.project-tags {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: uppercase;
    white-space: nowrap;
    min-width: 150px;
    text-align: right;
    color: rgba(255, 255, 255, 0.6);
    /* Reduced contrast for hierarchy */
}

/* =========================================
   KINETIC PREVIEW (FLOATING IMAGE)
   ========================================= */
.preview-container {
    position: fixed;
    top: 0;
    left: 0;
    width: auto;
    height: auto;
    max-width: 50vw;
    max-height: 70vh;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    transform-origin: center center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    /* Transition is handled by JS requestAnimationFrame for performance */
}

.preview-container.visible {
    opacity: 1;
}

#preview-image {
    width: auto;
    height: auto;
    max-width: 50vw;
    max-height: 70vh;
    object-fit: contain;
    display: block;
}

/* =========================================
   OVERLAY: PROJECT DETAILS & ABOUT
   ========================================= */
.overlay {
    background: #fff;
    color: #000;
    z-index: 200;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

/* Back Button (Unified) */
.back-btn {
    position: fixed;
    top: 30px;
    left: 40px;
    background: none;
    color: #000;
    border: none;
    font-size: 0.9rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    cursor: pointer;
    z-index: 210;
    transition: opacity 0.2s;
}

.back-btn:hover {
    opacity: 0.5;
}

/* Split Layout for Project Detail */
.overlay-content.split-layout {
    display: grid;
    grid-template-columns: 35% 65%;
    height: 100vh;
    width: 100%;
}

.project-text-column {
    padding: 100px 50px 60px;
    border-right: 1px solid #eee;
    overflow-y: auto;
}

/* Gallery (Right Side) */
.gallery {
    padding: 100px 40px 60px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Thin grid gap */
    background: #fff;
}

.gallery-row {
    display: flex;
    gap: 4px;
}

.gallery-item {
    flex-basis: 0;
    flex-grow: var(--ratio, 1);
    aspect-ratio: var(--ratio, 1);
    overflow: hidden;
    cursor: pointer;
    border: 1px solid #e0e0e0;
}

.gallery-item img,
.gallery-item video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.03);
}

/* Project Metadata Styles */
#overlay-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-transform: none;
    line-height: 1;
    letter-spacing: -0.02em;
}

#overlay-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #000;
    padding-bottom: 15px;
    margin-bottom: 40px;
}

#overlay-meta .meta-date,
#overlay-meta .meta-tags,
.meta-link {
    font-family: var(--font-mono);
    text-transform: uppercase;
}

#overlay-meta .meta-date {
    font-size: 0.9rem;
    font-weight: 400;
}

#overlay-meta .meta-tags {
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.05em;
}

.meta-link {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #000;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
    margin-left: 15px;
}

.meta-link:hover {
    border-bottom-color: #000;
}

#overlay-description {
    font-size: 1rem;
    line-height: 1.6;
    max-width: 65ch;
    /* Optimal reading length */
}

#overlay-description p {
    margin-bottom: 1em;
}

/* About Layout Specifics */
.overlay-content.about-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 120px 50px 80px;
    overflow-y: auto;
    height: 100vh;
}

#about-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 30px;
    line-height: 1;
    letter-spacing: -0.02em;
    padding-bottom: 15px;
    border-bottom: 1px solid #000;
}

/* Basic markdown styling for About text */
#about-description {
    font-size: 0.95rem;
    line-height: 1.8;
}

#about-description p {
    margin-bottom: 1.5em;
}

#about-description h2 {
    margin-top: 50px;
    margin-bottom: 20px;
    color: #666;
    font-size: 0.85rem;
    text-transform: uppercase;
}

#about-description ul {
    list-style: none;
    padding: 0;
}

#about-description li {
    margin-bottom: 10px;
}

#about-description a {
    color: #000;
    text-decoration: none;
    border-bottom: 1px solid #ccc;
}

#about-description a:hover {
    border-color: #000;
}

/* =========================================
   LIGHTBOX
   ========================================= */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
}

#lightbox-video {
    max-width: 90vw;
    max-height: 90vh;
    outline: none;
}

#lightbox-content-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: none;
    border: none;
    color: #fff;
    font-family: var(--font-mono);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    text-transform: uppercase;
}

.lightbox-close {
    top: 30px;
    left: 40px;
    font-size: 1rem;
}

.lightbox-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    padding: 20px;
    z-index: 310;
}

.lightbox-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    padding: 20px;
    z-index: 310;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    opacity: 1;
}


/* =========================================
   RESPONSIVE (MOBILE)
   ========================================= */
@media (max-width: 900px) {
    header {
        padding: 20px;
    }

    nav a {
        margin-left: 15px;
        font-size: 0.8rem;
    }

    main {
        padding: 100px 0;
    }

    /* Disable floating kinetic preview on mobile */
    .preview-container {
        display: none !important;
    }

    /* Stack project list */
    .project-item {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        padding: 25px 20px;
        gap: 10px 20px;
        /* Vertical | Horizontal gap to prevent collision */
    }

    .project-item:hover {
        padding: 25px 20px;
        /* Disable expansion on mobile */
    }

    .project-title {
        font-size: 1.8rem;
        width: 100%;
        margin-bottom: 8px;
        /* Break line */
    }

    .project-date {
        flex: 0 0 auto;
        text-align: left;
        font-size: 0.8rem;
    }

    .project-tags {
        flex: 1 0 auto;
        text-align: right;
        font-size: 0.8rem;
        margin-left: auto;
        white-space: normal;
        /* Allow wrapping on small screens */
        line-height: 1.4;
    }

    /* Stack Overlays */
    .overlay-content.split-layout {
        display: flex;
        flex-direction: column;
        height: auto;
    }

    .project-text-column {
        width: 100%;
        padding: 80px 20px 40px;
        border-right: none;
        border-bottom: 1px solid #eee;
        height: auto;
        overflow: visible;
    }

    .gallery {
        width: 100%;
        padding: 40px 20px 80px;
        height: auto;
        overflow: visible;
    }

    .overlay {
        overflow-y: auto;
    }

    /* Scroll entire page */
    .back-btn {
        top: 20px;
        left: 20px;
        z-index: 300;
    }

    .overlay-content.about-content {
        padding: 100px 20px 60px;
    }

    #overlay-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Animation Keyframes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Base state for project items: hidden initially, visible after animation */
.project-item {
    animation: fadeInUp 0.6s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
    opacity: 0;
    /* Important: Start hidden */
}

/* --- New Animations & Global Settings --- */
html {
    scroll-behavior: smooth;
}

.animate-in {
    animation: fadeInUp 0.6s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
    opacity: 0;
}

.theme-toggle {
    cursor: pointer;
    font-size: 1.2rem;
    /* Slightly larger for the dot */
    vertical-align: middle;
}