/* =====================================================================
   RMCM ANIMATED CHART SYSTEM
   Reusable data-viz components in the live RMCM brand: dark starfield
   panels, cream ink, orange/yellow accents, Bebas Neue numerals, Outfit
   labels. Motion is triggered by scripts/rmcm-charts.js adding `.is-in`
   to each [data-chart] block. See charts/design.md for usage + variants.

   IMPORTANT: chart sections must sit above the body::before vignette, so
   the containing section keeps `position: relative; z-index: 2;`.
   ===================================================================== */

.chart-section {
  position: relative;
  z-index: 2;
}

/* Centre the section heading + lede and use the site's spacing rhythm,
   exactly like .shift / .how-it-works. Card internals stay left-aligned. */
.chart-section .site-shell {
  display: grid;
  gap: var(--space-heading-copy);
  text-align: center;
}
.chart-section .lede {
  margin: 0 auto;
  max-width: 62ch;
}

/* Grid + card shell -------------------------------------------------- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.9rem, 1.6vw, 1.25rem);
}
.chart-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.chart-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 300px;
  padding: clamp(1.25rem, 2.4vw, 1.75rem);
  /* Matches .how-step on the live homepage: translucent, so the starfield
     shows through, with the same border, radius, and shadow. */
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(6, 19, 19, 0.55);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  text-align: left;
}

/* Label / tag row ---------------------------------------------------- */
.chart-tag {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  color: var(--orange-2);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.chart-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 10px 1px rgba(255, 90, 61, 0.7);
  animation: chart-pulse 2.4s ease-in-out infinite;
}
.chart-caption {
  margin: auto 0 0;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.5;
}
.chart-sub-note {
  margin: -0.4rem 0 0;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}
/* Full-width chips card sitting beneath a .chart-grid. Spacing from the grid
   comes from the section's own grid gap, so no extra margin is needed. */
.chart-card--chips {
  min-height: 0;
}

/* Numerals default to tabular so counting up never shifts width. */
.chart-num,
.chart-bar-val,
.chart-ring-num,
.chart-stat {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ *
   VARIANT 1 — Count-up stat
 * ------------------------------------------------------------------ */
.chart-stat {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: var(--font-display);
  line-height: 0.9;
}
.chart-num {
  color: var(--yellow);
  font-size: clamp(3rem, 6vw, 5rem);
}
.chart-unit {
  color: var(--muted);
  font-family: var(--font-accent);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  letter-spacing: 0.02em;
}
.chart-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--orange);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.85rem;
}

/* ------------------------------------------------------------------ *
   VARIANT 2 — Horizontal score bars
 * ------------------------------------------------------------------ */
.chart-bars {
  display: grid;
  gap: 0.8rem;
  margin: 0.2rem 0 0;
  padding: 0;
  list-style: none;
}
.chart-bars li {
  display: grid;
  grid-template-columns: 92px 1fr 2.4ch;
  align-items: center;
  gap: 0.7rem;
}
.chart-bar-label {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.82rem;
}
.chart-bar {
  height: 7px;
  border-radius: 99px;
  background: rgba(246, 240, 223, 0.1);
  overflow: hidden;
}
.chart-bar > i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--orange), var(--orange-2) 70%, var(--yellow));
  box-shadow: 0 0 12px rgba(255, 90, 61, 0.5);
  transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-chart].is-in .chart-bar > i { width: var(--v); }
.chart-bars li:nth-child(1) .chart-bar > i { transition-delay: 0.05s; }
.chart-bars li:nth-child(2) .chart-bar > i { transition-delay: 0.13s; }
.chart-bars li:nth-child(3) .chart-bar > i { transition-delay: 0.21s; }
.chart-bars li:nth-child(4) .chart-bar > i { transition-delay: 0.29s; }
.chart-bars li:nth-child(5) .chart-bar > i { transition-delay: 0.37s; }
.chart-bars li:nth-child(6) .chart-bar > i { transition-delay: 0.45s; }
.chart-bar-val {
  color: var(--yellow);
  font-family: var(--font-accent);
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-align: right;
}
/* Stacked rows for long category labels: label + value on top, full-width
   bar beneath. Use `class="chart-bars chart-bars--stack"`. */
.chart-bars--stack li {
  grid-template-columns: 1fr auto;
  gap: 0.3rem 0.7rem;
}
.chart-bars--stack .chart-bar-label { white-space: nowrap; }
.chart-bars--stack .chart-bar { grid-column: 1 / -1; }

/* ------------------------------------------------------------------ *
   VARIANT 3 — Before/after area + line chart
 * ------------------------------------------------------------------ */
.chart-line {
  margin-top: auto;
}
.chart-line svg {
  display: block;
  width: 100%;
  height: 104px;
  overflow: visible;
}
.cl-line {
  fill: none;
  stroke: var(--orange);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(255, 90, 61, 0.45));
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.7s cubic-bezier(0.4, 0, 0.2, 1) 0.15s;
}
[data-chart].is-in .cl-line { stroke-dashoffset: 0; }
.cl-area {
  opacity: 0;
  transition: opacity 0.9s ease 0.7s;
}
[data-chart].is-in .cl-area { opacity: 1; }
.cl-dot {
  fill: var(--yellow);
  opacity: 0;
  transition: opacity 0.4s ease 1.5s;
}
[data-chart].is-in .cl-dot { opacity: 1; }

/* ------------------------------------------------------------------ *
   VARIANT 4 — Radial gauge / progress ring
 * ------------------------------------------------------------------ */
.chart-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(150px, 20vw, 190px);
  aspect-ratio: 1;
  margin: 0.4rem auto auto;
}
.chart-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.cr-track {
  fill: none;
  stroke: rgba(246, 240, 223, 0.1);
  stroke-width: 9;
}
.cr-value {
  fill: none;
  stroke: var(--orange);
  stroke-width: 9;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(255, 90, 61, 0.45));
  /* circle carries pathLength="1"; --pct is the fill fraction (0..1). */
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.6s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
}
[data-chart].is-in .cr-value { stroke-dashoffset: calc(1 - var(--pct, 0.9)); }
.chart-ring-center {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 0.1rem;
}
.chart-ring-num {
  color: var(--yellow);
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3rem);
  line-height: 1;
}
.chart-ring-label {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------ *
   VARIANT 5 — Pass / check chips (staggered, checkmark draws)
 * ------------------------------------------------------------------ */
.chart-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chart-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.75rem;
  border: 1px solid rgba(255, 90, 61, 0.32);
  border-radius: 99px;
  background: rgba(255, 90, 61, 0.08);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(7px) scale(0.98);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-chart].is-in .chart-chip { opacity: 1; transform: none; }
.chart-chips .chart-chip:nth-child(1) { transition-delay: 0.08s; }
.chart-chips .chart-chip:nth-child(2) { transition-delay: 0.16s; }
.chart-chips .chart-chip:nth-child(3) { transition-delay: 0.24s; }
.chart-chips .chart-chip:nth-child(4) { transition-delay: 0.32s; }
.chart-chips .chart-chip:nth-child(5) { transition-delay: 0.40s; }
.chart-chips .chart-chip:nth-child(6) { transition-delay: 0.48s; }
.chart-check {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--orange);
}
.chart-check path {
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: stroke-dashoffset 0.5s ease;
}
[data-chart].is-in .chart-chip:nth-child(1) .chart-check path { transition-delay: 0.28s; stroke-dashoffset: 0; }
[data-chart].is-in .chart-chip:nth-child(2) .chart-check path { transition-delay: 0.36s; stroke-dashoffset: 0; }
[data-chart].is-in .chart-chip:nth-child(3) .chart-check path { transition-delay: 0.44s; stroke-dashoffset: 0; }
[data-chart].is-in .chart-chip:nth-child(4) .chart-check path { transition-delay: 0.52s; stroke-dashoffset: 0; }
[data-chart].is-in .chart-chip:nth-child(5) .chart-check path { transition-delay: 0.60s; stroke-dashoffset: 0; }
[data-chart].is-in .chart-chip:nth-child(6) .chart-check path { transition-delay: 0.68s; stroke-dashoffset: 0; }

/* ------------------------------------------------------------------ *
   VARIANT 6 — Equalizer / waveform (ambient loop)
 * ------------------------------------------------------------------ */
.chart-eq {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 46px;
}
.chart-eq > i {
  flex: 1;
  min-width: 3px;
  border-radius: 99px 99px 0 0;
  background: linear-gradient(180deg, var(--yellow), var(--orange));
  transform-origin: bottom;
  transform: scaleY(0.2);
}
[data-chart].is-in .chart-eq > i { animation: chart-eq 1.1s ease-in-out infinite; }
.chart-eq > i:nth-child(2) { animation-duration: 0.85s; }
.chart-eq > i:nth-child(3) { animation-duration: 1.25s; }
.chart-eq > i:nth-child(4) { animation-duration: 0.95s; }
.chart-eq > i:nth-child(5) { animation-duration: 1.15s; }
.chart-eq > i:nth-child(6) { animation-duration: 0.9s; }
.chart-eq > i:nth-child(7) { animation-duration: 1.3s; }

/* ------------------------------------------------------------------ *
   VARIANT 7 — Sparkline (draws once, then a runner dot loops)
 * ------------------------------------------------------------------ */
.chart-spark svg {
  display: block;
  width: 100%;
  height: 40px;
  overflow: visible;
}
.chart-spark path {
  fill: none;
  stroke: var(--orange);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.4s ease;
}
[data-chart].is-in .chart-spark path { stroke-dashoffset: 0; }

/* ------------------------------------------------------------------ *
   VARIANT 8 — Versus matrix (feature | you ✓ | them ✗)
   Rows fade up in sequence; the winning checkmark draws itself.
 * ------------------------------------------------------------------ */
.chart-versus {
  display: grid;
}
.chart-versus > div {
  display: grid;
  grid-template-columns: 1fr 64px 64px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.chart-versus > div:last-child { border-bottom: 0; }
.cv-head {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.cv-head > span:not(:first-child) {
  justify-self: center;
  font-family: var(--font-accent);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}
.cv-head .cv-col-you { color: var(--yellow); }
.cv-feature { color: var(--ink); font-size: 0.9rem; }
.cv-yes,
.cv-no { display: grid; place-items: center; }
.cv-no { color: var(--faint); font-size: 1.2rem; line-height: 1; }
.cv-yes .chart-check { width: 18px; height: 18px; }
.chart-versus .cv-row {
  opacity: 0;
  transform: translateY(7px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-chart].is-in .chart-versus .cv-row { opacity: 1; transform: none; }
.cv-yes .chart-check path { transition: stroke-dashoffset 0.5s ease; }
.chart-versus .cv-row:nth-child(2) { transition-delay: 0.08s; }
.chart-versus .cv-row:nth-child(3) { transition-delay: 0.16s; }
.chart-versus .cv-row:nth-child(4) { transition-delay: 0.24s; }
.chart-versus .cv-row:nth-child(5) { transition-delay: 0.32s; }
.chart-versus .cv-row:nth-child(6) { transition-delay: 0.40s; }
.chart-versus .cv-row:nth-child(7) { transition-delay: 0.48s; }
.chart-versus .cv-row:nth-child(8) { transition-delay: 0.56s; }
[data-chart].is-in .cv-row:nth-child(2) .chart-check path { transition-delay: 0.28s; stroke-dashoffset: 0; }
[data-chart].is-in .cv-row:nth-child(3) .chart-check path { transition-delay: 0.36s; stroke-dashoffset: 0; }
[data-chart].is-in .cv-row:nth-child(4) .chart-check path { transition-delay: 0.44s; stroke-dashoffset: 0; }
[data-chart].is-in .cv-row:nth-child(5) .chart-check path { transition-delay: 0.52s; stroke-dashoffset: 0; }
[data-chart].is-in .cv-row:nth-child(6) .chart-check path { transition-delay: 0.60s; stroke-dashoffset: 0; }
[data-chart].is-in .cv-row:nth-child(7) .chart-check path { transition-delay: 0.68s; stroke-dashoffset: 0; }
[data-chart].is-in .cv-row:nth-child(8) .chart-check path { transition-delay: 0.76s; stroke-dashoffset: 0; }

@keyframes chart-pulse {
  0%, 100% { box-shadow: 0 0 8px 1px rgba(255, 90, 61, 0.6); opacity: 1; }
  50% { box-shadow: 0 0 15px 3px rgba(255, 90, 61, 0.9); opacity: 0.8; }
}
@keyframes chart-eq {
  0%, 100% { transform: scaleY(0.28); }
  50% { transform: scaleY(1); }
}

/* ------------------------------------------------------------------ *
   VARIANT 9 — Local pack + map mock (service-page hero art)
   A stylized Google local 3-pack above a map with dropping pins. The
   #1 pin and top result are highlighted as the goal. Purely decorative
   (aria-hidden); the real claims live in the hero copy.
 * ------------------------------------------------------------------ */
.map-pack-mock {
  display: grid;
  gap: 0.85rem;
  width: min(100%, 460px);
  margin-inline: auto;
  padding: clamp(1rem, 2vw, 1.4rem);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(6, 19, 19, 0.62);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}
.mpm-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
}
.mpm-search svg { width: 15px; height: 15px; flex: none; color: var(--orange-2); }

.mpm-map {
  position: relative;
  height: clamp(140px, 22vw, 176px);
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 46% 48%, rgba(255, 90, 61, 0.14), transparent 60%),
    repeating-linear-gradient(90deg, rgba(246, 240, 223, 0.055) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(0deg, rgba(246, 240, 223, 0.055) 0 1px, transparent 1px 30px),
    #04100f;
}
.mpm-pin {
  position: absolute;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(246, 240, 223, 0.22);
  font-family: var(--font-accent);
  font-size: 0.9rem;
  opacity: 0;
  transform: translate(-50%, calc(-50% - 12px));
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-chart].is-in .mpm-pin { opacity: 1; transform: translate(-50%, -50%); }
.mpm-pin--1 {
  left: 46%; top: 50%;
  width: 30px; height: 30px;
  color: #fff;
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(255, 90, 61, 0.22), 0 0 14px rgba(255, 90, 61, 0.6);
  z-index: 2;
  transition-delay: 0.05s;
}
.mpm-pin--2 { left: 24%; top: 68%; transition-delay: 0.25s; }
.mpm-pin--3 { left: 71%; top: 33%; transition-delay: 0.15s; }

.mpm-pack {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.mpm-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-chart].is-in .mpm-row { opacity: 1; transform: none; }
.mpm-row:nth-child(1) { transition-delay: 0.35s; }
.mpm-row:nth-child(2) { transition-delay: 0.45s; }
.mpm-row:nth-child(3) { transition-delay: 0.55s; }
.mpm-row--top {
  border-color: rgba(255, 90, 61, 0.5);
  background: rgba(255, 90, 61, 0.09);
  box-shadow: 0 0 18px rgba(255, 90, 61, 0.15);
}
.mpm-rank {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(246, 240, 223, 0.15);
  color: var(--ink);
  font-family: var(--font-accent);
  font-size: 0.9rem;
}
.mpm-row--top .mpm-rank { background: var(--orange); color: #fff; }
.mpm-biz { display: grid; gap: 0.15rem; min-width: 0; }
.mpm-name {
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mpm-stars {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--yellow);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.mpm-stars b { color: var(--muted); font-weight: 700; }
.mpm-tag {
  flex: none;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  background: var(--orange);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
}

/* Responsive --------------------------------------------------------- */
@media (max-width: 860px) {
  .chart-grid,
  .chart-grid--2 { grid-template-columns: minmax(0, 1fr); }
  .chart-card { min-height: 0; }
}

/* Reduced motion: resolve to final states, no transitions or loops. */
@media (prefers-reduced-motion: reduce) {
  .chart-bar > i { width: var(--v) !important; transition: none; }
  .cl-line { stroke-dashoffset: 0 !important; transition: none; }
  .cl-area, .cl-dot { opacity: 1 !important; transition: none; }
  .cr-value { stroke-dashoffset: calc(1 - var(--pct, 0.9)) !important; transition: none; }
  .chart-chip { opacity: 1 !important; transform: none !important; transition: none; }
  .chart-check path { stroke-dashoffset: 0 !important; transition: none; }
  .chart-spark path { stroke-dashoffset: 0 !important; transition: none; }
  .chart-eq > i { animation: none !important; transform: scaleY(0.7); }
  .chart-dot { animation: none; }
  .chart-versus .cv-row { opacity: 1 !important; transform: none !important; transition: none; }
  .cv-yes .chart-check path { stroke-dashoffset: 0 !important; transition: none; }
  .map-pack-mock .mpm-pin { opacity: 1 !important; transform: translate(-50%, -50%) !important; transition: none; }
  .map-pack-mock .mpm-row { opacity: 1 !important; transform: none !important; transition: none; }
}
