/**
 * MAX巨幕影音 - 移动端与微信 H5 专属样式
 * Version: Mobile 1.0
 * 覆盖场景：手机浏览器、微信内置浏览器、平板
 */

/* ===========================
   0. 移动端全局 CSS 变量覆盖
   =========================== */
@media (max-width: 768px) {
    :root {
        --header-h: 60px;
        --radius-lg: 12px;
        --card-w: 120px;
    }
    body {
        padding-top: calc(var(--header-h) + 0px);
        /* 底部留给 tabbar */
        padding-bottom: 70px;
    }
}

/* ===========================
   1. 顶部通知栏移动端隐藏
   =========================== */
@media (max-width: 768px) {
    #notice-bar {
        display: none !important;
    }
    header {
        top: 0 !important;
    }
}

/* ===========================
   2. 导航栏移动端重塑
   =========================== */
@media (max-width: 768px) {
    .nav-content {
        grid-template-columns: 1fr auto !important;
        padding: 0 16px !important;
        gap: 0 !important;
    }

    /* 桌面导航隐藏 */
    .nav-links {
        display: none !important;
    }

    /* Logo 缩小 */
    .logo-text {
        font-size: 18px !important;
        letter-spacing: -0.5px !important;
    }

    /* 操作区简化 */
    .header-actions {
        gap: 10px !important;
    }

    /* 搜索触发器移动端精简 */
    .search-trigger {
        padding: 8px 12px !important;
        gap: 8px !important;
    }
    .search-trigger .text {
        display: none; /* 只显示图标 */
    }

    /* 登录按钮缩小 */
    .max-btn.btn-gold {
        padding: 8px 14px !important;
        font-size: 12px !important;
    }

    /* 汉堡菜单按钮 */
    .hamburger-btn {
        display: flex !important;
        flex-direction: column;
        justify-content: space-between;
        width: 26px;
        height: 20px;
        cursor: pointer;
        padding: 0;
        background: none;
        border: none;
        flex-shrink: 0;
    }
    .hamburger-btn span {
        display: block;
        width: 100%;
        height: 2px;
        background: #fff;
        border-radius: 2px;
        transition: all 0.35s ease;
    }
    .hamburger-btn.open span:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }
    .hamburger-btn.open span:nth-child(2) {
        opacity: 0;
    }
    .hamburger-btn.open span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }
}
/* 桌面端隐藏汉堡 */
.hamburger-btn { display: none; }


/* ===========================
   3. 移动端侧滑抽屉导航
   =========================== */
.mobile-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 80%;
    max-width: 300px;
    height: 100%;
    background: rgba(8, 8, 8, 0.98);
    backdrop-filter: blur(30px);
    z-index: 9998;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    padding-top: 70px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    overflow-y: auto;
}
.mobile-drawer.open {
    left: 0;
}
.mobile-drawer-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9997;
    display: none;
    opacity: 0;
    transition: opacity 0.35s;
}
.mobile-drawer-overlay.open {
    display: block;
    opacity: 1;
}

.drawer-logo {
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 20px;
    font-weight: 900;
    background: linear-gradient(135deg, #fff 0%, #d4af37 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.drawer-nav {
    padding: 20px 0;
}
.drawer-nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
    font-weight: 600;
    transition: all 0.25s;
    border-left: 3px solid transparent;
}
.drawer-nav a:hover,
.drawer-nav a.active {
    color: #d4af37;
    border-left-color: #d4af37;
    background: rgba(212, 175, 55, 0.08);
}
.drawer-nav a .nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.drawer-user-section {
    margin: 10px 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}
.drawer-user-section a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #d4af37;
    font-weight: 700;
    font-size: 14px;
}


/* ===========================
   4. 底部 Tabbar（手机专属）
   =========================== */
#mobile-tabbar {
    display: none;
}
@media (max-width: 768px) {
    #mobile-tabbar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background: rgba(8, 8, 8, 0.98);
        backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 1000;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .tabbar-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: rgba(255, 255, 255, 0.4);
        font-size: 10px;
        font-weight: 600;
        transition: color 0.2s;
        cursor: pointer;
        text-decoration: none;
    }
    .tabbar-item .tab-icon { font-size: 20px; line-height: 1; }
    .tabbar-item.active,
    .tabbar-item:hover {
        color: #d4af37;
    }
    .tabbar-search-btn {
        width: 52px;
        height: 52px;
        background: linear-gradient(135deg, #d4af37, #bd932a);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        box-shadow: 0 -5px 20px rgba(212, 175, 55, 0.4);
        margin-top: -15px;
        flex-shrink: 0;
    }
}


/* ===========================
   5. 首页 Hero 区移动端适配
   =========================== */
@media (max-width: 768px) {
    .hero-section {
        height: 60vw !important;
        min-height: 240px !important;
        max-height: 380px !important;
    }
    .hero-meta {
        bottom: 20px !important;
        padding: 0 16px !important;
    }
    .hero-title {
        font-size: 22px !important;
        margin-bottom: 8px !important;
    }
    .hero-tags,
    .hero-desc {
        display: none;
    }
    .hero-btns {
        gap: 10px !important;
    }
    .hero-btns .max-btn {
        padding: 10px 18px !important;
        font-size: 13px !important;
    }
    /* Swiper 分页圆点变小 */
    .swiper-pagination {
        bottom: 12px !important;
    }
}


/* ===========================
   6. 影视卡片网格移动端适配
   =========================== */
@media (max-width: 768px) {
    /* 首页推荐区域 */
    .vod-row {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
    }

    /* 卡片文字缩小 */
    .card-name {
        font-size: 13px !important;
        -webkit-line-clamp: 2 !important;
    }
    .card-remark {
        font-size: 11px !important;
    }
}

@media (max-width: 480px) {
    .vod-row {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
}


/* ===========================
   7. 分类页移动端适配
   =========================== */
@media (max-width: 768px) {
    .vod-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px !important;
    }
    /* 筛选条水平滚动 */
    .filter-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px !important;
        margin-bottom: 20px !important;
    }
    .filter-group {
        min-width: max-content;
        flex-wrap: nowrap !important;
        gap: 10px !important;
    }
    .filter-items {
        flex-wrap: nowrap !important;
    }
    .filter-items a {
        white-space: nowrap;
        padding: 5px 14px !important;
        font-size: 12px !important;
    }
}

@media (max-width: 480px) {
    .vod-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
}


/* ===========================
   8. 详情页移动端适配
   =========================== */
@media (max-width: 768px) {
    /* 海报+信息从两列改为一列 */
    .detail-layout,
    .detail-main {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    .detail-poster {
        width: 45% !important;
        max-width: 200px;
        margin: 0 auto;
    }
    .detail-title {
        font-size: 22px !important;
    }
    .detail-meta {
        font-size: 13px !important;
    }
    /* 剧集列表 */
    .episode-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }
    .ep-btn {
        padding: 8px 5px !important;
        font-size: 12px !important;
    }
}


/* ===========================
   9. 播放页移动端 (最关键)
   =========================== */
@media (max-width: 768px) {
    .play-layout {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    /* 侧边栏在手机上隐藏 */
    .play-sidebar {
        display: none !important;
    }
    /* 播放容器 16:9 / 竖屏全宽 */
    .player-wrapper {
        border-radius: 0 !important;
        margin: 0 -16px 16px !important;
        width: calc(100% + 32px) !important;
        aspect-ratio: 16/9;
        box-shadow: none !important;
    }
    /* 播放器内 iframe 强制全尺寸 */
    .player-wrapper iframe,
    .player-wrapper video,
    #playleft {
        width: 100% !important;
        height: 100% !important;
    }
    /* 播放信息卡片 */
    .play-info {
        padding: 16px !important;
        border-radius: 12px !important;
        margin-bottom: 16px !important;
    }
    .play-title {
        font-size: 16px !important;
        font-weight: 700;
        line-height: 1.4;
    }
    .play-actions {
        gap: 8px !important;
        flex-wrap: wrap;
    }
    .play-actions .max-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
    /* 选集 */
    .play-episodes {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }
    .episode-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }
    .ep-btn {
        padding: 10px 5px !important;
        font-size: 12px !important;
    }
    .play-container {
        padding: 0 !important;
    }
    /* 线路标签 */
    .tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        padding-bottom: 12px !important;
    }
}

/* 微信内播放器全屏修复 */
@media (max-width: 768px) {
    .player-wrapper {
        position: relative;
        -webkit-overflow-scrolling: touch;
    }
    .player-wrapper iframe {
        pointer-events: auto;
    }
}


/* ===========================
   10. 搜索覆盖层移动端优化
   =========================== */
@media (max-width: 768px) {
    .search-input-max {
        font-size: 18px !important;
        padding: 14px 20px !important;
    }
    .search-close {
        top: 20px !important;
        right: 20px !important;
        font-size: 28px !important;
    }
    .search-container-max {
        width: 95% !important;
        padding: 20px !important;
    }
}


/* ===========================
   11. 用户中心移动端适配
   =========================== */
@media (max-width: 768px) {
    .user-layout,
    .account-layout {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    .user-sidebar {
        display: none;
    }
    .user-card, .form-card {
        padding: 20px 16px !important;
        border-radius: 12px !important;
    }
}


/* ===========================
   12. 全局移动端细节打磨
   =========================== */
@media (max-width: 768px) {
    /* 容器内边距 */
    .container {
        padding: 0 12px !important;
    }
    /* 分页器 */
    .pagination-wrap {
        margin-top: 30px !important;
    }
    .maccms-page a, .maccms-page span {
        padding: 8px 14px !important;
        font-size: 13px !important;
    }
    /* 页脚简化 */
    footer {
        padding: 30px 0 80px !important; /* 底部留 tabbar 空间 */
        font-size: 12px;
    }
    footer .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        text-align: center;
    }
    /* 章节标题 */
    .section-header h2 {
        font-size: 20px !important;
    }
    /* 推荐标题区 */
    .section-title {
        font-size: 18px !important;
    }
    /* 禁止长按弹出菜单 */
    img {
        -webkit-touch-callout: none;
    }
    /* 全局过渡减速（移动端不需要 0.6s 过渡太慢） */
    :root {
        --transition: all 0.25s ease;
    }
}


/* ===========================
   13. 微信专属适配
   =========================== */
/* 微信内禁用 hover（避免触摸残留）*/
@media (hover: none) and (pointer: coarse) {
    .max-btn:hover,
    .btn-gold:hover,
    .card:hover {
        transform: none !important;
        filter: none !important;
    }
    .card:hover .card-overlay {
        opacity: 0 !important;
    }
}

/* 微信内安全区域适配 (iPhone 刘海/底部横条) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #mobile-tabbar {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(60px + env(safe-area-inset-bottom));
    }
    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
}

/* 微信内图片长按保存禁用 */
.card-poster img,
.hero-section img,
.detail-poster img {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}


/* ===========================
   14. 平板端 (768px - 1024px)
   =========================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .nav-content {
        grid-template-columns: 180px 1fr 260px !important;
        padding: 0 20px !important;
    }
    .vod-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    .vod-row {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    .play-layout {
        grid-template-columns: 1fr 260px !important;
    }
    .hero-title {
        font-size: 28px !important;
    }
}


/* ===========================
   15. 滚动条美化（移动端隐藏，桌面端金色）
   =========================== */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.4);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.8);
}

@media (max-width: 768px) {
    ::-webkit-scrollbar { width: 0; height: 0; }
}

/* 横向滚动区域顺滑 */
.tabs, .filter-section, .filter-group {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar,
.filter-section::-webkit-scrollbar {
    display: none;
}
