/* =========================================================
   YOUTUBE FEED

   Latest uploads as a scroll-snap slider or a grid.

   See /inc/youtube-feed.php,
       /templates/youtube-feed.php,
       /assets/js/youtube-feed.js
   ========================================================= */

.mwd-yt {
    --yt-card: 380px;
    --yt-gap: 24px;
    --yt-accent: #01bcef;
    --yt-arrow-bg: #e2eff7;
    --yt-red: #ff0033;
    --yt-text: #29292d;
    --yt-muted: #6b7681;

    position: relative;
    width: 100%;
}


/* =========================================================
   HEADER
   ========================================================= */

.mwd-yt-head {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;

    margin-bottom: 18px;
}


.mwd-yt-heading {
    margin: 0;

    font-size: 26px;
    line-height: 1.2;
    font-weight: 700;
    color: var(--yt-text);
}


.mwd-yt-head-actions {
    display: flex;
    align-items: center;

    gap: 14px;

    flex: 0 0 auto;
    margin-left: auto;
}


.mwd-yt-channel-link {
    position: relative;
    display: inline-block;

    padding: 5.4px 36px 5.4px 12.6px;

    background: none;

    border: 0;
    border-bottom: 1px dashed rgb(1, 188, 239);

    color: rgb(1, 188, 239);

    font-family: 'Space_Grotesk', Helvetica, Arial, Lucida, sans-serif;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;

    text-decoration: none;

    transition: opacity 150ms ease;
}


.mwd-yt-channel-link:hover {
    color: rgb(1, 188, 239);
    text-decoration: none;
    opacity: 0.75;
}


/* Divi's icon font supplies the arrow. */

.mwd-yt-channel-link::after {
    content: '$';

    position: absolute;
    top: 50%;
    right: 12.6px;

    transform: translateY(-50%);

    font-family: ETmodules !important;
    font-size: 1em;
    font-weight: 400;
    line-height: 1em !important;

    /* Keep the glyph upright regardless of inherited styles. */
    font-style: normal;
    font-variant: normal;
    text-transform: none;
    speak: none;

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* =========================================================
   ARROWS
   ========================================================= */

.mwd-yt-nav {
    display: flex;

    gap: 8px;
}


.mwd-yt-nav[hidden] {
    display: none;
}


.mwd-yt-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;

    padding: 0;

    border: 0;
    border-radius: 50%;

    background: var(--yt-arrow-bg);
    color: var(--yt-accent);

    cursor: pointer;

    transition:
        background 150ms ease,
        color 150ms ease,
        opacity 150ms ease;
}


.mwd-yt-arrow svg {
    display: block;

    width: 18px;
    height: 18px;
}


.mwd-yt-arrow:hover:not(:disabled) {
    background: var(--yt-accent);
    color: #fff;
}


.mwd-yt-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}


.mwd-yt-arrow:focus-visible {
    outline: 2px solid var(--yt-accent);
    outline-offset: 2px;
}


/* =========================================================
   RAIL
   ========================================================= */

.mwd-yt-rail {
    display: flex;

    gap: var(--yt-gap);

    margin: 0;
    padding: 0 0 4px;

    list-style: none;
}


.mwd-yt--slider .mwd-yt-rail {
    overflow-x: auto;
    overflow-y: hidden;

    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;

    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;

    /*
     * Let cards run to the edge of a full-width Divi section without
     * clipping the focus ring.
     */
    scroll-padding-left: 2px;
}


.mwd-yt--slider .mwd-yt-rail::-webkit-scrollbar {
    display: none;
}


.mwd-yt--slider .mwd-yt-item {
    flex: 0 0 var(--yt-card);
    width: var(--yt-card);

    scroll-snap-align: start;
}


/* Grid variant */

.mwd-yt--grid .mwd-yt-rail {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}


.mwd-yt--grid .mwd-yt-item {
    width: auto;
}

.mwd-yt .mwd-yt-rail,
.mwd-yt .mwd-yt-rail > li.mwd-yt-item {
    list-style: none !important;
    list-style-type: none !important;
    list-style-image: none !important;
}

.mwd-yt .mwd-yt-rail > li.mwd-yt-item::marker {
    content: none;
}

.mwd-yt .mwd-yt-rail > li.mwd-yt-item::before {
    content: none !important;
    display: none !important;
}


/* =========================================================
   CARD
   ========================================================= */

.mwd-yt-card {
    display: block;

    color: inherit;
    text-decoration: none;
}


.mwd-yt-card:hover {
    text-decoration: none;
}


.mwd-yt-card:focus-visible {
    outline: 2px solid var(--yt-accent);
    outline-offset: 3px;
    border-radius: 10px;
}


.mwd-yt-thumb {
    position: relative;
    display: block;

    width: 100%;
    aspect-ratio: 16 / 9;

    overflow: hidden;
    border-radius: 8px;

    background: #1e1e22;
}


.mwd-yt-thumb img {
    display: block;

    width: 100%;
    height: 100%;

    /*
     * hqdefault is 4:3 with letterboxing, so crop to the 16:9 box.
     */
    object-fit: cover;

    transition: transform 350ms ease;
}


.mwd-yt-card:hover .mwd-yt-thumb img {
    transform: scale(1.04);
}


.mwd-yt-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    display: flex;
    align-items: center;
    justify-content: center;

    width: 46px;
    height: 32px;

    border-radius: 7px;

    background: rgba(30, 30, 34, 0.72);
    color: #fff;

    opacity: 0.92;

    transition: background 200ms ease, transform 200ms ease;
}


.mwd-yt-play svg {
    display: block;

    width: 20px;
    height: 20px;
}


.mwd-yt-card:hover .mwd-yt-play {
    background: var(--yt-red);
    transform: translate(-50%, -50%) scale(1.06);
}


.mwd-yt-body {
    display: block;

    padding-top: 12px;
}


.mwd-yt-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;

    overflow: hidden;

    color: var(--yt-text);

    font-size: 16px;
    line-height: 1.4;
    font-weight: 600;
}


.mwd-yt-card:hover .mwd-yt-title {
    color: var(--yt-accent);
}


.mwd-yt-meta {
    display: flex;
    align-items: center;

    gap: 6px;

    padding-top: 6px;

    color: var(--yt-muted);

    font-size: 13px;
    line-height: 1.4;
}


/* =========================================================
   MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    .mwd-yt--slider .mwd-yt-rail {
        scroll-behavior: auto;
    }

    .mwd-yt-thumb img,
    .mwd-yt-play {
        transition: none;
    }

    .mwd-yt-card:hover .mwd-yt-thumb img {
        transform: none;
    }

}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 767px) {

    .mwd-yt {
        --yt-card: 280px;
        --yt-gap: 16px;
    }

    .mwd-yt-heading {
        font-size: 21px;
    }

    .mwd-yt-nav {
        display: none;
    }

    .mwd-yt-channel-link {
        padding: 5.4px 32px 5.4px 0;
        font-size: 16px;
    }

    .mwd-yt-channel-link::after {
        right: 8px;
    }

    .mwd-yt-title {
        font-size: 15px;
    }

}
