/* =========================================================
   CAROUSELS
   - Hero banner: 2500x500 images
   - Card carousels: small banners / blog previews / video previews
   ========================================================= */

/* External CSS makes the blocks visible after the stylesheet is loaded.
   If you use the critical inline snippet from the integration notes,
   it keeps them hidden until this file applies. */
[data-banner-carousel],
[data-card-carousel] {
    visibility: visible;
}

/* =========================================================
   HERO BANNER
   ========================================================= */

.main-banner {
    position: relative;
    width: 100%;
    max-width: 2500px;
    margin: 0 auto;
    overflow: hidden;
}

.main-banner__viewport {
    display: flex;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
}

.main-banner__viewport:active {
    cursor: grabbing;
}

.main-banner__viewport::-webkit-scrollbar {
    display: none;
}

.main-banner__slide {
    position: relative;
    flex: 0 0 100%;
    width: 100%;

    /*
       Image source is 2500x500 (5:1).
       The height is chosen so that:
       - top/bottom are never cropped because the slide is never lower than 20vw;
       - 30vh is the preferred height;
       - on narrow screens we do not make the banner so tall that less than
         about 1400 source pixels remain visible horizontally;
       - the banner never exceeds the source height of 500px.
    */
    height: min(500px, clamp(20vw, 30vh, 35.714vw));

    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
}

.main-banner__slide img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: none;
    -webkit-user-drag: none;
}

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

.main-banner__arrow,
.card-carousel__arrow {
    position: absolute;
    top: 50%;
    z-index: 10;
    transform: translateY(-50%);
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    color: #222;
    font-family: Arial, sans-serif;
    font-weight: 300;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);

    /* Hidden until JS initializes the carousel. */
    opacity: 0;
    pointer-events: none;

    transition: opacity 0.2s, background 0.2s;
}

.carousel-initialized .main-banner__arrow,
.carousel-initialized .card-carousel__arrow {
    opacity: 0.74;
    pointer-events: auto;
}

.carousel-initialized .main-banner__arrow:hover,
.carousel-initialized .card-carousel__arrow:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.98);
}

.main-banner__arrow {
    width: 44px;
    height: 64px;
    font-size: 42px;
    line-height: 60px;
}

.main-banner__arrow--prev,
.card-carousel__arrow--prev {
    left: 18px;
}

.main-banner__arrow--next,
.card-carousel__arrow--next {
    right: 18px;
}

/* =========================================================
   HERO DOTS
   ========================================================= */

.main-banner__dots {
    position: absolute;
    left: 50%;
    bottom: 12px;
    z-index: 10;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 7px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.carousel-initialized .main-banner__dots {
    opacity: 1;
    pointer-events: auto;
}

.main-banner__dot {
    display: block;
    width: 9px;
    height: 9px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.main-banner__dot.active {
    background: #fff;
    transform: scale(1.2);
}

/* =========================================================
   CARD CAROUSEL
   Small banners / blog cards / video cards
   ========================================================= */

.card-carousel {
    position: relative;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    --card-gap: 16px;
}

.card-carousel__viewport {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    cursor: grab;

    /* Edge fading is enabled by JS only when the carousel really overflows. */
}

.card-carousel__viewport:active {
    cursor: grabbing;
}

.card-carousel__viewport::-webkit-scrollbar {
    display: none;
}

.card-carousel__track {
    display: flex;
    align-items: stretch;
    gap: var(--card-gap);
    min-width: 100%;
}

.card-carousel__item {
    position: relative;
    display: flex;
    flex: 0 0 100%;
    min-width: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.card-carousel__item > * {
    width: 100%;
}

/* Fade only the side where hidden cards actually exist. */
.carousel-has-overflow:not(.carousel-at-start):not(.carousel-at-end) .card-carousel__viewport {
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 26px,
        #000 calc(100% - 26px),
        transparent 100%
    );
    mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 26px,
        #000 calc(100% - 26px),
        transparent 100%
    );
}

.carousel-has-overflow.carousel-at-start .card-carousel__viewport {
    -webkit-mask-image: linear-gradient(
        to right,
        #000 0,
        #000 calc(100% - 26px),
        transparent 100%
    );
    mask-image: linear-gradient(
        to right,
        #000 0,
        #000 calc(100% - 26px),
        transparent 100%
    );
}

.carousel-has-overflow.carousel-at-end .card-carousel__viewport {
    -webkit-mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 26px,
        #000 100%
    );
    mask-image: linear-gradient(
        to right,
        transparent 0,
        #000 26px,
        #000 100%
    );
}

.carousel-no-overflow .card-carousel__arrow {
    display: none;
}

.card-carousel__arrow {
    width: 40px;
    height: 56px;
    font-size: 36px;
    line-height: 52px;
}

/* 2 full cards + a small piece of the next one. */
@media (min-width: 700px) {
    .card-carousel__item {
        flex-basis: calc((100% - 64px) / 2);
    }
}

/* 3 full cards + a small piece of the next one. */
@media (min-width: 1000px) {
    .card-carousel__item {
        flex-basis: calc((100% - 80px) / 3);
    }
}

/* 4 full cards + a small piece of the next one. */
@media (min-width: 1400px) {
    .card-carousel__item {
        flex-basis: calc((100% - 96px) / 4);
    }
}

/* =========================================================
   SMALL IMAGE BANNERS, e.g. about 360x180
   ========================================================= */

.card-banner {
    display: block;
    height: 100%;
    overflow: hidden;
    border-radius: 10px;
    text-decoration: none;
    background: #f4f4f4;
}

.card-banner img {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

/* =========================================================
   BLOG ARTICLE PREVIEW
   Same width as small banners. All cards in the flex row stretch
   to the height of the tallest card.
   ========================================================= */

.article-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: #fff;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
}

.article-card__image {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

.article-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    padding: 14px 15px 16px;
}

.article-card__title {
    margin: 0 0 8px;
    font-size: 18px;
    line-height: 1.25;
    font-weight: 600;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.article-card__text {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    opacity: 0.78;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}

/* =========================================================
   VIDEO PREVIEW
   ========================================================= */

.video-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: #fff;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
}

.video-card__image-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 1;
    overflow: hidden;
    background: #111;
}

.video-card__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

.video-card__play {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.58);
    pointer-events: none;
}

.video-card__play::after {
    content: "";
    position: absolute;
    left: 19px;
    top: 14px;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 16px solid #fff;
}

.video-card__title {
    margin: 0;
    padding: 13px 15px 15px;
    font-size: 17px;
    line-height: 1.3;
    font-weight: 600;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

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

@media (max-width: 699px) {
    .main-banner__arrow,
    .card-carousel__arrow {
        display: none;
    }

    .main-banner__dots {
        bottom: 7px;
        gap: 6px;
    }

    .main-banner__dot {
        width: 7px;
        height: 7px;
    }

    .card-carousel__viewport {
        -webkit-mask-image: none;
        mask-image: none;
    }

    .card-carousel__item {
        flex-basis: 100%;
    }
}

/* =========================================================
   ACCESSIBILITY
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .main-banner__viewport,
    .card-carousel__viewport {
        scroll-behavior: auto;
    }
}
