/* ---------- Tokens (from Figma) ---------- */
:root {
  --page-bg: #fafafa;
  --card-bg: #f4f4f4;
  --card-bg-0: rgba(244, 244, 244, 0);
  --black: #000;
  --line: #d9d9d9;
  --knob-border: #d8d8d8;
  --muted: #abaaaa;
  --orange: #f78041;
  --yellow: #f8d040;
  --green: #06c363;
  --red: #fb4949;
  --suggested: rgba(0, 0, 0, 0.15);
  --pill-bg: rgba(0, 0, 0, 0.03);
  --pill-bg-hover: rgba(0, 0, 0, 0.06);
  --send-bg-hover: #fafafa;

  /* chart geometry (px, matches Figma) */
  --chart-left: 158px;
  --chart-top: 79px;
  --chart-w: 787px;
  --chart-h: 365px;   /* 79 → 444, room for marker hit areas */
  --dots-h: 329px;    /* 79 → 408 */
  --mask-h: 44px;

  /* ---------- Motion tokens (transitions.dev scale) ---------- */
  --duration-stagger: 40ms;
  --duration-micro: 80ms;
  --duration-quick: 150ms;
  --duration-fast: 250ms;
  --duration-medium: 350ms;
  --duration-slow: 400ms;
  --duration-very-slow: 500ms;

  --ease-smooth-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: ease-in-out;
  --ease-out: ease-out;
  --ease-linear: linear;
  --ease-bounce: cubic-bezier(0.34, 1.36, 0.64, 1);
  --ease-bounce-strong: cubic-bezier(0.34, 3.85, 0.64, 1);

  --distance-micro: 4px;
  --distance-small: 6px;
  --distance-base: 8px;
  --distance-medium: 12px;
  --distance-large: 30px;

  --scale-large: 0.96;
  --scale-medium: 0.97;
  --scale-small: 0.98;
  --scale-tiny: 0.99;

  --blur-small: 2px;
  --blur-medium: 3px;
  --blur-large: 8px;

  /* odometer reels */
  --reel-dur: var(--duration-fast);
  --reel-ease: var(--ease-smooth-out);

  /* tooltip */
  --tt-in-dur: var(--duration-quick);
  --tt-out-dur: 50ms;
  --tt-scale: var(--scale-small);
  --tt-delay: var(--duration-micro);
  --tt-in-ease: var(--ease-out);
  --tt-out-ease: var(--ease-out);
  --tt-move-dur: 160ms;
  --tt-move-ease: var(--ease-smooth-out);

  /* handle travel (marker click) — read by JS */
  --handle-dur: var(--duration-fast);

  /* staged entrance on first load */
  --enter-dur: var(--duration-slow);
  --enter-stagger: 100ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--page-bg);
  color: var(--black);
  font-family: InterVariable, Inter, system-ui, -apple-system, sans-serif;
  font-optical-sizing: auto;
  font-size: 14px;
  font-weight: 500;
  line-height: normal;
  -webkit-font-smoothing: antialiased;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  overflow: auto;
}

body.dragging {
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
}

p, h1 { margin: 0; font-weight: inherit; }
button {
  font: inherit;
  color: inherit;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}
img { display: block; }

.icon-12 { width: 12px; height: 12px; }
.icon-14 { width: 14px; height: 14px; }
.icon-16 { width: 16px; height: 16px; }
.icon-18 { width: 18px; height: 18px; }

/* ---------- Card ---------- */
.card {
  position: relative;
  width: 998px;
  height: 537px;
  flex: none;
  background: var(--card-bg);
  border-radius: 32px;
  overflow: hidden;
}

/* ---------- Header ---------- */
.stage {
  position: absolute;
  left: 32px;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.stage-label {
  font-size: 14px;
  opacity: 0.4;
}
.stage-title {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.stage-title img {
  transition: transform var(--duration-quick) var(--ease-smooth-out);
}
.stage-title:hover img {
  transform: translateX(-3px);   /* chevron tucks in toward the text */
}
.stage-title h1 {
  font-size: 24px;
  white-space: nowrap;
}

.head-actions {
  position: absolute;
  right: 24px;
  top: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px 0 16px;
  border-radius: 24px;
  background: var(--pill-bg);
  white-space: nowrap;
  transition-property: background-color, scale;
  transition-duration: var(--duration-quick);
  transition-timing-function: var(--ease-smooth-out);
}
.pill-round {
  width: 40px;
  padding: 0;
  justify-content: center;
}
.pill:hover { background: var(--pill-bg-hover); }
.pill:active { scale: var(--scale-large); }

/* ---------- Side labels ---------- */
.side-label {
  position: absolute;
  left: 24px;
  color: rgba(0, 0, 0, 0.4);   /* colour, not opacity: the entrance animates opacity */
  white-space: nowrap;
}
.side-candidates { top: 250px; }
.side-score { top: 408px; }

/* ---------- Chart ---------- */
.chart {
  position: absolute;
  left: var(--chart-left);
  top: var(--chart-top);
  width: var(--chart-w);
  height: var(--chart-h);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.chart::-webkit-scrollbar { display: none; }

.chart-content {
  position: relative;
  height: var(--chart-h);
}

.dots-scroll {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: var(--dots-h);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  overscroll-behavior-y: contain;
}
.dots-scroll::-webkit-scrollbar { display: none; }

.dots-content {
  position: relative;
  width: 100%;
}

.glow {
  position: absolute;
  width: 443px;
  height: 477px;
  pointer-events: none;
}

.dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin: -4px 0 0 -4px;
}
.dot-red    { background: var(--red); }
.dot-orange { background: var(--orange); }
.dot-yellow { background: var(--yellow); }
.dot-green  { background: var(--green); }

.mask {
  position: absolute;
  left: 0;
  width: 100%;
  height: var(--mask-h);
  pointer-events: none;
}
.mask-top {
  top: 0;
  background: linear-gradient(to bottom, var(--card-bg), var(--card-bg-0));
}
.mask-bottom {
  top: calc(var(--dots-h) - var(--mask-h));
  background: linear-gradient(to bottom, var(--card-bg-0), var(--card-bg));
}
.mask-left {
  position: absolute;
  left: 0;
  top: 14px;
  height: 312px;
  width: 0;
  pointer-events: none;
  background: linear-gradient(
    to right,
    rgba(244, 244, 244, 0.82) 0,
    rgba(244, 244, 244, 0.82) calc(100% - 342px),
    rgba(244, 244, 244, 0.55) 100%
  );
}

/* Handle */
.handle {
  position: absolute;
  left: -16px;
  top: 40px;
  width: 32px;
  height: 265px;
  will-change: transform;
}
.handle-line {
  position: absolute;
  left: 16px;
  top: 0;
  width: 1px;
  height: 100%;
  background: var(--line);
}
.knob {
  position: absolute;
  left: 0;
  top: 118px;
  width: 32px;
  height: 32px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--knob-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  touch-action: none;
  transition-property: box-shadow, border-color;
  transition-duration: var(--duration-quick);
  transition-timing-function: var(--ease-smooth-out);
}
.knob img { width: 16px; height: 16px; }
.knob:hover,
.dragging .knob {
  border-color: #cdcdcd;
  box-shadow: 0 2px 10px -2px rgba(0, 0, 0, 0.12);
}

.handle-label {
  position: absolute;
  left: 0;
  top: 40px;
  width: 0;
  height: 17px;
  will-change: transform;
  pointer-events: none;
  white-space: nowrap;
}
.hl-left {
  position: absolute;
  right: 14px;
  top: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}
.hl-muted { color: var(--muted); }
.hl-right {
  position: absolute;
  left: 20px;
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.hl-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
/* outside stroke in the card colour so the label stays legible over dots */
.hl-left span,
.hl-right span {
  paint-order: stroke fill;
  -webkit-text-stroke: 4px var(--card-bg);
}
.hl-item img {
  filter:
    drop-shadow(1px 0 0 var(--card-bg)) drop-shadow(-1px 0 0 var(--card-bg))
    drop-shadow(0 1px 0 var(--card-bg)) drop-shadow(0 -1px 0 var(--card-bg))
    drop-shadow(1px 1px 0 var(--card-bg)) drop-shadow(-1px -1px 0 var(--card-bg))
    drop-shadow(1px -1px 0 var(--card-bg)) drop-shadow(-1px 1px 0 var(--card-bg));
}

/* Axis */
.axis {
  position: absolute;
  left: 0;
  top: var(--dots-h);
  width: 100%;
  height: calc(var(--chart-h) - var(--dots-h));
}
.axis-label {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  opacity: 0.6;
  white-space: nowrap;
}
.marker {
  position: absolute;
  top: -5px;               /* pill top = 403 in card = 324 in chart */
  width: 24px;
  height: 40px;
  margin-left: -12px;
  cursor: pointer;
}
.marker-pill {
  position: absolute;
  left: 3.5px;
  top: 0;
  width: 17px;
  height: 31px;
  border-radius: 24px;
  background: var(--pill-bg);
  opacity: 0;
  transition: opacity var(--duration-quick) var(--ease-smooth-out);
}
.marker:hover .marker-pill { opacity: 1; }
.marker-bar {
  position: absolute;
  left: 10.5px;
  top: 8px;
  width: 3px;
  height: 15px;
  border-radius: 3px;
}
.marker-avg .marker-bar { background: var(--orange); }
.marker-median .marker-bar { background: var(--yellow); }
.marker-suggested .marker-bar { background: var(--suggested); }
.marker-sparkle {
  position: absolute;
  left: 6px;
  top: 25px;
  width: 12px;
  height: 12px;
}

/* Tooltip (transitions.dev tooltip motion: delayed fade+scale in, instant out, travels) */
.tooltip {
  position: absolute;
  left: 0;
  top: 286px;
  width: 168px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff;
  box-shadow:
    0 -1px 0 -0.5px rgba(255, 255, 255, 0.16),
    0 0 0 0.5px rgba(0, 0, 0, 0.08),
    0 4px 12px -8px rgba(0, 0, 0, 0.12),
    0 4px 24px -8px rgba(0, 0, 0, 0.12);
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
  pointer-events: none;
  translate: var(--tt-x, 0px) 0;
  scale: var(--tt-scale);
  transform-origin: 50% 100%;
  opacity: 0;
  /* Leave state: no delay, so hiding plays immediately. Move lane always live. */
  transition:
    opacity   var(--tt-out-dur) var(--tt-out-ease),
    scale     var(--tt-out-dur) var(--tt-out-ease),
    translate var(--tt-move-dur) var(--tt-move-ease);
}
.tooltip[data-show="true"] {
  opacity: 1;
  scale: 1;
  transition:
    opacity   var(--tt-in-dur) var(--tt-in-ease) var(--tt-delay),
    scale     var(--tt-in-dur) var(--tt-in-ease) var(--tt-delay),
    translate var(--tt-move-dur) var(--tt-move-ease);
}
.tt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tt-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tt-bar {
  width: 3px;
  height: 15px;
  border-radius: 8px;
  background: var(--orange);
}
.tt-label { opacity: 0.3; white-space: nowrap; }
.tt-value { white-space: nowrap; }

/* ---------- Footer ---------- */
.foot-left {
  position: absolute;
  left: 24px;
  top: 480px;
  display: flex;
  align-items: flex-start;
  gap: 24px;
}
.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.stat-key {
  display: flex;
  align-items: center;
  gap: 5px;
}
.stat-key span { opacity: 0.4; }

.send {
  position: absolute;
  right: 24px;
  top: 465px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px;
  border-radius: 32px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
  line-height: 18px;
  white-space: nowrap;
  transition-property: background-color, scale;
  transition-duration: var(--duration-quick);
  transition-timing-function: var(--ease-smooth-out);
}
.send:hover { background: var(--send-bg-hover); }
.send:active { scale: var(--scale-large); }

/* ---------- Numbers: odometer reels ---------- */
.num {
  font-variant-numeric: tabular-nums;
}
/* reserve two digits so neighbouring labels never shift when a count changes width */
.stat .num,
.hl-item .num {
  min-width: 2ch;
}
.reel {
  --reel-bleed: 5px;   /* extra window above/below the digit so neighbours fade in and out */
  display: inline-flex;
  height: calc(1.2em + var(--reel-bleed) * 2);
  height: calc(1lh + var(--reel-bleed) * 2);
  margin: calc(var(--reel-bleed) * -1) 0;
  overflow: hidden;
  vertical-align: top;
}
.reel-col {
  position: relative;
  height: 100%;
  overflow: hidden;
  padding: var(--reel-bleed) 2px;   /* 2px sides: room for the outside text stroke */
  margin: 0 -2px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 4px, #000 8px, #000 calc(100% - 8px), transparent calc(100% - 4px));
  mask-image: linear-gradient(to bottom, transparent 4px, #000 8px, #000 calc(100% - 8px), transparent calc(100% - 4px));
}
.reel-strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
  transition: transform var(--reel-dur) var(--reel-ease);
}
.reel-digit {
  display: block;
  height: 1.2em;
  height: 1lh;
  line-height: 1lh;
}

/* ---------- Staged entrance on first load ---------- */
@keyframes enter-up {
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
.enter {
  opacity: 0;
  transform: translateY(var(--distance-medium));
  filter: blur(4px);
  animation: enter-up var(--enter-dur) var(--ease-out) forwards;
}
.enter-0 { animation-delay: 0ms; }                               /* the card itself */
.enter-1 { animation-delay: var(--enter-stagger); }
.enter-2 { animation-delay: calc(var(--enter-stagger) * 2); }
.enter-3 { animation-delay: calc(var(--enter-stagger) * 3); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .reel-strip { transition: none !important; }
  .tooltip { transition: none !important; }
  .enter { animation: none !important; opacity: 1; transform: none; filter: none; }
  .pill, .send, .knob, .marker-pill { transition: none !important; }
}
