@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300;400&display=swap');

/* General Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font: 300 1em 'Fredoka', sans-serif;
}

body {
    padding: 50px 100px;
}

header {
    text-align: center;
    margin: 30px 0px 70px 0px;
    color: #444;
    font-size: 2.5em;
}

#name {
    font-weight: 400;
}

/* --- Gallery Grid --- */
#gallery-container {
    display: grid;
    /* Creates a responsive grid that fits as many columns as possible */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 50px;
    max-width: 1200px;
    margin: 0 auto;
}

.gallery-item {
    cursor: pointer;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid #ccc;
    transition: all 0.2s;
    box-shadow: -4px 5px 2px #e2ecef;
    padding: 10px;
}

.gallery-item:hover {
    /* 1. Move the tile 10px Right and 10px Up */
    transform: translate(6px, -6px) scale(1.04);
    
    /* 2. Shift the shadow to the bottom-left (-2px X, +6px Y) 
       and increase the blur (12px) to make it look "lifted". */
    box-shadow: -8px 10px 7px #e8f4f7;
}

.gallery-item img {
    width: 100%;
    /* Keeps the tile square */
    aspect-ratio: 1 / 1;
    
    /* UPDATED: 'contain' ensures the whole image is visible */
    object-fit: contain;    
    
    display: block;
}

/* --- Lightbox Modal (Refined Layout) --- */
#lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#lightbox.active {
    opacity: 1;
    pointer-events: auto;
}

/* The Container */
.lightbox-content {
    display: flex;
    /* Desktop Default: Side-by-side (Row) */
    flex-direction: row; 
    align-items: center;
    justify-content: center;
    
    /* Ensure it fits within the screen with some padding */
    width: auto;
    max-width: 90%;
    max-height: 90vh;
    
    position: relative;
    background: transparent;
    gap: 30px; /* Space between image and caption */
}

/* The Image */
#lightbox-img {
    /* Allow image to shrink if needed, but grow to fill space */
    flex: 1 1 auto; 
    
    /* These limits prevent the image from overflowing the flex container */
    max-width: 100%; 
    max-height: 90vh;
    
    object-fit: contain;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border-radius: 4px;
    
    /* Crucial for flexbox image sizing */
    min-width: 0; 
    min-height: 0;
}

/* The Caption */
.lightbox-caption {
    /* REMOVED position: fixed. Now it flows naturally in the flexbox */
    position: static;
    
    /* Fixed width for the sidebar on desktop */
    width: 320px;
    min-width: 320px; /* Prevents it from getting squished */
    
    background-color: rgba(20, 20, 20, 0.6);
    color: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #333;
    backdrop-filter: blur(10px);
    
    /* If the description is huge, scroll internally */
    max-height: 80vh;
    overflow-y: auto;
}

#lightbox-title {
    margin-bottom: 5px;
    font-size: 1.2rem;
    font-family: 'Fredoka', sans-serif;
    font-weight:100;
}

#lightbox-date {
    font-size: 0.85em;
    color: #aaa;
    margin-bottom: 10px;
}

#lightbox-desc {
    font-size: 0.95em;
    line-height: 1.4;
}

#close-btn {
    /* UPDATED: Fixed ensures it stays in the screen corner */
    position: fixed; 
    top: 20px;
    right: 30px;
    
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    z-index: 1005; /* High z-index to sit on top of everything */
}

/* --- Mobile Adjustments --- */
@media (max-width: 900px) {
    .lightbox-content {
        /* Switch to Vertical Stack on Tablets/Mobile */
        flex-direction: column;
        width: 95%;
    }

    .lightbox-caption {
        /* Caption becomes a bottom bar */
        width: 100%;
        min-width: auto;
        max-height: 30vh; /* Limit height so it doesn't cover whole screen */
        border-radius: 8px 8px 0 0; /* Round top corners only */
        background-color: rgba(10, 10, 10, 0.95); /* Darker on mobile for readability */
        margin-top: 10px;
        position: relative;
        bottom: auto;
        right: auto;
    }

    #lightbox-img {
        /* Leave room for the caption */
        max-height: 60vh;
    }
    
    #close-btn {
        top: 10px;
        right: 20px;
    }
}