/* The Train model button with the falling loss curve. One rounded box (.tm__body, moved only by GSAP) holds a clip
   layer with the graphite base, the SVG chart, the pointer light and the reflection; over it the rim that catches
   the light and the row with the icon, the words and the chip. The page is near black with a soft light and grain. */
:root {
  --page: #08090b;            /* the page */
  --pill: #15171b;            /* the body of the button */
  --ink: #f1f2f4;             /* the words */
  --muted: rgba(241, 242, 244, 0.56); /* the small words */
  --accent: #7df0c0;          /* the loss curve and the success */
  --second: #7a92ff;          /* the validation curve */
  --edge: rgba(255, 255, 255, 0.09);  /* the edge at rest */
}

* {
  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 page: a soft cold light from above, a faint mint pool under the button, a vignette and grain */
.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(60% 46% at 50% 38%, rgba(140, 160, 200, 0.07), transparent 70%),
    radial-gradient(34% 22% at 50% 60%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 75%),
    radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55)),
    var(--page);
}

.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  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 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

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

/* the light the button throws on the floor */
.tm__floor {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 110%;
  height: 44px;
  margin: -16px 0 0 -55%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 55%, transparent), color-mix(in srgb, var(--second) 18%, transparent) 60%, transparent);
  filter: blur(16px);
  opacity: 0.08;
  pointer-events: none;
}

.tm__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;
}

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

.tm__body {
  --mx: 50%;
  --my: 50%;
  position: relative;
  display: block;
  width: min(84vw, 296px);
  height: 60px;
  border-radius: 999px;
  isolation: isolate;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.8),
    0 6px 14px -6px rgba(0, 0, 0, 0.9),
    0 26px 50px -24px rgba(0, 0, 0, 1),
    0 0 0 1px rgba(0, 0, 0, 0.6);
}

.tm__clip,
.tm__base,
.tm__shine,
.tm__sweep,
.tm__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.tm__clip,
.tm__sweep {
  overflow: hidden;
}

/* graphite: lighter at the top, a little darker at the bottom */
.tm__base {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.015) 50%, rgba(0, 0, 0, 0.18)),
    var(--pill);
}

.tm__chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tm__chart path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tm__grid line {
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.tm__ghost {
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1;
  stroke-dasharray: 1.5 2.5;
}

.tm__area {
  fill: url(#tm-area) !important;
  stroke: none !important;
}

.tm__val {
  stroke: var(--second);
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
  opacity: 0.75;
}

.tm__glow {
  stroke: var(--accent);
  stroke-width: 4;
  opacity: 0.5;
}

.tm__line {
  stroke: var(--accent);
  stroke-width: 1.6;
}

.tm__ticks line {
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 1;
}

.tm__ticks line.is-on {
  stroke: var(--accent);
}

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

/* the reflection that crosses the pill at the end */
.tm__sweep-band {
  position: absolute;
  top: -30%;
  left: 0;
  width: 34%;
  height: 160%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0.04) 30%, rgba(255, 255, 255, 0.22) 50%, rgba(255, 255, 255, 0.04) 70%, transparent 100%);
}

/* the 1px edge, the light on the top lip and the shadow on the bottom one */
.tm__rim {
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    inset 0 -12px 18px -14px rgba(0, 0, 0, 0.7);
}

.tm__rim::after {
  content: '';
  position: absolute;
  left: 14%;
  right: 14%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  opacity: 0.6;
}

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

.tm__icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 2px 6px -2px rgba(0, 0, 0, 0.8);
}

.tm__icon svg {
  width: 20px;
  height: 20px;
  overflow: visible;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tm__mini-axis {
  stroke: rgba(255, 255, 255, 0.32);
  stroke-width: 1.4;
}

.tm__mini {
  stroke: var(--accent);
  stroke-width: 1.9;
}

.tm__check {
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
}

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

.tm__label {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-width: 0;
}

.tm__main {
  font-size: 16px;
  line-height: 1.15;
  font-weight: 580;
  font-variation-settings: 'wdth' 104;
  letter-spacing: 0.003em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (hover: hover) {
  .tm__btn:hover .tm__main {
    font-variation-settings: 'wdth' 112;
  }
}

/* Training shimmers: a band of light slides through the letters (GSAP moves background-position) */
.tm__main--busy {
  background: linear-gradient(90deg, var(--ink) 0%, var(--ink) 38%, #ffffff 46%, var(--accent) 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;
}

.tm__sub {
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.2;
  font-weight: 480;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* the epoch number rolls: the old one goes up, the new one comes from below */
.tm__roll {
  position: relative;
  display: inline-grid;
  vertical-align: baseline;
  overflow: hidden;
  height: 1.2em;
  line-height: 1.2em;
  min-width: 0.62em;
  text-align: center;
  color: var(--ink);
}

.tm__roll > span {
  grid-area: 1 / 1;
  display: block;
  line-height: 1.2em;
}

.tm__chip {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 72px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.025));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.13), 0 1px 3px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: hidden;
}

.tm__chip-face {
  grid-area: 1 / 1;
  font-size: 12px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wdth' 92;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tm__ver {
  color: var(--accent);
}

/* the loss, written at the top right of the chart */
.tm__value {
  fill: var(--ink);
  font-size: 10.5px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wdth' 92;
  letter-spacing: 0.02em;
}

/* before the script runs, only the rest state shows */
.tm__label + .tm__label {
  opacity: 0;
}
