/* Mobile & Responsive Overrides for StreamFlix */

:root {
    --container-padding-mobile: 5%;
}

/* -------------------------
   Base small-screen tweaks
   ------------------------- */
@media (max-width: 1024px) {
    .header-container {
        padding: 0 var(--container-padding-mobile);
        gap: 12px;
    }

    /* Ensure header-right stays visible for search + hamburger */
    .header-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .nav {
        display: none;
    }

    .hamburger-btn {
        display: flex;
    }

    .search-input {
        width: 0 !important;
        opacity: 0 !important;
    }

    /* When JS toggles this class, reveal the search input on mobile */
    .search-container.search-open .search-input {
        width: 70vw !important;
        max-width: 420px !important;
        opacity: 1 !important;
        background: rgba(0, 0, 0, 0.85) !important;
        border-color: var(--color-text-primary) !important;
        padding-left: 44px !important;
    }

    .hero,
    .hero-carousel {
        min-height: 60vh !important;
        max-height: 760px;
    }

    .skeleton-hero {
        min-height: 45vh;
    }

    .skeleton-row {
        gap: 8px;
    }

    .skeleton-card {
        flex: 0 0 var(--card-width-sm);
    }

    .mobile-nav {
        width: 80%;
        right: -80%;
    }

    .mobile-nav.open {
        right: 0;
    }

    /* Avoid accidental blocking of taps by overlays/pseudo elements */
    .mobile-nav {
        pointer-events: none;
    }

    .mobile-nav.open {
        pointer-events: auto;
    }

    .mobile-nav-overlay {
        pointer-events: none;
    }

    .mobile-nav-overlay.open {
        pointer-events: auto;
    }
}

@media (max-width: 768px) {
    :root {
        --card-width: 220px;
        --card-width-sm: 160px;
    }

    .header {
        height: 60px;
    }

    .logo img,
    .logo .logo-img {
        height: 44px !important;
    }

    .hero {
        min-height: 50vh !important;
    }

    .hero-content {
        max-width: 100%;
        padding-top: 52px;
    }

    .hero-title {
        font-size: clamp(1.6rem, 6vw, 2.2rem) !important;
    }

    .hero-description {
        font-size: 0.95rem;
        max-width: 100%;
    }

    .hero-meta {
        gap: 8px;
        font-size: 0.9rem;
    }

    .hero-buttons .btn-lg {
        padding: 0.7rem 1.4rem;
        font-size: 0.95rem;
    }

    .skeleton-card {
        aspect-ratio: 2/3;
    }

    .back-to-top {
        right: 18px;
        bottom: 18px;
    }

    .footer-container {
        padding: 24px var(--container-padding-mobile);
    }
}

@media (max-width: 480px) {
    :root {
        --container-padding: 4%;
        --container-padding-mobile: 4%;
    }

    .header-container {
        gap: 8px;
    }

    .header-right {
        gap: 6px;
    }

    .logo img,
    .logo .logo-img {
        height: 40px !important;
    }

    .hero {
        min-height: 40vh !important;
        padding: 0 var(--container-padding-mobile);
    }

    .hero-content {
        flex-direction: column;
        gap: 14px;
        padding-top: 48px;
    }

    .hero-poster,
    .hero-poster img {
        width: 160px !important;
    }

    .hero-info {
        padding-right: 0;
    }

    .hero-title {
        font-size: 1.25rem !important;
        line-height: 1.15;
    }

    .hero-description {
        font-size: 0.9rem;
    }

    .nav-dropdown-content {
        left: 10px !important;
        transform: none !important;
    }

    /* Make rows horizontally scrollable on very small screens */
    .content-row,
    .row-cards,
    .skeleton-row {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: 8px !important;
        padding-bottom: 8px;
    }

    /* Ensure items inside scrollable rows remain clickable */
    .content-row a,
    .content-row button,
    .row-cards a,
    .row-cards button,
    .card,
    .card-item,
    .poster-card {
        pointer-events: auto !important;
    }

    .card,
    .card-item,
    .poster-card {
        flex: 0 0 calc(40vw);
        min-width: 140px;
    }

    .mobile-nav {
        width: 100%;
        right: -100%;
    }

    .detail-content,
    .container,
    .main-content {
        padding: 0 4% !important;
    }
}

/* Detail page specific fixes */
@media (max-width: 900px) {
    .detail-nav {
        padding: 12px 16px;
    }

    .detail-hero {
        min-height: 50vh;
        padding: 0 16px 32px;
    }

    .hero-content {
        gap: 20px;
        padding: 0;
    }

    .hero-poster {
        width: 200px;
    }

    .hero-title {
        font-size: 1.6rem;
    }

    .hero-overview {
        max-width: 100%;
    }

    .detail-content {
        padding: 0 16px 40px;
    }
}

@media (max-width: 768px) {

    /* Detail page nav: hide action buttons, show only back + home */
    .nav-actions {
        display: none;
    }

    .detail-hero {
        padding: 0 12px 24px;
    }

    /* Touch targets: min 44px on all interactive elements */
    .nav-link,
    .mobile-nav-link,
    .server-btn,
    .btn-lg,
    .btn-play,
    .btn-secondary,
    .nav-back,
    .season-btn,
    .share-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 10px 12px !important;
    }
}

@media (max-width: 480px) {
    .detail-nav {
        padding: 10px 12px;
    }

    .detail-hero {
        min-height: 36vh;
        padding: 0 12px 20px;
    }

    .hero-content {
        flex-direction: column;
        gap: 12px;
    }

    .hero-poster {
        width: 140px;
    }

    .hero-title {
        font-size: 1.2rem;
    }

    .player-wrapper {
        padding-bottom: 56.25%;
    }

    .cast-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    /* Episode cards should not exceed viewport */
    .episode-card {
        flex: 0 0 min(240px, 75vw);
    }

    /* Share buttons stack */
    .share-buttons {
        flex-direction: column;
    }

    .share-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Do not let decorative hero/backdrop layers intercept pointer events */
.hero::before,
.hero-backdrop::after,
.hero-backdrop,
.hero-backdrop img {
    pointer-events: none !important;
}

/* Dropdown hidden state should not capture pointer events */
.nav-dropdown-content {
    pointer-events: none;
}

.nav-dropdown-content.show {
    pointer-events: auto;
}

/* Card overlays should not block clicks to the card itself; allow overlay controls */
.card-overlay {
    pointer-events: none !important;
}

.card-overlay a,
.card-overlay button,
.card-overlay .btn,
.card-overlay .play-btn {
    pointer-events: auto !important;
}

/* Toast should not block page interactions */
.toast {
    pointer-events: none;
}

.toast.show {
    pointer-events: auto;
}