/**
 * 모바일 최적화 스타일
 * Phase 8.1: 시스템 안정화
 */

/* ======================
   기본 반응형 설정
   ====================== */

/* 모바일 터치 최적화 */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

button, a, input, select, textarea {
    touch-action: manipulation;
}

/* 텍스트 선택 방지 (UI 요소) */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ======================
   반응형 레이아웃
   ====================== */

/* 모바일 (< 640px) */
@media (max-width: 640px) {
    /* 컨테이너 */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* 텍스트 크기 조정 */
    h1 {
        font-size: 1.875rem; /* 30px */
        line-height: 2.25rem;
    }
    
    h2 {
        font-size: 1.5rem; /* 24px */
        line-height: 2rem;
    }
    
    h3 {
        font-size: 1.25rem; /* 20px */
        line-height: 1.75rem;
    }
    
    /* 버튼 크기 조정 */
    button, .btn {
        min-height: 44px; /* iOS 터치 최소 크기 */
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* 카드 간격 조정 */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* 비디오 컨테이너 */
    .video-container {
        max-height: 60vh;
        margin-bottom: 1rem;
    }
    
    /* 면접관 패널 */
    .interviewer-panel {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .interviewer-card {
        padding: 1rem;
    }
    
    .interviewer-avatar {
        width: 60px !important;
        height: 60px !important;
    }
    
    /* 메트릭 카드 */
    .metric-card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    /* 질문 영역 */
    #questionText {
        font-size: 1.125rem; /* 18px */
        line-height: 1.75rem;
    }
    
    /* 컨트롤 버튼 그룹 */
    .control-buttons {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    .control-buttons button {
        width: 100%;
    }
    
    /* Toast 알림 */
    .feedback-toast {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
    
    /* 모달 */
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
    
    /* 네비게이션 */
    nav {
        flex-direction: column;
        padding: 0.5rem;
    }
    
    nav a {
        padding: 0.75rem;
        width: 100%;
        text-align: center;
    }
}

/* 태블릿 (640px - 1024px) */
@media (min-width: 640px) and (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .interviewer-panel {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .video-container {
        max-height: 70vh;
    }
}

/* 데스크탑 (> 1024px) */
@media (min-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }
    
    .interviewer-panel {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ======================
   모바일 비디오 최적화
   ====================== */

@media (max-width: 640px) {
    video {
        width: 100%;
        height: auto;
        max-height: 60vh;
        object-fit: cover;
    }
    
    canvas {
        max-height: 60vh;
    }
    
    /* 비디오 오버레이 */
    .video-overlay {
        display: none; /* 모바일에서 오버레이 숨김 */
    }
}

/* ======================
   터치 제스처 지원
   ====================== */

.swipeable {
    touch-action: pan-y;
}

.draggable {
    cursor: grab;
    touch-action: none;
}

.draggable:active {
    cursor: grabbing;
}

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

/* GPU 가속 */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

/* 애니메이션 성능 최적화 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ======================
   접근성
   ====================== */

/* 포커스 표시 */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #a78bfa;
    outline-offset: 2px;
}

/* 스크린 리더 전용 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ======================
   다크 모드 지원
   ====================== */

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #a0a0a0;
    }
    
    body {
        background-color: var(--bg-primary);
        color: var(--text-primary);
    }
}

/* ======================
   로딩 상태
   ====================== */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ======================
   커스텀 스크롤바 (WebKit)
   ====================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(167, 139, 250, 0.7);
}

/* ======================
   인쇄 스타일
   ====================== */

@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a {
        text-decoration: underline;
    }
}

/* ======================
   유틸리티 클래스
   ====================== */

/* 숨김 */
.hidden {
    display: none !important;
}

.invisible {
    visibility: hidden;
}

/* 간격 */
.spacing-mobile {
    margin: 0.5rem;
}

@media (min-width: 640px) {
    .spacing-mobile {
        margin: 1rem;
    }
}

@media (min-width: 1024px) {
    .spacing-mobile {
        margin: 1.5rem;
    }
}

/* 전체 너비 (모바일) */
.full-width-mobile {
    width: 100%;
}

@media (min-width: 640px) {
    .full-width-mobile {
        width: auto;
    }
}

/* 텍스트 줄바꿈 */
.text-wrap {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* 텍스트 말줄임 */
.text-ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 멀티라인 말줄임 */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ======================
   안전 영역 (iOS)
   ====================== */

@supports (padding: max(0px)) {
    .safe-area-inset {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}
