/* Frontier-style animated charts — cream canvas, metal/blue ink */

.vx-chart {
  --vx-ink: #2c2c2c;
  --vx-muted: #5a6168;
  --vx-line: rgba(44, 44, 44, 0.1);
  --vx-paper: #fffdf6;
  --vx-cloud: #6b7280;
  --vx-cloud-soft: rgba(107, 114, 128, 0.14);
  --vx-vivral: #3d5a80;
  --vx-vivral-soft: rgba(93, 153, 198, 0.22);
  --vx-accent: #f2907a;
  --vx-good: #4a7c59;
  --vx-ease: cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  margin: 0;
  padding: clamp(22px, 3vw, 32px);
  background: var(--vx-paper);
  border: 1px solid var(--vx-line);
  border-radius: 20px;
  box-shadow: 0 18px 48px rgba(17, 19, 22, 0.06);
  overflow: hidden;
}

.vx-chart::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(93, 153, 198, 0.08), transparent 60%),
    radial-gradient(ellipse 40% 35% at 0% 100%, rgba(242, 144, 122, 0.06), transparent 55%);
}

.vx-chart-head {
  position: relative;
  z-index: 1;
  margin-bottom: 18px;
}

.vx-chart-kicker {
  margin: 0 0 6px;
  color: var(--vx-vivral);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.vx-chart-head h3,
.vx-chart-title {
  margin: 0;
  color: var(--vx-ink);
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.vx-chart-sub {
  margin: 8px 0 0;
  color: var(--vx-muted);
  font-size: 0.92rem;
  line-height: 1.45;
  max-width: 42ch;
}

.vx-chart-body {
  position: relative;
  z-index: 1;
}

.vx-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.vx-chart-legend {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  margin-top: 16px;
  padding: 0;
  list-style: none;
}

.vx-chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--vx-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.vx-swatch {
  width: 18px;
  height: 3px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.vx-swatch.cloud {
  background: var(--vx-cloud);
}

.vx-swatch.vivral {
  background: var(--vx-vivral);
}

.vx-swatch.accent {
  background: var(--vx-accent);
}

/* Big stat row */
.vx-stat-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.vx-stat {
  padding: 14px 14px 16px;
  background: rgba(244, 241, 225, 0.55);
  border: 1px solid var(--vx-line);
  border-radius: 14px;
}

.vx-stat-value {
  display: block;
  color: var(--vx-ink);
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.vx-stat-value em {
  font-style: normal;
  color: var(--vx-good);
}

.vx-stat-label {
  display: block;
  margin-top: 6px;
  color: var(--vx-muted);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
}

/* SVG draw defaults */
.vx-grid line {
  stroke: rgba(44, 44, 44, 0.08);
  stroke-width: 1;
}

.vx-axis-label {
  fill: var(--vx-muted);
  font-size: 11px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

.vx-line {
  fill: none;
  stroke-width: 2.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.vx-line.cloud {
  stroke: var(--vx-cloud);
}

.vx-line.vivral {
  stroke: var(--vx-vivral);
}

.vx-area.cloud {
  fill: url(#vxCloudFill);
}

.vx-area.vivral {
  fill: url(#vxVivralFill);
}

.vx-dot {
  stroke: var(--vx-paper);
  stroke-width: 2.5;
}

.vx-dot.cloud {
  fill: var(--vx-cloud);
}

.vx-dot.vivral {
  fill: var(--vx-vivral);
}

/* Lines + dots are driven by JS (lockstep). Soft defaults only. */
.js .vx-chart:not(.is-drawn) .vx-line {
  stroke-dasharray: var(--path-len, 1200);
  stroke-dashoffset: var(--path-len, 1200);
}

.js .vx-chart:not(.is-drawn) .vx-area {
  opacity: 0;
}

.js .vx-chart.is-drawn .vx-area {
  animation: vx-fade-area 1s var(--vx-ease) 0.4s both;
}

/* Dots ride the path — no pop-in jump */
.js .vx-chart .vx-dot {
  opacity: 0;
  transition: opacity 180ms ease;
}

.js .vx-chart.is-drawn .vx-dot.is-riding {
  opacity: 1;
}

.js .vx-chart.is-drawn .vx-dot.is-settled {
  filter: drop-shadow(0 2px 4px rgba(17, 19, 22, 0.18));
}

.js .vx-chart:not(.is-drawn) .vx-bar {
  transform: scaleY(0);
  transform-box: fill-box;
  transform-origin: bottom center;
}

.js .vx-chart.is-drawn .vx-bar {
  animation: vx-grow-bar 1s var(--vx-ease) both;
}

.js .vx-chart.is-drawn rect.vx-bar:nth-of-type(1) { animation-delay: 0.12s; }
.js .vx-chart.is-drawn rect.vx-bar:nth-of-type(2) { animation-delay: 0.24s; }
.js .vx-chart.is-drawn rect.vx-bar:nth-of-type(3) { animation-delay: 0.36s; }
.js .vx-chart.is-drawn rect.vx-bar:nth-of-type(4) { animation-delay: 0.48s; }

.js .vx-chart:not(.is-drawn) .vx-hbar-fill {
  transform: scaleX(0);
  transform-origin: left center;
}

.js .vx-chart.is-drawn .vx-hbar-fill {
  animation: vx-grow-hbar 1.05s var(--vx-ease) both;
}

.js .vx-chart.is-drawn .vx-hbar-row:nth-child(1) .vx-hbar-fill { animation-delay: 0.15s; }
.js .vx-chart.is-drawn .vx-hbar-row:nth-child(2) .vx-hbar-fill { animation-delay: 0.3s; }
.js .vx-chart.is-drawn .vx-hbar-row:nth-child(3) .vx-hbar-fill { animation-delay: 0.45s; }

.js .vx-chart:not(.is-drawn) .vx-ring-progress {
  stroke-dashoffset: var(--ring-circ, 280);
}

.js .vx-chart.is-drawn .vx-ring-progress {
  transition: stroke-dashoffset 1.4s var(--vx-ease) 0.15s;
  stroke-dashoffset: var(--ring-offset, 0);
}



@keyframes vx-fade-area {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes vx-grow-bar {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

@keyframes vx-grow-hbar {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* Layout helpers on pages */
.vx-chart-wrap {
  margin-top: clamp(28px, 4vw, 40px);
}

.vx-chart-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: clamp(28px, 4vw, 40px);
}

.vx-chart.compact {
  padding: 20px;
}

.vx-ring-wrap {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.vx-ring-label {
  text-align: center;
}

.vx-ring-value {
  display: block;
  margin-top: -8px;
  color: var(--vx-ink);
  font-size: 1.75rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.vx-ring-caption {
  display: block;
  margin-top: 2px;
  color: var(--vx-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.vx-hbar-list {
  display: grid;
  gap: 14px;
}

.vx-hbar-row {
  display: grid;
  gap: 6px;
}

.vx-hbar-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--vx-muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.vx-hbar-meta strong {
  color: var(--vx-ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.vx-hbar-track {
  height: 10px;
  overflow: hidden;
  background: rgba(44, 44, 44, 0.06);
  border-radius: 999px;
}

.vx-hbar-fill {
  height: 100%;
  width: var(--w, 50%);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--vx-vivral), #5d99c6);
  transform-origin: left center;
}

.vx-hbar-fill.cloud {
  background: linear-gradient(90deg, #8b919a, #6b7280);
}

.vx-hbar-fill.good {
  background: linear-gradient(90deg, #4a7c59, #6fa37d);
}

/* Cost section integration on home */
.hv-section .vx-chart-wrap {
  width: 100%;
}

.cost-grid .vx-chart {
  height: 100%;
}

/* Replace old cost panel visual spacing */
.band .cost-grid {
  align-items: stretch;
}

@media (max-width: 900px) {
  .vx-chart-pair {
    grid-template-columns: 1fr;
  }

  .vx-stat-row {
    grid-template-columns: 1fr;
  }

  .vx-ring-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .vx-hbar-list {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .vx-chart .vx-line,
  .js .vx-chart .vx-area,
  .js .vx-chart .vx-dot,
  .js .vx-chart .vx-bar,
  .js .vx-chart .vx-hbar,
  .js .vx-chart .vx-ring-progress,
  .js .vx-chart .vx-hbar-fill {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
    stroke-dashoffset: 0 !important;
  }
}
