/* The yard savings calculator with rising numbers: a light card with three sliders and the dark results panel of
   Yardline, a made-up yard operating system. The panel's shape (rounded corners, the tab on top and the notch that
   travels) is one SVG path rebuilt by the script; the same path clips the glow, the haze, the divider and the grain. */
:root {
  --page: #e8ebe5;          /* the page */
  --page-glow: #f6f8f1;     /* the light behind the card */
  --card: #fbfcf8;          /* the card */
  --ink: #052424;           /* the words, the filled track, the panel */
  --muted: #6c7a75;         /* the small words */
  --rail: rgba(5, 36, 36, 0.13); /* the empty part of a track */
  --hot: #86c900;           /* the tip of the track under the moving thumb */
  --panel: #041c1c;         /* the panel, bottom */
  --panel-top: #0a3431;     /* the panel, top */
  --on-panel: #f1f5ec;      /* the words on the panel */
  --on-panel-muted: rgba(241, 245, 236, 0.5); /* the small words on the panel */
  --lime: #abff02;          /* the one accent */
}

* {
  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: 16px;
  overflow: hidden;
  background: radial-gradient(70% 60% at 50% 42%, var(--page-glow), transparent 70%), var(--page);
}

/* the grain on the page, a tile made by the script */
.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--grain, none);
  background-size: 128px 128px;
  opacity: 0.1;
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the card */
.calc {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1.06fr;
  gap: 8px;
  width: min(880px, 94vw);
  padding: 8px;
  border-radius: 26px;
  background: linear-gradient(180deg, #ffffff, var(--card) 40%);
  box-shadow:
    0 0 0 1px rgba(5, 36, 36, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 2px rgba(5, 36, 36, 0.05),
    0 10px 24px -10px rgba(5, 36, 36, 0.12),
    0 44px 80px -36px rgba(5, 36, 36, 0.28);
  opacity: 0;
}

.calc__inputs {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(14px, 3.4vh, 30px);
  padding: clamp(16px, 4vh, 36px) clamp(16px, 3vw, 34px);
  min-width: 0;
}

.calc__head {
  display: grid;
  gap: 8px;
}

.calc__eyebrow,
.panel__label {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.calc__title {
  margin: 0;
  font-size: clamp(19px, min(2.7vw, 4.4vh), 30px);
  line-height: 1.04;
  font-weight: 560;
  font-variation-settings: 'wdth' 96;
  letter-spacing: -0.032em;
  text-wrap: balance;
}

/* ---------------------------------------------------------------- a slider */
.knob {
  display: grid;
  gap: 10px;
}

.knob__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.knob__label {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--muted);
  transition: color 0.3s ease;
}

.knob.is-active .knob__label {
  color: var(--ink);
}

.knob__value {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.knob__unit {
  margin-left: 4px;
  font-weight: 400;
  color: var(--muted);
}

.knob__rail {
  position: relative;
  height: 22px;
}

.knob__track {
  position: absolute;
  left: 0;
  right: 0;
  top: 9px;
  height: 4px;
  border-radius: 4px;
  background: var(--rail);
  box-shadow: inset 0 1px 1px rgba(5, 36, 36, 0.08);
}

.knob__ticks {
  position: absolute;
  left: 0;
  right: 0;
  top: 18px;
  height: 4px;
  display: flex;
  justify-content: space-between;
}

.knob__ticks i {
  width: 1px;
  height: 3px;
  background: var(--ink);
  opacity: 0.16;
  transition: opacity 0.25s ease, height 0.25s ease;
}

.knob__ticks i.on {
  opacity: 0.5;
}

.knob__ticks i.near {
  height: 4px;
  opacity: 0.9;
}

/* GSAP moves the thumb, the face under it takes the pressure */
.knob__thumb {
  position: absolute;
  left: -11px;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  z-index: 1;
}

.knob__face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #ffffff, #eef1ea 70%);
  box-shadow:
    0 0 0 1px rgba(5, 36, 36, 0.16),
    inset 0 1px 0 #ffffff,
    0 1px 2px rgba(5, 36, 36, 0.18),
    0 4px 10px -2px rgba(5, 36, 36, 0.2);
  transition: transform 0.42s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

/* the little core: dark at rest, lime while held */
.knob__face::before {
  content: '';
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--ink);
  transition: background-color 0.2s ease, inset 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* the halo of the press */
.knob__face::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(5, 36, 36, 0.12);
  background: rgba(171, 255, 2, 0.16);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.25s ease, transform 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.knob.is-pressed .knob__face {
  transform: scale(0.9);
  box-shadow:
    0 0 0 1px rgba(5, 36, 36, 0.24),
    inset 0 1px 0 #ffffff,
    0 1px 1px rgba(5, 36, 36, 0.2);
}

.knob.is-pressed .knob__face::before {
  inset: 6px;
  background: var(--lime);
  box-shadow: inset 0 0 0 1px rgba(5, 36, 36, 0.35);
}

.knob.is-pressed .knob__face::after {
  opacity: 1;
  transform: scale(1);
}

/* the real range input lies over the rail, invisible, for the finger, the mouse and the keyboard */
.knob__input {
  position: absolute;
  left: -11px;
  right: -11px;
  top: -8px;
  bottom: -8px;
  width: calc(100% + 22px);
  height: calc(100% + 16px);
  margin: 0;
  opacity: 0;
  cursor: pointer;
  touch-action: none;
}

.knob__input:focus-visible ~ .knob__thumb .knob__face {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink);
}

@media (hover: hover) {
  .knob__rail:hover .knob__face {
    transform: scale(1.08);
  }
  .knob.is-pressed .knob__rail:hover .knob__face {
    transform: scale(0.9);
  }
}

/* ---------------------------------------------------------------- the panel */
.panel {
  position: relative;
  min-width: 0;
  color: var(--on-panel);
}

.panel__shape {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 18px 24px rgba(4, 28, 28, 0.22));
}

.panel__edge {
  fill: none;
  stroke-width: 1;
}

.panel__divider {
  fill: none;
  stroke: url(#yl-div);
  stroke-width: 1;
}

.panel__grain {
  opacity: 0.09;
  mix-blend-mode: screen;
}

.panel__in {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: clamp(40px, 7vh, 58px) clamp(18px, 3vw, 34px) clamp(16px, 3.4vh, 28px) clamp(48px, 5.4vw, 58px);
  min-height: 100%;
}

.panel__kicker {
  margin: 0;
  font-size: clamp(15px, min(1.9vw, 3vh), 21px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.panel__kicker span {
  color: var(--on-panel-muted);
}

.panel__total {
  margin: clamp(6px, 1.4vh, 12px) 0 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: clamp(34px, min(5.4vw, 9vh), 58px);
  line-height: 1;
  font-weight: 520;
  font-variation-settings: 'wdth' 100;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  white-space: nowrap;
}

.panel__cur {
  font-size: 0.56em;
  font-weight: 450;
  align-self: flex-start;
  margin-top: 0.12em;
  color: var(--on-panel-muted);
}

.panel__per {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--on-panel-muted);
  margin-left: 4px;
}

.panel__pct {
  margin: clamp(8px, 1.6vh, 14px) 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--on-panel-muted);
}

/* the percentage: two columns of digits that roll */
.pct {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 7px;
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 600;
  line-height: 24px;
  color: var(--lime);
  background: rgba(171, 255, 2, 0.08);
  box-shadow: inset 0 0 0 1px rgba(171, 255, 2, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.pct__col {
  display: inline-block;
  height: 24px;
  overflow: hidden;
}

.pct__col span {
  display: block;
  height: 24px;
}

.panel__rule {
  display: block;
  height: 1px;
  margin: clamp(14px, 3.2vh, 26px) 0 clamp(12px, 2.4vh, 18px);
}

.panel__label {
  margin: 0 0 clamp(8px, 1.6vh, 12px);
  color: var(--on-panel-muted);
  font-size: 10px;
}

/* ---------------------------------------------------------------- the savings lines */
.items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: clamp(6px, 1.5vh, 12px);
}

.item {
  display: grid;
  grid-template-columns: minmax(0, 7.6em) 1fr auto;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
}

.item__name {
  color: var(--on-panel-muted);
  white-space: nowrap;
  transition: color 0.3s ease;
}

.item__bar {
  position: relative;
  height: 3px;
  border-radius: 3px;
  background: rgba(241, 245, 236, 0.09);
}

/* GSAP scales the fill */
.item__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(241, 245, 236, 0.5);
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.item__amount {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 7ch;
}

.item.is-active .item__name {
  color: var(--on-panel);
}

.item.is-active .item__fill {
  background: var(--lime);
  box-shadow: 0 0 10px rgba(171, 255, 2, 0.55);
}

/* ---------------------------------------------------------------- the button */
.cta {
  margin-top: clamp(14px, 3.4vh, 28px);
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cta__face {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 14px 0 16px;
  border-radius: 9px;
  background: linear-gradient(180deg, #c3ff4a, var(--lime) 55%, #9ef000);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(5, 36, 36, 0.18),
    0 0 0 1px rgba(5, 36, 36, 0.5),
    0 6px 18px -6px rgba(171, 255, 2, 0.45);
  transition: box-shadow 0.3s ease;
}

.cta__words {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: pre;
}

.cta__words .ch {
  display: inline-block;
  visibility: hidden;
}

.cta__arrow {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cta.is-hover .cta__arrow {
  transform: translateX(2px);
}

.cta.is-hover .cta__face {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(5, 36, 36, 0.18),
    0 0 0 1px rgba(5, 36, 36, 0.5),
    0 8px 26px -6px rgba(171, 255, 2, 0.7);
}

.cta:focus-visible {
  outline: none;
}

.cta:focus-visible .cta__face {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--lime);
}

/* ---------------------------------------------------------------- the drawn pointer */
.hand {
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  margin: -3px 0 0 -4px;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}

.hand__svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 2px 3px rgba(5, 36, 36, 0.3));
}

.hand__svg path {
  fill: #ffffff;
  stroke: var(--ink);
  stroke-width: 1.3;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------------- the phone: stacked, sliders over the result */
@media (max-width: 640px) {
  .stage {
    padding: 6px 10px;
  }
  .calc {
    grid-template-columns: 1fr;
    width: min(100%, 440px);
    gap: 4px;
    padding: 5px;
    border-radius: 20px;
  }
  .calc__inputs {
    gap: min(8px, 1.8vh);
    padding: min(12px, 2.6vh) 12px min(6px, 1.4vh);
  }
  .calc__eyebrow {
    display: none;
  }
  .calc__title {
    font-size: clamp(15px, 4.6vw, 20px);
  }
  .knob {
    gap: 0;
  }
  .knob__label,
  .knob__value {
    font-size: 12.5px;
  }
  .knob__rail {
    height: 20px;
  }
  .knob__track {
    top: 8px;
  }
  .knob__ticks {
    top: 16px;
  }
  .knob__thumb {
    top: -1px;
  }
  .panel__in {
    padding: 31px 14px 10px;
  }
  .panel__kicker {
    font-size: 12.5px;
  }
  .panel__total {
    margin-top: 2px;
    font-size: clamp(26px, min(8.6vw, 7.4vh), 40px);
  }
  .panel__per {
    font-size: 10px;
  }
  .panel__pct {
    position: absolute;
    right: 14px;
    top: 52px;
    margin: 0;
  }
  .panel__pct-words {
    display: none;
  }
  .panel__rule {
    margin: min(9px, 1.8vh) 0 min(7px, 1.4vh);
  }
  .panel__label {
    display: none;
  }
  .items {
    gap: min(4px, 0.8vh);
  }
  .item {
    font-size: 12px;
    gap: 10px;
  }
  .item__amount {
    font-size: 11.5px;
  }
  .cta {
    margin-top: min(10px, 2vh);
    align-self: stretch;
  }
  .cta__face {
    width: 100%;
    justify-content: space-between;
    height: 32px;
  }
  .cta__words {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .knob__face,
  .knob__face::before,
  .knob__face::after,
  .cta__arrow {
    transition-property: opacity, background-color, box-shadow;
  }
}
