/* The investment plan that grows over the years on scroll. Colours in :root (the Playground palette): mint is the
   value and the growth, lilac is what you put in, everything else is a cool neutral on a near black page. GSAP moves
   .frame, the CSS styles .card inside it; GSAP moves .ms (the milestones) and .ms__tag inside is styled by the CSS. The
   point on the curve and the cursor sit at --x and --y on .chart__plot (set by the script), in fractions of the plot. */
:root {
  --page: #0b0c0f;          /* the page */
  --page-lift: #14161b;     /* the soft lift of the page behind the card */
  --card: #15171c;          /* the card */
  --ink: #eef0f3;           /* the words */
  --muted: #8a8f99;         /* the small words */
  --line: rgba(255, 255, 255, 0.07); /* the hairlines of the chart */
  --mint: #5ff0b8;          /* the value and the growth */
  --lilac: #a79bff;         /* the deposits */
  --cash: #5b606b;          /* the cash in the mix */
  --button: #f2f3f5;        /* the button */
  --button-ink: #0b0c0f;    /* the words on the button */
}

* { 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); }

.years { position: relative; height: 420vh; }
.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(120% 90% at 50% 40%, var(--page-lift), var(--page) 70%);
}
@supports (height: 100lvh) {
  .stage { height: 100lvh; }
}

/* two soft lights behind the card, mint low on the right and lilac high on the left; they drift with the years */
.light {
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 50%;
  width: min(72vw, 72vh, 540px);
  height: min(72vw, 72vh, 540px);
  margin: calc(min(72vw, 72vh, 540px) / -2) 0 0 calc(min(72vw, 72vh, 540px) / -2);
  border-radius: 50%;
  pointer-events: none;
  filter: blur(46px);
}
.light--a { background: radial-gradient(closest-side, color-mix(in srgb, var(--lilac) 26%, transparent), color-mix(in srgb, var(--lilac) 6%, transparent) 60%, transparent); }
.light--b { background: radial-gradient(closest-side, color-mix(in srgb, var(--mint) 22%, transparent), color-mix(in srgb, var(--mint) 5%, transparent) 60%, transparent); }
.grain {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.12;
  mix-blend-mode: overlay;
  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%, 420px); }
.card {
  position: relative;
  border-radius: clamp(18px, 4.4vh, 26px);
  padding: clamp(11px, 3vh, 22px) clamp(12px, 3.6vw, 22px) clamp(11px, 2.8vh, 20px);
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 255, 255, 0.06), transparent 60%),
    linear-gradient(180deg, color-mix(in srgb, var(--card) 88%, transparent), color-mix(in srgb, var(--card) 96%, transparent));
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  backdrop-filter: blur(22px) saturate(140%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 10px 24px -10px rgba(0, 0, 0, 0.6),
    0 40px 80px -30px rgba(0, 0, 0, 0.7);
}
/* the edge that catches the light at the top */
.card__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.02) 34%, transparent 60%, color-mix(in srgb, var(--mint) 22%, transparent));
  -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);
}
/* the light under the pointer */
.card__glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, -30%), color-mix(in srgb, var(--mint) 7%, transparent), transparent 70%);
}
@media (hover: hover) {
  .card:hover .card__glow { opacity: 1; }
}

.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(--mint) 80%, white), color-mix(in srgb, var(--mint) 70%, #0b3b2a));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -1px 0 rgba(0, 0, 0, 0.15), 0 6px 14px -6px color-mix(in srgb, var(--mint) 60%, transparent);
}
.head__mark svg { width: 15px; height: 15px; fill: none; stroke: #07231a; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.head__text { flex: 1; min-width: 0; }
.head__title { font-size: clamp(13px, 3.4vh, 15px); font-weight: 640; 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;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.chip .muted { font-weight: 500; }

/* ---------------------------------------------------------------- the value */
.value { margin-top: clamp(8px, 2.6vh, 20px); }
.value__label { font-size: clamp(10px, 2.6vh, 11.5px); font-weight: 520; letter-spacing: 0.01em; }
.value__num {
  margin-top: 1px;
  font-size: clamp(26px, 8.4vh, 40px);
  line-height: 1.05;
  font-weight: 640;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff 30%, color-mix(in srgb, var(--ink) 70%, var(--mint)) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.value__split {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin-top: clamp(2px, 0.8vh, 6px);
  font-size: clamp(10.5px, 2.7vh, 12px);
  font-variant-numeric: tabular-nums;
}
.split b { font-weight: 600; }
.split--dep b { color: var(--lilac); }
.split--grow b { color: var(--mint); }

/* ---------------------------------------------------------------- the chart */
.chart { margin-top: clamp(8px, 2.4vh, 18px); }
.chart__plot {
  position: relative;
  height: clamp(84px, 28vh, 190px);
  margin-right: 34px;
}
.chart__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.area--dep { fill: url(#dep); }
.area--grow { fill: url(#grow); }
.ln { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.ln--dep { stroke: color-mix(in srgb, var(--lilac) 80%, transparent); stroke-width: 1.2; stroke-dasharray: 3 3; }
.ln--val { stroke: var(--mint); stroke-width: 2; filter: drop-shadow(0 2px 6px color-mix(in srgb, var(--mint) 35%, transparent)); }

.gl {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--at) * 100%);
  height: 1px;
  background: linear-gradient(90deg, var(--line), var(--line) 50%, transparent 50%) 0 0 / 6px 1px;
  transform-origin: 0 50%;
}
.gl--base { background: rgba(255, 255, 255, 0.1); }
.gl em {
  position: absolute;
  left: calc(100% + 6px);
  top: -0.65em;
  font-style: normal;
  font-size: clamp(9px, 2.3vh, 10.5px);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* the milestones on the curve */
.ms {
  position: absolute;
  left: calc(var(--mx) * 100%);
  bottom: calc(var(--my) * 100%);
  width: 0;
  height: 0;
  opacity: 0;
}
.ms__tick {
  position: absolute;
  left: -0.5px;
  bottom: 4px;
  width: 1px;
  height: clamp(10px, 3.4vh, 18px);
  background: linear-gradient(0deg, transparent, rgba(255, 255, 255, 0.4));
  transform-origin: 50% 100%;
}
.ms__tag {
  position: absolute;
  left: 0;
  bottom: calc(clamp(10px, 3.4vh, 18px) + 5px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink);
  background: rgba(30, 33, 40, 0.86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 14px -6px rgba(0, 0, 0, 0.7);
  transition: color 0.4s ease, background-color 0.4s ease;
}
.ms.is-past .ms__tag { color: var(--muted); }
.ms--goal .ms__tag { transform: translateX(-88%); color: #07231a; background: var(--mint); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 6px 16px -6px color-mix(in srgb, var(--mint) 70%, transparent); }
.ms--goal .ms__tag svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* the cursor: the line of today, the point on the curve and the year on a pill */
.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(255, 255, 255, 0.28) 30%, rgba(255, 255, 255, 0.12));
}
.cursor__pt {
  position: absolute;
  left: -5px;
  bottom: calc(var(--y, 0) * 100% - 5px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: inset 0 0 0 2px var(--mint), 0 0 0 3px color-mix(in srgb, var(--card) 80%, transparent);
}
.pill {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  transform: translate(-50%, 0);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 19px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  color: var(--button-ink);
  background: var(--button);
  box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.7), inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}
.dg { display: inline-block; height: 1.2em; line-height: 1.2em; overflow: hidden; }
.dg__strip { display: flex; flex-direction: column; will-change: transform; }
.dg__strip b { display: block; height: 1.2em; font-weight: inherit; text-align: center; width: 0.62em; }

.axis {
  display: flex;
  justify-content: space-between;
  margin: 5px 34px 0 0;
  font-size: clamp(9px, 2.3vh, 10.5px);
  font-variant-numeric: tabular-nums;
}
.axis span { transition: opacity 0.25s ease; }
.axis span.is-hidden { opacity: 0; }
.axis span:first-child { transform: translateX(-2px); }
.axis span:last-child { transform: translateX(6px); }

/* ---------------------------------------------------------------- the mix of the portfolio */
.mix { margin-top: clamp(8px, 2.4vh, 18px); }
.mix__bar {
  display: flex;
  gap: 3px;
  height: clamp(6px, 1.7vh, 8px);
}
.seg { flex: 1 1 0; min-width: 4px; border-radius: 999px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.seg--a { background: linear-gradient(180deg, color-mix(in srgb, var(--mint) 86%, white), var(--mint)); }
.seg--b { background: linear-gradient(180deg, color-mix(in srgb, var(--lilac) 86%, white), var(--lilac)); }
.seg--c { background: var(--cash); }
.mix__legend {
  display: flex;
  justify-content: space-between;
  margin-top: clamp(4px, 1.2vh, 8px);
  font-size: clamp(10px, 2.6vh, 11.5px);
  color: var(--muted);
}
.mix__legend b { font-weight: 620; font-variant-numeric: tabular-nums; display: inline-block; min-width: 2.4em; color: var(--ink); }
.mix__legend span:nth-child(1) b { color: var(--mint); }
.mix__legend span:nth-child(2) b { color: var(--lilac); }

/* ---------------------------------------------------------------- the foot */
.foot {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: clamp(10px, 2.8vh, 20px);
  padding-top: clamp(9px, 2.4vh, 16px);
  border-top: 1px solid var(--line);
}
.goal { flex: 1; min-width: 0; }
.goal__row { display: flex; justify-content: space-between; gap: 6px; font-size: clamp(10.5px, 2.7vh, 12px); font-variant-numeric: tabular-nums; }
.goal__row b { font-weight: 620; }
.goal__track { display: block; position: relative; margin-top: 6px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.goal__fill { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, color-mix(in srgb, var(--mint) 40%, transparent), var(--mint)); transform-origin: 0 50%; transform: scaleX(0); }

.btn {
  position: relative;
  flex: none;
  height: clamp(34px, 9vh, 42px);
  padding: 0 clamp(13px, 3.6vw, 18px);
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  font: inherit;
  font-size: clamp(12px, 3.2vh, 13.5px);
  font-weight: 620;
  color: var(--button-ink);
  background: var(--button);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 8px 20px -10px rgba(0, 0, 0, 0.8);
  -webkit-tap-highlight-color: transparent;
}
.btn__fill { position: absolute; inset: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--mint) 80%, white), var(--mint)); transform-origin: 0 50%; transform: scaleX(0); }
.btn__face { position: relative; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.btn__words { display: inline-block; }
.btn__icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.btn__check { stroke-dasharray: 1; stroke-dashoffset: 1; }
.btn:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
@media (hover: hover) {
  .btn:hover .btn__icon [data-arrow] { transform: translateX(2px); }
  .btn__icon [data-arrow] { transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
}

@media (max-width: 360px) {
  .value__split .split--dep { display: none; }
}
@media (max-height: 460px) {
  .value__label { display: none; }
  .chart__plot { height: clamp(70px, 24vh, 190px); }
}
