@charset 'utf-8';

/*  ========================================================================
    JUICE -> ELEMENTS -> FORM -> TEXTAREA
    ========================================================================  */

// Check if the elements with textarea should be imported
@if $import-elements and $import-element-textarea {
    textarea {
        appearance: none;
        background-color: $textarea-background-color;
        border: 0 $textarea-border-style $textarea-border-color;
        border-bottom-left-radius: $textarea-border-radius-bottom-left;
        border-bottom-right-radius: $textarea-border-radius-bottom-right;
        border-top-left-radius: $textarea-border-radius-top-left;
        border-top-right-radius: $textarea-border-radius-top-right;
        border-bottom-width: $textarea-border-width-bottom;
        border-left-width: $textarea-border-width-left;
        border-right-width: $textarea-border-width-right;
        border-top-width: $textarea-border-width-top;
        color: $textarea-font-color;
        display: flex;
        font-family: $textarea-font-family;
        font-size: $textarea-font-size;
        line-height: 1.5;
        margin: 0;
        margin-bottom: $textarea-element-spacing;
        min-width: 100%;
        outline: none;
        padding: $textarea-content-spacing;
        resize: none;
        width: 100%;
        z-index: stack-index('default');

        // Pseudo classes
        &:hover {
            background-color: $select-background-color-hover;
            border-color: $select-border-color-hover;
            color: $select-font-color-hover;
            z-index: stack-index('hover');
        }

        &:focus {
            background-color: $select-background-color-focus;
            border-color: $select-border-color-focus;
            box-shadow: 0 0 0 $input-accessibility-focus-width $input-accessibility-focus-color;
            color: $select-font-color-focus;
            z-index: stack-index('focus');
        }

        &:active {
            background-color: $select-background-color-active;
            border-color: $select-border-color-active;
            color: $select-font-color-active;
            z-index: stack-index('active');
        }

        // Pseudo elements
        &::placeholder {
            color: $textarea-placeholder-color;
        }

        // Modifiers: Props
        &[disabled] {
            // Styles
            @include disabled();
        }

        // Check if the textarea size modifiers should be declared
        @if $textarea-size-modifiers {
            // Cycle through all of the sizes
            @each $size in $sizes {
                // Modifiers: Sizes
                &.is-#{$size} {
                    font-size: map-get($select-font-size-sizes, $size);
                    padding: map-get($select-content-spacing-sizes, $size);
                }

                // Check if the textarea size modifiers with breakpoints should be declared
                @if $textarea-size-modifiers-with-breakpoints {
                    // Cycle through all of the breakpoints
                    @each $breakpoint-name, $breakpoint-value in $breakpoints {
                        // Breakpoint
                        @include breakpoint($breakpoint-name) {
                            // Modifiers: Size
                            &.is-#{$size}\@#{$breakpoint-name} {
                                font-size: map-get($select-font-size-sizes, $size);
                                padding: map-get($select-content-spacing-sizes, $size);
                            }
                        }
                    }
                }
            }
        }

        // Check if the textarea feedback modifiers should be declared
        @if $textarea-feedback-modifiers {
            // Cycle through all of the feedback colors
            @each $feedback-name, $feedback-value in $feedback-colors {
                // Modifiers: Feedback colors
                &.has-#{$feedback-name} {
                    border-color: feedback-color($feedback-name);

                    // Pseudo classes
                    &:focus,
                    &:active {
                        box-shadow: 0 0 0 $input-accessibility-focus-width feedback-color('#{$feedback-name}-accessibility-focus');
                    }

                    // Modifiers: Props
                    &[disabled] {
                        border-color: feedback-color($feedback-name) !important;
                    }
                }
            }
        }

        // Check if the textarea resize modifier should be declared
        @if $textarea-resize-modifier {
            // Modifiers
            &.textarea--resize {
                resize: vertical;
            }
        }

        // Check if the textarea scrollbar modifier should be declared
        @if $textarea-scrollbar-modifier {
            // Modifiers
            &.textarea--scrollbar {
                border-bottom-right-radius: 0;
                border-top-right-radius: 0;
                overflow-y: scroll;
            }
        }
    }
}
