@import "~theme/globals";

:host {
    ion-card {
        --vertical-margin: 12px;

        display: flex;
        flex-direction: column;
        align-self: stretch;
        height: calc(100% - var(--vertical-margin) - var(--vertical-margin));
        margin-top: var(--vertical-margin);
        margin-bottom: var(--vertical-margin);

        @for $i from 0 to length($core-course-image-background) {
            &[course-color="#{$i}"] .core-course-thumb {
                background: var(--core-course-color-#{$i});
            }
        }

        .core-course-thumb {
            padding-top: 40%;
            width: 100%;
            overflow: hidden;
            cursor: pointer;
            pointer-events: auto;
            position: relative;
            background-position: center;
            background-size: cover;
            -webkit-transition: all 50ms ease-in-out;
            transition: all 50ms ease-in-out;

            &.core-course-color-img {
                background: var(--ion-item-background);
            }

            img {
                position: absolute;
                top: 0;
                bottom: 0;
                right: 0;
                left: 0;
                margin: auto;
            }
        }

        @if ($core-course-hide-thumb-on-cards) {
            .core-course-thumb {
                display: none;
            }
        }

        @if ($core-course-thumb-on-cards-background) {
            .core-course-thumb {
                background: $core-course-thumb-on-cards-background !important;
            }
        }

        .core-course-additional-info {
            margin-bottom: 8px;
        }

        .core-course-header {
            flex-grow: 1;
            display: flex;
            flex-direction: column;

            &.core-course-only-title {
                &::part(native) {
                    flex-grow: 1;
                }

            }

            .core-course-title {
                margin: 12px 0;
                flex-grow: 1;

                .item-heading ion-icon {
                    margin-right: 4px;
                    color: var(--core-star-color);
                }
            }

            .core-button-spinner {
                margin: 0;
            }
            .core-button-spinner ion-spinner {
                vertical-align: top; // the better option for most scenarios
                vertical-align: -webkit-baseline-middle; // the best for those that support it
            }

            .core-button-spinner .core-icon-downloaded {
                font-size: 28.8px;
                margin-top: 8px;
                vertical-align: top;
            }

            .item-button[icon-only] {
                min-width: 50px;
                width: 50px;
            }
        }

        @if ($core-course-hide-progress-on-cards) {
            .core-course-progress {
                display: none;
            }
        }
    }

    button {
        z-index: 1;
    }
}

// Common styles.
:host-context(.core-horizontal-scroll) {
    @include horizontal_scroll_item(80%, 250px, 300px);

    ion-card {
        .core-course-thumb {
            padding-top: 30%;
        }

        .core-course-header {
            .core-course-title {
                margin: 7px 0;

                .item-heading ion-icon {
                    margin-right: 2px;
                }

                &.core-course-with-buttons {
                    max-width: calc(100% - 40px);
                }
            }
            .core-button-spinner {
                min-height: 40px;
                min-width: 40px;

                ion-spinner {
                    width: 20px;
                    height: 20px;
                }
            }
            .item-button[icon-only] {
                min-width: 40px;
                width: 40px;
                padding: 8px;
            }

        }
    }
}
