@import '../../../../styles/mixins.scss';

$box-shadow: 0 2px 8px 0 var(--shadow-color, rgba(0,1,0,0.2));
$content-width-desktop: 632px;
$horizontal-padding-desktop: 110px;
$horizontal-padding-mobile: 54px;
$section-height: var(--height, 350px);

$wrapper-selector: ".imageStyle_wrapper";

.imageStyle {
    &_wrapper {
        position: relative;

        @include media-lg-up { 
            height: $section-height
        }

        @include media-sm-down {
            height: calc($section-height * 2);
        }

        display: flex;
        flex-direction: row;
        
        &:before {
            @include full-window-width;
            content: "";

            background-color: var(--background-color, #F4F4F4);
            background-position: center;
            background-size: cover;

            box-shadow: $box-shadow;
        }
    }

    &_backgroundImage {
        object-fit: cover;
        max-width: inherit;

        &--scaleToFitPage {
            @include page-width;
        }

        &--scaleToFitScreen {
            @include full-window-width;
        }
    }

    &_backgroundImageOverlay {
        &--scaleToFitPage {
            @include page-width;
        }

        &--scaleToFitScreen {
            @include full-window-width;
        }

        background-color: var(--overlay-color, rgba(0,0,0,0.4));
    }

    &_content {
        width: 100%;
        height: 100%;

        @include media-md-down {
            height: calc($section-height * 2);
        }

        @include media-lg-up { 
            position: relative;
            display: flex;
            justify-content: space-between;
            
            // foregroundImagePosition
            &--image-align-left {
                flex-direction: row-reverse;
            }
    
            &--image-align-right {
                flex-direction: row;
            }
        }

        @include media-lg-down { 
            display: flex;
            justify-content: space-between;
            
            // foregroundImagePosition
            &--image-align-left {
                flex-wrap: wrap-reverse;
            }
    
            &--image-align-right {
                flex-wrap: wrap;
            }
        }

        overflow: hidden;
    }

    &_details {
        display: flex;
        flex-direction: column;

        // textPositionImageStyle
        &--position-top {
            justify-content: flex-start;
        }

        &--position-middle {
            justify-content: center;
        }

        &--position-bottom {
            justify-content: flex-end;
        }

        // textAlignment
        &--align-center {
            text-align: center;
            align-items: center;
        }

        &--align-left {
            text-align: left;
            align-items: flex-start;
        }

        &--align-right {
            text-align: right;
            align-items: flex-end;
        }

        @include media-lg-up {
            max-width: 50%;
        }

        @include media-md-up {
            position: relative;
            // max-width: $content-width-desktop;
            flex-grow: 1;

            &--height-large, &--height-xlarge {
                padding: 36px $horizontal-padding-desktop 36px $horizontal-padding-desktop;
            }

            &--height-medium {
                padding: 23px $horizontal-padding-desktop 23px $horizontal-padding-desktop;
            }

            &--height-small, &--height-xsmall {
                padding: 18px $horizontal-padding-desktop 18px $horizontal-padding-desktop;
            }
        }

        // on mobile, absolutely positioned to take full viewport width
        @include media-md-down { 
            @include full-window-width;
            height: $section-height;

            &--image-align-left {
                top: $section-height;
            }
    
            &--image-align-right {
                top: 0
            }

            &--height-xlarge {
                padding: 36px $horizontal-padding-mobile 36px $horizontal-padding-mobile;
            }

            &--height-large {
                padding: 32px $horizontal-padding-mobile 32px $horizontal-padding-mobile;
            }

            &--height-medium {
                padding: 24px $horizontal-padding-mobile 24px $horizontal-padding-mobile;
            }

            &--height-small, &--height-xsmall {
                padding: 20px $horizontal-padding-mobile 20px $horizontal-padding-mobile;
            }
        }

        @include media-between-md-lg {
            padding-left: 0px;
            padding-right: 0px;
        }
    }

    &_tagline {
        color: var(--tagline-color, #474747);
        font-weight: bold;
        line-height: 1.2;

        // textSize
        &--text-size-small {
            margin-bottom: 20px;
        }

        &--text-size-medium {
            margin-bottom: 30px;

            #{$wrapper-selector}--height-xsmall & {
                margin-bottom: 15px;
            }
        }

        &--text-size-large {
            margin-bottom: 35px;
        }

        @include media-md-up {
            font-size: 22px;
        }

        @include media-md-down {
            font-size: 18px;
        }
    }

    &_title {
        @include title-3;

        color: var(--title-color, #474747);
        line-height: 1.2;

        @include media-md-up {
            &--text-size-small {
                font-size: 35px;
            }
    
            &--text-size-medium {
                font-size: 42px;
            }
    
            &--text-size-large {
                font-size: 48px;
            }
        }

        @include media-md-down {
            &--text-size-small {
                font-size: 20px;
            }
    
            &--text-size-medium {
                font-size: 24px;
            }
    
            &--text-size-large {
                font-size: 26px;
            }
        }
    }

    &_text {
        color: var(--description-color, #474747);

        @include media-md-up {
            line-height: 1.4;

            &--text-size-small {
                font-size: 18px;
                margin-bottom: 20px;
            }
    
            &--text-size-medium {
                font-size: 20px;
                margin-bottom: 35px;
            }
    
            &--text-size-large {
                font-size: 20px;
                margin-bottom: 40px;
            }
        }

        @include media-md-down {
            font-size: 16px;
            line-height: 1.5;

            &--text-size-small {
                margin-bottom: 20px;
            }
    
            &--text-size-medium {
                margin-bottom: 25px;

                #{$wrapper-selector}--height-xsmall & {
                    margin-bottom: 20px;
                }
            }
    
            &--text-size-large {
                margin-bottom: 30px;
            }
        }
    }

    &_buttonContainer {
        display: flex;
        flex-direction: row;
        gap: 15px;

        @include media-md-down {
            flex-direction: column;
            align-items: flex-start;
        }
    }
    &_button {
        white-space: nowrap;
    }

    &_divider {
        margin-top: 30px;
    }

    &_iconLink {
        width: 10px;
        margin-left: 5px;
    }

    &_foregroundImage {
        &--default-image {
            background-color: #EAEAEA;
        }

        @include media-lg-up {
            max-width: 50%;
        }

        @include media-md-up {
            // max-width: $content-width-desktop;
            flex-grow: 1;
            position: relative;
            height: 100%;
            align-self: center;
        }

        // on mobile, absolutely positioned to take full viewport width
        @include media-md-down { 
            @include full-window-width;
            height: $section-height;

            &--image-align-left {
                top: 0
            }
            
            &--image-align-right {
                top: $section-height;
            }
        }

        img {
            height: 100%;
            width: 100%;
        }

        // foregroundImageSize
        &--image-scaleToFit {
            img {
                object-fit: contain;
            }
        }

        &--image-scaleToFill {
            img {
                object-fit: cover;
            }
        }
    }

    &_defaultImage {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    }
}
