/*
 * Stories rail and full-screen story viewer (components/stories.blade.php), modelled on nba.com "Stories".
 * Loaded through the "stories" asset bundle.
 */

.stories {
    --stories-gap: 20px;
    --stories-badge: #fbafd8;
    background: #f6f6f6;
}

.stories__heading {
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e2e2;
    color: #111;
    _font-family: Oswald, Roboto, sans-serif;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: .5px;
    line-height: 1.1;
    text-transform: uppercase;
}

.stories__rail-wrap {
    position: relative;
}

.stories__rail {
    display: flex;
    gap: var(--stories-gap);
    margin: 0;
    padding: 0;
    overflow-x: auto;
    list-style: none;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.stories__rail::-webkit-scrollbar {
    display: none;
}

.stories__item {
    flex: 0 0 42%;
    scroll-snap-align: start;
}

@media (min-width: 576px) {
    .stories__item {
        flex-basis: 30%;
    }
}

@media (min-width: 992px) {
    .stories__item {
        flex-basis: calc((100% - 4 * var(--stories-gap)) / 4.6);
    }
}

.stories__card {
    position: relative;
    display: block;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: #222;
    margin-bottom: 2em;
}

.stories__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
}

.stories__card:hover .stories__image,
.stories__card:focus-visible .stories__image {
    transform: scale(1.05);
}

.stories__card::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 50%;
    background: linear-gradient(transparent, rgba(0, 0, 0, .85));
    content: "";
}

.stories__badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    padding: 1px 8px;
    background: var(--stories-badge);
    color: #111;
    font-size: 13px;
    font-weight: 700;
    line-height: 18px;
    text-transform: uppercase;
}

.stories__title {
    position: absolute;
    right: 10px;
    bottom: 12px;
    left: 10px;
    z-index: 1;
    display: -webkit-box;
    overflow: hidden;
    color: #fff;
    font-family: Roboto, sans-serif;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.6;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.stories__arrow {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    padding: 0;
    border: 0;
    background: #111;
    color: #fff;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
    cursor: pointer;
    transition: background-color .2s ease;
}

.stories__arrow:hover,
.stories__arrow:focus-visible {
    background: #c60000;
}

.stories__arrow[hidden] {
    display: none;
}

.stories__arrow--prev {
    left: 20px;
}

.stories__arrow--next {
    right: 20px;
}

@media (hover: none) {
    .stories__arrow {
        display: none;
    }
}

/* ---------------------------------------------------------------- Viewer */

.story-viewer {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .92);
}

.story-viewer[hidden] {
    display: none;
}

body.story-viewer-open {
    overflow: hidden;
}

.story-viewer__frame {
    position: relative;
    width: min(92vw, calc(92vh * 9 / 16));
    aspect-ratio: 9 / 16;
    overflow: hidden;
    background: #111;
    user-select: none;
}

.story-viewer__backdrop {
    position: absolute;
    inset: -20px;
    background-position: center;
    background-size: cover;
    filter: blur(20px) brightness(.6);
}

.story-viewer__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.story-viewer__progress {
    position: absolute;
    top: 10px;
    right: 10px;
    left: 10px;
    z-index: 2;
    display: flex;
    gap: 4px;
}

.story-viewer__bar {
    flex: 1;
    height: 3px;
    overflow: hidden;
    background: rgba(255, 255, 255, .35);
}

.story-viewer__bar span {
    display: block;
    width: 0;
    height: 100%;
    background: #fff;
}

.story-viewer__bar.is-done span {
    width: 100%;
}

.story-viewer__bar.is-active span {
    animation: story-progress var(--story-duration, 6s) linear forwards;
}

.story-viewer.is-paused .story-viewer__bar.is-active span {
    animation-play-state: paused;
}

@keyframes story-progress {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

.story-viewer__tap {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 1;
    width: 35%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.story-viewer__tap--prev {
    left: 0;
}

.story-viewer__tap--next {
    right: 0;
    width: 65%;
}

.story-viewer__caption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    padding: 80px 20px 24px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .85));
    color: #fff;
}

.story-viewer__title {
    margin: 0 0 14px;
    color: #fff;
    font-family: Roboto, sans-serif;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.35;
    text-transform: none;
}

.story-viewer__link {
    display: inline-block;
    padding: 8px 18px;
    background: #fff;
    color: #111;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
}

.story-viewer__link:hover,
.story-viewer__link:focus-visible {
    background: var(--stories-badge, #fdb927);
    color: #111;
}

.story-viewer__close,
.story-viewer__nav {
    position: absolute;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    color: #fff;
    cursor: pointer;
}

.story-viewer__close {
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, .15);
    font-size: 22px;
}

.story-viewer__nav {
    top: 50%;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    background: #fff;
    color: #111;
    font-size: 20px;
}

.story-viewer__nav--prev {
    left: calc(50% - min(46vw, calc(46vh * 9 / 16)) - 70px);
}

.story-viewer__nav--next {
    right: calc(50% - min(46vw, calc(46vh * 9 / 16)) - 70px);
}

.story-viewer__nav[hidden] {
    display: none;
}

@media (max-width: 767px) {
    .story-viewer__frame {
        width: 100vw;
        height: 100vh;
        aspect-ratio: auto;
    }

    .story-viewer__nav {
        display: none;
    }

    .story-viewer__close {
        top: 24px;
        right: 12px;
    }
}

/* ---------------------------------------------------------------- Video stories */

.stories__preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity .3s ease;
}

.stories__card.is-previewing .stories__preview {
    opacity: 1;
}

.stories__play {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding-left: 2px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: 12px;
    border-radius: 50%;
}

.story-viewer__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #000;
    object-fit: contain;
}

.story-viewer__video[hidden],
.story-viewer__image[hidden] {
    display: none;
}

.story-viewer__sound {
    position: absolute;
    top: 24px;
    right: 12px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

.story-viewer__sound[hidden] {
    display: none;
}

.story-viewer.is-loading .story-viewer__frame::after {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    animation: story-spin .8s linear infinite;
    content: "";
}

@keyframes story-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 767px) {
    .story-viewer__sound {
        right: 64px;
    }
}
