/* =====================================================================
   LIVE DATA Widget v2.1 — Animation Styles (Quick tick + Drift)
   Approach B per Coder's UX feedback:
     - Phase 1: 0 → ~90% in 4s (feels fast, grabby — user sees change)
     - Phase 2: 90% → 100% drift over 56s (real-time data feel)
     - Total: ~60s as owner requested
   JS controls counter + chart line; CSS controls pulse + fade-in
   Brand: Navy #0B1F3A + Gold #FFC000
===================================================================== */

.live-widget {
  background: #0B1F3A;
  border-radius: 22px;
  padding: 18px;
  color: #fff;
  font-family: 'Inter', 'Noto Sans Thai', sans-serif;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(11, 31, 58, 0.35);
}

.live-widget__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.live-widget__brand { color: #FFC000; }

/* ---- LIVE dot pulse — unchanged ---- */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #FFC000;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #FFC000;
  position: relative;
  animation: live-pulse 1.8s ease-in-out infinite;
}
.live-dot::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: #FFC000;
  opacity: 0.4;
  animation: live-pulse-ring 1.8s ease-out infinite;
}
@keyframes live-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(0.85); opacity: 0.7; }
}
@keyframes live-pulse-ring {
  0%   { transform: scale(0.6); opacity: 0.6; }
  100% { transform: scale(2.4); opacity: 0;   }
}

.live-widget__metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.metric {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  color: #0B1F3A;
}
.metric small {
  display: block;
  color: #64748B;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.metric strong {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  color: #0B1F3A;
  font-variant-numeric: tabular-nums;
  animation: count-entry 0.6s ease-out 0.2s both;
}
.metric strong[data-direction="down"] { color: #00875A; }
@keyframes count-entry {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0);  }
}

/* ---- Chart card ---- */
.live-widget__chart-wrap {
  background: linear-gradient(180deg, #183D69, #102B4C);
  border-radius: 10px;
  padding: 14px;
  position: relative;
  overflow: hidden;
}
.live-widget__chart-label {
  position: absolute;
  top: 10px; left: 12px;
  font-size: 9px; font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.live-widget__chart {
  width: 100%;
  height: 120px;
  display: block;
  overflow: visible;
}

/* ---- Chart line + area + dot ----
   JS controls stroke-dashoffset directly for the quick-tick + drift timing.
   CSS only handles initial state and the final end-dot pop. */
.chart-line {
  fill: none;
  stroke: #FFC000;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-area {
  fill: #FFC000;
  opacity: 0;
  /* Area appears after quick tick phase (4s) — feels natural */
  transition: opacity 1.2s ease-out;
}
.chart-area.show { opacity: 0.12; }
.chart-end-dot {
  fill: #FFC000;
  opacity: 0;
  transform-origin: 400px 15px;
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}
.chart-end-dot.show {
  opacity: 1;
  transform: scale(1);
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .live-dot,
  .live-dot::before,
  .metric strong {
    animation: none !important;
  }
}
