/* Mobile-app layout for MyVdo user portal */

:root {
    --mobile-tab-h: 64px;
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-chrome-bottom: calc(var(--mobile-tab-h) + var(--mobile-safe-bottom));
}

/* Hidden on desktop */
.mobile-tab-bar,
.mobile-drawer,
.mobile-drawer-overlay,
.mobile-search-sheet {
    display: none;
}

/* ========== MOBILE (≤768px) ========== */
@media (max-width: 768px) {
    :root {
        --stream-nav-h: 56px;
    }

    .streaming-app {
        padding-bottom: var(--mobile-chrome-bottom);
        -webkit-tap-highlight-color: transparent;
    }

    /* Top bar — compact app header */
    .stream-nav {
        height: 56px;
        background: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .stream-nav-inner {
        gap: 12px;
        padding: 0 16px;
    }

    .stream-nav .brand-logo,
    .stream-nav .brand-logo-img {
        font-size: 1.25rem;
        max-height: 32px;
    }

    .stream-nav-desktop {
        display: none !important;
    }

    .stream-nav-actions {
        margin-left: auto;
        gap: 4px;
    }

    .stream-icon-btn {
        display: flex;
    }

    /* Bottom tab bar */
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 300;
        height: var(--mobile-tab-h);
        padding-bottom: var(--mobile-safe-bottom);
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-top: 1px solid var(--brand-border);
        box-shadow: 0 -4px 24px rgba(31, 33, 36, 0.08);
    }

    .mobile-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 4px;
        border: none;
        background: none;
        color: var(--brand-text-muted);
        font-family: var(--stream-font);
        font-size: 0.65rem;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
        transition: color 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-tab-icon {
        font-size: 1.35rem;
        line-height: 1;
    }

    .mobile-tab.active {
        color: var(--brand-teal);
    }

    .mobile-tab.active .mobile-tab-icon {
        transform: scale(1.05);
    }

    /* Search sheet */
    .mobile-search-sheet {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 400;
        background: var(--brand-surface);
        border-bottom: 1px solid var(--brand-border);
        box-shadow: 0 8px 32px rgba(31, 33, 36, 0.12);
        transform: translateY(-110%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding-top: env(safe-area-inset-top, 0px);
    }

    .mobile-search-sheet.open {
        transform: translateY(0);
    }

    .mobile-search-sheet-inner {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 16px;
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
    }

    .mobile-search-form {
        flex: 1;
        display: flex;
        gap: 8px;
        align-items: center;
    }

    .mobile-search-form input[type="search"] {
        flex: 1;
        padding: 12px 16px;
        border: 1px solid var(--brand-border);
        border-radius: 12px;
        font-size: 1rem;
        background: var(--brand-white);
        color: var(--brand-text);
        outline: none;
        -webkit-appearance: none;
    }

    .mobile-search-form input[type="search"]:focus {
        border-color: var(--brand-teal);
        box-shadow: 0 0 0 3px var(--brand-teal-light);
    }

    .mobile-search-form .btn {
        flex-shrink: 0;
        border-radius: 12px;
        padding: 12px 16px;
    }

    .mobile-sheet-close {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border: none;
        border-radius: 50%;
        background: var(--brand-bg);
        color: var(--brand-charcoal);
        font-size: 1.1rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Drawer */
    .mobile-drawer-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 450;
        background: rgba(31, 33, 36, 0.45);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
    }

    .mobile-drawer-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    .mobile-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 500;
        width: min(300px, 85vw);
        background: var(--brand-surface);
        box-shadow: -8px 0 32px rgba(31, 33, 36, 0.15);
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding-top: env(safe-area-inset-top, 0px);
    }

    .mobile-drawer.open {
        transform: translateX(0);
    }

    .mobile-drawer-header {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 24px 20px;
        border-bottom: 1px solid var(--brand-border);
        background: linear-gradient(135deg, var(--brand-teal-light) 0%, var(--brand-surface) 100%);
    }

    .mobile-drawer-header strong {
        display: block;
        font-size: 1rem;
        color: var(--brand-charcoal);
        margin-bottom: 2px;
    }

    .mobile-drawer-header span {
        font-size: 0.8rem;
        color: var(--brand-text-muted);
        word-break: break-all;
    }

    .mobile-drawer-header .mobile-sheet-close {
        margin-left: auto;
    }

    .mobile-user-avatar {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: var(--brand-teal);
        color: #fff;
        font-size: 1.25rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .mobile-drawer-nav {
        display: flex;
        flex-direction: column;
        padding: 12px 0;
        flex: 1;
    }

    .mobile-drawer-nav a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 24px;
        font-size: 1rem;
        font-weight: 500;
        color: var(--brand-charcoal);
        text-decoration: none;
        transition: background 0.2s;
    }

    .mobile-drawer-nav a:hover,
    .mobile-drawer-nav a.active {
        background: var(--brand-teal-light);
        color: var(--brand-teal-dark);
    }

    .mobile-drawer-logout {
        margin-top: auto;
        border-top: 1px solid var(--brand-border);
        color: #dc2626 !important;
    }

    body.mobile-menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }

    /* Footer hidden — tab bar replaces it */
    .stream-footer-desktop {
        display: none;
    }

    /* Alerts */
    .streaming-app .alert {
        margin: calc(56px + 12px) 16px 0;
        max-width: none;
        border-radius: 12px;
    }

    /* Hero */
    .stream-hero {
        height: 58vh;
        min-height: 300px;
        max-height: 520px;
        margin-bottom: -32px;
    }

    .stream-hero-content {
        bottom: 18%;
        left: 16px;
        right: 16px;
        max-width: none;
    }

    .stream-hero-title {
        font-size: 1.75rem;
    }

    .stream-hero-desc {
        font-size: 0.9rem;
        -webkit-line-clamp: 2;
        margin-bottom: 16px;
    }

    .stream-hero-actions {
        gap: 8px;
    }

    .btn-play,
    .btn-info {
        font-size: 0.9rem;
        padding: 10px 20px;
    }

    /* Content rows — horizontal carousel with snap */
    .content-rows {
        padding-bottom: 24px;
    }

    .content-row {
        padding: 0 16px;
        margin-bottom: 28px;
    }

    .row-heading {
        font-size: 1.1rem;
        margin-bottom: 10px;
    }

    .row-track {
        gap: 12px;
        padding: 4px 0 12px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .row-track .poster-card {
        scroll-snap-align: start;
        width: 130px;
    }

    .row-track .poster-card-wide {
        width: 200px;
    }

    /* Grid layout for series browse page */
    .content-row-grid .row-slider {
        overflow: visible;
    }

    .content-row-grid .row-track {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        overflow: visible;
        scroll-snap-type: none;
    }

    .content-row-grid .poster-card {
        width: 100% !important;
    }

    .content-row-grid .poster-card:hover {
        transform: none;
    }

    .content-row-grid .poster-meta {
        white-space: normal;
        font-size: 0.75rem;
    }

    /* Programs list page */
    .programs-page {
        padding: calc(56px + 12px) 16px calc(16px + var(--mobile-chrome-bottom));
    }

    .programs-page-header {
        margin-bottom: 16px;
    }

    .programs-page-header h1 {
        font-size: 1.35rem;
    }

    .programs-page-header p {
        font-size: 0.85rem;
    }

    .programs-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .programs-grid .poster-title {
        font-size: 0.85rem;
        margin-top: 8px;
        -webkit-line-clamp: 2;
    }

    .programs-grid .poster-meta {
        white-space: normal;
        font-size: 0.7rem;
    }

    /* Program detail */
    .program-detail {
        padding: calc(56px + 8px) 16px 4px;
    }

    .program-back-link-inline {
        margin-bottom: 12px;
        font-size: 0.85rem;
    }

    .program-detail-top {
        gap: 14px;
    }

    .program-detail-poster {
        width: 100px;
        border-radius: 8px;
    }

    .program-detail-summary h1 {
        font-size: 1.15rem;
    }

    .program-detail-meta {
        margin-bottom: 12px;
    }

    .program-detail-meta span {
        font-size: 0.75rem;
        padding: 3px 8px;
    }

    .program-detail-desc {
        font-size: 0.875rem;
        margin-top: 14px;
    }

    .program-detail-play {
        max-width: none;
        width: 100%;
        font-size: 0.875rem;
        padding: 10px 16px;
    }

    .program-access-page {
        padding: calc(56px + 8px) 16px calc(16px + var(--mobile-chrome-bottom));
    }

    .program-access-page .access-gate {
        margin: 0;
        padding: 24px 18px;
    }

    .program-access-page .access-gate-thumb {
        max-width: 120px;
        margin: 0 auto 16px;
        display: block;
    }

    .program-access-page .access-gate h2 {
        font-size: 1.15rem;
        margin-bottom: 8px;
    }

    .episodes-section-compact {
        padding: 8px 16px calc(12px + var(--mobile-chrome-bottom));
    }

    .episodes-section-compact h2 {
        font-size: 1.05rem;
        margin-bottom: 12px;
    }

    .episode-row {
        padding: 8px 10px;
        gap: 10px;
    }

    .episode-row-thumb {
        width: 64px;
        height: 42px;
    }

    .episode-row-info h3 {
        font-size: 0.9rem;
    }

    .stream-empty-compact {
        padding: 32px 16px calc(24px + var(--mobile-chrome-bottom));
    }

    /* Page bar */
    .page-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: calc(56px + 20px) 16px 20px;
    }

    .page-bar h1 {
        font-size: 1.4rem;
    }

    .page-bar .btn-info {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    /* Legacy series hero — hidden on mobile (replaced by program-detail) */
    .series-hero {
        display: none;
    }

    /* Series detail (legacy overrides) */
    .watch-page {
        padding-top: 56px;
        padding-bottom: var(--mobile-chrome-bottom);
    }

    .watch-player-wrap {
        max-height: none;
        aspect-ratio: 16 / 9;
        background: #000;
    }

    .watch-player-wrap video {
        max-height: none;
        height: 100%;
        object-fit: contain;
    }

    .watch-details {
        padding: 20px 16px 16px;
    }

    .watch-details h1 {
        font-size: 1.35rem;
    }

    .watch-episodes-row {
        padding-bottom: 8px !important;
    }

    /* Access gate */
    .streaming-app .access-gate {
        margin: 24px 16px;
        padding: 28px 20px;
        border-radius: 16px;
    }

    .access-gate-icon {
        font-size: 2.5rem;
    }

    .access-gate-thumb {
        max-width: 100%;
        border-radius: 12px;
    }

    /* Empty state */
    .stream-empty {
        padding: 48px 20px;
    }

    /* Search results grid on home */
    .content-rows[style*="padding-top"] {
        padding-top: calc(56px + 16px) !important;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .row-track .poster-card {
        width: 110px;
    }

    .content-row-grid .row-track {
        gap: 10px;
    }

    .mobile-tab {
        font-size: 0.6rem;
    }

    .mobile-tab-icon {
        font-size: 1.2rem;
    }
}

/* Tablet — show desktop nav, hide mobile chrome */
@media (min-width: 769px) {
    .mobile-tab-bar,
    .mobile-drawer,
    .mobile-drawer-overlay,
    .mobile-search-sheet {
        display: none !important;
    }

    .stream-nav-desktop {
        display: flex;
    }

    .stream-nav-actions {
        margin-left: auto;
    }

    .stream-nav-right.stream-nav-desktop {
        display: flex;
    }
}
