﻿/* 모바일 UX 개선사항 통합 CSS */
/* Last updated: 2025-01-21 */

/* ============================================
   1. 터치 타겟 크기 최적화 (최소 44x44px)
   ============================================ */

/* 모든 클릭 가능한 요소에 최소 터치 타겟 크기 보장 */
button:not(.admin-only),
a:not(.admin-only),
input[type="button"],
input[type="submit"],
.tab-button:not(.admin-only),
.sub-tab-button:not(.admin-only),
.cert-button,
.subject-item,
.notice-link,
.btn,
.linear-header__nav-link,
.linear-header__mobile-toggle {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 작은 버튼도 터치 타겟 확보 */
@media (max-width: 768px) {
  /* 버튼 내부 패딩으로 터치 영역 확보 */
  button,
  .btn {
    padding: 12px 20px;
    min-height: 44px;
  }

  /* 탭 버튼은 tabs.css에서 별도 관리 */
  .tab-button,
  .sub-tab-button {
    min-height: 44px;
  }
  
  /* 링크도 터치 영역 확보 */
  a:not(.skip-link) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  
  /* 작은 아이콘 버튼도 터치 영역 확보 */
  .linear-header__mobile-toggle {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }
}

/* ============================================
   2. 모바일 스크롤 성능 개선
   ============================================ */

@media (max-width: 768px) {
  /* 부드러운 스크롤 */
  html {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  body {
    /* 스크롤 성능 최적화 */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  
  /* 스크롤 가능한 컨테이너 */
  .container,
  .main-content,
  .tab-content,
  .sub-tab-content {
    /* 스크롤 성능 최적화 */
    will-change: scroll-position;
    -webkit-overflow-scrolling: touch;
  }
  
  /* 카드 리스트 스크롤 최적화 */
  .subjects-list,
  .notice-list {
    -webkit-overflow-scrolling: touch;
    transform: translateZ(0);
  }
}

/* ============================================
   3. 모바일 폰트 크기 및 가독성 개선
   ============================================ */

@media (max-width: 768px) {
  /* 기본 폰트 크기 증가 */
  body {
    font-size: 16px; /* iOS Safari 최소 크기 (줌 방지) */
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  
  /* 제목 크기 조정 */
  h1 {
    font-size: 1.75rem;
    line-height: 1.3;
  }
  
  h2 {
    font-size: 1.5rem;
    line-height: 1.3;
  }
  
  h3 {
    font-size: 1.25rem;
    line-height: 1.4;
  }
  
  /* 본문 텍스트 가독성 개선 */
  p {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 1rem;
  }
  
  /* 작은 텍스트도 가독성 유지 */
  .subject-code,
  .notice-badge,
  .notice-date {
    font-size: 0.875rem; /* 최소 14px */
  }
}

@media (max-width: 480px) {
  body {
    font-size: 15px;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.25rem;
  }
  
  h3 {
    font-size: 1.125rem;
  }
}

/* ============================================
   4. 모바일 버튼/카드 터치 피드백 개선
   ============================================ */

@media (max-width: 768px) {
  /* 터치 피드백: active 상태 강화 */
  button:active,
  .btn:active,
  .tab-button:active,
  .sub-tab-button:active,
  .cert-button:active,
  .subject-item:active,
  .notice-link:active {
    transform: scale(0.98);
    opacity: 0.9;
    transition: transform 0.1s ease, opacity 0.1s ease;
  }
  
  /* 터치 피드백: hover 대신 active 사용 */
  .subject-item {
    -webkit-tap-highlight-color: rgba(95, 178, 201, 0.2);
    tap-highlight-color: rgba(95, 178, 201, 0.2);
  }
  
  /* 버튼 터치 피드백 */
  .btn,
  .tab-button,
  .sub-tab-button,
  .cert-button {
    -webkit-tap-highlight-color: rgba(95, 178, 201, 0.2);
    tap-highlight-color: rgba(95, 178, 201, 0.2);
  }
  
  /* 카드 터치 피드백 */
  .subject-item,
  .notice-item {
    -webkit-tap-highlight-color: rgba(95, 178, 201, 0.15);
    tap-highlight-color: rgba(95, 178, 201, 0.15);
  }
}

/* ============================================
   5. 모바일 탭/서브탭 스크롤 가능하도록 개선
   ============================================ */

@media (max-width: 768px) {
  /* .access-tabs 스타일은 tabs.css에서 관리 */
  
  /* 서브탭도 가로 스크롤 가능 */
  .sub-tabs {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 8px;
    margin-bottom: 24px;
  }
  
  .sub-tabs::-webkit-scrollbar {
    display: none;
  }
  
  /* 서브탭 버튼 최소 너비 보장 */
  .sub-tabs .sub-tab-button {
    flex: 0 0 auto;
    min-width: 90px;
    white-space: nowrap;
  }
}

/* ============================================
   6. 모바일 네비게이션 UX 개선
   ============================================ */

@media (max-width: 768px) {
  /* 모바일 메뉴 애니메이션 개선 */
  .linear-header__mobile-menu {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
    transform-origin: top;
  }
  
  /* 모바일 메뉴 링크 터치 영역 확보 */
  .linear-header__mobile-menu .linear-header__nav-link {
    padding: 16px 20px;
    min-height: 48px;
    font-size: 16px;
    -webkit-tap-highlight-color: rgba(95, 178, 201, 0.2);
    tap-highlight-color: rgba(95, 178, 201, 0.2);
  }
  
  /* 모바일 메뉴 링크 active 상태 */
  .linear-header__mobile-menu .linear-header__nav-link:active {
    background: rgba(95, 178, 201, 0.1);
    transform: scale(0.98);
  }
}

/* ============================================
   7. 모바일 카드/리스트 아이템 개선
   ============================================ */

@media (max-width: 768px) {
  /* 과목 아이템 터치 영역 확보 */
  .subject-item {
    padding: 20px 16px;
    min-height: 100px;
    margin-bottom: 12px;
  }
  
  /* 공지사항 아이템 터치 영역 확보 */
  .notice-link {
    padding: 16px;
    min-height: 60px;
  }
  
  /* 카드 간격 조정 */
  .subjects-list {
    gap: 12px;
    padding: 16px;
  }
  
  .notice-list {
    gap: 10px;
  }
}

/* ============================================
   8. 모바일 입력 필드 개선
   ============================================ */

@media (max-width: 768px) {
  /* 입력 필드 최소 크기 보장 */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea {
    font-size: 16px; /* iOS Safari 줌 방지 */
    min-height: 44px;
    padding: 12px 16px;
    border-radius: 8px;
  }
  
  /* 입력 필드 포커스 스타일 */
  input:focus,
  textarea:focus {
    outline: 2px solid var(--penguin-skyblue);
    outline-offset: 2px;
  }
}

/* ============================================
   9. 모바일 간격 및 패딩 최적화
   ============================================ */

@media (max-width: 768px) {
  /* 컨테이너 패딩 조정 */
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }
  
  /* 섹션 간격 조정 */
  .exam-section {
    margin-bottom: 24px;
  }
  
  /* 메인 콘텐츠 패딩 조정 */
  .main-content {
    padding-top: 20px;
    padding-bottom: 40px;
  }
}

@media (max-width: 480px) {
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }
  
  .main-content {
    padding-top: 16px;
    padding-bottom: 32px;
  }
}

/* ============================================
   10. 모바일 로딩 상태 개선
   ============================================ */

@media (max-width: 768px) {
  /* 로딩 텍스트 가독성 */
  .loading-text {
    font-size: 16px;
    padding: 24px;
  }
  
  /* 스켈레톤 로딩 (필요시) */
  .skeleton {
    background: linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.05) 25%,
      rgba(0, 0, 0, 0.1) 50%,
      rgba(0, 0, 0, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
  }
  
  @keyframes loading {
    0% {
      background-position: 200% 0;
    }
    100% {
      background-position: -200% 0;
    }
  }
}

/* ============================================
   11. 모바일 접근성 개선
   ============================================ */

@media (max-width: 768px) {
  /* 포커스 가시성 개선 */
  *:focus-visible {
    outline: 3px solid var(--penguin-skyblue);
    outline-offset: 2px;
    border-radius: 4px;
  }
  
  /* 스킵 링크 모바일 최적화 */
  .skip-link:focus {
    position: fixed;
    left: 16px;
    top: 16px;
    z-index: 10000;
    padding: 12px 16px;
    font-size: 16px;
  }
}

/* ============================================
   12. 모바일 성능 최적화
   ============================================ */

@media (max-width: 768px) {
  /* 하드웨어 가속 */
  .subject-item,
  .notice-item,
  .tab-button,
  .sub-tab-button {
    will-change: transform;
  }
  
  /* 애니메이션 감소 설정 지원 */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms;
      animation-iteration-count: 1;
      transition-duration: 0.01ms;
    }
  }
}

