/**
 * VTN Architects - Gallery Page Styles
 * BIG.dk inspired layout
 */

/* ============================================
   RESET & GLOBAL
   ============================================ */
/* ============================================
   RESET & GLOBAL
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-color);
    color: var(--text-color);
    width: 100%;
    overflow-x: hidden;
}

img {
    display: block;
    max-width: 100%;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
}

/* ============================================
   TOKENS
   ============================================ */
:root {
    --project-spine-width: min(480px, 56vw);
    --row-padding-y: 6px;
    --row-padding-x: clamp(10px, 2vw, 18px);
    --project-image-scale: 0.97;
}

/* ============================================
   GALLERY PAGE CONTAINER
   ============================================ */

.gallery-page {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.8s ease;
}

body.page-loaded .gallery-page {
    opacity: 1;
}

/* ============================================
   HEADER
   ============================================ */

/* Header overrides in gallery.css are no longer needed as they are in base.css */
.gallery-header {
    background: var(--bg-color);
}

/* System Dark Mode Support for Logo Inversion Removed */

/* ============================================
   PROJECT GRID (MK27 STYLE)
   ============================================ */

.project-stack {
    padding: 126px 0 30px; /* Aligned vertically with logo top-gap */
    width: 100%;
    max-width: 1160px; /* Centered grid matching Nakamura reference */
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 15px; /* Increased gap as requested */
    background-color: var(--bg-color); 
}

/* Keep the home-page footer at the bottom when the grid is shorter than the viewport. */
.gallery-page > .site-footer {
    margin-top: auto;
}

.project-item {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    cursor: pointer;
    background-color: transparent; /* Seamless with background */
    display: block;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.project-item.hidden {
    display: none;
}

.project-image {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.project-image img,
.project-preview-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(0%) brightness(1); /* Full color and brightness by default */
    transition: filter 0.6s ease, transform 0.8s cubic-bezier(0.2, 1, 0.3, 1);
}

.project-preview-video {
    display: block;
}

/* Hover State */
@media (hover: hover) and (pointer: fine) {
    .project-item:hover .project-image img,
    .project-item:hover .project-preview-video {
        filter: grayscale(0%) brightness(1);
        transform: scale(1.02);
    }

    .project-item:hover .project-overlay {
        opacity: 1;
    }
}

/* Click zoom-in before leaving */
.project-item.zoom-open .project-image img,
.project-item.zoom-open .project-preview-video {
    transform: scale(1.05);
    transition: transform 0.35s ease;
}

/* Text Overlay */
.project-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 12px 10px 10px;
    opacity: 0; /* Hidden by default */
    background-color: rgba(255, 255, 255, 0.88);
    pointer-events: none;
    transition: opacity 0.4s ease;
}

/* Video Indicator (Play Icon) */
.video-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease, background 0.3s ease;
    pointer-events: none;
    z-index: 5;
}

.video-indicator svg {
    width: 24px;
    height: 24px;
    margin-left: 3px; /* Center the play triangle */
}

/* Show indicator in video view or on hover */
.is-video-view .video-indicator {
    opacity: 0.8;
}

.project-item:hover .video-indicator {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
    background: rgba(255, 255, 255, 0.95);
}

.project-name {
    font-family: var(--font-display);
    font-size: 0.65rem; /* Ultra-minimalist size for high-end aesthetic */
    font-weight: 600;
    color: #000000;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin: 0 0 4px 0;
    text-align: left;
}

.project-year {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: #666666;
    letter-spacing: 0.1em;
    margin: 0;
    text-align: left;
}

/* Particle Background Canvas Fix */
#particleCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.project-item.filter-out {
    animation: fadeOut 0.4s ease forwards;
}

.project-item.filter-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeOut {
    to { opacity: 0; transform: scale(0.98); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1200px) {
    .project-stack {
        grid-template-columns: repeat(4, 1fr);
        padding-left: 40px;
        padding-right: 40px;
    }
}

/* Tablets & Small Laptops */
@media (max-width: 1024px) {
    .project-stack {
        padding-top: 140px; /* Increased from 116px for header clearance on tablets */
    }
}

/* Touch Devices & Tablets */
@media (hover: none) and (pointer: coarse), (max-width: 768px) {
    .project-stack {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on small mobile-tablet */
        padding-top: 140px; /* Header clearance */
    }

    /* On mobile/touch devices, show title over a subtle bottom gradient so images are 100% clear */
    .project-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0.25) 50%, rgba(0, 0, 0, 0) 100%);
        justify-content: flex-end;
        align-items: flex-start;
        padding: 12px 10px 10px;
    }

    .project-name {
        color: #ffffff;
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
        margin-bottom: 2px;
        font-size: 0.7rem;
        text-align: left;
    }

    .project-year {
        color: rgba(255, 255, 255, 0.85);
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
        font-size: 0.6rem;
    }

    .video-indicator {
        opacity: 0.9;
        background: rgba(255, 255, 255, 0.9);
        color: #000000;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

/* Mobile Devices */
@media (max-width: 480px) {
    .project-stack {
        grid-template-columns: 1fr;
        padding-top: 160px; /* Header clearance on small mobile screens */
        padding-bottom: 40px;
        padding-left: 20px; 
        padding-right: 20px;
        grid-gap: 15px;
    }

    .project-overlay {
        padding: 14px 14px 14px;
        align-items: flex-start;
    }

    .project-name {
        font-size: 0.72rem;
        text-align: left;
    }
}


