/* The Trade in button that values your old phone. The button is one rounded box (.ti__body, moved only by GSAP) with
   layers inside: the brushed graphite (.ti__metal), a stretched highlight that follows the pointer (.ti__spec), a
   soft band that scans while it works (.ti__scan), the reflection of the end (.ti__glint) and a 1px rim cut out with
   a mask (.ti__rim). On top the row: the well with the little phone, the two lines of words and the chip, which holds
   both the starting price and the rolling digits in the same cell, so nothing shifts when they swap. */
:root {
  --page: #0b0a09;            /* the page */
  --page-glow: #3a2c1c;       /* the warm light on the page behind the button */
  --metal-top: #2e2c29;       /* the graphite at the top */
  --metal-bottom: #141312;    /* the graphite at the bottom */
  --champagne: #e9caa0;       /* the accent: credit, scan, light */
  --champagne-deep: #c79d68;  /* the darker side of the accent */
  --ink: #f4efe7;             /* the words */
  --muted: rgba(244, 239, 231, 0.56); /* the small words */
  --on-accent: #241a0f;       /* words over the 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;
}

/* a fine grain over the whole page */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  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='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.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(min(70vw, 520px) min(42vh, 300px) at 50% 46%, color-mix(in srgb, var(--page-glow) 85%, transparent), transparent 70%),
    radial-gradient(min(110vw, 900px) min(80vh, 600px) at 50% 120%, rgba(255, 255, 255, 0.035), transparent 70%);
}

.ti {
  position: relative;
  display: grid;
  place-items: center;
}

/* the warm light the button throws on the floor */
.ti__floor {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 100%;
  height: 40px;
  margin: -12px 0 0 -50%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--champagne) 42%, transparent), color-mix(in srgb, var(--champagne-deep) 14%, transparent) 60%, transparent);
  filter: blur(14px);
  opacity: 0.3;
  pointer-events: none;
}

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

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

.ti__body {
  --mx: 50%;
  --my: 40%;
  position: relative;
  display: block;
  width: min(88vw, 322px);
  height: 60px;
  border-radius: 999px;
  isolation: isolate;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.9),
    0 2px 3px rgba(0, 0, 0, 0.55),
    0 12px 22px -10px rgba(0, 0, 0, 0.9),
    0 30px 60px -30px rgba(0, 0, 0, 1),
    0 14px 30px -18px color-mix(in srgb, var(--champagne-deep) 45%, transparent);
}

.ti__metal,
.ti__spec,
.ti__scan,
.ti__glint {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
}

/* brushed graphite: horizontal grain from stretched noise, a soft sheen and a darker belly */
.ti__metal {
  z-index: -2;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='120'%3E%3Cfilter id='b'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.003 0.95' numOctaves='2' seed='7'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23b)' opacity='0.55'/%3E%3C/svg%3E"),
    linear-gradient(102deg, transparent 18%, rgba(255, 255, 255, 0.05) 34%, transparent 52%, rgba(255, 255, 255, 0.03) 74%, transparent 88%),
    linear-gradient(180deg, var(--metal-top), var(--metal-bottom) 78%, #191816);
  background-size: 420px 120px, 100% 100%, 100% 100%;
  background-blend-mode: soft-light, normal, normal;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -10px 18px -10px rgba(0, 0, 0, 0.65),
    inset 0 10px 16px -12px rgba(255, 255, 255, 0.08);
}

/* the highlight on brushed metal is stretched across the grain: a tall soft ellipse under the pointer */
.ti__spec {
  z-index: -1;
  opacity: 0;
  background:
    radial-gradient(34px 70px at var(--mx) var(--my), rgba(255, 238, 212, 0.26), transparent 70%),
    radial-gradient(120px 90px at var(--mx) var(--my), color-mix(in srgb, var(--champagne) 14%, transparent), transparent 72%);
  mix-blend-mode: screen;
}

/* while it works: a soft champagne band goes back and forth across the metal */
.ti__scan {
  z-index: -1;
  opacity: 0;
}

.ti__scan-band {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 34%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--champagne) 16%, transparent) 50%, transparent);
  mix-blend-mode: screen;
}

/* the reflection that crosses the metal once at the end */
.ti__glint-band {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 26%;
  background: linear-gradient(90deg, transparent, rgba(255, 246, 232, 0.05) 30%, rgba(255, 246, 232, 0.32) 50%, rgba(255, 246, 232, 0.05) 70%, transparent);
  mix-blend-mode: screen;
}

/* the 1px rim: light on top, almost nothing on the sides, a warm hint under */
.ti__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.06) 38%, rgba(255, 255, 255, 0.02) 62%, color-mix(in srgb, var(--champagne) 26%, 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);
}

.ti__rim--hot {
  opacity: 0;
  padding: 1.2px;
  background:
    radial-gradient(70px 40px at var(--mx) 0%, rgba(255, 240, 216, 0.95), transparent 70%),
    radial-gradient(70px 40px at var(--mx) 100%, color-mix(in srgb, var(--champagne) 75%, transparent), transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--champagne) 40%, transparent), color-mix(in srgb, var(--champagne) 40%, transparent));
}

.ti__row {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 0 10px;
}

/* the round well the old phone sits in, pressed into the metal */
.ti__well {
  flex: none;
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 30%, #121110, #1d1b19 70%, #24221f);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.75),
    inset 0 -1px 0 rgba(255, 255, 255, 0.07),
    0 1px 0 rgba(255, 255, 255, 0.06);
}

.ti__dev {
  display: block;
  width: 28px;
  height: 28px;
}

.ti__dev svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ti__case {
  fill: #2b2926;
  stroke: rgba(244, 239, 231, 0.82);
  stroke-width: 1.2;
}

.ti__glass {
  fill: #0e0d0c;
}

.ti__lit {
  fill: var(--champagne);
  opacity: 0;
}

.ti__speaker {
  fill: none;
  stroke: rgba(244, 239, 231, 0.5);
  stroke-width: 0.8;
  stroke-linecap: round;
}

.ti__scanline {
  fill: none;
  stroke: var(--champagne);
  stroke-width: 0.7;
  stroke-linecap: round;
}

.ti__scanglow {
  fill: var(--champagne);
  opacity: 0.22;
}

[data-scanline] {
  opacity: 0;
}

.ti__check {
  fill: none;
  stroke: var(--on-accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
}

.ti__text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.ti__stack {
  display: grid;
  overflow: hidden;
  padding: 1px 0;
}

.ti__stack > * {
  grid-area: 1 / 1;
  white-space: nowrap;
}

.ti__label {
  font-size: 15.5px;
  line-height: 1.15;
  font-weight: 620;
  font-stretch: 104%;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.ti__cap {
  font-size: 11.5px;
  line-height: 1.2;
  font-weight: 460;
  letter-spacing: 0.01em;
  color: var(--muted);
}

/* the chip: the starting price and the rolling digits share one cell */
.ti__chip {
  flex: none;
  position: relative;
  display: grid;
  place-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.5);
  isolation: isolate;
}

.ti__chip-fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  opacity: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 50%) top / 100% 50% no-repeat,
    linear-gradient(180deg, var(--champagne), var(--champagne-deep));
  box-shadow:
    inset 0 0 0 1px rgba(255, 240, 216, 0.5),
    0 4px 14px -4px color-mix(in srgb, var(--champagne) 60%, transparent);
}

.ti__face {
  grid-area: 1 / 1;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 560;
  letter-spacing: 0.005em;
  color: rgba(244, 239, 231, 0.8);
  font-variant-numeric: tabular-nums;
}

.ti__odo {
  display: flex;
  align-items: center;
  font-size: 14.5px;
  font-weight: 660;
  color: var(--champagne);
  opacity: 0;
}

.ti__cur {
  margin-right: 0.5px;
}

.ti__cols {
  display: flex;
  line-height: 1.2em;
  height: 1.2em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}

.ti__col {
  display: block;
  width: 0.6em;
  text-align: center;
}

.ti__strip {
  display: block;
  line-height: 1.2em;
  will-change: transform;
}

.ti__strip > span {
  display: block;
  height: 1.2em;
  line-height: 1.2em;
}
