/*
 * Homepage card rails.
 *
 * PHP emits Splide's final track/list/slide tree. Until Splide initializes,
 * that same tree is a native horizontal scroller with identical card widths,
 * 16px gaps and 20px edge breathing room. This keeps the layout stable and
 * usable if JavaScript or the CDN dependency is unavailable.
 */
.mz-splide-carousel {
    --mz-rail-fade-width: 40px;
    --mz-rail-card-width: 160px;
    position: relative;
    visibility: visible;
    direction: rtl;
}

.mz-splide-carousel.mz-wide-card-carousel {
    --mz-rail-card-width: 200px;
}

.mz-splide-carousel .splide__track {
    touch-action: pan-y pinch-zoom;
}

.mz-splide-carousel:not(.is-initialized) .splide__track {
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.mz-splide-carousel:not(.is-initialized) .splide__track::-webkit-scrollbar {
    display: none;
}

.mz-splide-carousel:not(.is-initialized) .splide__list {
    box-sizing: border-box;
    width: max-content;
    min-width: 100%;
    height: auto;
    gap: 16px;
    padding-inline: 20px !important;
    transform: none !important;
}

/* CSS is the single owner of card dimensions; Splide only owns movement. */
.mz-splide-carousel .splide__slide {
    width: auto;
    height: auto;
    flex-shrink: 0;
}

/* Splide's core stylesheet uses backface hiding as a generic 3D safeguard.
 * These rails translate only in 2D, so that declaration needlessly retains a
 * layer for every list and card. The rules below promote each moving list,
 * with desktop pointer devices retaining it between gestures. */
.mz-splide-carousel .splide__list,
.mz-splide-carousel .splide__slide {
    -webkit-backface-visibility: visible;
    backface-visibility: visible;
}

/* Keep the initial GPU surface close to the viewport instead of rasterizing
 * every card in a long transformed list. The head bootstrap is fail-open, and
 * the carousel clears the class after initialization. */
html.mz-carousel-window-pending .mz-splide-carousel:not(.is-mz-visibility-fallback) .splide__slide:nth-child(n + 11) {
    visibility: hidden !important;
}

html.mz-carousel-window-pending .mz-splide-carousel.is-mz-visibility-fallback .splide__slide {
    visibility: visible !important;
}

/* style.css historically promoted every native rail to a compositor layer.
 * Splide moves only its inner list, so the root must remain an ordinary layer. */
.carousel-draggable {
    will-change: auto;
}

/* Card rails are gesture surfaces, not selectable reading content. Apply this
 * before initialization so a slow mobile load cannot begin a native selection. */
.carousel-draggable,
.carousel-draggable *,
.mz-splide-carousel,
.mz-splide-carousel * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.carousel-draggable,
.mz-splide-carousel {
    touch-action: pan-y pinch-zoom;
}

.carousel-draggable a,
.carousel-draggable img,
.mz-splide-carousel a,
.mz-splide-carousel img {
    -webkit-user-drag: none;
    user-drag: none;
}

/* Splide's fixedWidth option reads the same responsive value through
 * --mz-rail-card-width. These rules also preserve the exact native fallback. */
.mz-splide-carousel .splide__slide[class~="w-[160px]"] {
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    flex: 0 0 160px !important;
}

.mz-splide-carousel .splide__slide[class~="min-w-[200px]"] {
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    flex: 0 0 200px !important;
}

/* A desktop mouse/pointer gets the larger cards. Touch devices retain the
 * compact card size even when they expose a tablet-sized viewport. */
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
    .mz-splide-carousel:not(.mz-wide-card-carousel) {
        --mz-rail-card-width: 190px;
    }

    .mz-splide-carousel .splide__slide[class~="md:w-[190px]"] {
        width: 190px !important;
        min-width: 190px !important;
        max-width: 190px !important;
        flex-basis: 190px !important;
    }
}

/* The market card appends a price ticket below the common manga card. Keep its
 * width locked in both the native fallback and enhanced states. */
.mz-market-carousel .splide__slide {
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    flex: 0 0 160px !important;
}

@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
    .mz-market-carousel .splide__slide {
        width: 190px !important;
        min-width: 190px !important;
        max-width: 190px !important;
        flex-basis: 190px !important;
    }
}

/* Keep the cover's rounded silhouette without clipping the whole painted
 * subtree as one GPU surface. The children occupy the cover's inner border
 * box, so their radius is exactly the outer 12/16px radius minus its 1px
 * border. Geometry, colour, shadow and hit targets remain unchanged. */
.mz-splide-carousel:not(.mz-market-carousel) .splide__slide .aspect-\[2\/3\] {
    overflow: visible !important;
}

.mz-splide-carousel:not(.mz-market-carousel) .splide__slide .aspect-\[2\/3\] > img,
.mz-splide-carousel:not(.mz-market-carousel) .splide__slide .aspect-\[2\/3\] > .w-full.h-full,
.mz-splide-carousel:not(.mz-market-carousel) .splide__slide .aspect-\[2\/3\] > .absolute.inset-0 {
    border-radius: 11px !important;
}

@media (min-width: 768px) {
    .mz-splide-carousel:not(.mz-market-carousel) .splide__slide .aspect-\[2\/3\] > img,
    .mz-splide-carousel:not(.mz-market-carousel) .splide__slide .aspect-\[2\/3\] > .w-full.h-full,
    .mz-splide-carousel:not(.mz-market-carousel) .splide__slide .aspect-\[2\/3\] > .absolute.inset-0 {
        border-radius: 15px !important;
    }
}

/* ---- Lightweight card chrome -----------------------------------------
 * backdrop-filter samples and blurs the moving cover behind every chip. A
 * viewport containing two rails can therefore create dozens of live backdrop
 * surfaces. These near-opaque layered gradients retain the dark glass visual,
 * contrast and fine highlight without any backdrop readback while moving. */
.mz-splide-carousel .mz-card-chip,
.mz-splide-carousel .backdrop-blur-md {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

.mz-splide-carousel .mz-card-chip {
    border-color: rgba(255, 255, 255, 0.12) !important;
    background: linear-gradient(145deg, rgba(29, 29, 35, 0.97), rgba(8, 8, 11, 0.96)) !important;
    box-shadow:
        0 3px 9px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.07) !important;
}

/* The desktop status pill is the only backdrop-blur-md element in a card. */
.mz-splide-carousel .backdrop-blur-md {
    border-color: rgba(255, 255, 255, 0.14) !important;
    background: linear-gradient(145deg, rgba(27, 27, 33, 0.97), rgba(7, 7, 10, 0.96)) !important;
    box-shadow:
        0 4px 11px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.07) !important;
}

/* Keep depth, but collapse the compiled multi-shadow card treatment to one
 * restrained shadow that rasterizes cheaply. Type colours remain unchanged. */
.mz-splide-carousel .shadow-black\/50 {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3) !important;
}

.mz-splide-carousel .manga-type-badge {
    top: -3px !important;
    opacity: 1 !important;
    text-shadow: none !important;
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.13) !important;
}

.mz-splide-carousel .drop-shadow-lg {
    filter: none !important;
}

/* A stationary pointer used to activate several hover transitions on every
 * card passing beneath it. During movement, make the active rail a single
 * compositor job; hover interaction returns as soon as snapping completes. */
.mz-splide-carousel.is-mz-moving .splide__list {
    will-change: transform;
}

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
    /* Reuse desktop card rasterization through successive drag gestures. */
    .mz-splide-carousel.is-initialized .splide__list {
        will-change: transform;
    }
}

/* While moving, an unpainted shield over the track takes every hit test, so
 * no card is hovered or clicked mid-swipe (Splide still receives the events
 * through the track). This replaces `.group { pointer-events: none }`, which
 * is inherited and therefore restyled every card descendant on each toggle. */
.mz-splide-carousel.is-initialized > .splide__track::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.mz-splide-carousel.is-mz-moving > .splide__track::after {
    pointer-events: auto;
}

/* Only these card parts declare transitions (the type badge, the market
 * ticket and its price; no card part animates). Naming them, instead of every
 * descendant via `.group *`, keeps the moving-class toggle from restyling the
 * whole rail (~900 elements) at the start and end of every swipe. Add a hook
 * here if a card part gains a transition. */
.mz-splide-carousel.is-mz-moving .mz-carousel-more__cover,
.mz-splide-carousel.is-mz-moving .group,
.mz-splide-carousel.is-mz-moving .manga-type-badge,
.mz-splide-carousel.is-mz-moving .transition,
.mz-splide-carousel.is-mz-moving .transition-all,
.mz-splide-carousel.is-mz-moving .transition-colors,
.mz-splide-carousel.is-mz-moving .transition-opacity,
.mz-splide-carousel.is-mz-moving .transition-transform,
.mz-splide-carousel.is-mz-moving .transition-shadow {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    animation: none !important;
}

@media (hover: hover) {
    .mz-splide-carousel.is-initialized.is-mz-overflow {
        cursor: grab;
    }

    .mz-splide-carousel.is-initialized.is-mz-overflow:active {
        cursor: grabbing;
    }
}

/* ---- Edge fades -------------------------------------------------------
 * A rail that continues past an edge should say so. These overlays change
 * only opacity and never mask the moving list, avoiding re-rasterization while
 * cards move underneath them. Each section supplies --mz-rail-fade so the
 * opaque outside pixel exactly matches its background. */
.mz-splide-carousel::before,
.mz-splide-carousel::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: var(--mz-rail-fade-width);
    z-index: 30;
    pointer-events: none;
    background: var(--mz-rail-fade, #080808);
    opacity: 0;
    transition: opacity 0.28s ease;
}

.mz-splide-carousel::before {
    left: 0;
    -webkit-mask-image: linear-gradient(to right, #fff, transparent);
    mask-image: linear-gradient(to right, #fff, transparent);
}

.mz-splide-carousel::after {
    right: 0;
    -webkit-mask-image: linear-gradient(to left, #fff, transparent);
    mask-image: linear-gradient(to left, #fff, transparent);
}

.mz-splide-carousel.is-fade-left::before,
.mz-splide-carousel.is-fade-right::after {
    opacity: 1;
}

@media (max-width: 767px) {
    .mz-splide-carousel {
        --mz-rail-fade-width: 18px;
    }
}

/* A restrained archive link with the same footprint as the title cards. */
.mz-carousel-more {
    box-sizing: border-box;
    display: block;
    width: 100%;
    padding-bottom: 40px;
    color: #c7c7cc;
    text-decoration: none;
}

.mz-carousel-more__cover {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    aspect-ratio: 2 / 3;
    padding: 16px 12px;
    border: 1px solid rgba(255, 255, 255, 0.045);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    text-align: center;
    transition: background-color 0.18s ease, border-color 0.18s ease;
}

.mz-carousel-more__symbol {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    margin-bottom: 2px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.045);
}

.mz-carousel-more__symbol svg {
    width: 18px;
    height: 18px;
}

.mz-carousel-more__heading {
    color: #dedee3;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.6;
}

.mz-carousel-more__description {
    margin-top: -6px;
    color: #8e8e93;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.65;
}

@media (hover: hover) {
    .mz-carousel-more:hover .mz-carousel-more__cover {
        border-color: rgba(255, 255, 255, 0.09);
        background-color: rgba(255, 255, 255, 0.04);
    }
}

.mz-carousel-more:focus-visible {
    outline: none;
}

.mz-carousel-more:focus-visible .mz-carousel-more__cover {
    outline: 2px solid #9cbbea;
    outline-offset: -4px;
}

@media (min-width: 768px) {
    .mz-carousel-more__cover {
        border-radius: 16px;
    }
}

@media (max-width: 767.98px) {
    .mz-carousel-more__cover {
        gap: 10px;
        padding: 10px;
    }

    .mz-carousel-more__symbol {
        width: 36px;
        height: 36px;
    }

    .mz-carousel-more__symbol svg {
        width: 16px;
        height: 16px;
    }

    .mz-carousel-more__heading {
        font-size: 13px;
        line-height: 1.55;
    }

    .mz-carousel-more__description {
        font-size: 10px;
        line-height: 1.6;
    }

}

@media (prefers-reduced-motion: reduce) {
    .mz-carousel-more__cover {
        transition: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mz-splide-carousel::before,
    .mz-splide-carousel::after {
        transition: none;
    }
}

/* On phones, let the standard portrait rails show about two-and-a-half cards.
 * The real fixed width changes (rather than visually scaling the card), so the
 * 2:3 cover ratio, hit target, clipping and Splide snap geometry stay aligned.
 * Reading and market rails keep their purpose-built sizes. */
@media (max-width: 767.98px) {
    .mz-splide-carousel:not(.mz-wide-card-carousel):not(.mz-market-carousel) {
        --mz-rail-card-width: clamp(120px, 32vw, 136px);
    }

    .mz-splide-carousel:not(.mz-wide-card-carousel):not(.mz-market-carousel)
        .splide__slide[class~="w-[160px]"] {
        width: var(--mz-rail-card-width) !important;
        min-width: var(--mz-rail-card-width) !important;
        max-width: var(--mz-rail-card-width) !important;
        flex-basis: var(--mz-rail-card-width) !important;
    }
}
