/* ================================================
   SnapFlow Mobile Responsive CSS (Wavve Style)
   ================================================ */

/* ==============================================
   1. 기본 모바일 설정
   ============================================== */
@media screen and (max-width: 768px) {
    * {
        -webkit-tap-highlight-color: transparent;
    }

    html, body {
        width: 100%;
        overflow-x: hidden;
    }

    body {
        padding-bottom: 60px; /* 하단 네비게이션 공간 확보 */
    }

    /* ==============================================
       2. 헤더 모바일 최적화
       ============================================== */
    .header-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: #1a1a1a;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }

    .navbar-container {
        padding: 10px 16px;
    }

    .navbar-content {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
    }

    /* 로고 크기 조정 */
    .logo img {
        height: 28px !important;
        width: auto;
    }

    /* 카테고리 메뉴 */
    .category-list {
        flex: 1;
        margin: 0 16px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }

    .category-list::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }

    .category-list .w-menu-list {
        display: flex;
        flex-wrap: nowrap;
        gap: 20px;
        white-space: nowrap;
    }

    .category-list .w-menu-item {
        flex-shrink: 0;
    }

    .category-list .item-link {
        font-size: 15px;
        font-weight: 500;
        color: rgba(255, 255, 255, 0.7);
        padding: 8px 0;
        display: inline-block;
    }

    .category-list .item-link:hover,
    .category-list .item-link:active {
        color: #ffffff;
    }

    /* 검색 & 프로필 - PC에서 숨김 */
    .navbar-content > .w-menu-list {
        display: none !important;
    }

    /* ==============================================
       3. 메인 콘텐츠 영역
       ============================================== */
    #contents.main {
        padding-top: 48px; /* 헤더 높이만큼 */
        padding-bottom: 0;
    }

    .super-multi-section-list {
        padding: 0;
    }

    /* ==============================================
       4. 메인 배너 (세로형 포스터) - Wavve 스타일
       ============================================== */
    #main-banner {
        margin: 0;
        padding: 0;
        height: auto !important;
    }

    /* Wavve 방식: width는 widget_banner.html의 CSS로 제어 (100% !important) */
    /* spaceBetween: 8로 margin-right만 Swiper가 적용 */

    #main-banner .picture-area {
        width: 100%;
        position: relative;
    }

    #main-banner .swiper-slide img.big-banner {
        width: 100%;
        height: auto;
        border-radius: 0;
        display: block;
    }

    /* 배너 타이틀 이미지 */
    #main-banner .banner-title {
        position: absolute;
        bottom: 80px;
        left: 16px;
        width: 40%;
        max-width: 200px;
        height: auto;
    }

    /* 배너 버튼 숨김 (모바일에서 스와이프) */
    #main-banner .swiper-button-prev,
    #main-banner .swiper-button-next {
        display: none !important;
    }

    /* 페이지네이션 */
    #main-banner .swiper-pagination-fraction {
        display: block;
        position: absolute;
        bottom: 16px;
        right: 16px;
        color: rgba(255, 255, 255, 0.9);
        font-size: 13px;
        font-weight: 500;
        background: rgba(0, 0, 0, 0.5);
        padding: 4px 10px;
        border-radius: 12px;
        left: auto;
        width: auto;
    }

    /* ==============================================
       5. 콘텐츠 섹션 (6블록)
       ============================================== */
    .multi.portrait-cell {
        padding: 24px 0;
        margin: 0;
    }

    /* 섹션 타이틀 */
    .multi .title {
        padding: 0 16px 16px;
    }

    .multi .title-area {
        font-size: 18px;
        font-weight: 700;
        color: #ffffff;
    }

    /* 포스터 슬라이더 */
    .swiper.portrait-cell {
        padding: 0 16px;
        overflow: visible;
    }

    /* .portrait 클래스 고정 너비 해제 (default03.css 덮어쓰기) */
    .portrait {
        width: 100% !important;
        float: none !important;
    }

    /* .wrap 전역 덮어쓰기 (default07.css 1240px 고정 너비 해제) */
    .wrap {
        width: 100% !important;
        margin: 0 auto !important;
    }

    /* .list-view-detail 전역 덮어쓰기 (default07.css PC 레이아웃 해제) */
    .list-view-detail {
        width: 100% !important;
        overflow: visible !important;
        margin: 0 !important;
    }

    .list-view-detail .inner-box {
        float: none !important;
        margin: 0 !important;
    }

    .list-view-detail .portrait {
        margin: 0 !important;
    }

    /* 5n 선택자 해제 (PC에서는 5개씩 보여주지만 모바일에서는 3개씩) */
    .list-view-detail .thumb:nth-child(5n),
    .list-view-detail .inner-box:nth-child(5n) {
        margin-right: 0 !important;
    }

    .swiper.portrait-cell .swiper-wrapper {
        display: flex;
    }

    .swiper.portrait-cell .swiper-slide {
        /* 반응형 너비: (전체 너비 - 패딩 32px - 간격 24px) / 2.5개 슬라이드 */
        width: calc((100vw - 32px - 24px) / 2.5) !important;
        max-width: 140px !important;
        min-width: 100px !important;
        margin-right: 12px !important;
        flex-shrink: 0;
    }

    /* 매우 작은 화면 (360px 이하)에서 추가 최적화 */
    @media screen and (max-width: 360px) {
        .swiper.portrait-cell .swiper-slide {
            width: calc((100vw - 32px - 12px) / 2.5) !important;
            min-width: 90px !important;
            margin-right: 6px !important;
        }

        .swiper.portrait-cell .swiper-slide[style] {
            margin-right: 6px !important;
        }
    }

    /* Swiper 포스터 인라인 스타일 강제 덮어쓰기 */
    .swiper.portrait-cell .swiper-slide[style] {
        width: calc((100vw - 32px - 24px) / 2.5) !important;
        max-width: 140px !important;
        min-width: 100px !important;
        margin-right: 12px !important;
    }

    /* 포스터 이미지 */
    .portrait .thumb-image {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 2/3;
        min-height: 150px;
        border-radius: 6px;
        overflow: hidden;
        background: #2a2a2a;
    }

    .portrait .thumb-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s;
    }

    .portrait .thumb-image:active img {
        transform: scale(0.95);
    }

    /* 포스터 정보 */
    .swiper-slide .data {
        margin-top: 8px;
        margin-bottom: 0;
    }

    .data h2 {
        font-size: 14px;
        line-height: 18px;
        margin-bottom: 4px;
    }

    .data span {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.6);
    }

    /* 슬라이더 버튼 숨김 */
    .swiper-button-prev,
    .swiper-button-next {
        display: none !important;
    }

    /* ==============================================
       6. 하단 네비게이션 바
       ============================================== */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: #1a1a1a;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        padding: 0;
    }

    .mobile-bottom-nav .nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: rgba(255, 255, 255, 0.6);
        font-size: 11px;
        font-weight: 500;
        padding: 8px 0;
        transition: color 0.2s;
    }

    .mobile-bottom-nav .nav-item:active {
        background: rgba(255, 255, 255, 0.05);
    }

    .mobile-bottom-nav .nav-item.active {
        color: #ffffff;
    }

    .mobile-bottom-nav .nav-item svg {
        width: 24px;
        height: 24px;
        margin-bottom: 4px;
        stroke: currentColor;
        fill: none;
    }

    .mobile-bottom-nav .nav-item.active svg {
        fill: currentColor;
    }

    /* ==============================================
       7. VOD 플레이어 모바일 최적화
       ============================================== */
    .vod.player-wrap {
        padding-top: 48px;
    }

    .video-js {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16/9;
    }

    /* 플레이어 컨트롤 터치 최적화 */
    .vjs-control-bar {
        height: 48px !important;
    }

    .vjs-control-bar button {
        min-width: 44px;
        min-height: 44px;
    }

    /* ==============================================
       8. 검색 페이지 모바일
       ============================================== */
    /* 검색 섹션 전체 너비 조정 (default02.css 1240px 덮어쓰기) */
    .search-section {
        width: 100% !important;
        margin: 0 !important;
    }

    /* 모바일 검색 페이지 헤더 */
    .search-section .header-search {
        display: block !important;
        position: fixed;
        top: 65px;
        left: 0;
        right: 0;
        z-index: 1000;
        background: #1a1a1a;
        padding: 10px 16px;
    }

    .search-section .search-box-container {
        width: 100% !important;
    }

    .search-section .w-search-box {
        width: 100% !important;
    }

    .search-section .search-input-box {
        width: 100%;
        padding: 12px 40px 12px 40px;
        font-size: 15px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        color: #ffffff;
    }

    .search-section .search-input-box::placeholder {
        color: rgba(255, 255, 255, 0.5);
    }

    /* 검색 결과 영역 */
    .search-section #contents {
        padding-top: 125px !important;
    }

    .search-section .wrap {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 16px !important;
    }

    .search-section .title-box {
        padding: 0;
    }

    .search-section .search-result-text {
        font-size: 16px;
        font-weight: 600;
    }

    /* 검색 결과 그리드 */
    .search-section .list-view-detail {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
        width: 100% !important;
        overflow: visible !important;
        margin: 0 !important;
    }

    .search-section .list-view-detail .inner-box {
        width: 100% !important;
        float: none !important;
        margin: 0 !important;
    }

    .search-section .portrait {
        width: 100% !important;
        float: none !important;
        margin: 0 !important;
    }

    .search-section .portrait .thumb-image {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 2/3;
        border-radius: 6px;
    }

    .search-section .data {
        margin-top: 8px;
    }

    .search-section .data h2 {
        font-size: 13px;
        line-height: 16px;
        margin-bottom: 4px;
    }

    .search-section .data span {
        font-size: 11px;
    }

    /* 검색 결과 5n 선택자 해제 */
    .search-section .search-body .thumb:nth-child(5n) {
        margin-right: 0 !important;
    }

    .search-section .search-body {
        margin-top: 0 !important;
        min-height: auto !important;
        padding-bottom: 80px !important;
    }

    /* ==============================================
       9. 더보기 페이지 모바일
       ============================================== */
    #contents.sub-category {
        padding-top: 48px;
    }

    .list-view .top-section {
        padding: 16px;
    }

    .list-view .page-header .title {
        font-size: 22px;
        font-weight: 700;
    }

    .list-view .contents-section {
        padding: 0 16px;
    }

    /* 더보기 페이지 그리드 */
    .list-view .list-view-detail {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
        width: 100% !important;
        overflow: visible !important;
        margin: 0 !important;
    }

    .list-view .list-view-detail .inner-box {
        width: 100% !important;
        float: none !important;
        margin: 0 !important;
    }

    .list-view .portrait {
        width: 100% !important;
        float: none !important;
        margin: 0 !important;
    }

    .list-view .portrait .thumb-image {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 2/3;
        border-radius: 6px;
        overflow: hidden;
        background: #2a2a2a;
    }

    .list-view .data {
        margin-top: 8px;
    }

    .list-view .data h2 {
        font-size: 13px;
        line-height: 16px;
        margin-bottom: 4px;
    }

    .list-view .data span {
        font-size: 11px;
        color: rgba(255, 255, 255, 0.6);
    }

    /* ==============================================
       10. 시청기록 페이지 모바일
       ============================================== */
    .history-section #contents {
        padding-top: 48px;
    }

    .history-section .wrap {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 16px !important;
    }

    .history-section .list-view-detail {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
        width: 100% !important;
        overflow: visible !important;
        margin: 0 !important;
    }

    .history-section .list-view-detail .inner-box {
        width: 100% !important;
        float: none !important;
        margin: 0 !important;
    }

    .history-section .portrait {
        width: 100% !important;
        float: none !important;
        margin: 0 !important;
    }

    .history-section .portrait .thumb-image {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 2/3;
        border-radius: 6px;
        overflow: hidden;
        background: #2a2a2a;
    }

    /* ==============================================
       11. VOD 플레이어 모바일 최적화
       ============================================== */
    /* VOD 페이지 컨테이너 */
    .vod {
        min-width: 100% !important;
        min-height: auto !important;
        height: auto !important;
        padding: 0 !important;
    }

    /* 플레이어 컨테이너 */
    .play-container {
        height: auto !important;
        aspect-ratio: 16 / 9;
        margin-bottom: 0 !important;
    }

    .play-container .player_container {
        height: 100%;
    }

    .play-container .ui_container {
        height: 100%;
    }

    /* 플레이어 UI - 모바일 최소한의 수정만 */

    /* 진행바 높이 증가 (터치 친화적) */
    .player .uis .seek-box {
        margin-bottom: 16px !important;
    }

    .player .uis .seek-box .bar {
        height: 24px !important;
        margin: 0 8px !important;
    }

    .player .uis .seek-box .bar .bar-progress {
        top: -60% !important;
    }

    .player .uis .seek-box .bar .thumb-seekable {
        width: 20px !important;
        height: 20px !important;
        margin-left: -10px !important;
        top: -100% !important;
    }

    /* 중앙 버튼 크기 조정 */
    .player .ui-box .ui-set .btn-center button {
        width: 60px !important;
        height: 60px !important;
    }

    .player .ui-box .ui-set .btn-back,
    .player .ui-box .ui-set .btn-front {
        width: 44px !important;
        height: 44px !important;
    }

    /* 에피소드 박스 숨기기 */
    .player .uis .episode-box {
        display: none !important;
    }

    .player .uis .bottom-area .add-on-area {
        display: none !important;
    }

    /* 이전/다음 버튼 숨기기 */
    .player .uis .bottom-area .btn-play-prev,
    .player .uis .bottom-area .btn-play-next {
        display: none !important;
    }

    /* 볼륨 바 숨기기 */
    .player .uis .bottom-area .volume-box {
        display: none !important;
    }

    /* 재생 버튼 텍스트 숨기고 아이콘만 표시 */
    .player .uis .bottom-area .play-box button {
        font-size: 0 !important;
        min-width: 40px !important;
        min-height: 40px !important;
        padding: 8px !important;
    }

    /* 기능 버튼 크기 축소 */
    .player .uis .bottom-area .function-box button {
        width: 36px !important;
        height: 36px !important;
    }

    /* 텍스트 사이즈 모바일 최적화 */
    .text-info {
        font-size: 14px !important;
    }

    .text-line-limit {
        font-size: 13px !important;
        line-height: 1.4 !important;
    }

    .font-big {
        font-size: 16px !important;
    }

    .font-default {
        font-size: 13px !important;
    }

    /* VOD 상세정보 텍스트 */
    .preview-detail-box .preview-title {
        font-size: 18px !important;
    }

    .preview-detail-box .preview-dsc {
        font-size: 13px !important;
    }

    /* 오프닝 스킵 버튼 */
    .opening-skip-btn {
        font-size: 12px !important;
        padding: 8px 12px !important;
    }

    /* 로딩 스피너 */
    .loading-spinner {
        width: 48px !important;
        height: 48px !important;
    }

    /* 모바일 일반 너비 제약 제거 (1240px 고정값 및 최소값 해제) */
    [style*="width: 1240px"],
    [style*="width:1240px"],
    [style*="min-width: 1240px"],
    [style*="min-width:1240px"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
    }

    /* 상세정보 영역 최적화 */
    .detail-view-content-area {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 16px 60px 16px !important;
    }

    .player-bottom-contents {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 0 !important;
    }

    .preview-detail-box {
        padding: 16px 0 !important;
    }

    .preview-detail-box .preview-title {
        font-size: 18px !important;
        line-height: 1.3 !important;
    }

    .preview-detail-box .preview-dsc {
        font-size: 13px !important;
        line-height: 1.5 !important;
        max-height: 60px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* 상세 정보 표 최적화 */
    .detail-view-box {
        display: none !important; /* 모바일에서는 상세정보 박스 숨기기 */
    }

    .detail-info-table {
        font-size: 12px !important;
    }

    .detail-info-table th,
    .detail-info-table td {
        padding: 8px !important;
    }

    .detail-info-table th {
        width: 80px !important;
    }

    /* 에피소드 리스트 컨테이너 최적화 */
    .player-component01 {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 0 16px !important;
    }

    .player-list {
        width: 100% !important;
        max-width: 100% !important;
    }

    .episode-list {
        width: 100% !important;
        padding: 0 !important;
    }

    /* 에피소드 리스트 최적화 */
    .vod-all-list-item {
        margin-bottom: 12px !important;
    }

    .vod-all-list-link {
        display: flex !important;
        flex-direction: column !important;
    }

    .vod-all-list-image {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16 / 9 !important;
        margin-bottom: 8px !important;
    }

    .vod-all-list-image .thumb-image {
        height: 100% !important;
    }

    .vod-all-list-subject {
        padding: 0 !important;
    }

    .vod-all-list-subject .title1 {
        font-size: 14px !important;
        line-height: 1.4 !important;
    }

    .vod-all-list-dsc-box {
        padding: 0 !important;
        margin-top: 4px !important;
    }

    .vod-all-list-dsc-box .dsc {
        font-size: 12px !important;
        line-height: 1.3 !important;
        max-height: 40px !important;
        overflow: hidden !important;
    }

    /* 시즌 탭 최적화 */
    .player-nav {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 12px 16px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .player-nav ul {
        gap: 8px !important;
        display: flex !important;
        flex-wrap: nowrap !important;
    }

    .player-nav button {
        padding: 8px 16px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    /* 마이크로 PIP 플레이어 숨기기 */
    #mini-pip-player {
        display: none !important;
    }

    /* ==============================================
       12. 푸터 최적화
       ============================================== */
    footer {
        padding: 24px 16px 80px; /* 하단 네비 공간 확보 */
        font-size: 12px;
    }

    /* ==============================================
       13. 유틸리티 클래스
       ============================================== */
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }

    /* 스크롤 스냅 (iOS Safari 최적화) */
    .swiper-wrapper {
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
    }

    .swiper-slide {
        scroll-snap-align: start;
    }
}

/* ==============================================
   타블렛 (768px ~ 1024px)
   ============================================== */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .mobile-bottom-nav {
        display: none;
    }

    .swiper.portrait-cell .swiper-slide {
        /* 태블릿: 4개 슬라이드 표시 (widget_6block.html breakpoint 768 설정) */
        width: calc((100vw - 32px - 36px) / 4) !important;
        max-width: 200px !important;
        min-width: 150px !important;
    }

    .portrait .thumb-image {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 2/3;
        min-height: 225px;
    }
}

/* ==============================================
   데스크톱 (1025px 이상)
   ============================================== */
@media screen and (min-width: 1025px) {
    .mobile-bottom-nav {
        display: none !important;
    }

    .mobile-only {
        display: none !important;
    }

    .desktop-only {
        display: block !important;
    }
}
