/* The savings year with the chart that fills and the goals that become badges on scroll. Colours in :root (the
   Playground palette): one cobalt accent for the savings, the goals and the bright face of the badges, warm neutrals
   for everything else on a warm white page. GSAP moves .frame, .coin, .badge__tilt, .lock, the rays and the shine; the
   CSS styles .card and the faces inside them. The cursor sits at --x and --y on .plot (set by the script), in fractions. */
:root {
  --page: #f3f1ec;          /* the page */
  --page-lift: #fbfaf7;     /* the soft lift of the page behind the card */
  --card: #ffffff;          /* the card */
  --ink: #17181c;           /* the words */
  --muted: #8b8a86;         /* the small words */
  --line: rgba(23, 24, 28, 0.08); /* the hairlines */
  --accent: #3554f5;        /* the savings, the goals, the unlocked badges */
  --accent-deep: #1f33b8;   /* the shadow side of the bright coin */
  --coin: #f2f1ee;          /* the locked coin */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--page); }
html, body { overflow-x: clip; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }

.year { position: relative; height: 400vh; }
.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2.4vh, 40px) 12px;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(110% 80% at 50% 38%, var(--page-lift), var(--page) 72%);
}
@supports (height: 100lvh) {
  .stage { height: 100lvh; }
}

/* one soft cobalt halo under the card; it rises a little with the savings */
.halo {
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 58%;
  width: min(80vw, 70vh, 560px);
  height: min(46vw, 40vh, 320px);
  margin: calc(min(46vw, 40vh, 320px) / -2) 0 0 calc(min(80vw, 70vh, 560px) / -2);
  border-radius: 50%;
  pointer-events: none;
  filter: blur(50px);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 20%, transparent), color-mix(in srgb, var(--accent) 5%, transparent) 60%, transparent);
}
.grain {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- the card */
.frame { width: min(100%, 400px); }
.card {
  position: relative;
  overflow: hidden;
  border-radius: clamp(18px, 4.4vh, 26px);
  padding: clamp(11px, 3vh, 22px) clamp(12px, 3.6vw, 22px) clamp(10px, 2.6vh, 20px);
  background: linear-gradient(180deg, #ffffff, #fdfcfa);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 0 0 1px rgba(23, 24, 28, 0.05),
    0 1px 2px rgba(23, 24, 28, 0.05),
    0 10px 24px -12px rgba(23, 24, 28, 0.16),
    0 40px 80px -36px color-mix(in srgb, var(--accent) 30%, rgba(23, 24, 28, 0.3));
}
.card__glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, -30%), color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%);
}
@media (hover: hover) {
  .card:hover .card__glow { opacity: 1; }
}
/* a band of light that crosses the card when the year is complete */
.card__sweep {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 40%;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--accent) 5%, transparent) 45%, rgba(255, 255, 255, 0.6) 50%, color-mix(in srgb, var(--accent) 5%, transparent) 55%, transparent 80%);
}

.head { position: relative; display: flex; align-items: center; gap: 10px; }
.head__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: clamp(26px, 7vh, 34px);
  height: clamp(26px, 7vh, 34px);
  border-radius: 10px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 78%, white), var(--accent) 60%, var(--accent-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 6px 14px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.head__mark svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.head__text { flex: 1; min-width: 0; }
.head__title { font-size: clamp(13px, 3.4vh, 15px); font-weight: 650; font-variation-settings: 'wdth' 104; letter-spacing: -0.005em; white-space: nowrap; }
.head__text .muted { font-size: clamp(10.5px, 2.8vh, 12px); margin-top: 1px; white-space: nowrap; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px 0 5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  background: #f5f4f1;
  box-shadow: inset 0 0 0 1px rgba(23, 24, 28, 0.06), inset 0 1px 0 #fff;
}
.chip__sw {
  position: relative;
  width: 22px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.18);
}
.chip__knob {
  position: absolute;
  top: 2px;
  left: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.chip__words { display: inline-block; }

/* ---------------------------------------------------------------- the total */
.total { margin-top: clamp(8px, 2.6vh, 20px); }
.total__label { font-size: clamp(10px, 2.6vh, 11.5px); font-weight: 520; letter-spacing: 0.01em; }
.total__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.total__num {
  font-size: clamp(26px, 8.4vh, 40px);
  line-height: 1.05;
  font-weight: 650;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.delta {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent);
}
.delta__words { display: inline-block; }

/* ---------------------------------------------------------------- the chart */
.chart { margin-top: clamp(8px, 2.2vh, 18px); }
.plot {
  position: relative;
  height: clamp(70px, 22vh, 150px);
  margin-right: 34px;
}
.cols { position: absolute; inset: 0; display: flex; }
.cols i { flex: 1; border-left: 1px solid rgba(23, 24, 28, 0.035); }
.cols i:first-child { border-left: 0; }
.base { position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: rgba(23, 24, 28, 0.12); transform-origin: 0 50%; }
.plot__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.area { fill: url(#fill); }
.ln { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 2px 5px color-mix(in srgb, var(--accent) 30%, transparent)); }

/* the goal lines: dashed until the savings reach them, then a solid cobalt line runs along */
.gl {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--at) * 100%);
  height: 1px;
  background: linear-gradient(90deg, rgba(23, 24, 28, 0.16), rgba(23, 24, 28, 0.16) 50%, transparent 50%) 0 0 / 6px 1px;
  transform-origin: 0 50%;
}
.gl__hit { position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 55%, transparent); transform-origin: 0 50%; transform: scaleX(0); }
.gl em {
  position: absolute;
  left: calc(100% + 6px);
  top: -0.65em;
  font-style: normal;
  font-size: clamp(9px, 2.3vh, 10.5px);
  font-weight: 560;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: color 0.35s ease;
}
.gl.is-hit em { color: var(--accent); }

.cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--x, 0) * 100%);
  width: 0;
  pointer-events: none;
}
.cursor__line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -0.5px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(23, 24, 28, 0.22) 30%, rgba(23, 24, 28, 0.08));
}
.cursor__pt {
  position: absolute;
  left: -5px;
  bottom: calc(var(--y, 0) * 100% - 5px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 3px rgba(255, 255, 255, 0.9), 0 2px 6px rgba(23, 24, 28, 0.2);
}
.pill {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  transform: translate(-50%, 0);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 640;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 4px 10px -4px rgba(23, 24, 28, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.pill__win { display: inline-block; height: 1.25em; line-height: 1.25em; overflow: hidden; }
.pill__strip { display: flex; flex-direction: column; will-change: transform; }
.pill__strip b { display: block; height: 1.25em; font-weight: inherit; text-align: center; min-width: 1.9em; }

.axis {
  display: flex;
  justify-content: space-between;
  margin: 4px 34px 0 0;
  font-size: clamp(9px, 2.3vh, 10.5px);
}
.axis span { transition: opacity 0.25s ease; }
.axis span.is-hidden { opacity: 0; }

/* ---------------------------------------------------------------- the badges */
.badges {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: clamp(10px, 2.8vh, 22px);
  padding-top: clamp(9px, 2.4vh, 16px);
  border-top: 1px solid var(--line);
}
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.badge__tilt {
  --s: clamp(40px, 11vh, 60px);
  position: relative;
  display: grid;
  place-items: center;
  width: var(--s);
  height: var(--s);
  border: 0;
  padding: 0;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.badge__tilt:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 2; }
.ring__track { stroke: rgba(23, 24, 28, 0.07); }
.ring__fill { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.coin {
  position: relative;
  width: 76%;
  height: 76%;
  border-radius: 50%;
}
.coin__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  transition: opacity 0.01s linear;
}
.coin__face svg { width: 46%; height: 46%; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.coin__face--off {
  background: radial-gradient(90% 90% at 35% 25%, #ffffff, var(--coin) 60%, #e6e4df);
  box-shadow: inset 0 0 0 1px rgba(23, 24, 28, 0.06), inset 0 -2px 3px rgba(23, 24, 28, 0.06), 0 2px 4px rgba(23, 24, 28, 0.06);
}
.coin__face--off svg { stroke: #b2b0aa; }
.coin__face--on {
  opacity: 0;
  background: radial-gradient(100% 100% at 32% 22%, color-mix(in srgb, var(--accent) 55%, white), var(--accent) 55%, var(--accent-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -2px 4px rgba(0, 0, 0, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 6px 14px -5px color-mix(in srgb, var(--accent) 70%, transparent);
}
.coin__face--on svg { stroke: #fff; position: relative; }
.coin__shine {
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: -60%;
  width: 40%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
}
.badge.is-on .coin__face--on { opacity: 1; }
.badge.is-on .coin__face--off { opacity: 0; }

.lock {
  position: absolute;
  right: -1px;
  bottom: -1px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(23, 24, 28, 0.06), 0 2px 5px rgba(23, 24, 28, 0.14);
}
.lock svg { width: 11px; height: 11px; overflow: visible; }
.lock rect { fill: var(--muted); }
.lock__shackle { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; }

.rays { position: absolute; inset: 0; pointer-events: none; }
.rays i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.5px;
  height: 7px;
  margin: -3.5px 0 0 -0.75px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
}

.badge__name {
  margin-top: clamp(4px, 1.2vh, 8px);
  font-size: clamp(10.5px, 2.8vh, 12px);
  font-weight: 620;
  white-space: nowrap;
}
.badge__state { margin-top: 1px; font-size: clamp(9.5px, 2.5vh, 11px); font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge__state span { display: inline-block; }
.badge.is-on .badge__state { color: var(--accent); font-weight: 600; }

@media (hover: hover) {
  .badge__tilt:hover .ring__track { stroke: rgba(23, 24, 28, 0.12); }
}
@media (max-height: 460px) {
  .total__label { display: none; }
  .plot { height: clamp(60px, 20vh, 150px); }
}
@media (max-width: 340px) {
  .chip__words { display: none; }
  .chip { padding-right: 5px; }
}
