/* Chart kit: Mebius chart styling (mebius.design/freebies/charts) with
 * OffsetMap hues from the --ck-* tokens in tokens.css.
 * Every value and its Mebius source: docs/CHART_STYLE.md. */

:root {
  /* anime.js v4 easings as Mebius ships them (frame-*.js: Quad t^2, Quart t^4, Sine 1-cos(t*pi/2), Expo 2^(10t-10),
     Back(s) (s+1)t^3-s*t^2). Polynomials of degree <= 3 are exact cubic beziers; the rest are linear() curves sampled
     from the same formulas (max error .0015, regenerate: python tools/ck_easing.py). */
  --ck-ease-out-expo: linear(0 0%, 0.1050 1.6%, 0.2045 3.3%, 0.2978 5.1%, 0.3844 7%, 0.4641 9%, 0.5399 11.2%, 0.6104 13.6%, 0.6747 16.2%, 0.7339 19.1%, 0.7868 22.3%, 0.8339 25.9%, 0.8750 30%, 0.9104 34.8%, 0.9400 40.6%, 0.9639 47.9%, 0.9815 57.6%, 0.9934 72.4%, 1 100%);
  --ck-ease-out-quad: cubic-bezier(0.3333, 0.6667, 0.6667, 1);    /* 1-(1-t)^2, exact */
  --ck-ease-out-back: cubic-bezier(0.3333, 1.7333, 0.6667, 1);    /* outBack(2.2), exact: bezier(1/3, (s+3)/3, 2/3, 1) */
  --ck-ease-in-out-quart: linear(0 0%, 0.0032 14.1%, 0.0141 20.5%, 0.0328 25.3%, 0.0590 29.3%, 0.0926 32.8%, 0.1344 36%, 0.1832 38.9%, 0.2396 41.6%, 0.3053 44.2%, 0.3773 46.6%, 0.4574 48.9%, 0.5718 51.9%, 0.6480 54.2%, 0.7188 56.7%, 0.7805 59.3%, 0.8349 62.1%, 0.8813 65.1%, 0.9202 68.4%, 0.9515 72.1%, 0.9752 76.4%, 0.9910 81.7%, 0.9990 89.3%, 1 100%);
  --ck-ease-in-out-sine: linear(0 0%, 0.0059 4.9%, 0.0240 9.9%, 0.0545 15%, 0.0983 20.3%, 0.1577 26%, 0.2361 32.3%, 0.3425 39.8%, 0.6708 61.1%, 0.7732 68.4%, 0.8491 74.6%, 0.9063 80.2%, 0.9490 85.5%, 0.9784 90.6%, 0.9950 95.5%, 1 100%);
}

/* Tooltip: light = chart-tooltip-series; dark = net-worth/financial-breakdown house shell */
.ck-tip {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--om-r-control);
  background: var(--ck-surface-white);
  box-shadow: 0 0 0 1px var(--ck-tip-ring), var(--om-e3);
  color: var(--ck-fg-loud);
  font-family: var(--font-ui);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 200ms;
}
.ck-tip[hidden] { display: none; }
.ck-tip__title { font: 500 var(--om-t-body)/1 var(--font-ui); color: var(--ck-fg-soft); }
.ck-tip__row { display: flex; align-items: center; gap: 6px; }
.ck-tip__row--off { opacity: 0.7; }  /* muted series stay readable (>=4.5:1) */
.ck-tip__swatch {
  flex: none;
  width: 4px;
  height: 20px;
  border-radius: 2px;
  background: var(--ck-swatch, currentColor);
  box-shadow: 0 2px 4px rgb(9 9 11 / 0.16), 0 1px 2px rgb(9 9 11 / 0.08), inset 0 1px 20px rgb(255 255 255 / 0.16);
}
.ck-tip__value { font: 500 16px/1 var(--font-ui); color: var(--ck-fg-loud); }
.ck-tip__label { font: 400 14px/1 var(--font-ui); color: var(--ck-fg-soft); }

html[data-theme="dark"] .ck-tip {
  padding: 8px 16px 8px 8px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--ck-surface-loud);
  box-shadow: inset 0 2px 8px rgb(255 255 255 / 0.24), 0 0 0 1px var(--ck-surface-muted), 0 2px 4px rgb(0 0 0 / 0.06), 0 4px 16px rgb(0 0 0 / 0.08);
  color: var(--ck-fg-on-loud);
}
html[data-theme="dark"] .ck-tip__title { font-weight: 400; color: var(--ck-fg-normal); }
html[data-theme="dark"] .ck-tip__row { padding: 2px 0; }
html[data-theme="dark"] .ck-tip__swatch { width: 16px; height: 6px; }
html[data-theme="dark"] .ck-tip__value { color: var(--ck-fg-on-loud); }

/* Change badge: chart-change-badge */
.ck-badge {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  font: 500 12px/1 var(--font-ui);
  white-space: nowrap;
  transition: color 300ms, background-color 300ms;
}
.ck-badge--up { background: var(--ck-good-50); color: var(--ck-good-500); }
.ck-badge--down { background: var(--ck-danger-50); color: var(--ck-danger-500); }
.ck-badge--flat { background: var(--ck-surface-soft); color: var(--ck-fg-normal); }
.ck-badge svg { width: 12px; height: 12px; flex: none; }

/* KPI number block: net-worth / total-value amount */
.ck-kpi { display: flex; flex-direction: column; gap: 12px; }
.ck-kpi__label { font: 500 16px/1 var(--font-ui); color: var(--ck-fg-normal); }
.ck-kpi__value { width: fit-content; font: 500 32px/1 var(--om-font-display); letter-spacing: var(--om-track-display); color: var(--ck-fg-loud); white-space: nowrap; }
.ck-kpi--sm .ck-kpi__value { font-size: 20px; }  /* financial-breakdown stat, heading-01-semibold */

/* Legend dot / swatch: chart-legend-dot */
.ck-legend-dot {
  position: relative;
  display: inline-block;
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--ck-dot, currentColor);
  box-shadow: 0 7.2px 12.96px -3.6px rgb(var(--ck-shadow-ink) / 0.2), 0 0 0 1px var(--ck-dot, currentColor), inset 0 -3.6px 6.48px -3.6px rgb(0 0 0 / 0.05);
}
.ck-legend-dot::after {
  /* Mebius draws a 1px SVG rim stroked #fff .24 -> 0 top to bottom. */
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(rgb(255 255 255 / 0.24), rgb(255 255 255 / 0));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.ck-legend-dot--sm {
  width: 12px;
  height: 12px;
  box-shadow: 0 6.171px 11.106px -3.085px rgb(var(--ck-shadow-ink) / 0.2), 0 0 0 0.857px var(--ck-dot, currentColor), inset 0 -3.085px 5.554px -3.085px rgb(0 0 0 / 0.05);
}
.ck-legend-dot--square {
  border-radius: 4.667px;
  box-shadow: 0 7.2px 14.4px -3.6px rgb(var(--ck-shadow-ink) / 0.2), 0 0 0 1.167px var(--ck-dot, currentColor), inset 0 -3.6px 7.2px -3.6px rgb(0 0 0 / 0.05);
}

/* Segmented meter: budget (2 rows of 12px cells, 4px row gap, 1px min column gap, rx 3) */
.ck-meter {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, 12px);
  grid-auto-columns: minmax(0, 12px);
  gap: 4px 1px;
  justify-content: space-between;
  border-radius: 3px;
}
.ck-meter__cell {
  border-radius: 3px;
  background: var(--ck-surface-disable);
  transition: background-color 200ms;
}
.ck-meter__cell.is-lit {
  background: var(--ck-accent-500);
  animation: ck-cell-in 550ms var(--ck-ease-out-back) both;
  animation-delay: var(--ck-delay, 0ms);
}
.ck-meter__cell.is-preview { background: var(--ck-accent-100); }
.ck-meter__cell.is-lit.is-preview { background: color-mix(in srgb, var(--ck-accent-500) 35%, transparent); }
.ck-meter__cell.is-over { background: var(--ck-danger-500); }
@keyframes ck-cell-in { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: scale(1); } }

/* Pill progress: budget-health (32px meter, 24px bar at y 4, radius 4, 4px ticks every 6px, 4px handle) */
.ck-pill-progress {
  position: relative;
  height: 32px;
}
.ck-pill-progress::before {
  content: "";
  position: absolute;
  inset: 4px 0;
  border-radius: 4px;
  background: repeating-linear-gradient(90deg, var(--ck-surface-soft) 0 4px, transparent 4px 6px);
}
.ck-pill-progress__fill {
  position: absolute;
  top: 4px;
  left: 0;
  height: 24px;
  width: var(--ck-value, 0%);
  border-radius: 4px;
  background: var(--ck-accent-500);
  transition: width 1300ms var(--ck-ease-in-out-quart), background-color 300ms;
}
.ck-pill-progress__fill::after {
  content: "";
  position: absolute;
  top: -4px;
  right: 0;
  width: 4px;
  height: 32px;
  border-radius: 4px;
  background: inherit;
}
.ck-pill-progress__scale { display: flex; justify-content: space-between; font: 500 14px/1 var(--font-ui); color: var(--ck-fg-soft); }

/* SVG helpers */
.ck-grid { stroke: var(--ck-surface-soft); stroke-width: 1; stroke-dasharray: 5 5; stroke-dashoffset: 2.5; fill: none; }
.ck-grid--zero { stroke-dasharray: none; }
.ck-tick { font: 400 14px/1 var(--font-ui); fill: var(--ck-fg-normal); color: var(--ck-fg-normal); white-space: nowrap; }
.ck-tick.is-active { fill: var(--ck-accent-500); color: var(--ck-accent-500); }
.ck-bar { fill: var(--ck-surface-subdued); transition: fill 300ms; }
.ck-bar.is-active { fill: var(--ck-accent-500); }
.ck-bar--negative.is-active { fill: var(--ck-danger-500); }
.ck-stripes { fill: #fff; fill-opacity: 0.15; }
.ck-band { fill: var(--ck-accent-500); fill-opacity: 0.12; transition: x 550ms var(--ck-ease-out-expo), opacity 400ms; }
.ck-band--stacked { fill-opacity: 0.16; }
.ck-line { fill: none; stroke: var(--ck-accent-500); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ck-area { fill-opacity: 0.32; }
.ck-guide { fill: none; stroke: var(--ck-accent-500); stroke-opacity: 0.5; stroke-width: 1; stroke-dasharray: 4 4; }
.ck-cell { fill: var(--ck-surface-disable); transition: fill 200ms; }
.ck-cell--soft { fill: var(--ck-surface-soft); }
.ck-cell--on { fill: var(--ck-accent-500); }
.ck-hit:focus-visible { outline: var(--om-focus-w) solid var(--ck-focus); outline-offset: 0; border-radius: 8px; }

/* End marker: finance-overview-area (8px dot, surface ring, accent halo, pulse 1 -> 2.8) */
.ck-marker {
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1px solid var(--ck-surface-white);
  border-radius: 999px;
  background: var(--ck-accent-500);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ck-accent-500) 24%, transparent);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.ck-marker::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: var(--ck-accent-500);
  animation: ck-pulse 2500ms var(--ck-ease-out-quad) infinite;  /* 1800ms pulse + 700ms loopDelay */
  opacity: 0;
}
@keyframes ck-pulse { 0% { transform: scale(1); opacity: 0.35; } 72% { transform: scale(2.8); opacity: 0; } 100% { transform: scale(2.8); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .ck-tip, .ck-badge, .ck-meter__cell, .ck-pill-progress__fill, .ck-bar, .ck-band, .ck-cell {
    transition: none !important;
  }
  .ck-meter__cell.is-lit, .ck-marker::before { animation: none !important; }
}

/* Foundation numerals: every chart figure is tabular with a slashed zero. */
.ck-tip__value, .ck-tip__label, .ck-kpi__value, .ck-badge, .ck-tick, .ck-pill-progress__scale { font-variant-numeric: var(--om-num); }
