/* The stage elevation profile with the climbs that light up: the route card of a made-up cycling app on a near black
   page with two soft lights and a fine grain. The chart is one SVG rebuilt in pixels at every resize, so its lines
   stay one pixel thin at any size; the tooltip, the climb flags and the axis are HTML over it. */
:root {
  --page: #09090b;          /* the page */
  --card: #111114;          /* the body of the card */
  --card-top: #17171b;      /* the top of the card, where the light falls */
  --edge: rgba(255, 255, 255, 0.075); /* its edge at rest */
  --ink: #eeeef1;           /* the words */
  --muted: #85858f;         /* the small words */
  --faint: rgba(255, 255, 255, 0.06); /* the grid */
  --flat: #c9cedb;          /* the line on the flat */
  --amber: #ffbe62;         /* the line on a climb */
  --coral: #ff6a4f;         /* the line where it gets steep */
  --button: #f3f3f4;        /* the button */
  --button-ink: #0b0b0d;    /* 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:
    radial-gradient(60vmax 40vmax at 18% 8%, rgba(255, 170, 80, 0.075), transparent 70%),
    radial-gradient(50vmax 40vmax at 88% 96%, rgba(120, 140, 190, 0.07), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* the grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}

.stage {
  min-height: 100svh;
  max-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.route {
  position: relative;
  width: min(100%, 560px);
  display: grid;
  gap: clamp(8px, 2.2vh, 16px);
  padding: clamp(14px, 3.6vh, 24px) clamp(14px, 4.4vw, 24px);
  border-radius: clamp(18px, 4vh, 24px);
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(255, 255, 255, 0.035), transparent 60%),
    linear-gradient(180deg, var(--card-top), var(--card));
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 12px 24px -12px rgba(0, 0, 0, 0.7),
    0 40px 80px -40px rgba(0, 0, 0, 0.9);
  opacity: 0;
}

/* the rim that catches the light of the cursor */
.route__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: radial-gradient(34% 60% at var(--lx, 50%) 30%, var(--lc, var(--amber)), transparent 70%);
  -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: var(--li, 0);
}

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

.route__title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.route__eyebrow {
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.route__name {
  margin: 0;
  font-size: clamp(16px, 3.6vh, 21px);
  font-weight: 620;
  font-stretch: 108%;
  letter-spacing: -0.015em;
  line-height: 1.1;
  white-space: nowrap;
}

.route__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 26px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 540;
  color: var(--amber);
  background: rgba(255, 190, 98, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 190, 98, 0.18);
}

.route__chip svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* ---------------------------------------------------------------- the chart */
.route__chart {
  position: relative;
  padding-top: 28px;
  padding-bottom: 16px;
  touch-action: pan-y;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

.plot {
  display: block;
  width: 100%;
  height: clamp(96px, 30vh, 230px);
  overflow: visible;
}

.plot__grid line {
  stroke: var(--faint);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.plot__grid line.plot__base {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-dasharray: none;
}

.plot__grid text {
  font-size: 9px;
  fill: var(--muted);
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.plot__area {
  opacity: 0.2;
}

.plot__line {
  fill: none;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.plot__line--dim {
  opacity: 0.5;
}

.plot__band {
  fill: var(--amber);
}

.plot__seg {
  fill: none;
  stroke-width: 2.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

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

.plot__summit {
  fill: var(--card);
  stroke: var(--ink);
  stroke-width: 1.2;
}

.plot__column {
  mix-blend-mode: screen;
}

.plot__hair {
  stroke: rgba(255, 255, 255, 0.4);
  stroke-width: 1;
}

.plot__ring-shadow {
  fill: rgba(0, 0, 0, 0.55);
}

.plot__ring {
  fill: var(--card);
  stroke: #fff;
  stroke-width: 1.6;
}

/* the climb flags */
.flags {
  position: absolute;
  inset: 28px 0 16px;
  pointer-events: none;
}

.flag {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  cursor: pointer;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: inherit;
}

.flag__face {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 640;
  letter-spacing: 0.03em;
  color: var(--ink);
  background: rgba(20, 20, 24, 0.86);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 4px 10px -4px rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  white-space: nowrap;
  transition: color 0.3s, background-color 0.3s, box-shadow 0.3s;
}

.flag.is-on .flag__face {
  color: var(--button-ink);
  background: var(--fc, var(--amber));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 6px 16px -6px var(--fc, var(--amber));
}

@media (hover: hover) {
  .flag:hover .flag__face {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3), 0 4px 10px -4px rgba(0, 0, 0, 0.8);
  }
}

/* the tooltip that rides over the cursor */
.tip {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  opacity: 0;
}

.tip__face {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 22px;
  padding: 0 4px 0 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: rgba(28, 28, 33, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 18px -8px rgba(0, 0, 0, 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.tip__km {
  color: var(--muted);
}

.tip__alt {
  font-weight: 600;
}

.tip__grade {
  display: inline-flex;
  align-items: center;
  height: 15px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 650;
  color: var(--button-ink);
  background: var(--gc, var(--flat));
}

.axis {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 12px;
}

.axis span {
  position: absolute;
  top: 0;
  font-size: 9px;
  line-height: 12px;
  color: var(--muted);
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
  white-space: nowrap;
}

.axis span:first-child {
  transform: none;
}

.axis span:last-child {
  transform: translateX(-100%);
}

/* ---------------------------------------------------------------- the numbers */
.stats {
  display: grid;
  gap: 6px;
  padding-top: clamp(8px, 2vh, 12px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.stats__caption {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  height: 14px;
  line-height: 14px;
}

.stats__caption span {
  display: inline-block;
}

.stats__row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.stat__label {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.stat__value {
  display: block;
  font-size: clamp(16px, 3.8vh, 22px);
  font-weight: 600;
  font-stretch: 104%;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat__value small {
  margin-left: 3px;
  font-size: 0.56em;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
}

/* ---------------------------------------------------------------- the button */
.send {
  display: block;
  width: 100%;
  height: clamp(38px, 8.4vh, 46px);
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.send__face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  border-radius: 999px;
  color: var(--button-ink);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  background: linear-gradient(180deg, #ffffff, var(--button));
  box-shadow:
    inset 0 1px 0 #fff,
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 10px 24px -12px rgba(255, 255, 255, 0.28);
  transition: box-shadow 0.3s;
}

@media (hover: hover) {
  .send:hover .send__face {
    box-shadow:
      inset 0 1px 0 #fff,
      inset 0 -1px 0 rgba(0, 0, 0, 0.12),
      0 1px 2px rgba(0, 0, 0, 0.4),
      0 14px 30px -12px rgba(255, 190, 98, 0.45);
  }
}

.send__icon {
  position: relative;
  width: 18px;
  height: 18px;
}

.send__icon svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.send__arc {
  stroke-dasharray: 0.28 0.72;
  opacity: 0;
  transform-origin: 9px 9px;
}

.send__check {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  stroke-width: 1.8;
}

.send__words {
  display: inline-block;
  white-space: nowrap;
}

.send.is-done .send__face {
  color: #1d1306;
  background: linear-gradient(180deg, #ffd38c, var(--amber));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -1px 0 rgba(120, 60, 0, 0.25),
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 14px 30px -12px rgba(255, 190, 98, 0.55);
}

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