/*
 * NKALL Category Deck
 *
 * ONE mechanism at every size: a CSS scroll-snap track. Only how many cards fit
 * changes — 4 across on desktop, 1 across on mobile. The browser does the
 * scrolling and the snapping, so it all still works with JavaScript off; the JS
 * only adds arrows, dots and an optional slow pan.
 *
 * Card height is equal BY CONSTRUCTION: every card is a flex column and the
 * body takes the slack, so a 2-line blurb and a 3-line blurb give the same
 * height. (The Kadence slider this replaced needed JS for that and still left a
 * 23px spread on mobile.)
 */

.nkall-deck {
    --deck-ink: #12131a;
    --deck-ink-soft: #1b1d28;
    --deck-line: #2a2c3a;
    --deck-text: #ffffff;
    --deck-muted: #b9bdcc;
    --deck-accent: #6d3bc4;
    --deck-accent-2: #5680e9;
    --deck-radius: 18px;
    --deck-gap: 18px;
    --deck-visible: 4;      /* overridden inline by the block */
    --deck-peek: 0.35;      /* how much of the next card shows */
    --deck-edge: 2px;       /* room so hover-lift and shadow are not clipped */

    margin: 0 auto;
    padding: 4px 0;
}

.nkall-deck__heading {
    text-align: center;
    margin: 0 0 16px;
}

/* ------------------------------------------------------------- the viewport */

.nkall-deck__viewport {
    position: relative;
}

/* -------------------------------------------------------------- the track ---
   Always a flex scroll-snap row. `--deck-visible` decides how many fit; the
   fractional `--deck-peek` is what makes the next card show, which is the only
   honest way to say "there is more" without a scrollbar. */

/* The doubled class is deliberate. This is a <ul>, and the theme's own list
   rules set padding-left: 36px with enough specificity to beat a single class.
   That pushed the first card 36px in, so the browser's snap point was at 34
   rather than 0 — the row loaded looking scrolled, with the first card clipped
   and the back arrow already lit. Measured, not guessed:
   getComputedStyle(track).paddingLeft === "36px" while this rule said 2px. */
.nkall-deck__track.nkall-deck__track {
    list-style: none;
    margin: 0;
    padding: var(--deck-edge) var(--deck-edge) 6px;
    display: flex;
    gap: var(--deck-gap);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;

    /* The card images are lazy-loaded, and as each one arrives the browser's
       scroll anchoring nudges the track to keep "what you were looking at" in
       place — on a horizontal scroller that shows up as the row starting a few
       pixels in, clipping the first card and lighting the back arrow before the
       customer has done anything. Measured: 42px of drift on a clean load. */
    overflow-anchor: none;
    scroll-padding-inline-start: var(--deck-edge);
}

.nkall-deck__track::-webkit-scrollbar {
    display: none;
}

.nkall-deck__item {
    margin: 0;
    display: flex;
    scroll-snap-align: start;
    flex: 0 0 calc(
        (100% - (var(--deck-visible) - 1) * var(--deck-gap))
        / (var(--deck-visible) + var(--deck-peek))
    );
}

/* Grid mode: no scrolling, everything on screen at once. */
.nkall-deck--desktop-grid .nkall-deck__track {
    display: grid;
    grid-template-columns: repeat(var(--deck-visible), minmax(0, 1fr));
    overflow: visible;
}

.nkall-deck--desktop-grid .nkall-deck__item {
    flex: initial;
}

/* ----------------------------------------------------------------- the card */

.nkall-deck__card {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-decoration: none;
    color: var(--deck-text);
    background: var(--deck-ink);
    border: 1px solid var(--deck-line);
    border-radius: var(--deck-radius);
    overflow: hidden;            /* without this the square art covers the radius */
    box-shadow: 0 6px 20px rgba(18, 19, 26, .16);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.nkall-deck__card:hover,
.nkall-deck__card:focus-visible {
    transform: translateY(-3px);
    border-color: var(--deck-accent);
    box-shadow: 0 14px 30px rgba(109, 59, 196, .32);
}

.nkall-deck__card:focus-visible {
    outline: 2px solid var(--deck-accent-2);
    outline-offset: 3px;
}

.nkall-deck__media {
    display: block;
    aspect-ratio: 1 / 1;         /* identical tiles whatever the source art */
    background: var(--deck-ink);
    overflow: hidden;
}

.nkall-deck__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .5s ease;
}

.nkall-deck__card:hover .nkall-deck__img {
    transform: scale(1.045);
}

.nkall-deck__body {
    display: flex;
    flex: 1 1 auto;              /* absorbs 2 lines vs 3 */
    flex-direction: column;
    gap: 5px;
    padding: 13px 14px 15px;
    text-align: center;
    background: linear-gradient(180deg, var(--deck-ink-soft) 0%, var(--deck-ink) 100%);
}

.nkall-deck__title {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--deck-text);
}

.nkall-deck__blurb {
    font-size: .86rem;
    line-height: 1.45;
    color: var(--deck-muted);
}

/* ---------------------------------------------------------------- the arrows
   Revealed by JS only when the track can actually scroll — an arrow that does
   nothing is worse than no arrow. Never shown on touch, where you just swipe. */

.nkall-deck__arrow {
    position: absolute;
    top: calc(50% - 34px);       /* sit on the artwork, not the text panel */
    transform: translateY(-50%);
    z-index: 3;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0 3px;
    font-size: 26px;
    line-height: 1;
    color: var(--deck-text);
    background: rgba(18, 19, 26, .82);
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 50%;
    cursor: pointer;
    backdrop-filter: blur(3px);
    transition: background .18s ease, border-color .18s ease, opacity .18s ease;
}

.nkall-deck__arrow:hover {
    background: var(--deck-accent);
    border-color: var(--deck-accent);
}

.nkall-deck__arrow:focus-visible {
    outline: 2px solid var(--deck-accent-2);
    outline-offset: 2px;
}

.nkall-deck__arrow[hidden] {
    display: none;
}

.nkall-deck__arrow--prev { left: -14px; }
.nkall-deck__arrow--next { right: -14px; }

@media (hover: none) {
    .nkall-deck__arrow { display: none !important; }
}

/* ------------------------------------------------------------------ the dots */

.nkall-deck__dots {
    display: flex;
    justify-content: center;
    gap: 7px;
    margin-top: 12px;
}

.nkall-deck__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #c9cbd6;
    transition: background .2s ease, transform .2s ease;
}

.nkall-deck__dot.is-active {
    background: var(--deck-accent);
    transform: scale(1.35);
}

.nkall-deck--desktop-grid .nkall-deck__dots { display: none; }

/* ============================================================ MOBILE: DECK ==
   One card centred, the next peeking, so the stack reads as a deck rather than
   a cut-off row. */

@media (max-width: 767px) {

    .nkall-deck {
        --deck-gap: 14px;
    }

    .nkall-deck--mobile-deck .nkall-deck__track.nkall-deck__track {
        scroll-padding-inline: 18px;
        padding-inline: 18px;
        margin-inline: -18px;               /* bleed to the screen edge */
    }

    .nkall-deck--mobile-deck .nkall-deck__item {
        flex: 0 0 78%;
        scroll-snap-align: center;
    }

    /* Cards either side sit back and dim; the centred one is full strength. */
    .nkall-deck--mobile-deck .nkall-deck__card {
        transform: scale(.955);
        opacity: .72;
        transition: transform .28s ease, opacity .28s ease, box-shadow .28s ease;
    }

    .nkall-deck--mobile-deck .nkall-deck__item.is-current .nkall-deck__card {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 12px 28px rgba(109, 59, 196, .30);
    }

    .nkall-deck--mobile-grid .nkall-deck__track,
    .nkall-deck--desktop-grid.nkall-deck--mobile-grid .nkall-deck__track {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
    }

    .nkall-deck--mobile-grid .nkall-deck__dots { display: none; }
}

/* Tablet: three fit comfortably whatever the desktop count is. */
@media (min-width: 768px) and (max-width: 1024px) {
    .nkall-deck { --deck-visible: 3; }
}

/* Respect the setting: no pan, no lift, no zoom. */
@media (prefers-reduced-motion: reduce) {
    .nkall-deck__track { scroll-behavior: auto; }
    .nkall-deck__card,
    .nkall-deck__img,
    .nkall-deck__dot { transition: none; }
    .nkall-deck__card:hover { transform: none; }
    .nkall-deck__card:hover .nkall-deck__img { transform: none; }
}
