// Photos Page
.photos {
    // Intro Section
    &__intro {
        overflow: hidden;
        margin-bottom: clamp(32px, 7.5vw, 96px);
        color: $color-text;
        text-align: center;

        // Title
        h1 {
            margin: -20px 0 48px;
            color: $color-secondary;
            line-height: 1;

            @include bp (sm) {
                margin: -100px 0 0;
            }
        }
        // Text
        p {
            max-width: 456px;
            margin: 20px auto 56px;

            @include bp (sm) {
                margin: 50px auto 72px;
                max-width: 524px;
            }
        }
    }

    // Filter
    .filter {
        position: relative;
        max-width: 982px;
        margin: 0 auto;
        padding: 0 16px;

        @include bp (sm) {
            padding: 0 32px;
        }

        // Span
        &__label {
            display: block;
            color: rgba($color-tertiary, 0.7);

            @include bp (sm) {
                position: absolute;
                left: 64px;
                top: 52%;
                transform: translateY(-50%);
                margin-bottom: 0;
            }
        }

        &__bar {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 64px;
            margin-top: 20px;
            padding: 0 12px;
            background: $color-primary-darker;
            border-radius: 50vh;

            @include bp (mob-lg) {
                padding: 0 16px;
            }
            @include bp (sm) {
                height: 72px;
                margin-top: 0;
                padding: 28px 32px;
            }

            ul {
                display: flex;
                flex-wrap: wrap;
                align-items: center;
                justify-content: center;
            }
            li {
                display: block;
                margin: 8px 2px;
                font-size: rem(14px);
                color: #fff;

                @include bp (sm) {
                    margin: 0 2px;
                    font-size: rem(16px);
                }
            }
            .icon {
                display: block;
                width: 20px;
                height: 20px;
                overflow: hidden;
                margin-right: 12px;
                fill: #fff;
                border-radius: 100%;
                transition: fill 0.2s;

                @include bp (sm) {
                    width: 26px;
                    height: 26px;
                }
            }

            .select {
                position: relative;
                display: flex;
                align-items: center;
                padding: 8px 12px 8px 8px;
                font-weight: 900;
                border-radius: 100vh;
                transition: background-color 0.2s;

                @include bp (sm) {
                    padding: 8px 16px;
                }

                select {
                    opacity: 0;
                    position: absolute;
                    top: 0;
                    left: 8px;
                    width: 100%;
                    height: 100%;
                    cursor: pointer;
                }
            }

            // Hover
            li:hover {
                .icon {
                    fill: $color-secondary-light;
                }
                .select {
                    background-color: $color-primary-tertiary20;
                }
            }
        }

        // Actions
        &__actions {
            display: flex;
            align-items: center;
            justify-content: center;
            margin-top: 20px;

            @include bp (sm) {
                position: absolute;
                top: 50%;
                right: 56px;
                transform: translateY(-50%);
                margin-top: 0;
            }

            a {
                display: block;
                text-decoration: none;
                color: rgba(#fff, 0.6);
                font-size: rem(14px);
                font-weight: 900;
                line-height: 1;

                img {
                    display: block;
                }
            }

            // Reset link
            .reset {
                margin-right: 16px;
                padding: 0;
                color: rgba($color-tertiary, 0.6);
                font-weight: 900;
                font-size: rem(14px);
                transition: color 0.3s;

                &:hover {
                    color: $color-tertiary;
                }
            }

            // Shuffle button
            .shuffle {
                display: flex;
                align-items: center;
                justify-content: center;
                height: 32px;
                background-color: $color-tertiary;
                padding: 0 16px;
                border-radius: 50vh;
            }
        }
    }

    // Content Block
    &__content {
        --corners: 8px;
        position: relative;
        padding: 20px 0;
        background-color: $color-tertiary;

        @include bp (sm) {
            padding: clamp(40px, 5vw, 64px) 24px;
        }
        @include bp (md) {
            margin: 0 30px;
            padding-left: 0;
            padding-right: 0;
        }

        &:before, &:after {
            @include bp (md) {
                content: "";
                display: block;
                position: absolute;
                z-index: -1;
                top: 0;
                width: 25%;
                height: 100%;
                background: $color-tertiary;
                transition: transform 0.8s var(--ease-quart);
            }
        }
        &:before {
            @include bp (md) {
                border-radius: var(--corners) 0 0 var(--corners);
                left: 0;
                transform: translate3d(calc(-1 * var(--margin-sides)), 0, 0);
            }
        }
        &:after {
            @include bp (md) {
                border-radius: 0 var(--corners) var(--corners) 0;
                right: 0;
                transform: translate3d(var(--margin-sides), 0, 0);
            }
        }
    }

    // Photo Grid
    &__grid {
        display: grid;
        grid-column: span var(--columns);
        // Template: 2 / 1-1
        grid-template-columns: repeat(2, 1fr);
        grid-gap: 16px;

        @include bp (mob-lg) {
            grid-gap: 20px;
        }
        @include bp (sm) {
            // Swich to template: 2-1-1 / 1-1-2 / 4
            grid-template-columns: repeat(4, 1fr);
            grid-gap: 24px;
        }
        @include bp (sd) {
            grid-column: 2 / span 22;
            grid-gap: 40px;
        }

        // Photo
        .photo {
            position: relative;

            a {
                display: block;
            }
            figcaption {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                pointer-events: none;
            }

            /**
             * Photo sizes
             */
            // MOBILE
            // 1st photo = 2 columns
            &:nth-child(5n + 1) {
                @include bp (sm, max) {
                    grid-column: span 2;
                    grid-row: span 2;
                    margin-bottom: 8px;
                }
            }
            // 4 next photos = 1 column each
            &:nth-child(5n + 4),
            &:nth-child(5n + 5) {
                @include bp (sm, max) {
                    margin-bottom: 8px;
                }
            }


            // DESKTOP
            // 1st photo = left 2 columns, 2 rows
            &:nth-child(11n + 1){
                @include bp (sm) {
                    grid-column: span 2;
                    grid-row: span 2;
                }
            }
            // 8th photo = right 2 columns, 2 rows
            &:nth-child(11n + 8){
                @include bp (sm) {
                    grid-column: 3 / span 2;
                    grid-row: span 2;
                }
            }
            // 11th photo = 4 columns
            &:nth-child(11n){
                @include bp (sm) {
                    grid-column: span 4;
                }
            }
            // Additional spacing between grid patterns
            &:nth-child(11n + 11){
                @include bp (sm) {
                    margin-top: 12px;
                }
                @include bp (sd) {
                    margin-top: 16px;
                }
            }
            &:nth-child(11n),
            &:nth-child(11n + 1),
            &:nth-child(11n + 4),
            &:nth-child(11n + 5){
                @include bp (sm) {
                    margin-bottom: 12px;
                }
                @include bp (sd) {
                    margin-bottom: 16px;
                }
            }


            // Postcard
            .postcard {
                position: absolute;
                bottom: 0;
                right: 0;
                border-top-left-radius: 8px;
                pointer-events: none;
                opacity: 0;
                transform: translate3d(12%, 23%, 0) rotate(-5deg);
                transition: opacity 0.4s var(--ease-quart), transform 1.0s var(--ease-quart);

                &--small {
                    border-radius: 6px 6px 0 0;
                    transform: translate3d(8%, 12%, 0) rotate(-3deg);
                }
            }

            // Show postcard on hover
            &:hover {
                .postcard {
                    opacity: 1;
                    transform: translate3d(3%, 3%, 0) rotate(2deg);

                    &--small {
                        transform: translate3d(0,0,0);
                    }
                }
            }
        }
    }


    // Message
    &__message {
        // grid-column: ;
        text-align: center;
        padding: clamp(48px, 10vw, 160px) 0;
        color: $color-text;

        @include bp (sm) {
            grid-column: 3 / span 20;
        }
    }


    /**
     * Controls
     */
    .controls {
        grid-column: span var(--columns);
        display: grid;
        margin: 48px auto;
        align-items: center;
        justify-content: center;

        @include bp (sm) {
            justify-content: space-between;
            margin: clamp(56px, 4.5vw, 80px) 0;
        }
        @include bp (sd) {
            --columns: 22;
            grid-column: 2 / span var(--columns);
        }

        // Updated Date
        &__date {
            grid-column: span var(--columns);
            grid-row: 2;
            font-size: rem(18px);
            color: rgba($color-gray, 0.6);
            font-weight: 300;
            text-align: center;
            margin: 24px 0 48px;
            line-height: 1.35;

            @include bp (sm) {
                grid-column: span 5;
                grid-row: 1;
                text-align: left;
                margin: 0;
            }

            time {
                display: block;

                @include bp (sd) {
                    display: inline;
                }
            }
        }

        // See More Photos
        .button {
            grid-column: span var(--columns);
            grid-row: 1;
            margin: 0 auto;

            @include bp (sm) {
                grid-column: 7 / span 12;
            }
            @include bp (sd) {
                grid-column-start: 6;
            }
        }

        // Photo Count
        &__count {
            grid-column: span var(--columns);
            grid-row: 3;
            text-align: center;
            color: rgba($color-text, 0.3);
            font-family: $font-serif;
            font-size: rem(64px);
            font-weight: 200;
            line-height: 1;
            letter-spacing: -0.05em;

            @include bp (sm) {
                grid-column: 18 / span 7;
                grid-row: 1;
                margin-left: auto;
                text-align: right;
            }
            @include bp (sd) {
                grid-column-start: 16;
            }

            span {
                display: inline-block;
                margin: 0 -6px;

                &:last-child {
                    margin-right: 0;
                }
            }
        }
    }

    // Modules
    .grid-modules {
        grid-column: span var(--columns);
        margin-bottom: 0;

        @include bp (sd) {
            grid-column: 2 / span 22;
        }
    }
}