/**
 * Mobile-first polish — load last after video-page.css.
 * Safe areas, fluid grids, touch-friendly spacing, no horizontal bleed.
 */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

img,
video,
iframe {
    max-width: 100%;
}

/* ——— Shell (.ui-nova) ——— */
/* --shell-pad-x: set in ui-shell.css (do not override to 0 here — mobile-theme loads last) */

.shell-header {
    padding-top: env(safe-area-inset-top, 0px);
}

/* Match desktop desi header: warm gradient + gold border (not flat grey bar) */
@media (max-width: 992px) {
    .shell-header.shell-header--desi {
        position: sticky;
        background: var(
            --header-surface,
            linear-gradient(105deg, rgba(69, 10, 10, 0.97) 0%, rgba(15, 10, 12, 0.96) 38%, rgba(12, 8, 14, 0.98) 100%)
        );
        border-bottom: 1px solid var(--header-border-glow, rgba(245, 158, 11, 0.22));
        box-shadow:
            0 4px 28px rgba(0, 0, 0, 0.5),
            inset 0 -1px 0 rgba(185, 28, 28, 0.14),
            inset 0 1px 0 rgba(255, 255, 255, 0.05);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        overflow: hidden;
    }

    .shell-header.shell-header--desi::before {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        background: radial-gradient(ellipse 95% 90% at 100% 0%, rgba(185, 28, 28, 0.22), transparent 52%),
            radial-gradient(ellipse 70% 60% at 0% 100%, rgba(245, 158, 11, 0.1), transparent 48%);
        z-index: 0;
    }

    .shell-header.shell-header--desi .shell-header__stack {
        position: relative;
        z-index: 1;
    }

    [data-theme="light"] .shell-header.shell-header--desi {
        box-shadow:
            0 4px 28px rgba(15, 23, 42, 0.08),
            inset 0 -1px 0 rgba(15, 23, 42, 0.06),
            inset 0 1px 0 rgba(255, 255, 255, 0.85);
    }

    [data-theme="light"] .shell-header.shell-header--desi::before {
        background: radial-gradient(ellipse 95% 90% at 100% 0%, rgba(59, 130, 246, 0.1), transparent 52%),
            radial-gradient(ellipse 70% 60% at 0% 100%, rgba(99, 102, 241, 0.06), transparent 48%);
    }
}

.shell-header__sub {
    padding-left: max(var(--shell-pad-x), env(safe-area-inset-left, 0px));
    padding-right: max(var(--shell-pad-x), env(safe-area-inset-right, 0px));
}

.shell-header__inner {
    padding-left: max(var(--shell-pad-x), env(safe-area-inset-left, 0px));
    padding-right: max(var(--shell-pad-x), env(safe-area-inset-right, 0px));
}

.shell-main {
    padding-left: max(var(--shell-pad-x), env(safe-area-inset-left, 0px));
    padding-right: max(var(--shell-pad-x), env(safe-area-inset-right, 0px));
}

.shell-footer {
    padding-left: max(var(--shell-pad-x), env(safe-area-inset-left, 0px));
    padding-right: max(var(--shell-pad-x), env(safe-area-inset-right, 0px));
}

.shell-chips {
    padding-left: max(var(--shell-pad-x), env(safe-area-inset-left, 0px));
    padding-right: max(var(--shell-pad-x), env(safe-area-inset-right, 0px));
}

@media (max-width: 992px) {
    .shell-bottom-nav {
        width: calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        max-width: min(420px, calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    }
}

@media (max-width: 380px) {
    .shell-brand {
        font-size: 1rem;
        gap: 6px;
    }

    .shell-hot-badge {
        display: none;
    }
}

/* ——— Legacy sidebar layout (public-layout) ——— */
@media (max-width: 992px) {
    .main-content {
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
        padding-top: max(80px, calc(60px + env(safe-area-inset-top, 0px) + 12px));
    }

    .mobile-header {
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(60px + env(safe-area-inset-top, 0px));
        align-items: center;
    }
}

/* ——— Listing grids (latest-home.css defines base; keep gap + columns in sync here — loads last) ——— */
.video-grid-v2 {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(0.85rem, 2.5vw, 1.5rem);
}

@media (min-width: 768px) {
    .video-grid-v2 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.latest-shell-v2 {
    padding: clamp(1rem, 4vw, 1.75rem);
    border-radius: clamp(14px, 4vw, 20px);
}

@media (max-width: 767px) {
    /*
     * Latest panel stays normal width (inside shell padding).
     * Only the thumbnail grid is flush to the panel’s left/right — no side gap beside cards.
     * Title row keeps the usual horizontal inset.
     */
    .latest-shell-v2 {
        padding-left: 0;
        padding-right: 0;
        padding-top: clamp(1rem, 4vw, 1.75rem);
        padding-bottom: clamp(1rem, 4vw, 1.75rem);
    }

    .latest-shell-v2 .section-header {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.6rem 0.75rem;
        padding-left: clamp(1rem, 4vw, 1.75rem);
        padding-right: clamp(1rem, 4vw, 1.75rem);
    }

    .latest-shell-v2 .section-header > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .latest-shell-v2 .section-header__meta {
        font-size: 0.7rem;
        line-height: 1.28;
        margin-top: 0.12rem;
        max-width: 100%;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .latest-shell-v2 .section-header__link {
        flex: 0 0 auto;
        align-self: center;
        max-width: min(10.5rem, 40%);
        padding: 0.32rem 0.62rem;
        font-size: 0.68rem;
        font-weight: 700;
        justify-content: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .latest-shell-v2 .section-header__link i {
        flex-shrink: 0;
        font-size: 0.65em;
    }

    .latest-shell-v2--stream .section-header__link {
        width: auto;
        max-width: min(10.5rem, 40%);
        justify-self: end;
    }
}

.latest-shell-v2--stream {
    padding: clamp(1rem, 4vw, 1.85rem) clamp(1rem, 4vw, 2.05rem);
}

.latest-shell-v2--stream .video-grid-v2--stream {
    padding: clamp(0.75rem, 3vw, 1.35rem);
}

.video-grid-v2--stream {
    gap: clamp(0.85rem, 2.5vw, 1.4rem);
}

/* Trending card widths: <768px = full-bleed in trending-home.css */
@media (min-width: 768px) {
    .trending-item-v2 {
        min-width: min(16.75rem, calc(100vw - 2.75rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
        width: min(16.75rem, calc(100vw - 2.75rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    }

    .trending-item-v2--top {
        min-width: min(18.5rem, calc(100vw - 2.75rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
        width: min(18.5rem, calc(100vw - 2.75rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    }
}

@media (min-width: 900px) {
    .trending-item-v2--top {
        min-width: min(20rem, calc(100vw - 3.5rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
        width: min(20rem, calc(100vw - 3.5rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
    }
}

.trending-panel {
    padding: clamp(1rem, 4vw, 1.75rem);
    border-radius: clamp(14px, 4vw, 20px);
}

/* ——— Hero + sections (theme-v2 / components) ——— */
.hero-spotlight {
    padding: clamp(1.25rem, 5vw, 3.25rem);
    margin-bottom: clamp(1.25rem, 4vw, 2rem);
}

.section-header {
    gap: 0.75rem;
}

@media (max-width: 520px) {
    .section-header__link {
        white-space: normal;
    }
}

/* ——— Video watch page ——— */
.ui-video .video-related-scroll,
.ui-video .watch-video-static-grid--episodes {
    scroll-padding-inline: 12px;
}

.ui-video .video-series-strip__scroll .video-card-premium {
    flex: 0 0 clamp(168px, 72vw, 240px);
    max-width: 260px;
}

@media (max-width: 560px) {
    .ui-video .video-main-info.watch-main-info {
        padding: 1rem 1.1rem;
    }

    .ui-video .glass-card.watch-panel {
        padding: 1rem 1.1rem;
    }

    .ui-video .watch-breadcrumb {
        /* Keep breadcrumb (home + current title) in one line on small mobiles */
        flex-wrap: nowrap;
        white-space: nowrap;
        row-gap: 0;
        font-size: 12px;
    }

    .ui-video .watch-breadcrumb span {
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ——— Modals ——— */
@media (max-width: 480px) {
    .shell-modal,
    .modal-content {
        width: calc(100% - 1.25rem);
        max-width: none;
        max-height: min(88dvh, 88vh);
        margin: 0 env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
    }

    .shell-modal__body,
    .modal-body {
        padding: 1rem;
    }
}

/* ——— Pagination ——— */
.pagination-v2 {
    gap: 0.35rem;
    margin-top: 1.75rem;
}

.pagination-v2 a {
    min-width: 2.35rem;
    height: 2.35rem;
    font-size: 0.8125rem;
}

/* ——— Cards: slightly gentler hover on coarse pointers ——— */
@media (hover: none) {
    .video-card-premium:hover,
    .trending-card-v2:hover,
    .video-grid-v2--stream .video-card-premium:hover {
        transform: none;
    }

    .video-card-premium:hover .video-card-premium__thumb img,
    .trending-card-v2:hover img {
        transform: none;
    }
}
