:root {
    --bg-color: #f1d9cd; /* 5% lighter than #e5cfc3 */
    --text-color: #1a1a1a;
    --red-title: #990f1e;
    --border-color: #1a1a1a;
    --border-thickness: 3px;
    --font-mono: 'Courier Prime', monospace;
}

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

/* Physics draggable constraints to prevent scrolling while dragging */
.art-card, .header-title, .header-subtitle, .nav-item {
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none; /* Disables native ghost dragging on links! */
    will-change: transform, left, top;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-mono);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Subtle Art-Gallery Paper Grain Texture Overlay */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.15; /* Subtle blend strength */
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.layout {
    min-height: 100vh;
    display: flex;
    padding: 4rem 5rem;
    position: relative;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* CRITICAL FIX: Allows container to shrink gracefully so side-nav isn't chopped off */
}

/* Header Typography */
.header {
    margin-bottom: 3rem;
    max-width: 600px;
}

.header-subtitle {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.header-line {
    width: 100%;
    height: var(--border-thickness);
    background-color: var(--border-color);
    margin-bottom: 1.5rem;
}

.header-title {
    font-size: 3rem;
    font-weight: 700;
    color: var(--red-title);
    letter-spacing: 2px;
}

/* Gallery Grid */
.gallery-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.gallery-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 Columns is technically much better for 2x2 bento ratios */
    grid-auto-rows: 180px; /* FIXED ROW HEIGHT for strict bento control */
    grid-auto-flow: dense;
    gap: 1.5rem;
    max-width: 1100px;
}



.art-card {
    border: var(--border-thickness) solid var(--border-color);
    background-color: #F1D5C1;
    position: relative;
    cursor: grab;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    box-shadow: 4px 4px 0 var(--border-color); /* Brutalist tactile shadow */
}

.art-card:hover {
    transform: translate(-4px, -4px);
    box-shadow: 8px 8px 0 var(--border-color); /* Lifted feeling */
}

.art-card:active {
    transform: translate(0px, 0px);
    box-shadow: 2px 2px 0 var(--border-color);
}

/* Subtle, thematic section palettes for card backgrounds */
.card-cat-work { background-color: #dbe4dc !important; }    /* Subtle sage green */
.card-cat-fun { background-color: #ffb6c1 !important; }     /* Baby pink */
.card-cat-writing { background-color: #f5f1e6 !important; } /* Papery cream */
.card-cat-memories { background-color: #f0dbdf !important; }/* Dusty rose */

.art-card:active {
    cursor: grabbing;
}

.art-card.is-dragging {
    opacity: 0.4;
    transform: scale(0.95);
    background-color: rgba(255, 255, 255, 0.2);
}

.art-card.drag-over {
    background-color: rgba(0, 0, 0, 0.05);
    border-style: dashed;
}

/* Physics overrides so CSS rules don't fight the JS Engine */
.art-card[data-physics-active="true"] {
    transition: none !important;
    will-change: transform, left, top;
}
.art-card[data-physics-active="true"]:hover {
    box-shadow: 4px 4px 0 var(--border-color) !important;
}

/* Dark Residue Crater below extracted Physics Objects */
.art-card.physics-ghost {
    background-color: rgba(0, 0, 0, 0.15) !important;
    border: var(--border-thickness) dashed rgba(0, 0, 0, 0.25) !important;
    box-shadow: inset 4px 4px 8px rgba(0, 0, 0, 0.1) !important;
}
.art-card.physics-ghost * {
    opacity: 0 !important; /* Hide content inside the crater */
}


/* Bento Box Sizing Rules */
.card-size-standard {
    grid-column: span 1;
    grid-row: span 1;
}

.card-size-wide {
    grid-column: span 2;
    grid-row: span 1;
}

.card-size-tall {
    grid-column: span 1;
    grid-row: span 2;
}

.card-size-large {
    grid-column: span 2;
    grid-row: span 2;
}

.card-size-cinema {
    grid-column: span 4;
    grid-row: span 1;
}

.card-size-hero {
    grid-column: span 4;
    grid-row: span 2;
}

.card-size-portrait {
    grid-column: span 2;
    grid-row: span 3;
}

/* Content inside the card (like in memories.png) */
.card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Removed justify-content: flex-end to prevent massive empty air */
    text-align: left;
    font-size: 0.8rem;
    line-height: 1.3;
}

.card-text {
    margin-bottom: 1rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 6; /* Extended to 6 lines so Github project tech stacks are visible */
    line-clamp: 6;
    -webkit-box-orient: vertical;
}

.card-text.no-media {
    flex: 1; /* Automatically pushes line and title to the bottom if there is no image */
}

/* Dynamic Image Sizing Constraints */
.card-media {
    width: 100%;
    flex: 1; /* Automatically grows perfectly to fill remainder of Bento box */
    min-height: 0; /* Critical for container containment */
    object-fit: contain; /* Prevents image from being cropped by maintaining aspect ratio */
    margin-bottom: 1rem;
    border: var(--border-thickness) solid var(--border-color);
}

.card-line {
    width: 100%;
    height: var(--border-thickness);
    background-color: var(--border-color);
    margin-bottom: 0.8rem;
}

.card-title {
    font-weight: 700;
    font-size: 1rem;
}

/* Article inside view */
.article-view {
    max-width: 800px;
    overflow-y: auto;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
}
.article-view::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome/Safari */
}

.article-date {
    font-weight: 700;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.article-body {
    line-height: 1.5;
    font-size: 1rem;
}

/* Themed Video Player */
.themed-player {
    border: var(--border-thickness) solid var(--border-color);
    box-shadow: 4px 4px 0 var(--border-color);
    margin-bottom: 2rem;
    background: #1a1a1a;
}

.themed-player video {
    width: 100%;
    max-height: 50vh;
    object-fit: cover;
    display: block;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    background: var(--bg-color);
    border-top: var(--border-thickness) solid var(--border-color);
    font-family: var(--font-mono);
}

.player-btn {
    background: var(--red-title);
    color: white;
    border: 2px solid var(--border-color);
    padding: 0.3rem 0.8rem;
    cursor: pointer;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.9rem;
}

.player-btn:hover {
    background: var(--border-color);
}

.player-progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    cursor: pointer;
    position: relative;
}

.player-progress {
    height: 100%;
    width: 0%;
    background: var(--red-title);
    transition: width 0.1s linear;
}

.player-time {
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 40px;
    text-align: right;
}

/* Side Navigation */
.side-nav {
    width: 200px;
    display: flex;
    justify-content: flex-end;
    position: sticky;
    top: 4rem;
    height: fit-content;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 1rem;
}

.nav-links li {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Text on right */
}

.nav-item {
    text-decoration: none;
    color: var(--text-color);
    font-size: 1.2rem;
    font-weight: 400;
    transition: color 0.2s;
}

.nav-item:hover {
    color: var(--red-title);
}

.nav-line {
    width: 120px;
    height: var(--border-thickness);
    background-color: var(--border-color);
    margin-top: 0.3rem;
}

/* Footer — Red Carpet */
.footer {
    background: linear-gradient(180deg, #7a1018 0%, #8c0c1b 30%, #6b0a15 100%);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
    border-top: 3px solid #1a1a1a;
    box-shadow: inset 0 8px 20px rgba(0,0,0,0.5), inset 0 -4px 10px rgba(0,0,0,0.3);
    text-align: left;
    padding: 3rem 5rem;
    position: relative; 
    z-index: 10;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, #1a1a1a 20%, #333 50%, #1a1a1a 80%, transparent 100%);
}

.footer-warning {
    font-size: 0.7rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #1a1a1a;
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.footer-text {
    font-size: 0.9rem;
    color: #1a1a1a;
}

.footer-links {
    margin-top: 0.8rem;
}

.footer-links a {
    color: #1a1a1a;
    text-decoration: none;
    margin-right: 1.5rem;
    font-weight: 700;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #f1d9cd;
}

/* Responsive adjustments (Mobile Optimization) */
@media (max-width: 800px) {
    .layout {
        height: auto; 
        min-height: 100vh;
        flex-direction: column;
        padding: 2rem 1.5rem;
    }
    
    .main-content {
        display: contents; /* Allows re-ordering header and gallery dynamically */
    }

    .header {
        order: 1;
        margin-bottom: 1.5rem;
    }

    .header-title {
        font-size: 2.2rem;
    }

    .side-nav {
        order: 2;
        position: static; /* Prevent sticky overlap */
        width: 100%;
        justify-content: flex-start;
        margin-top: 0rem;
        margin-bottom: 2rem;
    }

    .nav-links {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1.5rem;
        margin-top: 0;
    }

    .nav-links li {
        align-items: center; 
    }

    .nav-line {
        width: 100%;
        margin-top: 0.1rem;
    }

    .gallery-area {
        order: 3;
        flex: none; 
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 220px; /* Taller row heights to accommodate wrapped text on narrow screens */
        gap: 1rem;
    }

    /* Restore native mobile scrolling by overriding the desktop physics drag locks */
    .art-card, .header-title, .header-subtitle, .nav-item {
        touch-action: auto;
        user-select: auto;
        -webkit-user-drag: auto;
    }

    /* Force all gigantic bento boxes to fit safely within the 2-column mobile grid */
    .card-size-wide     { grid-column: span 2; grid-row: span 1; }
    .card-size-large    { grid-column: span 2; grid-row: span 2; }
    .card-size-cinema   { grid-column: span 2; grid-row: span 1; }
    .card-size-hero     { grid-column: span 2; grid-row: span 2; }
    .card-size-portrait { grid-column: span 2; grid-row: span 2; }

    .footer {
        padding: 2rem 1.5rem;
    }

    .footer-warning {
        display: none; /* Hide drag warning on mobile */
    }
}