/* ============================================================================
   의정활동지수 v4.0 — Design System & Base Styles
   
   Design Philosophy:
   - Light mode default (밝고 신뢰감 있는 디자인)
   - 다크모드 지원 (data-theme="dark")
   - 정치적 중립 색상 (Navy + Slate + Teal accent)
   - WCAG AA 접근성 준수
   - 데이터 가독성 최우선
   ============================================================================ */

/* ─── CSS Custom Properties (Design Tokens) ─── */
:root {
  /* Brand Colors — 정치적 중립, 신뢰감 */
  --brand-50:  #f0f7ff;
  --brand-100: #e0effe;
  --brand-200: #baddfd;
  --brand-300: #7dc2fc;
  --brand-400: #38a3f8;
  --brand-500: #0e87e9;
  --brand-600: #0269c7;
  --brand-700: #0354a1;
  --brand-800: #074885;
  --brand-900: #0c3d6e;

  /* Accent — Teal (중립적이고 현대적) */
  --accent-50:  #effefb;
  --accent-100: #c8fff4;
  --accent-200: #91feea;
  --accent-300: #52f5db;
  --accent-400: #20e0c7;
  --accent-500: #07c4ad;
  --accent-600: #029e8e;
  --accent-700: #067e73;
  --accent-800: #0a645d;
  --accent-900: #0d524d;

  /* Neutral (Slate) */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --gray-950: #020617;

  /* Semantic Colors */
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger:  #dc2626;
  --danger-light: #fee2e2;
  --info:    #0284c7;
  --info-light: #e0f2fe;

  /* Score Category Colors (색맹 배려 팔레트) */
  --score-attendance:   #2563eb;
  --score-legislation:  #7c3aed;
  --score-progress:     #0891b2;
  --score-performance:  #c2410c;
  --score-news:         #0f766e;
  --score-likes:        #be185d;
  --score-career:       #9333ea;

  /* Party Colors */
  --party-democratic:   #004EA2;
  --party-ppp:          #E61E2B;
  --party-jukuk:        #003DA5;
  --party-reform:       #FF6D00;
  --party-progressive:  #D6001C;
  --party-basic:        #00C73C;
  --party-social:       #E85312;
  --party-independent:  #78716c;

  /* Light Theme Surfaces */
  --bg-primary:    #ffffff;
  --bg-secondary:  #f8fafc;
  --bg-tertiary:   #f1f5f9;
  --bg-elevated:   #ffffff;
  --bg-overlay:    rgba(15, 23, 42, 0.5);
  --bg-hero:       linear-gradient(135deg, #0c3d6e 0%, #074885 40%, #0269c7 100%);

  /* Text Colors */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-tertiary:  #64748b;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;
  --text-link:      #0269c7;

  /* Borders */
  --border-default: #e2e8f0;
  --border-light:   #f1f5f9;
  --border-strong:  #cbd5e1;
  --border-focus:   #0e87e9;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl:  0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 8px 30px rgba(14, 135, 233, 0.12);

  /* Radius */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Typography */
  --font-sans: 'Pretendard Variable', 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  /* Layout */
  --header-height: 64px;
  --max-width: 1280px;
  --sidebar-width: 320px;
}

/* ─── Dark Theme ─── */
[data-theme="dark"] {
  --bg-primary:    #0f172a;
  --bg-secondary:  #1e293b;
  --bg-tertiary:   #334155;
  --bg-elevated:   #1e293b;
  --bg-overlay:    rgba(0, 0, 0, 0.6);
  --bg-hero:       linear-gradient(135deg, #020617 0%, #0f172a 40%, #1e293b 100%);

  --text-primary:   #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary:  #94a3b8;
  --text-muted:     #64748b;
  --text-inverse:   #0f172a;
  --text-link:      #38a3f8;

  --border-default: #334155;
  --border-light:   #1e293b;
  --border-strong:  #475569;

  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:  0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg:  0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl:  0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 8px 30px rgba(14, 135, 233, 0.2);

  --success-light: rgba(22, 163, 74, 0.15);
  --warning-light: rgba(217, 119, 6, 0.15);
  --danger-light:  rgba(220, 38, 38, 0.15);
  --info-light:    rgba(2, 132, 199, 0.15);
}

/* ─── Global Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ─── Typography Scale ─── */
h1, h2, h3, h4, h5, h6 { line-height: 1.3; font-weight: 700; color: var(--text-primary); }
h1 { font-size: 1.875rem; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; letter-spacing: -0.015em; }
h3 { font-size: 1.25rem; letter-spacing: -0.01em; }
h4 { font-size: 1.125rem; }

p { color: var(--text-secondary); line-height: 1.7; }

/* ─── Links ─── */
a { color: var(--text-link); text-decoration: none; transition: color var(--duration-fast); }
a:hover { color: var(--brand-500); }

/* ─── Selection ─── */
::selection { background: rgba(14, 135, 233, 0.15); color: var(--text-primary); }

/* ─── Focus ─── */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--gray-900); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--gray-600); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ─── Transitions ─── */
.transition-colors { transition: color var(--duration-fast), background-color var(--duration-fast), border-color var(--duration-fast); }
.transition-all { transition: all var(--duration-normal) var(--ease-out); }
.transition-transform { transition: transform var(--duration-normal) var(--ease-out); }

/* ─── Animations ─── */
@keyframes fadeIn { 
  from { opacity: 0; transform: translateY(12px); } 
  to { opacity: 1; transform: translateY(0); } 
}
@keyframes fadeInUp { 
  from { opacity: 0; transform: translateY(24px); } 
  to { opacity: 1; transform: translateY(0); } 
}
@keyframes slideDown { 
  from { opacity: 0; transform: translateY(-8px); } 
  to { opacity: 1; transform: translateY(0); } 
}
@keyframes scaleIn { 
  from { opacity: 0; transform: scale(0.96); } 
  to { opacity: 1; transform: scale(1); } 
}
@keyframes shimmer { 
  0% { background-position: -200% 0; } 
  100% { background-position: 200% 0; } 
}
@keyframes pulse { 
  0%, 100% { opacity: 1; } 
  50% { opacity: 0.5; } 
}
@keyframes heartBeat { 
  0% { transform: scale(1); } 
  25% { transform: scale(1.25); } 
  50% { transform: scale(1); } 
  75% { transform: scale(1.12); } 
  100% { transform: scale(1); } 
}
@keyframes heartFloat { 
  0% { opacity: 1; transform: translateY(0) scale(1); } 
  100% { opacity: 0; transform: translateY(-50px) scale(0.6); } 
}
@keyframes countUp { 
  from { transform: translateY(8px); opacity: 0; } 
  to { transform: translateY(0); opacity: 1; } 
}
@keyframes spin { 
  to { transform: rotate(360deg); } 
}
@keyframes progressFill {
  from { width: 0; }
}
@keyframes numberReveal {
  from { opacity: 0; transform: translateY(20px) scale(0.8); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.animate-fadeIn { animation: fadeIn 0.4s var(--ease-out) both; }
.animate-fadeInUp { animation: fadeInUp 0.5s var(--ease-out) both; }
.animate-slideDown { animation: slideDown 0.3s var(--ease-out) both; }
.animate-scaleIn { animation: scaleIn 0.3s var(--ease-out) both; }
.animate-heartBeat { animation: heartBeat 0.6s ease-in-out; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-numberReveal { animation: numberReveal 0.6s var(--ease-spring) both; }

/* Stagger animation delays */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.20s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.30s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.40s; }

/* ─── Loading ─── */
#loading-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg-primary);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s var(--ease-out);
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
#loading-overlay .spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-default);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── Utility Classes ─── */
.glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}
[data-theme="dark"] .glass {
  background: rgba(15, 23, 42, 0.7);
  border-color: rgba(148, 163, 184, 0.1);
}

.shimmer {
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-default) 50%, var(--bg-tertiary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.text-gradient {
  background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Number/Data emphasis */
.data-number {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  font-weight: 800;
}

/* ─── Print ─── */
@media print {
  .no-print, .app-header, .app-footer, #toast-container, .heart-btn { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ccc; box-shadow: none; background: #fff; }
}
