/* The loan slider that works out the monthly payment: the personal loan card of an invented lender, alone on black.
   The slider is a ruler of thin ticks; script.js lifts the ticks near the handle, lights the ones on its left and
   moves the pool of light under it. The card's top edge catches the same light (--gx). */
:root {
  --page: #000000;          /* the page */
  --card: #0e0f12;          /* the body of the card */
  --card-top: #15171b;      /* the top of the card, a little lighter */
  --edge: rgba(255, 255, 255, 0.07); /* the edge at rest */
  --ink: #eef0f2;           /* the words */
  --muted: #80858f;         /* the small words */
  --tick: #3a3e46;          /* the ticks that are off */
  --accent: #5ef0b0;        /* the light: lit ticks, the pool, the principal */
  --button: #f3f4f5;        /* the button */
  --button-ink: #0b0c0e;    /* the words on the button */
}

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

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

.card {
  --gx: 30%;
  position: relative;
  width: min(90vw, 340px);
  padding: clamp(14px, 3.6vh, 22px) clamp(16px, 5vw, 22px) clamp(14px, 3.4vh, 20px);
  border-radius: 22px;
  background:
    radial-gradient(120% 60% at var(--gx) -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    linear-gradient(180deg, var(--card-top), var(--card) 46%);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 24px 50px -24px rgba(0, 0, 0, 0.95),
    0 40px 90px -40px color-mix(in srgb, var(--accent) 22%, transparent);
  user-select: none;
  -webkit-user-select: none;
}

/* the top edge catches the light above the handle */
.card__edge {
  position: absolute;
  left: 18px; right: 18px; top: 0;
  height: 1px;
  background: radial-gradient(closest-side at var(--gx) 50%, color-mix(in srgb, var(--accent) 85%, #fff), transparent);
  opacity: 0.7;
  pointer-events: none;
}

.head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #23262c, #121418);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.logo svg { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.head__text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.head__title { font-size: 14px; font-weight: 600; font-variation-settings: 'wdth' 104; letter-spacing: 0.005em; }
.head__meta { font-size: 11.5px; color: var(--muted); }

.chip {
  font-size: 11px;
  font-weight: 560;
  color: var(--accent);
  padding: 4px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 24%, transparent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ask {
  margin: clamp(12px, 3.4vh, 22px) 0 0;
  font-size: 12px;
  color: var(--muted);
}

.amount {
  margin: 2px 0 0;
  font-size: clamp(36px, min(12.4vw, 11vh), 50px);
  line-height: 1.08;
  font-weight: 620;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* rolling text: every character in a window one line high */
.roll { display: inline-flex; white-space: pre; }
.ch {
  position: relative;
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  height: 1.12em;
  line-height: 1.12em;
  transition: width 0.25s ease;
}
.ch__g { display: block; }
.ch__g + .ch__g { position: absolute; left: 0; top: 0; }

/* the slider */
.slider {
  position: relative;
  margin-top: clamp(6px, 1.8vh, 12px);
  padding: 0 2px;
  cursor: grab;
  touch-action: none;
  outline: none;
  border-radius: 10px;
}
.slider.held { cursor: grabbing; }
.slider:focus-visible { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px color-mix(in srgb, var(--accent) 60%, transparent); }

.ruler {
  position: relative;
  height: clamp(38px, 10vh, 48px);
}

.ruler__pool {
  position: absolute;
  left: 0; bottom: -6px;
  width: 140px; height: 54px;
  margin-left: -70px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 26%, transparent), transparent);
  pointer-events: none;
  will-change: transform;
}

.ruler__ticks { position: absolute; inset: 0; }

.tick {
  position: absolute;
  bottom: 6px;
  width: 1.5px;
  height: 100%;
  margin-left: -0.75px;
  border-radius: 1px;
  background: var(--tick);
  transform-origin: 50% 100%;
}
.tick.big { width: 2px; margin-left: -1px; }
.tick.on { background: var(--accent); }

.ruler__base {
  position: absolute;
  left: 0; right: 0; bottom: 3px;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}
.ruler__lit {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 20%, transparent), var(--accent));
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent);
}

.handle {
  position: absolute;
  left: 0; top: -4px; bottom: 0;
  width: 0;
  pointer-events: none;
}
.handle::before {
  content: '';
  position: absolute;
  left: -1px; top: 6px; bottom: 3px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, #fff, color-mix(in srgb, var(--accent) 70%, #fff));
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.handle__knob {
  position: absolute;
  left: -11px; top: -8px;
  width: 22px; height: 16px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #d9dde2 60%, #c4c9cf);
  box-shadow:
    inset 0 1px 0 #fff,
    inset 0 -1px 1px rgba(0, 0, 0, 0.18),
    0 1px 1px rgba(0, 0, 0, 0.5),
    0 6px 14px -4px rgba(0, 0, 0, 0.8),
    0 0 18px -2px color-mix(in srgb, var(--accent) 50%, transparent);
  display: grid;
  place-items: center;
  transform-origin: 50% 100%;
}
.handle__grip {
  width: 8px; height: 5px;
  background: repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.32) 0 1px, transparent 1px 3.5px);
}

.scale {
  position: relative;
  height: 14px;
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.scale span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  transition: color 0.3s ease;
}
.scale span:first-child { transform: none; }
.scale span:last-child { transform: translateX(-100%); }
.scale span.on { color: var(--ink); }

/* the numbers below */
.stats {
  margin: clamp(10px, 2.8vh, 18px) 0 0;
  display: grid;
  grid-template-columns: 1.25fr 0.9fr 1fr;
  gap: 8px;
}
.stat { margin: 0; }
.stat dt { font-size: 11px; color: var(--muted); }
.stat dd {
  margin: 3px 0 0;
  font-size: 14px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat .stat__big { font-size: 17px; font-weight: 620; letter-spacing: -0.01em; color: var(--ink); }
.stat--end { text-align: right; }
.stat--end dd .roll { justify-content: flex-end; }

.split {
  position: relative;
  display: flex;
  gap: 3px;
  height: 4px;
  margin-top: clamp(8px, 2vh, 12px);
}
.split span { display: block; flex: 1 1 0; min-width: 4px; height: 100%; border-radius: 4px; }
.split__a { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, transparent), var(--accent)); }
.split__b { background: color-mix(in srgb, var(--accent) 22%, #2a2d33); }

/* the button */
.go {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: clamp(44px, 11vh, 50px);
  margin-top: clamp(12px, 3.2vh, 20px);
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, var(--button));
  color: var(--button-ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 100;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 1px 0 rgba(255, 255, 255, 0.1), 0 10px 24px -12px rgba(255, 255, 255, 0.25);
  transition: font-variation-settings 0.35s cubic-bezier(.3, 1.6, .5, 1);
  -webkit-tap-highlight-color: transparent;
}
.go:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (hover: hover) {
  .go:hover { font-variation-settings: 'wdth' 112; }
}
.go > span { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 7px; }
.go__label { gap: 0.28em !important; }
.go__label .roll { font-variant-numeric: tabular-nums; }
.go__shine {
  position: absolute !important;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--accent) 45%, #fff) 50%, transparent 70%);
  transform: translateX(-110%);
  z-index: -1;
  opacity: 0.6;
}
.go__wait, .go__done { opacity: 0; }
.go__wait svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-dasharray: 30 60; stroke-linecap: round; }
.go__done svg { width: 18px; height: 18px; fill: none; stroke: #0b7a4f; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.go.done { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent)); }
.go { transition: font-variation-settings 0.35s cubic-bezier(.3, 1.6, .5, 1), background 0.4s ease; }

.ghost {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px;
  pointer-events: none; z-index: 5; opacity: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}
.ghost path { fill: #ffffff; stroke: #0b0c0e; stroke-width: 1.3; stroke-linejoin: round; }

/* on large screens the card grows a little */
@media (min-width: 1000px) and (min-height: 700px) {
  .card { transform: scale(1.4); }
}
