/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #fff;
    color: #1E293B;
    font-family: 'Poppins', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 1rem 5rem;
}

h1 {
    font-size: 3rem;
    color: #f97316;
    font-weight: 800;
    margin-bottom: 0.3em;
    letter-spacing: 0.05em;
    text-shadow: 0 0 8px #fb8500a8;
}

h2 {
    font-weight: 500;
    font-size: 1.25rem;
    margin-top: 0;
    margin-bottom: 2.5rem;
    color: #334e68;
    letter-spacing: 0.04em;
}

/* Filters */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 3rem;
}

.filter-btn {
    background-color: transparent;
    color: #f97316;
    border: 2.5px solid #f97316;
    border-radius: 50px;
    padding: 0.6rem 1.8rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: 0.35s ease all;
    user-select: none;
    box-shadow: 0 0 0 rgba(255 115 22 / 0);
    position: relative;
    overflow: hidden;
}

.filter-btn::before {
    content: '';
    position: absolute;
    height: 100%;
    width: 100%;
    background: #f97316;
    top: 0;
    left: -100%;
    z-index: -1;
    transition: left 0.35s ease;
    border-radius: 50px;
}

.filter-btn:hover::before {
    left: 0;
}

.filter-btn:hover,
.filter-btn.active {
    color: white;
    box-shadow: 0 8px 15px #f9731699;
    border-color: #f97316;
}

.filter-btn.active::before {
    left: 0;
}

.filter-btn:focus {
    outline: 3px solid #fb8500;
    outline-offset: 3px;
}

/* Gallery grid: Masonry columns */
.gallery {
    column-count: 4;
    column-gap: 1.25rem;
    width: 100%;
    max-width: 1200px;
}

@media (max-width: 1024px) {
    .gallery {
        column-count: 3;
    }
}

@media (max-width: 720px) {
    .gallery {
        column-count: 2;
    }
}

@media (max-width: 420px) {
    .gallery {
        column-count: 1;
    }
}

/* Gallery items */
.gallery-item {
    margin-bottom: 1.3rem;
    break-inside: avoid;
    cursor: pointer;
    position: relative;
    border-radius: 20px;
    box-shadow: 0 6px 16px rgb(249 115 22 / 0.15);
    background: #fff;
    overflow: hidden;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.gallery-item:hover,
.gallery-item:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 15px 35px rgb(249 115 22 / 0.4);
    z-index: 5;
}

.gallery-item img {
    width: 100%;
    border-radius: 20px;
    display: block;
    transition: transform 0.35s ease;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
    transform: scale(1.12) rotate(2deg);
}

/* Caption overlay */
.caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(180deg, transparent, rgba(249, 115, 22, 0.85));
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    padding: 1.1rem 1rem;
    opacity: 0;
    border-radius: 0 0 20px 20px;
    transition: opacity 0.35s ease;
    user-select: none;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.55);
}

.gallery-item:hover .caption,
.gallery-item:focus-visible .caption {
    opacity: 1;
}

/* Modal styles */
#modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(30, 41, 59, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 1100;
}

#modal.active {
    opacity: 1;
    pointer-events: all;
}

#modal img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 28px;
    box-shadow: 0 0 60px #f97316cc;
    user-select: none;
}

/* Modal controls */
#modalClose {
    position: fixed;
    top: 28px;
    right: 28px;
    background: transparent;
    border: none;
    font-size: 3.5rem;
    color: #f97316;
    cursor: pointer;
    padding: 0;
    user-select: none;
    text-shadow: 0 0 10px #f97316cc;
    transition: transform 0.3s ease;
    z-index: 1200;
}

#modalClose:hover,
#modalClose:focus-visible {
    transform: rotate(90deg);
    outline: none;
}

.modal-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    font-size: 4rem;
    color: #f97316;
    background: rgba(249, 115, 22, 0.8);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s ease;
    z-index: 1200;
}

.modal-nav:hover,
.modal-nav:focus-visible {
    background: #ea580c;
    outline: none;
}

#modalPrev {
    left: 28px;
}

#modalNext {
    right: 28px;
}

/* Modal caption */
#modalCaption {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    color: #f97316;
    font-weight: 700;
    font-size: 1.3rem;
    text-align: center;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
    max-width: 90vw;
    user-select: none;
    z-index: 1200;
}

/* Accessibility focus outline for buttons */
.filter-btn:focus-visible,
#modalClose:focus-visible,
.modal-nav:focus-visible {
    outline: 3px solid #fb8500;
    outline-offset: 3px;
}

/* Footer */
footer {
    margin-top: auto;
    font-size: 0.9rem;
    color: #64748b;
    padding: 1.5rem;
    text-align: center;
    user-select: none;
}