/* ============================================================
   Mobile UI/UX Improvements — all pages
   Applied globally at ≤ 768px
   ============================================================ */

@media (max-width: 768px) {

    /* ── 1. GLOBAL ─────────────────────────────────────── */

    body {
        font-size: var(--font-size-xl);
        background: var(--color-bg-page);
    }

    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Contain any rogue absolutely-positioned elements */
    header, footer, #dt_contenedor, #contenedor, .content, .content-left {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Remove bg.jpg repeat on mobile — cleaner solid bg */
    #dt_contenedor,
    #contenedor {
        background: var(--color-bg-page);
    }

    /* White cards on gray page */
    .block-tab,
    .content-left .block {
        background: var(--color-white);
        border-radius: 0;
        margin-bottom: 8px;
    }

    /* ── 2. FOOTER ──────────────────────────────────────── */

    footer {
        padding: 20px 16px 24px;
        text-align: center;
    }

    footer .container {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        overflow: visible;
    }

    footer ul {
        justify-content: center;
        gap: 8px 12px;
        flex-wrap: wrap;
        max-width: 100%;
    }

    footer ul li a {
        font-size: 12.5px;
        white-space: nowrap;
    }

    footer .copyright-text {
        font-size: var(--font-size-md);
        text-align: center;
        width: 100%;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    /* ── 3. TAB PILLS (block-tab) ───────────────────────── */

    .block-tab > ul.tab {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0;
        border-bottom: 2px solid var(--color-hover);
        padding: 0 8px;
        background: var(--color-white);
    }

    .block-tab > ul.tab::-webkit-scrollbar {
        display: none;
    }

    .block-tab > ul.tab li {
        flex: 0 0 auto;
        padding: 11px 18px;
        font-size: var(--font-size-lg);
        font-weight: var(--font-weight-semibold);
        color: #888;
        cursor: pointer;
        border-bottom: 3px solid transparent;
        margin-bottom: -2px;
        white-space: nowrap;
        list-style: none;
        background: none;
    }

    .block-tab > ul.tab li.selected,
    .block-tab > ul.tab li.Recently,
    .block-tab > ul.tab li:hover {
        color: var(--color-primary, #3ec2cf);
        border-bottom-color: var(--color-primary, #3ec2cf);
    }

    .block-tab .tab-container {
        padding: 8px;
    }

    /* ── 4. EPISODE / MOVIE GRID CARDS ─────────────────── */

    .list-episode-item {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 4px 0 8px;
        width: 100%;
        font-size: initial;
    }

    .list-episode-item li {
        position: relative;
        display: block;
        width: auto; /* grid controls width */
        padding-top: 0; /* aspect-ratio: 2/3 set in base handles height */
        border-radius: var(--radius-lg); /* minimal per design */
        overflow: hidden;
        background: var(--color-card-bg);
    }

    /* Stronger gradient for small-screen readability */
    .list-episode-item li:before {
        height: 80px;
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.92) 0%,
            rgba(0, 0, 0, 0.55) 50%,
            transparent 100%
        );
    }

    .list-episode-item li .title {
        font-size: var(--font-size-md);
        font-weight: var(--font-weight-semibold);
        bottom: 22px;
        left: 8px;
        width: calc(100% - 52px);
        line-height: 1.35;
        max-height: 34px;
        -webkit-line-clamp: 2;
        text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    }

    .list-episode-item li .time {
        font-size: var(--font-size-sm);
        bottom: 8px;
        left: 8px;
        width: calc(100% - 52px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        opacity: 0.85;
    }

    .list-episode-item li .ep {
        font-size: var(--font-size-sm);
        width: 38px;
        right: -6px;
        bottom: 8px;
    }

    /* Type badge (MOVIE / SUB) */
    .list-episode-item .type,
    .list-episode-item li .type {
        display: block;
        position: absolute;
        top: 7px;
        left: 7px;
        z-index: 5;
        font-size: var(--font-size-sm);
        font-weight: var(--font-weight-bold);
        padding: 2px 6px;
        border-radius: var(--radius-md);
        text-transform: uppercase;
        color: var(--color-white);
        letter-spacing: 0.5px;
    }

    .list-episode-item .type.SUB,
    .list-episode-item .type.sub {
        background: var(--color-primary, #3ec2cf);
    }

    .list-episode-item .type.MOVIE,
    .list-episode-item .type.movie {
        background: var(--color-secondary, #fdb813);
        color: var(--color-text-dark);
    }

    /* ── 5. COMPACT LIST CARDS (.list-item) ────────────── */

    .list-item {
        column-count: 1;
    }

    .list-item li {
        padding: 10px 8px;
        border-bottom: 1px solid var(--color-bg-gray);
        align-items: center;
    }

    .list-item li:last-child {
        border-bottom: none;
    }

    .list-item li .img {
        border-radius: var(--radius-lg);
        overflow: hidden;
        flex-shrink: 0;
    }

    .list-item li .txt h3 {
        font-size: var(--font-size-lg);
        font-weight: var(--font-weight-semibold);
        color: var(--color-text-dark);
        line-height: 1.35;
    }

    .list-item li .txt h3 a {
        color: var(--color-text-dark);
    }

    .list-item li .ep-latest {
        font-size: var(--font-size-base);
        color: var(--color-primary, #3ec2cf);
        margin-top: 4px;
    }

    /* ── 6. ARCHIVE PAGE HEADING ────────────────────────── */

    .heading-archive {
        font-size: var(--font-size-4xl);
        font-weight: var(--font-weight-bold);
        color: var(--color-text-dark);
        padding: 14px 12px 10px;
        margin-bottom: 0 !important;
        border-bottom: 2px solid var(--color-primary, #3ec2cf);
    }

    /* ── 7. VIEW MORE BUTTON ────────────────────────────── */

    .view-more {
        text-align: center;
        padding: 14px 0 6px;
    }

    .view-more a {
        display: inline-block;
        padding: 9px 28px;
        border: 1.5px solid var(--color-primary, #3ec2cf);
        border-radius: 24px;
        color: var(--color-primary, #3ec2cf);
        font-size: var(--font-size-lg);
        font-weight: var(--font-weight-semibold);
        background: transparent;
    }

    /* ── 8. PAGINATION ──────────────────────────────────── */

    .pagination {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
        padding: 16px 0 8px;
        margin-top: 8px;
    }

    .pagination li {
        border-radius: var(--radius-lg);
        border: 1px solid var(--color-border-light);
        border-right: 1px solid var(--color-border-light);
        overflow: hidden;
    }

    .pagination li a {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 38px;
        height: 38px;
        padding: 0 10px;
        font-size: var(--font-size-xl);
        font-weight: var(--font-weight-medium);
    }

    /* ── 9. TV SHOW SINGLE — fix poster gap ─────────────── */

    .content-left .details .img {
        height: auto !important;
        float: none;
        min-height: 0;
    }

    .content-left .details .img img {
        position: static !important;
        width: 100%;
        height: auto !important;
        min-height: 0 !important;
        object-fit: cover;
    }

    /* ── 10. MOVIE SINGLE — server list, watch text ─────── */

    body.single-movies .natural-watch-info {
        padding: 12px 12px;
        margin-bottom: 10px;
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
    }

    body.single-movies .natural-watch-info p {
        font-size: var(--font-size-lg);
        line-height: 1.65;
        word-break: break-word;
        overflow-wrap: anywhere;
        white-space: normal;
    }

    body.single-movies .muti_link {
        padding: 0;
    }

    body.single-movies .muti_link ul {
        list-style: none;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    body.single-movies .muti_link li {
        display: flex;
        align-items: center;
        padding: 12px 14px;
        background: var(--color-bg-gray-lighter);
        border: 1px solid #e8eaed;
        border-radius: 8px;
        font-size: var(--font-size-lg);
        font-weight: var(--font-weight-semibold);
        color: #333;
        cursor: pointer;
    }

    body.single-movies .muti_link li.selected,
    body.single-movies .muti_link li.video-server.selected {
        background: var(--color-primary, #3ec2cf);
        color: var(--color-white);
        border-color: var(--color-primary, #3ec2cf);
    }

    body.single-movies .muti_link li span {
        margin-left: auto;
        font-size: var(--font-size-base);
        font-weight: var(--font-weight-normal);
        opacity: 0.65;
    }

    body.single-movies .movie-server-hint {
        font-size: var(--font-size-lg);
        padding: 10px 0;
        margin: 8px 0;
    }

    /* ── 11. ACTION BAR (plugins/switch off light) ─────── */

    .plugins {
        padding: 6px 0;
    }

    .plugins ul {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        list-style: none;
        padding: 0;
    }

    .plugins ul li {
        padding: 7px 12px;
        background: var(--color-border-section);
        border-radius: var(--radius-xl);
        font-size: var(--font-size-md);
        font-weight: var(--font-weight-medium);
        color: #444;
    }

    .plugins ul li.off_light a,
    .plugins ul li a {
        color: #444;
    }

    /* ── 12. SWITCH VIEW TOGGLE — hide on mobile ─────────  */

    .switch-view {
        display: none !important;
    }

    /* ── 13. SEARCH / ARCHIVE HEADINGS ─────────────────────  */

    .block-tab h1,
    .content-left .block-tab h1 {
        font-size: var(--font-size-2xl);
        font-weight: var(--font-weight-bold);
        color: var(--color-text-dark);
        padding: 12px 12px 10px;
        border-bottom: 2px solid var(--color-primary, #3ec2cf);
        margin-bottom: 4px;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Type-list / taxonomy description text */
    .term-description,
    .term-description p {
        font-size: var(--font-size-lg);
        color: #555;
        padding: 6px 0 10px;
        line-height: 1.55;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* ── 14. HOME — recently tabs section spacing ────────── */

    .content-left > .block-tab:first-child {
        margin-top: 0;
    }

    /* ── 15. BLOCK CARD SECTIONS — overall spacing ───────── */

    .content-left .block-tab,
    .content-left > .block {
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }

    /* Content-left full bleed white sections */
    .content,
    .content-left {
        background: transparent;
    }

    /* ── 16. TV SHOW DETAILS — info text wrap ────────────── */

    .content-left .details .info p {
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .content-left .details .info h1 {
        font-size: var(--font-size-5xl);
        line-height: 1.3;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    /* ── 17. EPISODE / MOVIE WATCH TITLE — compact on mobile ── */

    /* Main h1 title */
    .info-drama .name h1,
    .info-drama h1,
    .watch .title {
        font-size: var(--font-size-2xl);
        font-weight: var(--font-weight-bold);
        line-height: 1.35;
        margin: 0 0 6px;
        padding: 0;
        /* Clamp to 2 lines — keeps it compact */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        border-bottom: none;
    }

    /* "SHOW: …" breadcrumb row */
    .info-drama .category {
        font-size: var(--font-size-md);
        margin: 0 0 8px;
        padding: 0;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 3px;
        white-space: normal;
        overflow: visible;
    }

    .info-drama .category span {
        font-size: var(--font-size-base);
        font-weight: var(--font-weight-semibold);
        text-transform: uppercase;
        color: #888;
    }

    .info-drama .category a {
        font-size: var(--font-size-md);
    }

    .info-drama .category .sep {
        color: var(--color-text-lighter);
        margin: 0 2px;
    }

    /* Overall info-drama block — tight on mobile */
    .info-drama {
        margin-bottom: 6px;
        padding: 10px 8px 8px;
        border-bottom: 1px solid var(--color-hover);
    }
}

/* Extra small: ≤ 480px */
@media (max-width: 480px) {

    /* Slightly tighter gap on very small screens */
    .list-episode-item {
        gap: 6px;
    }

    .list-episode-item li {
        border-radius: var(--radius-lg);
    }

    /* Footer links break into two columns */
    footer ul {
        gap: 8px 14px;
    }
}

/* ══════════════════════════════════════════════════════════
   RECOMMENDATION HUB — portrait poster grid (ALL viewports)
   Matches the homepage card style: portrait 2:3 ratio,
   gradient overlay, title + year at bottom, MOVIE badge.
   ══════════════════════════════════════════════════════════ */

.recommendation-hub .list-episode-item {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 10px 12px 12px;
}

.recommendation-hub .list-episode-item li {
    width: auto;
    padding-top: 0;
    aspect-ratio: 2 / 3;
    position: relative;
    border-radius: var(--radius-lg); /* minimal */
    background: var(--color-card-bg);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: transform var(--transition-fast) ease, box-shadow var(--transition-fast) ease;
}

.recommendation-hub .list-episode-item li:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

/* Stronger gradient for portrait cards */
.recommendation-hub .list-episode-item li::before {
    height: 90px;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.92) 0%,
        rgba(0, 0, 0, 0.55) 50%,
        transparent 100%
    );
}

/* Title */
.recommendation-hub .list-episode-item li .title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    bottom: 24px;
    left: 8px;
    width: calc(100% - 16px);
    line-height: 1.35;
    max-height: 36px;
    -webkit-line-clamp: 2;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* Year / status line */
.recommendation-hub .list-episode-item li .time {
    font-size: var(--font-size-sm);
    bottom: 8px;
    left: 8px;
    width: calc(100% - 16px);
    opacity: 0.85;
}

/* MOVIE badge */
.recommendation-hub .list-episode-item .type {
    display: block;
    position: absolute;
    top: 7px;
    left: 7px;
    z-index: 5;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    padding: 2px 6px;
    border-radius: var(--radius-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--color-secondary, #fdb813);
    color: var(--color-text-dark);
}

/* Mobile: 2-column portrait grid (same ratio, tighter gap) */
@media (max-width: 768px) {
    .recommendation-hub .list-episode-item {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
    }

    .recommendation-hub .list-episode-item li {
        padding-top: 0;
        aspect-ratio: 2 / 3;
        border-radius: var(--radius-lg);
    }

    .recommendation-hub .list-episode-item li .title {
        font-size: var(--font-size-base);
        bottom: 22px;
        left: 7px;
        width: calc(100% - 14px);
    }

    .recommendation-hub .list-episode-item li .time {
        bottom: 7px;
        left: 7px;
    }
}
