* {
    box-sizing: border-box;
}


html {
    background: #f7f7f5;
}


body {
    margin: 0;

    background: #f7f7f5;
    color: #171717;

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;
}


/* HEADER */

.header {
    height: 90px;

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

    padding: 0 20px;
}


.header h1 {
    margin: 0;

    font-size: 20px;
    font-weight: 400;
    letter-spacing: 0.08em;

    text-align: center;
}


/* GALLERY */

.gallery {
    width: min(1600px, calc(100% - 40px));

    margin: 0 auto;
    padding: 20px 0 60px;

    display: grid;

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

    grid-auto-rows: 260px;

    grid-auto-flow: dense;

    gap: 16px;
}


/*
    Разные размеры карточек.
    Благодаря grid-auto-flow: dense
    пустот будет как можно меньше.
*/

.gallery-item {
    position: relative;

    overflow: hidden;

    background: #e9e9e7;

    cursor: pointer;
}


.gallery-item:nth-child(5n + 1) {
    grid-column: span 2;
    grid-row: span 2;
}


.gallery-item:nth-child(7n + 2) {
    grid-row: span 2;
}


.gallery-item:nth-child(9n + 4) {
    grid-column: span 2;
}


/* IMAGE */

.image-wrapper {
    width: 100%;
    height: 100%;
}


.image-wrapper img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: cover;

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


.gallery-item:hover img {
    transform: scale(1.025);
}


/* CAPTION */

.caption {
    position: absolute;

    left: 0;
    right: 0;
    bottom: 0;

    padding: 50px 18px 18px;

    color: white;

    background:
        linear-gradient(
            to bottom,
            transparent,
            rgba(0, 0, 0, 0.72)
        );

    opacity: 0;

    transform: translateY(8px);

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


.gallery-item:hover .caption {
    opacity: 1;
    transform: translateY(0);
}


.author {
    font-size: 15px;
    font-weight: 500;
}


.date {
    margin-top: 3px;

    font-size: 13px;

    opacity: 0.8;
}


.title {
    margin-top: 5px;

    font-size: 14px;

    opacity: 0.95;
}


/* EMPTY */

.empty {
    padding: 100px 20px;

    text-align: center;

    color: #888;
}


/* LIGHTBOX */

.lightbox {
    position: fixed;

    inset: 0;

    z-index: 100;

    display: none;

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

    padding: 50px;

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


.lightbox.open {
    display: flex;
}


.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;

    display: flex;
    flex-direction: column;

    align-items: center;

    justify-content: center;
}


#lightbox-image {
    display: block;

    max-width: 90vw;
    max-height: 78vh;

    width: auto;
    height: auto;

    object-fit: contain;
}


.lightbox-info {
    width: 100%;

    margin-top: 18px;

    color: white;

    text-align: center;
}


.lightbox-info .author {
    font-size: 16px;
}


.lightbox-info .date {
    font-size: 13px;
}


.lightbox-info .title {
    font-size: 14px;
}


/* CLOSE */

.close {
    position: absolute;

    top: 18px;
    right: 25px;

    width: 45px;
    height: 45px;

    padding: 0;

    border: 0;

    background: transparent;
    color: white;

    font-size: 38px;
    font-weight: 200;

    cursor: pointer;

    opacity: 0.8;
}


.close:hover {
    opacity: 1;
}


/* NAVIGATION */

.navigation {
    position: absolute;

    top: 50%;

    width: 60px;
    height: 80px;

    padding: 0;

    border: 0;

    background: transparent;
    color: white;

    font-size: 70px;
    font-weight: 200;
    line-height: 1;

    cursor: pointer;

    transform: translateY(-50%);

    opacity: 0.65;
}


.navigation:hover {
    opacity: 1;
}


.previous {
    left: 15px;
}


.next {
    right: 15px;
}


/* MOBILE */

@media (max-width: 700px) {

    .header {
        height: 70px;
    }


    .header h1 {
        font-size: 17px;
    }


    .gallery {
        width: calc(100% - 20px);

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

        grid-auto-rows: 180px;

        gap: 8px;
    }


    .gallery-item:nth-child(5n + 1) {
        grid-column: span 2;
        grid-row: span 2;
    }


    .gallery-item:nth-child(7n + 2) {
        grid-row: span 2;
    }


    .gallery-item:nth-child(9n + 4) {
        grid-column: span 1;
    }


    .caption {
        padding: 40px 10px 10px;

        opacity: 1;

        transform: none;
    }


    .author {
        font-size: 13px;
    }


    .date,
    .title {
        font-size: 12px;
    }


    .lightbox {
        padding: 20px;
    }


    #lightbox-image {
        max-width: 94vw;
        max-height: 78vh;
    }


    .navigation {
        width: 45px;

        font-size: 55px;
    }


    .previous {
        left: 0;
    }


    .next {
        right: 0;
    }
}

