/**
 * 모바일 최적화 CSS
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * 터치 친화적 UI, 반응형 디자인
 */

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1. 기본 모바일 설정
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

* {
    /* 터치 하이라이트 제거 */
    -webkit-tap-highlight-color: transparent;
}

html {
    /* 부드러운 스크롤 */
    -webkit-overflow-scrolling: touch;
}

body {
    /* iOS 텍스트 크기 자동 조정 방지 */
    -webkit-text-size-adjust: 100%;

    /* Safe Area (노치 대응) */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   2. 터치 친화적 버튼
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

button,
.btn,
a.btn {
    /* 최소 터치 영역: 44x44px (Apple 권장) */
    min-height: 44px;

    /* 터치 피드백 */
    transition: transform 0.1s ease;
}

button:active,
.btn:active {
    transform: scale(0.96);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   3. 입력 필드 최적화
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

input,
textarea,
select {
    /* iOS 자동 확대 방지 - 16px 이상 필수! */
    font-size: 16px !important;

    /* iOS 기본 스타일 제거 */
    -webkit-appearance: none;
    appearance: none;

    /* 터치 영역 */
    min-height: 44px;
    padding: 12px 16px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   4. 모바일 전용 컴포넌트
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* 하단 네비게이션 바 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;

    display: none;
    justify-content: space-around;

    background: white;
    border-top: 1px solid var(--bg-tertiary, #EDE8E0);
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));

    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;

    padding: 8px 16px;
    min-width: 60px;

    text-decoration: none;
    color: #999;

    transition: color 0.2s ease;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-icon {
    font-size: 24px;
}

.bottom-nav-label {
    font-size: 11px;
}

/* 플로팅 액션 버튼 (FAB) */
.fab {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: 16px;

    width: 56px;
    height: 56px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--primary);
    color: var(--text-inverse, white);

    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);

    font-size: 24px;
    text-decoration: none;

    z-index: 999;

    transition: all 0.3s ease;
}

.fab:active {
    transform: scale(0.9);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   5. 반응형 레이아웃
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

@media (max-width: 768px) {
    /* 컨테이너 여백 축소 */
    .container {
        padding: 1rem;
    }

    /* 폰트 크기 조정 */
    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.2rem; }

    /* 모달 전체 화면 */
    .modal {
        width: 100%;
        max-width: none;
        height: 100vh;
        border-radius: 0;
    }

    /* 하단 네비 있을 때 여백 */
    body.has-bottom-nav {
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
    }

    /* 하단 네비 표시 */
    .bottom-nav {
        display: flex;
    }
}

@media (max-width: 480px) {
    /* 작은 화면 최적화 */
    .container {
        padding: 0.75rem;
    }

    /* 버튼 전체 너비 */
    .btn-block {
        width: 100%;
        display: block;
    }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   6. PWA Standalone 모드
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

@media all and (display-mode: standalone) {
    /* 상단 여백 추가 (상태바 공간) */
    body {
        padding-top: env(safe-area-inset-top);
    }

    /* 네비게이션 바 상단 고정 시 */
    .navbar {
        padding-top: env(safe-area-inset-top);
    }
}

/* iOS Safari에서 standalone 모드 */
@supports (-webkit-touch-callout: none) {
    body.standalone {
        padding-top: constant(safe-area-inset-top);
        padding-top: env(safe-area-inset-top);
    }
}
