/* CSS Custom Properties (Variables) for Theming */
:root {
    --primary-color: #333;
    --bg-color: #f4f4f4;
    --text-color: #333;
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --gap: 20px;
    --padding: 20px;
    --font-family: system-ui, -apple-system, sans-serif; /* Modern stack for better performance */
}

/* Dark Mode Support (Optional: Toggle via media query or JS) */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #fff;
        --bg-color: #1a1a1a;
        --text-color: #fff;
    }
}

/* Reset and Base Styles (Minimalist, performant) */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    scroll-behavior: smooth; /* Smooth scrolling for better UX */
    overflow-x: hidden; /* Prevent horizontal overflow issues */
}

h1, h2 {
    font-weight: 600;
    line-height: 1.2;
}

/* Intro and Outro Sections (Fluid and Centered) */
.intro,
.outro {
    padding: clamp(50px, 10vw, 50px) var(--padding); /* Fluid padding */
    text-align: center;
    background-color: var(--bg-color);
}

.intro h1 {
    font-size: clamp(2em, 5vw, 3em); /* Responsive typography */
    margin-bottom: var(--gap);
    color: var(--primary-color);
}

.intro p,
.outro p {
    font-size: 1.1em;
    max-width: 600px;
    margin: 0 auto;
}

.outro h2 {
    font-size: clamp(1.5em, 4vw, 2.5em);
    margin-bottom: var(--gap);
    color: var(--primary-color);
}

/* Gallery Section (Pinned Container) */
.gallery-section {
    height: 100vh;
    position: relative;
    overflow: hidden;
    background-color: #fff; /* White for contrast; can be var() for theming */
    display: flex;
    align-items: center; /* Vertically center content */
}

.gallery-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.gallery-wrapper {
    display: flex;
    height: 100%;
    width: calc(100% * 3); /* Exact width for 5 items; no extra space (adjust # for your items) */
    gap: clamp(10px, 2vw, var(--gap)); /* Responsive gap between items only */
    padding-left: clamp(10px, 2vw, var(--padding)); /* Left padding for start; NO right padding for no end gap */
    padding-right: 0; /* Explicitly zero right padding */
    will-change: transform; /* Optimize for GSAP animations (GPU acceleration) */
    margin: 0; /* No margins to avoid gaps */
}

.gallery-item {
    flex: 0 0 calc(100% / 5); /* Precise for 5 items; adjust formula for more (e.g., 100%/8 for 8 items) */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px; /* Inner padding for breathing room; last item won't add extra */
    margin: 0; /* No margins on items */
}

.gallery-item img {
    width: 100%;
    height: auto;
    max-height: 80vh; /* Respect viewport */
    aspect-ratio: 4 / 3; /* Maintain consistent aspect ratio; adjust as needed */
    object-fit: cover;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease; /* Subtle hover effect */
    cursor: pointer; /* Indicate interactivity */
}

/* Hover and Focus States (Accessibility + UX) */
.gallery-item:hover img,
.gallery-item:focus-within img {
    transform: scale(1.05); /* Light zoom on hover/focus */
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.gallery-item:focus-within {
    outline: 2px solid #007bff; /* Focus ring for keyboard users */
    outline-offset: 2px;
}

/* Responsive Breakpoints (Mobile-First) */
@media (max-width: 768px) {
    :root {
        --gap: 10px;
        --padding: 10px;
    }

    .gallery-wrapper {
        width: calc(100% * 6); /* Exact for ~6 visible on mobile; adjust as needed */
        gap: clamp(5px, 1vw, 10px);
        padding-left: clamp(5px, 1vw, 10px); /* Reduced left padding; no right */
        padding-right: 0;
    }

    .gallery-item {
        flex: 0 0 calc(100% / 6); /* Smaller items on mobile */
        padding: 5px; /* Reduced inner padding */
    }

    .gallery-item img {
        aspect-ratio: 16 / 9; /* Wider for mobile portrait */
        max-height: 60vh; /* Smaller images to fit thumb */
    }

    .intro,
    .outro {
        padding: clamp(30px, 8vw, 50px) var(--padding);
    }
}

@media (max-width: 480px) {
    .gallery-wrapper {
        width: calc(100% * 8); /* Exact for tiny screens */
        padding-left: 5px; /* Minimal left padding */
        padding-right: 0;
    }

    .gallery-item {
        flex: 0 0 calc(100% / 8);
        padding: 3px;
    }

    .gallery-item img {
        border-radius: 4px; /* Smaller radius on mobile */
    }
}

@media (min-width: 1200px) {
    .gallery-wrapper {
        gap: 30px; /* Larger gap on big screens */
        padding-left: 30px; /* Scaled left padding */
        padding-right: 0;
    }

    .gallery-item {
        flex: 0 0 18%; /* Slightly larger items on desktop */
    }

    .gallery-item img {
        aspect-ratio: 3 / 2; /* More square for desktop */
    }
}

/* Print Styles (Optional: For Accessibility/Archiving) */
@media print {
    .gallery-section {
        height: auto;
        overflow: visible;
    }

    .gallery-wrapper {
        width: auto;
        flex-wrap: wrap;
        gap: 10px;
        padding-left: 0;
        padding-right: 0;
    }

    .gallery-item {
        flex: 1 1 300px; /* Stack in print */
    }
}
