﻿/* =========================================================
   HIDE RECOMMENDED WHILE ARTICLE READER IS OPEN
   ========================================================= */

body.article-reader-open .recommended-section,
body.article-reader-open .recommended-slot {
    display: none !important;
}


/* =========================================================
   RECOMMENDED SLOT
   ========================================================= */

.recommended-slot {
    position: relative;
    width: 100vw;
    max-width: 100vw;
    /*
     * Break out of any centered Bootstrap/container
     * that surrounds Index.cshtml.
     */
    margin-left: calc(50% - 50vw);
    margin-right: 0;
    box-sizing: border-box;
}

/* =========================================================
   NORMAL RECOMMENDED SECTION
   ========================================================= */

.recommended-section {
    width: min(1700px, calc(100vw - 32px));
    margin: 20px auto;
    padding: 0;
    box-sizing: border-box;
    background: #fff;
    opacity: 1;
    visibility: visible;
    transition: transform .28s ease, opacity .22s ease, visibility .22s ease;
}


/* =========================================================
   HEADER
   ========================================================= */

.recommended-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    margin-bottom: 10px;
}

    .recommended-header h3 {
        margin: 0;
        display: flex;
        align-items: center;
        gap: 7px;
        font-size: 19px;
        font-weight: 700;
        color: #222;
    }


/* =========================================================
   ARROWS
   ========================================================= */

.recommended-arrows {
    display: flex;
    gap: 6px;
}

    .recommended-arrows button {
        width: 34px;
        height: 34px;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: #f1f1f1;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: transform .2s ease, background .2s ease;
    }

        .recommended-arrows button:hover {
            background: #e5e5e5;
            transform: scale(1.05);
        }


/* =========================================================
   CAROUSEL
   ========================================================= */

.recommended-carousel {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scroll-behavior: smooth;
}

    .recommended-carousel::-webkit-scrollbar {
        display: none;
    }


/* =========================================================
   TRACK
   ========================================================= */

.recommended-track {
    display: flex;
    gap: 14px;
    width: max-content;
    padding: 2px 2px 10px;
}


/* =========================================================
   CARD
   ========================================================= */

.recommended-card {
    position: relative;
    flex: 0 0 220px;
    width: 220px;
    height: 155px;
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(0, 0, 0, .12);
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

    .recommended-card img {
        width: 100%;
        height: 100%;
        display: block;
        object-fit: cover;
        user-select: none;
        -webkit-user-drag: none;
    }


/* =========================================================
   NO IMAGE
   ========================================================= */

.recommended-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eee;
    color: #aaa;
    font-size: 32px;
}


/* =========================================================
   CARD TITLE
   ========================================================= */

.recommended-card-content {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 32px 12px 11px;
    background: linear-gradient( to bottom, transparent, rgba(0, 0, 0, .88) );
}

.recommended-card h4 {
    margin: 0;
    color: #fff;
    font-size: 14px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* =========================================================
   NORMAL SCROLLING
   ========================================================= */

body.is-scrolling .recommended-section {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-110%);
    pointer-events: none;
}


/* =========================================================
   FLOATING STATE
   ========================================================= */

.recommended-section.is-floating {
    position: fixed;
    top: calc( var(--top-section-height, 0px) + 8px );
    left: 0;
    right: 0;
    width: 100vw;
    max-width: none;
    margin: 0;
    padding: 8px 0 10px;
    box-sizing: border-box;
    z-index: 4000;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-bottom: 1px solid rgba(255,255,255,.55);
    box-shadow: 0 8px 28px rgba(0,0,0,.09);
    transform: translateY(0);
}


    /* =========================================================
   CENTER FLOATING CONTENT
   ========================================================= */

    .recommended-section.is-floating
    .recommended-header,
    .recommended-section.is-floating
    .recommended-carousel {
        width: min( 1700px, calc(100vw - 32px) );
        margin-left: auto;
        margin-right: auto;
    }


    /* =========================================================
   FLOATING HEADER
   ========================================================= */

    .recommended-section.is-floating
    .recommended-header {
        margin-bottom: 5px;
        padding-left: 0;
        padding-right: 0;
    }


/* =========================================================
   FLOATING CARDS - DESKTOP
   ========================================================= */

@media (min-width: 769px) {

    .recommended-section.is-floating
    .recommended-card {
        flex: 0 0 180px;
        width: 180px;
        height: 90px;
        border-radius: 12px;
    }

    .recommended-section.is-floating
    .recommended-card-content {
        padding: 20px 9px 7px;
    }

    .recommended-section.is-floating
    .recommended-card h4 {
        font-size: 11px;
    }
}


/* =========================================================
   FLOATING WHILE SCROLLING
   ========================================================= */

body.is-scrolling
.recommended-section.is-floating {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-110%);
    pointer-events: none;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 768px) {

    .recommended-section {
        width: 100%;
        margin: 12px 0;
        padding: 0 10px;
    }

    .recommended-header {
        padding: 0 2px;
        margin-bottom: 7px;
    }

        .recommended-header h3 {
            font-size: 17px;
        }


    /* -----------------------------------------
       Floating
       ----------------------------------------- */

    .recommended-section.is-floating {
        top: calc( var(--top-section-height, 0px) + 5px );
        width: 100%;
        padding: 6px 8px 8px;
        border-radius: 0 0 14px 14px;
    }


        .recommended-section.is-floating
        .recommended-header {
            width: 100%;
            padding: 0 2px;
            margin-bottom: 4px;
        }


            .recommended-section.is-floating
            .recommended-header h3 {
                font-size: 14px;
            }


        .recommended-section.is-floating
        .recommended-arrows button {
            width: 29px;
            height: 29px;
            font-size: 11px;
        }


        .recommended-section.is-floating
        .recommended-carousel {
            width: 100%;
        }


    /* -----------------------------------------
       Normal mobile cards
       ----------------------------------------- */

    .recommended-card {
        flex: 0 0 64vw;
        width: 64vw;
        height: 125px;
        border-radius: 13px;
    }


    .recommended-track {
        gap: 8px;
        padding: 2px 2px 8px;
    }


    /* -----------------------------------------
       Floating mobile cards
       ----------------------------------------- */

    .recommended-section.is-floating
    .recommended-carousel {
        max-height: 62px;
    }

    .recommended-section.is-floating
    .recommended-track {
        gap: 7px;
        padding: 0 2px 4px;
    }

    .recommended-section.is-floating
    .recommended-card {
        flex: 0 0 110px;
        width: 110px;
        height: 58px;
        border-radius: 9px;
    }

    .recommended-section.is-floating
    .recommended-card-content {
        padding: 14px 6px 5px;
    }

    .recommended-section.is-floating
    .recommended-card h4 {
        font-size: 9px;
        line-height: 1.2;
    }

    .recommended-slot {
        width: 100vw;
        max-width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: 0;
    }

    .recommended-section {
        width: 100%;
        margin: 12px 0;
        padding: 0 8px;
    }

        .recommended-section.is-floating {
            width: 100vw;
            margin: 0;
            padding: 6px 8px 8px;
        }

            .recommended-section.is-floating
            .recommended-header,
            .recommended-section.is-floating
            .recommended-carousel {
                width: 100%;
            }
}


/* =========================================================
   VERY SMALL MOBILE
   ========================================================= */

@media (max-width: 380px) {

    .recommended-card {
        flex-basis: 68vw;
        width: 68vw;
        height: 120px;
    }

    .recommended-header h3 {
        font-size: 15px;
    }
}

@media (min-width: 769px) {

    .recommended-section {
        margin-top: 12px;
    }
}