/* ==========================================================
   GRID GALLERY
   Complete CSS
========================================================== */


/* ==========================================================
   GLOBAL
========================================================== */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {

    font-family: DM Sans;
}


/* ==========================================================
   GALLERY WRAPPER
========================================================== */

/*
   Space for the menu/navigation at the top.
*/

.grid-gallery-wrapper {
    width: 100%;
    padding-top: 90px;
}


/* ==========================================================
   FILTER HEADER
========================================================== */

.grid-gallery-header {
    width: 100%;

    display: flex;
    justify-content: flex-end;
    align-items: center;

    padding: 20px 30px 25px;
}


/* ==========================================================
   FILTERS
========================================================== */

.grid-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;

    gap: 18px;

    margin: 0;
    padding: 0;

    list-style: none;
}

.grid-filters li {
    margin: 0;
    padding: 0;

    cursor: pointer;
    user-select: none;

    color: #888;

    font-size: 15px;
    line-height: 1.2;
    font-weight: 400;

    transition: color 0.25s ease;
}

.grid-filters li:hover {
    color: #222;
}

.grid-filters li.active {
    color: #000;
    font-weight: 600;
}


/* ==========================================================
   GALLERY GRID
========================================================== */

.grid-gallery {
    width: 100%;

    display: grid;

    grid-template-columns:
        repeat(
            auto-fill,
            minmax(240px, 1fr)
        );

    gap: 14px;

    padding: 0 30px 30px;

    opacity: 1;

    transition: opacity 0.35s ease;
}


/*
   Used by JavaScript while new images load.
*/

.grid-gallery.loading {
    opacity: 0;
}


/* ==========================================================
   GRID ITEM
========================================================== */

.grid-item {
    position: relative;

    width: 100%;

    /*
       ONLY THE GRID THUMBNAILS ARE SQUARE.
    */

    aspect-ratio: 1 / 1;

    overflow: hidden;

    background: #eee;

    cursor: pointer;
}


/* ==========================================================
   GRID IMAGE
========================================================== */

.grid-item img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;

    transition: transform 0.4s ease;
}

.grid-item:hover img {
    transform: scale(1.04);
}


/* ==========================================================
   LIGHTBOX OVERLAY
========================================================== */

.grid-lightbox {
    position: fixed;

    inset: 0;

    z-index: 9999;

    display: none;

    background: rgba(0, 0, 0, 0.92);

    padding: 40px;

    overflow: hidden;
}

.grid-lightbox.open {
    display: flex;

    align-items: flex-start;
    justify-content: center;
}


/* ==========================================================
   LIGHTBOX CONTAINER
========================================================== */

.grid-lightbox-container {

    display: flex;

    align-items: flex-start;

    gap: 50px;

    /*
       The container is only as wide as
       its actual contents.
    */

    width: max-content;

    /*
       Never allow the composition to
       exceed the available viewport.
    */

    max-width: calc(100vw - 80px);

    max-height: calc(100vh - 80px);

}


/* ==========================================================
   LIGHTBOX IMAGE AREA
========================================================== */


.grid-lightbox-image {

    display: flex;

    align-items: flex-start;
    justify-content: center;

    flex: 0 1 auto;

    min-width: 0;

    max-width: 70vw;

    max-height: calc(100vh - 80px);

}


/*
   IMPORTANT:

   There is deliberately NO aspect-ratio here.

   There is also no width: 100% or height: 100%.

   The image keeps its original aspect ratio.
*/


.grid-lightbox-image img {

    display: block;

    /*
       Preserve original image ratio.
    */

    width: auto;
    height: auto;

    max-width: 70vw;

    max-height: calc(100vh - 80px);

    object-fit: contain;

}


/* ==========================================================
   DESKTOP CAPTION
========================================================== */

.grid-lightbox-caption {

    /*
       Normal caption width.
    */

    width: 360px;

    max-width: 30vw;

    flex: 0 1 360px;
  
    line-height: 1.3; 

    min-width: 0;

    height: calc(100vh - 80px);

    color: #fff;

    overflow-x: hidden;

    overflow-y: auto;

    scrollbar-width: none;

    -ms-overflow-style: none;

}

.grid-lightbox-caption::-webkit-scrollbar {
    display: none;
}

/* ==========================================================
   CAPTION CONTENT
========================================================== */

.grid-lightbox-caption-content {
    min-height: 100%;

    display: flex;

    flex-direction: column;

    /*
       Short captions are vertically centered.
    */

    justify-content: center;
}


/*
   When JavaScript detects that the caption
   is too long, it adds .is-scrollable.
*/

.grid-lightbox-caption.is-scrollable
.grid-lightbox-caption-content {
    justify-content: flex-start;
}


/* ==========================================================
   CAPTION TYPOGRAPHY
========================================================== */

.grid-lightbox-caption h2 {
    margin: 0 0 10px;
    padding: 0;

    color: #fff;

    font-size: 30px;
    line-height: 1.3;

    font-weight: 500;
}

.grid-lightbox-caption h3 {
    margin: 0 0 25px;
    padding: 0;

    color: #fff;

    font-size: 16px;
    line-height: 1.3;

    font-weight: 500;

    opacity: 0.7;
}

.grid-lightbox-caption p {
    margin-top: 0;
    margin-bottom: 1em;

    color: #fff;

    font-size: 16px;
    line-height: 1.3;
}

.grid-lightbox-caption strong {
    font-weight: 700;
}

.grid-lightbox-caption em {
    font-style: italic;
}

.grid-lightbox-caption a {
    color: #fff;

    text-decoration: underline;
}


/* ==========================================================
   CLOSE BUTTON
========================================================== */

.grid-lightbox-close {
    position: fixed;

    top: 25px;
    right: 30px;

    z-index: 10001;

    width: 40px;
    height: 40px;

    padding: 0;

    border: none;

    background: transparent;

    color: #fff;

    font-size: 40px;
    font-weight: 300;

    line-height: 40px;

    text-align: center;

    cursor: pointer;

    opacity: 0.85;

    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
}

.grid-lightbox-close:hover {
    opacity: 1;

    transform: scale(1.08);
}


/* ==========================================================
   MOBILE
========================================================== */

@media (max-width: 900px) {


    /* ------------------------------------------------------
       GALLERY
    ------------------------------------------------------ */

    .grid-gallery-wrapper {
        padding-top: 180px;
    }


    /* ------------------------------------------------------
       FILTERS
    ------------------------------------------------------ */

    .grid-gallery-header {
        justify-content: center;

        padding:
            15px
            15px
            20px;
    }

    .grid-filters {
        justify-content: center;

        gap: 14px;
    }


    /* ------------------------------------------------------
       GRID
    ------------------------------------------------------ */

    .grid-gallery {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 10px;

        padding:
            0
            30px
            30px;
    }


    /* ------------------------------------------------------
       LIGHTBOX
    ------------------------------------------------------ */

    .grid-lightbox {
        padding: 20px 40px;

        display: none;

        align-items: flex-start;

        overflow-y: auto;
        overflow-x: hidden;
    }

    .grid-lightbox.open {
        display: flex;

        align-items: flex-start;
    }


    /* ------------------------------------------------------
       LIGHTBOX CONTAINER
    ------------------------------------------------------ */

    .grid-lightbox-container {

        display: block;

        width: 100%;
        max-width: 100%;

        /*
           IMPORTANT:
           Let the container grow naturally with
           the image and caption.
        */

        height: auto;
        max-height: none;

        margin-top: 45px;
    }


    /* ------------------------------------------------------
       MOBILE IMAGE
    ------------------------------------------------------ */

    .grid-lightbox-image {

        display: block;

        position: relative;

        width: 100%;
        max-width: 100%;

        height: auto;
        max-height: none;

        margin: 0 0 30px;

        flex: none;
    }

    .grid-lightbox-image img {

        display: block;

        width: 100%;
        height: auto;

        max-width: 100%;
        max-height: none;

        object-fit: contain;
    }

    /* ------------------------------------------------------
       MOBILE CAPTION
    ------------------------------------------------------ */

    .grid-lightbox-caption {

        display: block;

        position: relative;

        width: 100%;
        max-width: 100%;

        height: auto;
        max-height: none;

        min-height: 0;

        margin: 0;

        padding: 0 0 30px;

        overflow: visible;

        flex: none;
    }

    .grid-lightbox-caption-content {

        display: block;

        min-height: 0;

        height: auto;

        margin: 0;
    }

    .grid-lightbox-caption.is-scrollable {
        overflow: visible;
    }

    .grid-lightbox-caption.is-scrollable
    .grid-lightbox-caption-content {

        display: block;

        min-height: 0;

        height: auto;

    }


    /* ------------------------------------------------------
       MOBILE CLOSE BUTTON
    ------------------------------------------------------ */

    .grid-lightbox-close {

        top: 15px;
        right: 15px;

        width: 40px;
        height: 40px;

        z-index: 10001;
    }


    /* ------------------------------------------------------
       MOBILE TYPOGRAPHY
    ------------------------------------------------------ */

    .grid-lightbox-caption h2 {
        font-size: 25px;
    }

    .grid-lightbox-caption h3 {
        margin-bottom: 20px;

        font-size: 15px;
    }

    .grid-lightbox-caption p {
        font-size: 15px;
        line-height: 1.3;
    }
}


/* ==========================================================
   SMALL PHONES
========================================================== */

@media (max-width: 480px) {

    .grid-gallery-wrapper {
        padding-top: 90px;
    }

    .grid-gallery-header {
        padding-left: 10px;
        padding-right: 10px;
    }

    .grid-filters {
        gap: 10px;
    }

    .grid-filters li {
        font-size: 14px;
    }

    .grid-lightbox {
        padding: 15px;
    }

    .grid-lightbox-container {
        margin-top: 45px;
    }

    .grid-lightbox-image img {
        max-height: 60vh;
    }
}


/* ==========================================================
   REDUCED MOTION
========================================================== */

@media (prefers-reduced-motion: reduce) {

    .grid-gallery,
    .grid-item img,
    .grid-filters li,
    .grid-lightbox-close {
        transition: none;
    }
}