/**
 * Jumpy 하이브리드 앱 반응형 디자인 시스템
 *
 * 브레이크포인트:
 * - Mobile: 0-767px (기본)
 * - Tablet: 768px-1023px
 * - Desktop: 1024px+
 * - Foldable (unfolded): 768px-900px (특수)
 */

/* ========================================
   1. 컨테이너 시스템 (모든 페이지 공통)
   ======================================== */

.responsive-container {
  width: 100%;
  padding: 16px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .responsive-container {
    padding: 24px;
    max-width: 720px;
  }
}

@media (min-width: 1024px) {
  .responsive-container {
    padding: 32px;
    max-width: 1200px;
  }
}

/* ========================================
   2. 타이포그래피 (자동 크기 조절)
   ======================================== */

.responsive-h1 {
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: clamp(16px, 3vw, 24px);
}

.responsive-h2 {
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: clamp(12px, 2.5vw, 20px);
}

.responsive-h3 {
  font-size: clamp(18px, 3.5vw, 24px);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: clamp(10px, 2vw, 16px);
}

.responsive-body {
  font-size: clamp(14px, 2vw, 16px);
  line-height: 1.6;
}

.responsive-small {
  font-size: clamp(12px, 1.5vw, 14px);
  line-height: 1.5;
}

/* ========================================
   3. 버튼 시스템 (터치 최적화)
   ======================================== */

.responsive-btn {
  min-height: 44px; /* iOS 권장 터치 영역 */
  min-width: 44px;
  padding: 12px 24px;
  font-size: 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

@media (min-width: 768px) {
  .responsive-btn {
    min-height: 40px;
    padding: 10px 20px;
    font-size: 15px;
  }
}

.responsive-btn-large {
  min-height: 52px;
  padding: 16px 32px;
  font-size: 18px;
}

@media (min-width: 768px) {
  .responsive-btn-large {
    min-height: 48px;
    padding: 14px 28px;
    font-size: 16px;
  }
}

/* ========================================
   4. 입력 필드 (모바일 친화적)
   ======================================== */

.responsive-input {
  width: 100%;
  min-height: 48px; /* 모바일 터치 최적화 */
  padding: 12px 16px;
  font-size: 16px; /* iOS 자동 줌 방지 (16px 필수) */
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

@media (min-width: 768px) {
  .responsive-input {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 15px;
  }
}

.responsive-input:focus {
  outline: none;
  border-color: #5a67d8;
  box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.1);
}

/* ========================================
   5. 카드/패널 시스템
   ======================================== */

.responsive-card {
  background: #ffffff;
  border-radius: clamp(8px, 1.5vw, 16px);
  padding: clamp(16px, 3vw, 24px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: clamp(16px, 2vw, 24px);
}

/* ========================================
   6. 그리드 시스템 (자동 반응형)
   ======================================== */

.responsive-grid {
  display: grid;
  gap: clamp(16px, 2vw, 24px);
}

/* 1열 (모바일) → 2열 (태블릿) → 3열 (데스크톱) */
.responsive-grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

/* 모바일: 1열, 태블릿: 2열 */
.responsive-grid-2 {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .responsive-grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 모바일: 1열, 태블릿: 2열, 데스크톱: 3열 */
.responsive-grid-3 {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .responsive-grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .responsive-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========================================
   7. 플렉스 레이아웃
   ======================================== */

.responsive-flex {
  display: flex;
  gap: clamp(12px, 2vw, 20px);
  flex-wrap: wrap;
}

/* 모바일에서 세로 배치 */
.responsive-flex-vertical-mobile {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 768px) {
  .responsive-flex-vertical-mobile {
    flex-direction: row;
    gap: 24px;
  }
}

/* ========================================
   8. 사이드바/네비게이션
   ======================================== */

.responsive-sidebar {
  width: 100%;
  position: fixed;
  left: -100%; /* 모바일: 숨김 */
  top: 0;
  bottom: 0;
  background: #ffffff;
  transition: left 0.3s ease;
  z-index: 1000;
}

.responsive-sidebar.open {
  left: 0; /* 모바일: 열림 */
}

@media (min-width: 1024px) {
  .responsive-sidebar {
    position: static;
    left: 0;
    width: 280px;
  }
}

/* ========================================
   9. 테이블 (모바일 스크롤)
   ======================================== */

.responsive-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* iOS 스무스 스크롤 */
  margin: 16px 0;
}

.responsive-table {
  width: 100%;
  min-width: 600px; /* 최소 너비 보장 */
  border-collapse: collapse;
}

/* 모바일: 카드형 테이블 */
@media (max-width: 767px) {
  .responsive-table-card thead {
    display: none;
  }

  .responsive-table-card tbody tr {
    display: block;
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
  }

  .responsive-table-card tbody td {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border: none;
  }

  .responsive-table-card tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 12px;
  }
}

/* ========================================
   10. 이미지/미디어 (반응형)
   ======================================== */

.responsive-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.responsive-video-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 비율 */
  overflow: hidden;
  border-radius: 8px;
}

.responsive-video-wrapper iframe,
.responsive-video-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ========================================
   11. 스페이싱 시스템
   ======================================== */

.responsive-spacing-xs { margin: clamp(4px, 1vw, 8px); }
.responsive-spacing-sm { margin: clamp(8px, 1.5vw, 12px); }
.responsive-spacing-md { margin: clamp(16px, 2vw, 24px); }
.responsive-spacing-lg { margin: clamp(24px, 3vw, 32px); }
.responsive-spacing-xl { margin: clamp(32px, 4vw, 48px); }

/* 상하 여백만 */
.responsive-spacing-y-md {
  margin-top: clamp(16px, 2vw, 24px);
  margin-bottom: clamp(16px, 2vw, 24px);
}

/* ========================================
   12. 모달/다이얼로그
   ======================================== */

.responsive-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.responsive-modal-content {
  background: #ffffff;
  border-radius: clamp(12px, 2vw, 20px);
  padding: clamp(20px, 3vw, 32px);
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
}

@media (min-width: 768px) {
  .responsive-modal-content {
    max-width: 600px;
  }
}

/* ========================================
   13. 숨김/표시 유틸리티
   ======================================== */

.hide-mobile {
  display: none;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: block;
  }
}

.hide-tablet {
  display: block;
}

@media (min-width: 768px) and (max-width: 1023px) {
  .hide-tablet {
    display: none;
  }
}

.hide-desktop {
  display: block;
}

@media (min-width: 1024px) {
  .hide-desktop {
    display: none;
  }
}

.show-mobile-only {
  display: block;
}

@media (min-width: 768px) {
  .show-mobile-only {
    display: none;
  }
}

/* ========================================
   14. 터치 최적화
   ======================================== */

.touch-target {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 터치 피드백 */
.touch-feedback {
  position: relative;
  overflow: hidden;
}

.touch-feedback::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
}

.touch-feedback:active::after {
  width: 200%;
  height: 200%;
}

/* ========================================
   15. 폴더블 기기 대응
   ======================================== */

/* 갤럭시 폴드 (펼친 상태: 768px) */
@media (min-width: 768px) and (max-width: 900px) {
  .foldable-optimized {
    max-width: 720px;
    margin: 0 auto;
  }
}

/* ========================================
   16. 다크모드 대응 (선택사항)
   ======================================== */

@media (prefers-color-scheme: dark) {
  .responsive-card {
    background: #1a202c;
    color: #e2e8f0;
  }

  .responsive-input {
    background: #2d3748;
    color: #e2e8f0;
    border-color: #4a5568;
  }
}

/* ========================================
   17. 안전 영역 (iOS Notch 대응)
   ======================================== */

.safe-area-padding {
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

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

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

/* 스크롤 최적화 */
.smooth-scroll {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* 탭 하이라이트 제거 (Android) */
.no-tap-highlight {
  -webkit-tap-highlight-color: transparent;
}
