/* The set aside button with the glass that fills to the goal. A dark room with a soft mint lamp behind and a fine
   grain, and in the middle one pill of smoked glass. Inside, layered in one rounded box (.sv__body, moved only by
   GSAP): the glass, the SVG of the savings level (the hatched ghost of the next step, the mint liquid with its lip,
   the soft glow and the bright line of its surface, the goal mark), the light under the pointer, the edge light that
   turns towards the pointer and the glass rim. Then the row: the glass disc with the plane, two lines of words and
   the chip with the percent saved. Over everything, outside the pill, the thin anamorphic streak of the success. */
:root {
  --page: #06090a;            /* the room */
  --lamp: #0f2a24;            /* the soft lamp behind the button */
  --smoke: #0d1413;           /* the smoked glass */
  --mint: #8ff5cf;            /* the light: liquid surface, edge, streak, mark */
  --emerald: #23b688;         /* the body of the liquid */
  --deep: #0a5a45;            /* the bottom of the liquid */
  --ink: #eef7f3;             /* the words */
  --muted: rgba(226, 244, 236, 0.56); /* the small line under the words */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* the room: a soft mint lamp behind the button, a cool floor and a fine grain over everything */
.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  background:
    radial-gradient(min(72vw, 540px) min(44vh, 300px) at 50% 46%, color-mix(in srgb, var(--lamp) 92%, transparent), transparent 72%),
    radial-gradient(min(120vw, 900px) min(80vh, 600px) at 50% 128%, rgba(20, 70, 56, 0.32), transparent 70%),
    var(--page);
}

.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.9 0 0 0 0 1 0 0 0 0 0.95 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

.sv {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}

/* the light the glass throws on the table under it, stronger where the liquid is */
.sv__spill {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 104%;
  height: 40px;
  margin: -16px 0 0 -52%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--mint) 46%, transparent), color-mix(in srgb, var(--emerald) 16%, transparent) 55%, transparent);
  filter: blur(14px);
  opacity: 0.16;
  pointer-events: none;
}

/* the anamorphic streak: a hairline of light much wider than the pill, with a soft glow around it */
.sv__streak {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(100% + 2 * min(46px, 5vw));
  height: 0;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
  mix-blend-mode: screen;
}

.sv__streak-line,
.sv__streak-glow {
  position: absolute;
  left: 0;
  right: 0;
  opacity: 0;
}

.sv__streak-line {
  top: -1px;
  height: 1.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--mint) 70%, transparent) 22%, #f4fffb 50%, color-mix(in srgb, var(--mint) 70%, transparent) 78%, transparent);
}

.sv__streak-glow {
  top: -11px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--mint) 45%, transparent), transparent);
  filter: blur(4px);
}

.sv__btn {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

.sv__btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--mint) 80%, white);
  outline-offset: 5px;
}

.sv__body {
  --mx: 50%;
  --my: 50%;
  --ea: 200deg;
  position: relative;
  display: block;
  width: min(86vw, 328px);
  height: 60px;
  border-radius: 999px;
  isolation: isolate;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.8),
    0 8px 18px -10px rgba(0, 0, 0, 0.9),
    0 24px 48px -24px rgba(0, 0, 0, 1),
    0 12px 30px -20px color-mix(in srgb, var(--mint) 26%, transparent);
}

.sv__glass,
.sv__shine,
.sv__edge,
.sv__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

/* smoked glass: deep, lighter at the top, a faint cool reflection of the lamp across the upper half */
.sv__glass {
  background:
    radial-gradient(120% 140% at 50% -40%, rgba(200, 255, 235, 0.09), transparent 60%),
    linear-gradient(180deg, rgba(230, 255, 246, 0.07), rgba(230, 255, 246, 0.01) 50%, rgba(0, 0, 0, 0.32)),
    var(--smoke);
}

/* the savings level, drawn by the script in the pill's own pixels and clipped to its round ends */
.sv__level {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
  clip-path: inset(0 round 999px);
}

.sv__ghost {
  opacity: 0;
}

.sv__glow {
  fill: none;
  stroke: var(--mint);
  stroke-width: 7;
  stroke-opacity: 0.28;
}

.sv__surface {
  fill: none;
  stroke: color-mix(in srgb, var(--mint) 70%, white);
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-opacity: 0.9;
}

.sv__tick {
  fill: rgba(220, 255, 242, 0.13);
  transition: fill 0.4s;
}

.sv__tick.is-lit {
  fill: color-mix(in srgb, var(--mint) 55%, transparent);
}

.sv__mark {
  opacity: 0;
  filter: drop-shadow(0 0 3px color-mix(in srgb, var(--mint) 70%, transparent));
}

/* the light under the pointer */
.sv__shine {
  background: radial-gradient(110px 66px at var(--mx) var(--my), rgba(214, 255, 240, 0.12), rgba(214, 255, 240, 0.03) 50%, transparent 72%);
  opacity: 0;
}

/* the edge light: a mint arc on the hairline, turned towards the pointer (--ea) */
.sv__edge {
  z-index: 3;
  padding: 1px;
  background: conic-gradient(from calc(var(--ea) - 60deg), transparent 0deg, color-mix(in srgb, var(--mint) 80%, white) 60deg, transparent 120deg, transparent 360deg);
  -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);
  opacity: 0;
}

/* the glass rim: a cool hairline, bright at the top, dark at the bottom, and a soft highlight like a bevel */
.sv__rim {
  z-index: 3;
  box-shadow:
    inset 0 0 0 1px rgba(200, 255, 236, 0.12),
    inset 0 1px 0 rgba(236, 255, 248, 0.26),
    inset 0 -1px 0 rgba(0, 0, 0, 0.6),
    inset 0 -12px 18px -12px rgba(0, 0, 0, 0.55);
}

.sv__rim::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 1px;
  height: 42%;
  border-radius: 999px 999px 40% 40%;
  background: linear-gradient(180deg, rgba(236, 255, 248, 0.08), rgba(236, 255, 248, 0));
}

.sv__row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 9px 0 8px;
  gap: 11px;
}

/* the glass disc on the left: the trip's plane, then the check */
.sv__icon {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

.sv__icon-face {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 22%, rgba(236, 255, 248, 0.22), transparent 60%),
    linear-gradient(180deg, rgba(143, 245, 207, 0.16), rgba(10, 90, 69, 0.3));
  box-shadow:
    inset 0 0 0 1px rgba(200, 255, 236, 0.2),
    inset 0 1px 0 rgba(240, 255, 250, 0.4),
    inset 0 -6px 10px -6px rgba(0, 0, 0, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.5);
}

.is-done .sv__icon-face {
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.7), transparent 62%),
    linear-gradient(180deg, color-mix(in srgb, var(--mint) 92%, white), var(--emerald));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -6px 10px -6px rgba(0, 60, 40, 0.5),
    0 2px 10px color-mix(in srgb, var(--mint) 30%, transparent);
}

.sv__icon-face > svg {
  grid-area: 1 / 1;
  width: 21px;
  height: 21px;
  overflow: visible;
}

.sv__plane path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.sv__check path {
  fill: none;
  stroke: #04261c;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.sv__text {
  flex: 1;
  display: grid;
  min-width: 0;
  text-align: left;
}

.sv__state {
  grid-area: 1 / 1;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sv__state + .sv__state {
  opacity: 0;
}

.sv__title {
  font-size: 15.5px;
  font-weight: 580;
  font-variation-settings: 'wdth' 102;
  letter-spacing: 0.002em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

/* Moving shimmers: a mint band runs through the letters (GSAP moves background-position) */
.sv__title--busy {
  background: linear-gradient(90deg, var(--ink) 0%, var(--ink) 38%, #ffffff 46%, var(--mint) 50%, #ffffff 54%, var(--ink) 62%, var(--ink) 100%);
  background-size: 260% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.sv__sub {
  font-size: 11.5px;
  font-weight: 460;
  font-variation-settings: 'wdth' 96;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.sv__state--done .sv__sub {
  color: color-mix(in srgb, var(--mint) 78%, var(--ink));
}

/* the chip: the percent of the goal; on hover the next percent rises in */
.sv__chip {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 58px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(230, 255, 246, 0.09), rgba(230, 255, 246, 0.02));
  box-shadow:
    inset 0 0 0 1px rgba(200, 255, 236, 0.14),
    inset 0 1px 0 rgba(236, 255, 248, 0.16),
    0 1px 2px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 620;
  font-variation-settings: 'wdth' 96;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.sv__chip > * {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.sv__chip-unit {
  margin-left: 1px;
  font-size: 10.5px;
  font-weight: 520;
  opacity: 0.6;
}

.sv__chip-next {
  color: var(--mint);
  gap: 2px;
  opacity: 0;
}

.sv__chip-next svg {
  width: 11px;
  height: 11px;
}

.sv__chip-next path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.is-done .sv__chip {
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--mint) 40%, transparent),
    inset 0 1px 0 rgba(236, 255, 248, 0.24),
    0 0 14px -4px color-mix(in srgb, var(--mint) 40%, transparent);
  color: var(--mint);
  transition: box-shadow 0.6s, color 0.6s;
}
