/* =========================================================
   Shokamag – news homepage widgets
   Path: assets/css/widgets-news.css
   Only what Bootstrap 5.3 RTL does not provide. Uses logical
   properties (inset-inline-*, padding-inline ...) so it is RTL-safe.
   Mobile breakpoint = Bootstrap "lg" (992px).
   ========================================================= */

:root {
    --shn-accent: #7b1fa2;
    --shn-muted: #6b7280;
    --shn-line: #eceae6;
    --shn-placeholder: #e9e8e6;
    --shn-radius: 14px;

    /* Fallback ratio of the slider box. Normally the slider takes the ratio of its first
       image (the widget sets --shn-ratio inline); this is used only when no slide has an image. */
    --shn-slide-ratio: 16 / 9;
}

/* ---------- Shared ---------- */
/* Images keep their natural ratio: the width/height attributes WordPress prints reserve the
   space (no layout shift) and height:auto scales it. No fixed heights, no cropping. */
.shn-cover {
    display: block;
    width: 100%;
    height: auto;
}
/* only inside the slider is the image placed in a box (whose ratio = ratio of the first image) */
.shn-slide__media .shn-cover {
    height: 100%;
    object-fit: cover;
}
.shn-cat {
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.5;
    color: var(--shn-accent);
}
.shn-cat--light {
    color: #fff;
    opacity: .92;
}
.shn-meta {
    font-size: .75rem;
    line-height: 1.5;
    color: var(--shn-muted);
}
.shn-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 .75rem;
}
.shn-icon {
    color: #6001d2;
}

/* ---------- Sticky side columns (top value is set by news-home.js) ---------- */
.shn-sticky {
    position: sticky;
    top: 1rem;
}
.shn-sticky > .widget-item:last-child {
    margin-bottom: 0 !important;
}

/* =========================================================
   Hero slider
   ========================================================= */
.shn-hero {
    padding: 1rem 0;
}

.shn-slider {
    position: relative;
}

.shn-slider__track {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: var(--shn-radius);
}
.shn-slider__track::-webkit-scrollbar {
    display: none;
}
.shn-slider__track:focus-visible {
    outline: 2px solid var(--shn-accent);
    outline-offset: 2px;
}

/* desktop: snapping is done by news-home.js (buttons, mouse drag, trackpad) */
@media (min-width: 992px) {
    .shn-slider__track {
        scroll-snap-type: none;
    }
}
@media (hover: hover) and (pointer: fine) {
    .shn-slider__track {
        cursor: grab;
    }
}
.shn-slider__track.is-dragging {
    scroll-snap-type: none;
    cursor: grabbing;
    user-select: none;
}
.shn-slider__track.is-dragging a {
    pointer-events: none;
}

.shn-slide {
    display: grid;
    flex: 0 0 100%;
    aspect-ratio: var(--shn-ratio, var(--shn-slide-ratio));
    overflow: hidden;
    color: #fff;
    background: #2b2b2b;
    scroll-snap-align: center;
    scroll-snap-stop: always;
}
/* Image and caption share one grid cell (caption on top). Neither is positioned, so the
   stretched link (::after) is sized by .shn-slide itself and the WHOLE slide is clickable. */
.shn-slide__media,
.shn-slide__caption {
    grid-area: 1 / 1;
    min-width: 0;
    min-height: 0;
}

.shn-slide__caption {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: .35rem;
    padding: 1.25rem 1rem;
    padding-inline-end: 6rem; /* room for the arrows */
    background: linear-gradient(to top, rgba(0, 0, 0, .78) 0%, rgba(0, 0, 0, 0) 60%);
}
.shn-slide__title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shn-slider__counter {
    position: absolute;
    top: .75rem;
    inset-inline-end: .75rem;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .2rem .7rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, .5);
    color: #fff;
    font-size: .72rem;
}
.shn-slider__pause {
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: 0;
    background: none;
    color: #fff;
    line-height: 1;
}

.shn-slider__nav {
    position: absolute;
    inset-inline-end: 1rem;
    bottom: 1rem;
    z-index: 3;
    gap: .5rem;
}
.shn-slider__nav button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .4);
    color: #fff;
    transition: background-color .15s;
}
.shn-slider__nav button:hover {
    background: rgba(0, 0, 0, .65);
}
/* Bootstrap Icons chevrons point LTR; mirror them in RTL so "next" points to the next slide */
[dir="rtl"] .shn-slider__nav .bi {
    transform: scaleX(-1);
}

/* ---------- Small cards under the slider ---------- */
.shn-hero__cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.shn-hero {
    padding-inline: 1rem;
}

.shn-mini__media {
    margin-bottom: .5rem;
    overflow: hidden;
    border-radius: .5rem;
    background: var(--shn-placeholder);
}
.shn-mini__title {
    margin: 0 0 .25rem;
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.7;
}

/* =========================================================
   Feed
   ========================================================= */
.shn-feed__item {
    display: flex;
    gap: .9rem;
    padding-block: .8rem;
    border-bottom: 1px solid var(--shn-line);
}
.shn-feed__item:last-of-type {
    border-bottom: 0;
}

.shn-feed__media {
    flex: 0 0 clamp(120px, 38%, 250px);
    align-self: flex-start;
    overflow: hidden;
    border-radius: .4rem;
    background: var(--shn-placeholder);
}
.shn-feed__body {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    min-width: 0;
}
.shn-feed__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.7;
}
.shn-feed__excerpt {
    margin: 0;
    font-size: .85rem;
    line-height: 1.9;
    color: var(--shn-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =========================================================
   List (thumb / numbered / plain)
   ========================================================= */
.shn-list__title {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.shn-list__item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding-block: .6rem;
    border-bottom: 1px solid var(--shn-line);
}
.shn-list__item:last-child {
    border-bottom: 0;
}

.shn-list__thumb {
    flex: 0 0 64px;
    width: 64px;
    overflow: hidden;
    border-radius: .4rem;
    background: var(--shn-placeholder);
}
.shn-list__heading {
    margin: 0;
    font-size: .85rem;
    font-weight: 600;
    line-height: 1.8;
}
.shn-list--numbered .shn-list__heading,
.shn-list--plain .shn-list__heading {
    display: block;
}

.shn-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 1.15rem;
    height: 1.15rem;
    border: 1.5px solid currentColor;
    border-radius: .3rem;
    font-size: .65rem;
    font-weight: 700;
    line-height: 1;
}

/* =========================================================
   Ranked list ("Trending now": big first item + numbered titles)
   ========================================================= */
.shn-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 1.55rem;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: .4rem;
    background: #fbe3a0;
    color: #3b2f00;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1;
}

.shn-ranked__item {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding-block: .75rem;
    border-bottom: 1px solid var(--shn-line);
}
.shn-ranked__item:last-child {
    border-bottom: 0;
}

.shn-ranked__item--lead {
    display: block;
    padding-top: 0;
}

.shn-ranked__media {
    position: relative;
    margin-bottom: .6rem;
    overflow: hidden;
    border-radius: .9rem;
    background: var(--shn-placeholder);
}
.shn-ranked__media .shn-badge {
    position: absolute;
    top: .55rem;
    inset-inline-start: .55rem;
    z-index: 2;
    pointer-events: none;
}

.shn-ranked__title {
    margin: 0;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.8;
}
.shn-ranked__item--lead .shn-ranked__title {
    font-size: 1rem;
    font-weight: 700;
}

/* =========================================================
   Ad box
   ========================================================= */
.shn-ad {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.shn-ad__label {
    margin-bottom: .25rem;
    font-size: .7rem;
}

/* =========================================================
   Below Bootstrap "lg" (< 992px): side columns are already hidden
   by d-none d-lg-block in the template.
   ========================================================= */
@media (max-width: 991.98px) {

    .shn-hero {
        padding-inline: 0;
        padding-top: .75rem;
    }

    /* Swipeable strip: ~9% of the previous / next slide stays visible.
       Track padding is a % of the slider width; flex-basis 100% is a % of the
       track's CONTENT box (= 82% of the slider), so slide = 82% and peeks = 9% + 9%. */
    .shn-slider__track {
        gap: .5rem;
        padding-inline: 9%;
        border-radius: 0;
    }
    .shn-slide {
        border-radius: var(--shn-radius);
    }
    .shn-slide__caption {
        padding: 1rem .9rem;
    }
    .shn-slide__title {
        font-size: 1.05rem;
        -webkit-line-clamp: 2;
    }
    .shn-slider__counter {
        inset-inline-end: calc(9% + .75rem);
        top: .6rem;
    }

    /* cards: image beside the text */
    .shn-hero__cards {
        grid-template-columns: 1fr;
        gap: .9rem;
        padding-inline: 1rem;
    }
    .shn-mini {
        display: flex;
        gap: .75rem;
        align-items: flex-start;
    }
    .shn-mini__media {
        flex: 0 0 110px;
        margin: 0;
    }

    .shn-feed__media {
        flex-basis: 130px;
    }
    .shn-feed__title {
        font-size: 1rem;
    }
}

/* Tablet: three cards in a row again, image above text */
@media (min-width: 768px) and (max-width: 991.98px) {
    .shn-hero__cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .shn-mini {
        display: block;
    }
    .shn-mini__media {
        flex: none;
        margin-bottom: .5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shn-slider__nav button {
        transition: none;
    }
}
