/* =========================================================
   "Important For You" channel strip
   Partial: Views/Partials/channelsSection.cshtml
   Script:  wwwroot/scripts/dragScroll.js (shared, loaded in master.cshtml)
   Prefix:  chn-
   ========================================================= */

.channels {
    overflow: hidden; /* the strip bleeds to the edge; never scroll the page sideways */
}

.channels-header {
    text-align: center;
    /* Same gap under a section heading as every other section */
    margin-bottom: var(--section-title-gap);
}

/* ---------- Scroll strip ---------- */
.chn-slider {
    display: flex;
    justify-content: center;
    --chn-card-w: 280px;
    --chn-gap: 18px;
    --chn-radius: 16px;
    position: relative;
}

.chn-track {
    display: flex;
    /* .chn-track is .chn-slider's only flex child and relies on flex-basis:auto
       to size itself — Chromium resolves that to the track's full content
       width (~1182px in testing), but Safari/WebKit resolves the same
       flex-basis:auto to a tiny fraction of it (~62px) for a flex item that
       is also a scroll container (overflow-x: auto), which is what actually
       produced the "20px wide cards" — the cards were never wrong, the strip
       around them was collapsed. flex:1 1 0% sidesteps the ambiguous "auto"
       calculation entirely and is resolved identically by every engine;
       min-width:0 lets it still shrink below its scrollable content's
       intrinsic width, same flex/grid gotcha as elsewhere on this site. */
    flex: 1 1 0%;
    min-width: 0;
    /* flex-start, so the strip begins at the leading edge instead of centring */
    justify-content: center;
    gap: var(--chn-gap);
    margin: 0;
    padding: 4px 4px 12px;
    list-style: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    /* Hide the scrollbar — dragging and swiping are the affordance */
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
}

    .chn-track::-webkit-scrollbar {
        display: none;
    }

    /* Set by dragScroll.js while a pointer drag is in progress */
    .chn-track.is-dragging {
        cursor: grabbing;
        scroll-behavior: auto; /* smooth would fight per-frame scrollLeft writes */
        scroll-snap-type: none; /* snapping mid-drag makes it feel sticky */
    }

.chn-item {
    /* Longhand, not the `flex` shorthand: Safari has a long-standing bug
       where a CSS custom property used as the flex-basis component of the
       `flex` shorthand (flex: 0 0 var(--x)) fails to resolve and the basis
       collapses to near 0, shrinking each card down to a sliver — Chrome and
       every other engine parse the shorthand correctly. The three longhand
       properties below compute to the exact same values everywhere Safari
       already got right, so nothing changes outside Safari. */
    flex-grow: 0;
    flex-shrink: 0;
    flex-basis: var(--chn-card-w);
    max-width: var(--chn-card-w);
    scroll-snap-align: start;
}

/* ---------- Card ---------- */
.chn-card {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    border-radius: var(--chn-radius);
    overflow: hidden;
    text-decoration: none;
    background: var(--primary-dark-blue, #003B70);
    isolation: isolate;
}

    .chn-card:hover .chn-card__img {
        transform: scale(1.05);
    }

    .chn-card:focus-visible {
        outline: 3px solid var(--primary-teal, #00C4B3);
        outline-offset: 3px;
    }

.chn-card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.45s ease;
    /* stops the browser's native image drag from hijacking the pointer drag */
    -webkit-user-drag: none;
    user-select: none;
}

.chn-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 25, 50, 0) 35%, rgba(0, 25, 50, 0.35) 60%, rgba(0, 25, 50, 0.85) 100%);
}

.chn-card__body {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
}

.chn-card__text {
    min-width: 0; /* flex child holding text must be shrinkable */
    color: var(--white, #FFFFFF);
    font-size: 32px;
    font-weight: 400;
    line-height: 1.25;
    overflow-wrap: break-word;
}

.chn-card__arrow {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-self: flex-end;
    align-items: flex-end;
    justify-content: center;
    border-radius: 50%;
    /* background: rgba(255, 255, 255, 0.18); */
    color: var(--white, #FFFFFF);
    font-size: 22px;
    transition: background-color 0.25s ease, transform 0.25s ease;
}

/*.chn-card:hover .chn-card__arrow {
    background: rgba(255, 255, 255, 0.34);
}*/

/* ---------- RTL ---------- */
/* The flex track reverses on its own from dir="rtl" on <html>, so only the
   arrow glyph needs mirroring — it points at the destination, not at a side. */
html[dir="rtl"] .chn-card__arrow i {
    transform: scaleX(-1);
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .chn-slider {
        --chn-card-w: 240px;
        --chn-gap: 14px;
    }

    .chn-card__text {
        font-size: var(--text-lg, 18px);
    }
}

@media (max-width: 768px) {
    .chn-slider {
        --chn-card-w: 200px;
        --chn-gap: 12px;
    }

    .chn-card__body {
        padding: 14px;
    }

    .chn-card__text {
        font-size: var(--text-base, 16px);
    }

    .chn-card__arrow {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .chn-track {
        scroll-behavior: auto;
    }

    .chn-card__img,
    .chn-card__arrow {
        transition: none;
    }

    .chn-card:hover .chn-card__img {
        transform: none;
    }
}
@media (max-width: 768px) {
    .chn-track {
        justify-content: start;
    }
}