/* ========================================
   PORTFOLIO GALLERY - MOBILE FIRST
======================================== */

.portfolio-gallery {
    padding: 2rem 1rem;
    max-width: 100%;
    margin: 0 auto;
}

.gallery-section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #fff;
    text-align: center;
    border-bottom: 2px solid #333;
    padding-bottom: 0.5rem;
}

/* IMAGE GRID - Mobile First */
.image-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* IMAGE ITEM CONTAINER */
.image-item {
    position: relative;
    background: #111;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.image-container {
    position: relative;
    width: 100%;
    height: 70vh; /* Almost full screen on mobile */
    overflow: hidden;
}

.portfolio-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

/* CAPTION OVERLAY */
.image-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8), rgba(0,0,0,0.95));
    color: #fff;
    padding: 3rem 1.5rem 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    opacity: 0;
    visibility: hidden;
}

.image-caption h4 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #fff;
}

.image-caption p {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    color: #ddd;
}

.image-meta {
    font-size: 0.85rem;
    color: #999;
    font-weight: 300;
    font-style: italic;
}

/* HOVER/TOUCH STATES */
.image-item:hover .image-caption,
.image-item:focus-within .image-caption {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.image-item:hover .portfolio-image {
    transform: scale(1.05);
}

/* Touch devices - show caption on tap */
@media (hover: none) and (pointer: coarse) {
    .image-item.active .image-caption {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .image-item.active .portfolio-image {
        transform: scale(1.05);
    }
}

/* ========================================
   TABLET RESPONSIVE - 768px+
======================================== */
@media screen and (min-width: 768px) {
    .portfolio-gallery {
        padding: 3rem 2rem;
    }
    
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    .image-container {
        height: 60vh; /* Almost full screen on tablet */
    }
    
    .section-title {
        font-size: 2rem;
        margin-bottom: 2rem;
    }
    
    .image-caption {
        padding: 4rem 2rem 2rem;
    }
    
    .image-caption h4 {
        font-size: 1.4rem;
    }
    
    .image-caption p {
        font-size: 1rem;
        line-height: 1.5;
    }
}

/* ========================================
   DESKTOP RESPONSIVE - 1024px+
======================================== */
@media screen and (min-width: 1024px) {
    .portfolio-gallery {
        padding: 4rem 3rem;
        max-width: 1400px;
    }
    
    .image-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2.5rem;
    }
    
    .image-container {
        height: 75vh; /* Almost full screen on desktop */
    }
    
    .section-title {
        font-size: 2.5rem;
        margin-bottom: 3rem;
    }
    
    .image-caption {
        padding: 5rem 2.5rem 2.5rem;
    }
    
    .image-caption h4 {
        font-size: 1.6rem;
        margin-bottom: 1rem;
    }
    
    .image-caption p {
        font-size: 1.1rem;
        line-height: 1.6;
        margin-bottom: 1rem;
    }
    
    .image-meta {
        font-size: 0.95rem;
    }
}

/* ========================================
   LARGE DESKTOP - 1400px+
======================================== */
@media screen and (min-width: 1400px) {
    .image-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 3rem;
    }
    
    .image-container {
        height: 80vh; /* Almost full screen on large desktop */
    }
}

/* ========================================
   ACCESSIBILITY & PERFORMANCE
======================================== */

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .portfolio-image,
    .image-caption,
    .image-item {
        transition: none;
    }
}

/* Focus states for keyboard navigation */
.image-item:focus-within {
    outline: 2px solid #fff;
    outline-offset: 4px;
}

/* Loading state */
.portfolio-image[loading="lazy"] {
    background: #222;
    min-height: 200px;
}

/* ========================================
   FULLSCREEN OVERLAY - ALL DEVICES
======================================== */
.fullscreen-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    cursor: pointer;
}

.fullscreen-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-image {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    cursor: default;
}

.fullscreen-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    padding: 0.75rem;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    touch-action: manipulation;
}

.fullscreen-close:hover,
.fullscreen-close:active {
    background: rgba(0, 0, 0, 0.9);
}

/* Fullscreen click available on all devices */
.portfolio-image {
    cursor: pointer;
}

/* Mobile optimizations for fullscreen */
@media screen and (max-width: 767px) {
    .fullscreen-close {
        top: 1.5rem;
        right: 1.5rem;
        font-size: 1.8rem;
        width: 3rem;
        height: 3rem;
    }
    
    .fullscreen-image {
        max-width: 98vw;
        max-height: 98vh;
    }
}

/* Tablet and desktop optimizations */
@media screen and (min-width: 768px) {
    .fullscreen-close {
        top: 2rem;
        right: 2rem;
        font-size: 2rem;
        width: 3rem;
        height: 3rem;
    }
}