/**
 * mobile.css - 모바일 최적화 스타일
 * 반응형 레이아웃, 터치 최적화, 모바일 UI 개선
 */

/* ===================================
   1. 기본 터치 최적화
   =================================== */

/* 터치 영역 최소 크기 보장 */
button,
.cyber-btn,
.dock-item,
.lobby-action-btn,
.tab-btn,
.card,
.creature-card,
select,
input {
    min-height: 44px;
    min-width: 44px;
}

/* 터치 하이라이트 제거 및 최적화 */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

/* 스크롤 성능 최적화 */
.scroll-custom,
#creature-list,
#log-content,
#expedition-list,
#deck-pool {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ===================================
   2. 모바일 (max-width: 768px)
   =================================== */

@media screen and (max-width: 768px) {

    /* 헤더 */
    #game-header {
        padding: 8px 10px !important;
        flex-wrap: wrap;
        gap: 5px;
    }

    #user-info-area {
        display: none;
        /* 모바일에서 유저 정보 숨김 */
    }

    .resource-bar {
        flex: 1;
        justify-content: space-around;
        font-size: 0.85em;
    }

    .res-item {
        padding: 4px 8px;
    }

    .header-actions {
        gap: 4px;
    }

    .header-actions .cyber-btn {
        padding: 6px 8px !important;
        font-size: 0.9rem;
    }

    /* 메인 레이아웃 - 1컬럼 */
    #content-home.layout-dashboard {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
    }

    #left-panel,
    #center-panel,
    #right-panel {
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
    }

    #left-panel {
        order: 1;
        max-height: 40vh;
    }

    #center-panel {
        order: 2;
        max-height: 50vh;
    }

    #right-panel {
        order: 3;
        max-height: 30vh;
        display: none;
        /* 모바일에서 로그 패널 숨김 */
    }

    /* 로비 캐릭터 */
    #lobby-character-panel {
        position: fixed !important;
        bottom: 60px;
        right: 10px;
        width: 150px !important;
        height: 200px !important;
        z-index: 100;
    }

    #lobby-character-img {
        max-width: 100%;
        max-height: 100%;
    }

    /* 크리처 카드 그리드 */
    #creature-list {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }

    .creature-card {
        padding: 8px !important;
        font-size: 0.8em;
    }

    /* 하단 내비게이션 */
    #global-bottom-nav {
        padding: 5px 0 !important;
        gap: 0 !important;
    }

    .dock-item {
        padding: 8px 5px !important;
        min-width: 50px;
    }

    .dock-icon {
        font-size: 1.3rem !important;
    }

    .dock-label {
        font-size: 0.65rem !important;
    }

    /* 소환 뷰 */
    .summon-interface {
        padding: 10px !important;
    }

    .summon-control-panel {
        flex-direction: column;
        gap: 15px;
    }

    .summon-group {
        width: 100%;
    }

    .btn-row {
        flex-direction: column;
        gap: 10px;
    }

    .summon-btn {
        width: 100% !important;
        padding: 15px !important;
    }

    /* 팀 편성 뷰 */
    #deck-slots {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    #deck-pool {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    /* 전투 뷰 */
    #content-battle .glass-panel>div {
        padding: 10px !important;
    }

    /* 탐사 뷰 */
    .grid-expedition {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .expedition-card {
        min-height: 120px !important;
    }

    /* 모달 */
    .modal-content {
        width: 95% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        margin: 10px;
    }

    /* 로비 UI 오버레이 */
    .lobby-right-actions {
        right: 5px !important;
        top: 50% !important;
        transform: translateY(-50%);
        gap: 8px !important;
    }

    .lobby-action-btn {
        padding: 10px !important;
        min-width: 50px !important;
    }

    .lobby-action-btn .label {
        font-size: 0.7rem !important;
    }

    /* 광고 배너 */
    #ad-banner-top {
        min-height: 60px !important;
    }
}

/* ===================================
   3. 작은 모바일 (max-width: 480px)
   =================================== */

@media screen and (max-width: 480px) {

    /* 더 작은 폰트 */
    body {
        font-size: 14px;
    }

    /* 헤더 더 컴팩트 */
    #game-header {
        padding: 5px 8px !important;
    }

    .res-value {
        font-size: 0.8em !important;
    }

    /* 크리처 카드 4열 */
    #creature-list {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 5px !important;
    }

    .creature-card {
        padding: 5px !important;
    }

    .creature-card .rarity-badge {
        font-size: 0.6em !important;
    }

    /* 하단 네비 더 컴팩트 */
    .dock-item {
        padding: 5px 3px !important;
        min-width: 40px;
    }

    .dock-icon {
        font-size: 1.1rem !important;
    }

    .dock-label {
        font-size: 0.55rem !important;
    }

    /* 로비 캐릭터 더 작게 */
    #lobby-character-panel {
        width: 100px !important;
        height: 150px !important;
        bottom: 65px;
    }

    /* 버튼 컴팩트 */
    .cyber-btn {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
    }

    .cyber-btn.small {
        padding: 5px 8px !important;
        font-size: 0.75rem !important;
    }
}

/* ===================================
   4. 태블릿 (769px ~ 1024px)
   =================================== */

@media screen and (min-width: 769px) and (max-width: 1024px) {

    /* 2컬럼 레이아웃 */
    #content-home.layout-dashboard {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 15px !important;
    }

    #left-panel {
        grid-column: 1;
        grid-row: 1 / 3;
    }

    #center-panel {
        grid-column: 2;
        grid-row: 1;
    }

    #right-panel {
        grid-column: 2;
        grid-row: 2;
    }

    #lobby-character-panel {
        position: fixed;
        right: 20px;
        bottom: 80px;
        width: 200px;
        height: 280px;
    }

    /* 하단 네비 */
    .dock-item {
        padding: 10px 15px;
    }
}

/* ===================================
   5. 가로 모드 최적화
   =================================== */

@media screen and (max-height: 500px) and (orientation: landscape) {
    #game-header {
        padding: 3px 10px !important;
        min-height: 35px;
    }

    #global-bottom-nav {
        padding: 3px 0 !important;
    }

    .dock-label {
        display: none !important;
    }

    .dock-icon {
        font-size: 1.2rem !important;
    }

    #lobby-character-panel {
        display: none !important;
    }

    #main-area {
        padding-top: 40px !important;
        padding-bottom: 45px !important;
    }
}

/* ===================================
   6. 접근성 및 사용성
   =================================== */

/* 포커스 시각화 */
button:focus,
input:focus,
select:focus {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 2px;
}

/* 로딩 상태 표시 */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* 스와이프 힌트 */
.swipe-hint {
    animation: swipeHint 2s ease-in-out infinite;
}

@keyframes swipeHint {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(10px);
    }
}

/* ===================================
   7. 성능 최적화
   =================================== */

/* GPU 가속 */
.glass-panel,
.creature-card,
.modal-content,
#lobby-character-img {
    will-change: transform;
    transform: translateZ(0);
}

/* 애니메이션 감소 모드 지원 */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===================================
   8. PWA 상태바 대응
   =================================== */

/* iOS 노치/상태바 */
@supports (padding-top: env(safe-area-inset-top)) {
    #game-header {
        padding-top: calc(8px + env(safe-area-inset-top));
    }

    #global-bottom-nav {
        padding-bottom: calc(5px + env(safe-area-inset-bottom));
    }
}

console.log('[Mobile CSS] 모바일 최적화 스타일 로드됨');