/* ==========================================================================
   오늘배움 통합 디자인 시스템 v2.0
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Noto+Sans+KR:wght@400;500;600;700;800;900&display=swap');

/* ==========================================================================
   디자인 토큰 - 단일 소스 오브 트루스
   ========================================================================== */

:root {
  /* 🎨 브랜드 컬러 시스템 */
  --brand-primary: #667eea;
  --brand-primary-dark: #5a67d8;
  --brand-primary-light: #a5b4fc;
  --brand-secondary: #764ba2;
  --brand-accent: #10b981;
  --brand-accent-light: #34d399;
  
  /* 🌈 상태 컬러 */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-info: #3b82f6;
  
  /* 🖤 뉴트럴 컬러 */
  --color-white: #ffffff;
  --color-black: #000000;
  --color-gray-50: #fafafa;
  --color-gray-100: #f5f5f5;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;
  
  /* 📝 텍스트 컬러 */
  --text-primary: #1a1a1a;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --text-inverse: #ffffff;
  --text-link: var(--brand-primary);
  --text-link-hover: var(--brand-primary-dark);
  
  /* 🎨 배경 컬러 */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  
  /* ✨ 글래스모피즘 */
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  
  /* 🌈 그라디언트 */
  --gradient-primary: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
  --gradient-accent: linear-gradient(135deg, var(--brand-accent) 0%, #059669 100%);
  --gradient-warm: linear-gradient(135deg, var(--color-warning) 0%, #d97706 100%);
  --gradient-surface: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  --gradient-hero: radial-gradient(1200px 600px at 10% -20%, rgba(102, 126, 234, 0.15), transparent),
                   radial-gradient(900px 500px at 90% 0%, rgba(16, 185, 129, 0.12), transparent),
                   linear-gradient(180deg, #fafafa 0%, #f4f4f5 100%);
  
  /* 🔲 보더 및 반지름 */
  --border-color: #e5e7eb;
  --border-light: #f3f4f6;
  --border-focus: var(--brand-primary);
  --radius-sm: 0.5rem;   /* 8px */
  --radius-md: 1rem;     /* 16px */
  --radius-lg: 1.5rem;   /* 24px */
  --radius-xl: 2rem;     /* 32px */
  --radius-full: 9999px;
  
  /* 🌟 그림자 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.15);
  
  /* 📏 간격 시스템 */
  --space-1: 0.25rem;    /* 4px */
  --space-2: 0.5rem;     /* 8px */
  --space-3: 0.75rem;    /* 12px */
  --space-4: 1rem;       /* 16px */
  --space-5: 1.25rem;    /* 20px */
  --space-6: 1.5rem;     /* 24px */
  --space-8: 2rem;       /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */
  --space-20: 5rem;      /* 80px */
  --space-24: 6rem;      /* 96px */
  --space-32: 8rem;      /* 128px */
  
  /* 📱 타이포그래피 */
  --font-family-primary: 'Inter', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-family-heading: 'Inter', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  
  /* 📏 폰트 크기 - 반응형 (Mobile First) */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);      /* 12px → 14px */
  --text-sm: clamp(0.875rem, 0.8rem + 0.4vw, 1rem);          /* 14px → 16px */
  --text-base: clamp(1rem, 0.95rem + 0.3vw, 1.125rem);       /* 16px → 18px */
  --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.5rem);          /* 18px → 24px */
  --text-xl: clamp(1.25rem, 1.1rem + 0.8vw, 2rem);           /* 20px → 32px */
  --text-2xl: clamp(1.5rem, 1.3rem + 1vw, 2.5rem);           /* 24px → 40px */
  --text-3xl: clamp(1.875rem, 1.5rem + 1.5vw, 3rem);         /* 30px → 48px */
  --text-4xl: clamp(2.25rem, 1.8rem + 2vw, 3.5rem);          /* 36px → 56px */
  --text-5xl: clamp(2.5rem, 2rem + 2.5vw, 4rem);             /* 40px → 64px */
  --text-6xl: clamp(3rem, 2.5rem + 3vw, 5rem);               /* 48px → 80px */
  
  /* 🏋️ 폰트 굵기 */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;
  --font-black: 900;
  
  /* 📏 라인 높이 */
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;
  
  /* ⚡ 트랜지션 */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 200ms ease-in-out;
  --transition-slow: 300ms ease-in-out;
  --transition-bounce: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* 📐 Z-Index */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;
  
  /* 📱 브레이크포인트 */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
  
  /* 🎛️ 컨테이너 */
  --container-max-width: 1200px;
  --container-padding: var(--space-6);
  --header-height: 80px;
}

/* ==========================================================================
   기본 리셋 및 글로벌 스타일
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
}

/* ==========================================================================
   레이아웃 컴포넌트
   ========================================================================== */

.container {
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.section {
  position: relative;
  padding: var(--space-24) 0;
}

.section.is-tight {
  padding: var(--space-16) 0;
}

.section.is-spacious {
  padding: var(--space-32) 0;
}

/* ==========================================================================
   타이포그래피 컴포넌트
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p {
  margin-bottom: var(--space-4);
  line-height: var(--leading-relaxed);
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--text-link-hover);
}

/* ==========================================================================
   버튼 컴포넌트
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-family: var(--font-family-primary);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-bounce);
  white-space: nowrap;
}

.btn:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--gradient-primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--brand-primary);
}

.btn-accent {
  background: var(--gradient-accent);
  color: var(--text-inverse);
  box-shadow: var(--shadow-md);
}

.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-large {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
}

.btn-small {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

/* ==========================================================================
   카드 컴포넌트
   ========================================================================== */

.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-bounce);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* ==========================================================================
   그리드 시스템
   ========================================================================== */

.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

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

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

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

/* 텍스트 정렬 */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* 텍스트 크기 */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }

/* 텍스트 색상 */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-brand { color: var(--brand-primary); }
.text-accent { color: var(--brand-accent); }

/* 간격 */
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

/* 디스플레이 */
.hidden { display: none; }
.block { display: block; }
.flex { display: flex; }
.grid { display: grid; }

/* 애니메이션 */
.animate-fade-in {
  animation: fadeIn 0.6s ease-out;
}

.animate-slide-up {
  animation: slideUp 0.6s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { 
    opacity: 0; 
    transform: translateY(30px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

/* ==========================================================================
   반응형 디자인
   ========================================================================== */

@media (max-width: 768px) {
  :root {
    --container-padding: var(--space-4);
    --text-4xl: 2rem;
    --text-3xl: 1.5rem;
    --text-2xl: 1.25rem;
  }
  
  .section {
    padding: var(--space-16) 0;
  }
}

/* ==========================================================================
   다크 모드 지원 (미래 확장용)
   ========================================================================== */

/* ==========================================================================
   터치 인터랙션 & 접근성
   ========================================================================== */

/* 터치 하이라이트 색상 */
* {
  -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
}

/* 모든 인터랙티브 요소 */
a,
button,
[role="button"],
[type="button"],
[type="submit"],
input[type="checkbox"],
input[type="radio"],
select {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

/* 포커스 표시 (키보드 네비게이션) */
*:focus-visible {
  outline: 3px solid var(--brand-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 버튼 및 링크 터치 피드백 */
button:not(:disabled),
a:not([aria-disabled="true"]),
[role="button"]:not([aria-disabled="true"]) {
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:active:not(:disabled),
a:active:not([aria-disabled="true"]),
[role="button"]:active:not([aria-disabled="true"]) {
  transform: scale(0.97);
}

/* 터치 디바이스 전용 스타일 */
@media (hover: none) and (pointer: coarse) {
  /* 터치 디바이스에서 호버 효과 제거 */
  button:hover,
  a:hover {
    transform: none;
  }

  /* 탭 시 더 강한 피드백 */
  button:active:not(:disabled),
  a:active:not([aria-disabled="true"]) {
    opacity: 0.8;
    transform: scale(0.95);
  }
}

/* 모션 민감성 사용자 배려 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --border-color: #374151;
  }
}
