/* ==========================================================================
   STEP 3: Visual Design & Micro-animation (Glassmorphism 2.0 / WCAG AA)
   style.css 이후에 로드되어 기존 디자인 시스템을 확장/보정합니다.
   ========================================================================== */

/* --- WCAG AA contrast corrections (text >= 4.5:1) --- */
:root {
  --text-subtle: #8F98A9;          /* on #0B0F19 ≈ 6.3:1 */
  --primary-strong: #4F46E5;       /* white text ≈ 6.3:1 */
  --glass-blur: blur(16px) saturate(140%);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  --glass-glow: 0 0 0 1px rgba(129, 140, 248, 0.35), 0 8px 32px rgba(99, 102, 241, 0.28);
}
[data-theme="light"] {
  --text-subtle: #5B6B80;          /* on #FFF ≈ 5.5:1 */
  --text-muted: #546275;
  --primary-light: #4338CA;        /* ≈ 8:1 on white */
  --secondary: #0369A1;            /* ≈ 5.9:1 on white */
  --success: #047857;              /* ≈ 5.5:1 on white */
  --success-bg: rgba(4, 120, 87, 0.12);
  --warning: #B45309;
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  --glass-glow: 0 0 0 1px rgba(79, 70, 229, 0.3), 0 8px 28px rgba(79, 70, 229, 0.18);
}
[data-theme="light"] .rfm-card.grade-a .rfm-badge { color: #4338CA; }
[data-theme="light"] .rfm-card.grade-b .rfm-badge { color: #0E7490; }
[data-theme="light"] .rfm-card.grade-c .rfm-badge { color: #047857; }
[data-theme="light"] .rfm-card.grade-d .rfm-badge { color: #92400E; }
[data-theme="light"] .metric-tag.recency.alert { color: #92400E; }
[data-theme="light"] .rank-1 { color: #92400E; }
[data-theme="light"] .rank-2 { color: #374151; }
[data-theme="light"] .rank-3 { color: #7C2D12; }
[data-theme="light"] .highlight-badge-pill.gold { color: #92400E; }
[data-theme="light"] .custom-table th,
[data-theme="light"] .custom-table tr:hover td { background: rgba(15, 23, 42, 0.04); }
.tab-btn.active,
.filter-pill-btn.active,
.action-btn.primary { background: var(--primary-strong); color: #FFFFFF; }

/* --- Glass 2.0: blur 16px + inner highlight --- */
.kpi-card, .chart-card, .filter-toolbar, .rfm-card, .highlight-card, .target-gauge-card {
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-md), var(--glass-highlight);
}

/* --- Hover: subtle scale-up + glass glow --- */
.kpi-card, .rfm-card, .highlight-card, .chart-card, .target-gauge-card {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease,
              border-color 0.25s ease, background 0.25s ease;
}
.kpi-card:hover, .rfm-card:hover, .highlight-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--border-focus);
  box-shadow: var(--shadow-xl), var(--glass-glow), var(--glass-highlight);
}
.chart-card:hover, .target-gauge-card:hover {
  transform: translateY(-2px) scale(1.005);
  box-shadow: var(--shadow-xl), var(--glass-glow), var(--glass-highlight);
}
.action-btn, .filter-pill-btn, .tab-btn, .subnav-tab-btn {
  transition: transform 0.18s ease, box-shadow 0.2s ease, background 0.18s ease, color 0.18s ease;
}
.action-btn:hover, .filter-pill-btn:hover, .tab-btn:hover {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 4px 16px var(--primary-glow);
}
.action-btn:active, .filter-pill-btn:active, .tab-btn:active { transform: scale(0.97); }

/* --- Stronger color pulse on value change --- */
.kpi-pulse { animation: valuePulse 0.9s ease-out; }
@keyframes valuePulse {
  0%   { transform: scale(1); filter: brightness(1); text-shadow: 0 0 0 transparent; }
  30%  { transform: scale(1.06); filter: brightness(1.35); color: var(--primary-light);
         text-shadow: 0 0 18px var(--primary-glow); }
  100% { transform: scale(1); filter: brightness(1); text-shadow: 0 0 0 transparent; }
}

/* --- Target Progress Gauge --- */
.target-gauge-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.target-gauge-card.achieved::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(16, 185, 129, 0.12) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: gaugeShine 3.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes gaugeShine { from { background-position: 200% 0; } to { background-position: -100% 0; } }
.gauge-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 14px; position: relative;
}
.gauge-title { font-size: 15px; font-weight: 700; }
.gauge-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.gauge-badge {
  font-size: 13px; font-weight: 700; padding: 5px 14px; border-radius: var(--radius-full);
  background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.4);
  transition: background 0.4s ease, color 0.4s ease;
}
.gauge-badge.achieved {
  background: var(--success-bg); color: var(--success);
  border-color: rgba(16, 185, 129, 0.5);
  animation: badgePop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes badgePop { 0% { transform: scale(0.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.gauge-track {
  position: relative; height: 18px; border-radius: var(--radius-full);
  background: var(--bg-surface-elevated); border: 1px solid var(--border-subtle); overflow: hidden;
}
.gauge-fill {
  height: 100%; width: 0; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  box-shadow: 0 0 14px var(--primary-glow);
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1), background 0.4s ease;
}
.gauge-fill.achieved { background: linear-gradient(90deg, #10B981, #34D399, #06B6D4); box-shadow: 0 0 16px rgba(16, 185, 129, 0.5); }
.gauge-scale {
  display: flex; justify-content: space-between; margin-top: 8px;
  font-size: 12px; color: var(--text-muted); font-feature-settings: "tnum";
}
.gauge-scale strong { color: var(--text-main); }
.gauge-pct { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; font-feature-settings: "tnum"; }

@media (max-width: 600px) {
  .gauge-pct { font-size: 22px; }
  .kpi-card:hover, .rfm-card:hover, .highlight-card:hover { transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .kpi-pulse, .gauge-badge.achieved, .target-gauge-card.achieved::before { animation: none; }
  .gauge-fill { transition: none; }
  .kpi-card:hover, .rfm-card:hover, .highlight-card:hover, .chart-card:hover { transform: none; }
}
