/* The gathering chart: the distance card of a running app on a white page. A white card with a hairline edge, the
   total in a narrow, heavy Archivo, the periods in a grey track and the bars in signal orange; the bars are drawn by
   the script on a canvas, the numbers around them are text. */
:root {
  --page: #ffffff;          /* the page */
  --card: #ffffff;          /* the card */
  --edge: #ebebee;          /* the card's edge */
  --ink: #141418;           /* the total, the chosen period, the level line */
  --muted: #8a8a94;         /* the labels and the axis */
  --grid: #f0f0f3;          /* the lines across the chart */
  --base: #e2e2e7;          /* the line at zero */
  --bar: #ff5a1f;           /* the bars */
  --soft: #ffd6c4;          /* a bar below the level line */
  --rest: #e4e4ea;          /* a rest day, at zero */
  --track: #f2f2f5;         /* the periods' track */
}

* {
  box-sizing: border-box;
}

/* quick taps never become a double tap that zooms the page */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Archivo Variable', system-ui, sans-serif;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  /* in alto a sinistra nella scheda: la tabella per i lettori di schermo, larga e alta quanto le sue righe, non
     allunga la pagina né la fa scorrere di lato */
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

/* ---------------------------------------------------------------- the card */
.runs {
  position: relative;
  width: min(420px, 100%);
  padding: 20px 20px 16px;
  border: 1px solid var(--edge);
  border-radius: 26px;
  background: var(--card);
  box-shadow:
    0 1px 2px rgba(20, 20, 24, 0.04),
    0 18px 40px -22px rgba(20, 20, 24, 0.22);
}

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

.runs__title {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.005em;
}

/* the total, or the bar under the pointer: narrow and heavy, like the numbers on a race bib */
.runs__figure {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 14px 0 0;
  line-height: 1;
}

.runs__value {
  font-size: 46px;
  font-weight: 760;
  font-stretch: 78%;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.runs__unit {
  font-size: 17px;
  font-weight: 640;
  font-stretch: 88%;
  color: var(--muted);
}

.runs__when {
  height: 18px;
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------- the periods */
/* the chosen one sits on a white thumb; its ink is a copy of the words, clipped to the thumb, so the colour changes
   exactly where the thumb is while it slides */
.period {
  position: relative;
  display: flex;
  flex: none;
  padding: 3px;
  border-radius: 999px;
  background: var(--track);
}

.period__thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--card);
  box-shadow:
    0 1px 2px rgba(20, 20, 24, 0.1),
    0 3px 8px -2px rgba(20, 20, 24, 0.1);
}

.period__btn,
.period__ink span {
  height: 30px;
  padding: 0 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 30px;
  white-space: nowrap;
}

.period__btn {
  position: relative;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@media (hover: hover) and (pointer: fine) {
  .period__btn:hover {
    color: color-mix(in srgb, var(--muted), var(--ink) 45%);
  }
}

.period__btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.period__ink {
  position: absolute;
  inset: 3px;
  display: flex;
  color: var(--ink);
  pointer-events: none;
}

.period__ink span {
  display: block;
  text-align: center;
}

/* ---------------------------------------------------------------- the chart */
.plot {
  position: relative;
  height: 196px;
  margin-top: 18px;
  border-radius: 10px;
  outline: none;
  touch-action: pan-y;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.plot:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 6px;
}

.plot__canvas {
  position: absolute;
  inset: 0 0 auto 0;
  display: block;
  width: 100%;
  height: 172px;
}

/* the numbers of the lines across the chart, on the right */
.plot__ticks {
  position: absolute;
  top: 0;
  right: 0;
  width: 34px;
  height: 172px;
}

.plot__tick {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  will-change: transform, opacity;
}

/* the value at the level line, over the numbers on the right */
.plot__tag {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 36px;
  height: 20px;
  padding: 0 6px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--card);
  font-size: 11px;
  font-weight: 650;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

/* the days or the months underneath, riding with their bars */
.plot__days {
  position: absolute;
  top: 178px;
  left: 0;
  height: 18px;
  overflow: hidden;
}

.plot__day {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
  white-space: nowrap;
  transition: color 0.2s ease;
  will-change: transform, opacity;
}

.plot__day.is-on {
  color: var(--ink);
  font-weight: 650;
}

@media (max-width: 380px) {
  .runs {
    padding: 18px 16px 14px;
  }

  .period__btn,
  .period__ink span {
    padding: 0 11px;
  }

  .runs__value {
    font-size: 42px;
  }
}

/* una casella bassa (l'anteprima sul telefono, 341 per 410): meno margine intorno alla scheda, così sta in altezza
   senza rimpicciolirsi */
@media (max-height: 520px) {
  .stage {
    padding: 6px 16px;
  }
}
