/* The live visitors card: a dark analytics widget on a black page. The card has its own layers: a fine grain, a rim
   of light that follows the pointer (a masked border gradient), then the words, the stream of bars and the list. */
:root {
  --page: #000000;          /* the page */
  --card-top: #15161c;      /* the card, at the top */
  --card-bottom: #0b0b0f;   /* the card, at the bottom */
  --edge: rgba(255, 255, 255, 0.075); /* its edge at rest */
  --ink: #f1f1f4;           /* the words */
  --muted: #7d7f8c;         /* the small words */
  --faint: rgba(255, 255, 255, 0.06); /* tracks and rules */
  --accent: #8f7dff;        /* the live colour: the newest minute, the rim, the climbing page */
  --accent-2: #5cc8ff;      /* the cool end of the bars' gradient */
  --up: #54e0a5;            /* the change against an hour ago */
}

* {
  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;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(8px, 2.4vh, 20px) 14px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.lv {
  --mx: 30%;
  --my: 0%;
  --rim: 0.9;
  --row: clamp(22px, 6.2vh, 30px);
  --chart: clamp(40px, 12.5vh, 74px);
  position: relative;
  width: min(92vw, 352px);
  padding: clamp(13px, 3.6vh, 20px) clamp(15px, 4.6vw, 20px) clamp(10px, 2.8vh, 16px);
  border-radius: 22px;
  background:
    radial-gradient(120% 60% at var(--mx) -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    linear-gradient(180deg, var(--card-top), var(--card-bottom));
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 1px rgba(0, 0, 0, 0.6),
    0 12px 24px -12px rgba(0, 0, 0, 0.8),
    0 40px 80px -30px color-mix(in srgb, var(--accent) 22%, transparent);
  opacity: 0;
  isolation: isolate;
}

.lv__grain {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

/* the rim: a 1px ring of light only near the pointer (or the slow drift when nobody points) */
.lv__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  opacity: var(--rim);
  background: radial-gradient(160px 120px at var(--mx) var(--my), color-mix(in srgb, var(--accent) 95%, white), color-mix(in srgb, var(--accent) 30%, transparent) 45%, transparent 75%);
  -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);
  z-index: 3;
}

.lv > :not(.lv__grain):not(.lv__rim):not(.sr) {
  position: relative;
  z-index: 1;
}

/* ---------------------------------------------------------------- head */
.lv__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
}

.lv__title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 560;
  font-variation-settings: 'wdth' 104;
  letter-spacing: 0.005em;
}

.lv__signal {
  width: 16px;
  height: 13px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  overflow: visible;
}

.lv__signal path {
  opacity: 0.35;
}

.lv__site {
  color: var(--muted);
  font-size: 11.5px;
  font-variation-settings: 'wdth' 96;
}

/* ---------------------------------------------------------------- the big number */
.lv__now {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: clamp(8px, 2.4vh, 14px);
}

.lv__total {
  margin: 0;
  font-size: clamp(30px, min(11vw, 9.6vh), 44px);
  line-height: 1;
  font-weight: 620;
  font-variation-settings: 'wdth' 94;
  letter-spacing: -0.035em;
  font-variant-numeric: lining-nums;
}

/* one rolling digit: a window one line high over a strip of ten */
.dg {
  display: inline-block;
  height: 1em;
  line-height: 1;
  overflow: hidden;
  vertical-align: top;
  -webkit-mask: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
  mask: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
  padding: 0 0.005em;
}

.dg__strip {
  display: block;
  color: inherit;
}

.dg__strip span {
  display: block;
  height: 1em;
  text-align: center;
}

.lv__total .dg__strip span {
  color: transparent;
  background: linear-gradient(180deg, #ffffff 35%, #b4b5c2);
  -webkit-background-clip: text;
  background-clip: text;
}

.lv__total,
.pg__n,
.lv__delta [data-delta],
.lv__read [data-per] {
  display: inline-flex;
  align-items: flex-start;
}

.dg-sep {
  display: inline-block;
  line-height: 1;
}

.lv__total .dg-sep {
  color: #c9cad4;
  margin: 0 -0.06em 0 -0.03em;
}

.lv__delta {
  display: inline-flex;
  align-items: center;
  gap: 0;
  height: 22px;
  padding: 0 8px 0 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 560;
  font-variant-numeric: lining-nums;
  color: var(--up);
  background: color-mix(in srgb, var(--up) 11%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--up) 22%, transparent);
}

.lv__delta svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-right: 3px;
}

.lv__sub {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- labels */
.lv__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-top: clamp(10px, 3vh, 18px);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.lv__read {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  color: var(--ink);
  font-variant-numeric: lining-nums;
}

.lv__read .dg {
  -webkit-mask: none;
  mask: none;
}

.lv__when {
  display: inline-block;
  min-width: 2.6em;
  text-align: right;
  color: var(--muted);
}

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

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

/* ---------------------------------------------------------------- the stream of minutes */
.lv__chart {
  position: relative;
  height: var(--chart);
  margin-top: 7px;
  overflow: hidden;
  border-bottom: 1px solid var(--faint);
  touch-action: pan-y;
  cursor: crosshair;
  -webkit-mask: linear-gradient(90deg, transparent, #000 9%);
  mask: linear-gradient(90deg, transparent, #000 9%);
}

.lv__track {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
}

.bar {
  position: relative;
  flex: none;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar__fill {
  display: block;
  width: 62%;
  height: 0;
  border-radius: 2px 2px 1px 1px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-2) 70%, #ffffff), color-mix(in srgb, var(--accent-2) 40%, transparent) 30%, color-mix(in srgb, var(--accent-2) 8%, transparent));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--accent-2) 60%, #ffffff);
  opacity: 0.55;
  transition: opacity 0.35s ease, background 0.5s ease, box-shadow 0.5s ease;
}

.bar.is-now .bar__fill {
  opacity: 1;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 60%, #ffffff), var(--accent) 40%, color-mix(in srgb, var(--accent) 30%, transparent));
  box-shadow: 0 0 14px 1px color-mix(in srgb, var(--accent) 55%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.bar.is-picked .bar__fill {
  opacity: 1;
}

.lv__avg {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.14);
  pointer-events: none;
  z-index: 1;
}


.lv__cursor {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.45));
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}

/* ---------------------------------------------------------------- top pages */
.lv__label--pages {
  margin-top: clamp(9px, 2.6vh, 16px);
}

.lv__pages {
  position: relative;
  list-style: none;
  margin: 3px 0 0;
  padding: 0;
  height: calc(var(--row) * 4);
}

.pg {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--row);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 10px;
  font-size: 12.5px;
}

/* a short light that sweeps a row when it climbs */
.pg__glow {
  position: absolute;
  inset: 2px -8px;
  border-radius: 9px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 16%, transparent), color-mix(in srgb, var(--accent) 4%, transparent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
  opacity: 0;
  pointer-events: none;
}

.pg__path {
  position: relative;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-variation-settings: 'wdth' 98;
  color: #d7d8df;
}

.pg__share {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--faint);
  overflow: hidden;
  grid-column: 1 / -1;
}

.pg__share-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: inherit;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent-2) 40%, transparent), color-mix(in srgb, var(--accent) 85%, white 0%));
}

.pg__count {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: lining-nums;
  font-weight: 540;
}

.pg__up {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .bar__fill {
    transition: opacity 0.4s ease;
  }
}
