/* The performance report with the score rings that fill up: the audit panel of a made-up developer tool on a near
   black page. Four SVG rings, a filmstrip of the page loading and three metric bars; the lower half swaps with the
   detail of the ring under the pointer. The ring colours are set by the script while the numbers climb. */
:root {
  --page: #0a0b0d;          /* the page */
  --panel: #111316;         /* the body of the report */
  --panel-top: #16181c;     /* the top of the report, where the light falls */
  --edge: rgba(255, 255, 255, 0.075); /* the thin edge */
  --ink: #eceef1;           /* the words */
  --muted: #868b95;         /* the small words */
  --faint: rgba(255, 255, 255, 0.06); /* tracks and frames */
  --poor: #ff5b4f;          /* a low score */
  --fair: #ffa834;          /* a middle score */
  --good: #31d07c;          /* a high score */
  --button: #f2f3f5;        /* the Run again button */
  --button-ink: #0a0b0d;    /* 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(120% 80% at 50% 0%, #121418 0%, var(--page) 60%);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ------------------------------------------------------------------ the report */
.report {
  position: relative;
  width: min(94vw, 540px);
  padding: clamp(12px, 3.4vh, 20px) clamp(12px, 3.6vw, 22px) clamp(12px, 3.2vh, 20px);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel) 38%);
  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 24px 60px -24px rgba(0, 0, 0, 0.85);
  opacity: 0;
}

/* a whisper of grain on the body */
.report::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

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

.report__where {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.report__tool {
  font-size: 12.5px;
  font-weight: 620;
  font-variation-settings: 'wdth' 108;
  letter-spacing: 0.01em;
}

.report__url {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report__lock {
  width: 11px;
  height: 11px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
}

/* ------------------------------------------------------------------ Run again: the elastic pill */
.run {
  position: relative;
  flex: none;
  border: 0;
  padding: 0;
  background: none;
  color: var(--button-ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.run__bg {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--button);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px -8px rgba(0, 0, 0, 0.7);
}

.run__face {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px 8px 11px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.run__words {
  display: inline-block;
  font-variation-settings: 'wdth' var(--wdth, 100);
}

.run__icon {
  width: 14px;
  height: 14px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.run__spin {
  stroke-dasharray: 34 66;
  opacity: 0;
  transform-origin: 8px 8px;
}

.run:focus-visible {
  outline: 2px solid var(--good);
  outline-offset: 3px;
  border-radius: 999px;
}

.run[aria-busy='true'] {
  cursor: progress;
}

/* ------------------------------------------------------------------ the rings */
.rings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: clamp(12px, 3.4vh, 22px) 0 clamp(10px, 2.8vh, 18px);
}

.ring {
  --c: var(--poor);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1.2vh, 8px);
  padding: 6px 0 4px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.35s ease;
}

.ring:focus-visible {
  outline: 1px solid rgba(255, 255, 255, 0.25);
  outline-offset: -1px;
}

.rings.is-open .ring:not(.is-on) {
  opacity: 0.42;
}

.ring__dial {
  position: relative;
  display: block;
  width: clamp(48px, min(14vw, 12vh), 76px);
  aspect-ratio: 1;
}

.ring__dial svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}

.ring__disc {
  fill: var(--c);
  fill-opacity: 0.08;
  stroke: none;
}

.ring__track,
.ring__arc,
.ring__glow {
  fill: none;
  stroke-width: 4;
}

.ring__track {
  stroke: var(--faint);
}

.ring__arc,
.ring__glow {
  stroke: var(--c);
  stroke-linecap: round;
  stroke-dasharray: 0 100;
}

.ring__glow {
  stroke-width: 7;
  opacity: 0.22;
  filter: blur(3px);
}

.ring__num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(15px, min(4.6vw, 4.2vh), 22px);
  font-weight: 640;
  font-variation-settings: 'wdth' 94;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--c);
}

.ring__name {
  font-size: clamp(9.5px, 2.7vw, 11.5px);
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.3s ease;
}

.ring.is-on .ring__name {
  color: var(--ink);
}

/* ------------------------------------------------------------------ the lower half: load or detail */
.lower {
  position: relative;
  display: grid;
}

.load,
.detail {
  grid-area: 1 / 1;
}

.load__head,
.detail__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  color: var(--muted);
}

.load__total {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* the filmstrip */
.strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(4px, 1.2vw, 8px);
  margin: 8px 0 clamp(10px, 2.6vh, 16px);
}

.frame {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.frame__pic {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(30px, min(9vw, 8.5vh), 58px);
  border-radius: 5px;
  background: #0c0d10;
  box-shadow: inset 0 0 0 1px var(--faint);
  overflow: hidden;
}

.frame__pic svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.frame.is-lcp .frame__pic {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--good) 70%, transparent);
}

/* the playhead running over the frames while the page loads */
.strip__head {
  position: absolute;
  top: -3px;
  left: 0;
  width: 1px;
  height: calc(100% - 10px);
  margin-left: -0.5px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.75) 25%, rgba(255, 255, 255, 0.75) 75%, transparent);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.frame__t {
  opacity: 0.35;
  font-size: 9.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* the three metrics */
.metrics {
  display: grid;
  gap: clamp(6px, 1.6vh, 10px);
}

.metric {
  --c: var(--muted);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 2fr) 52px;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
}

.metric__name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric__long {
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}

.metric__bar {
  position: relative;
  height: 4px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--faint);
}

/* the three zones, good, needs work, poor, barely there under the fill */
.metric__zones {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: var(--z, 40% 25% 35%);
  gap: 2px;
}

.metric__zones i:nth-child(1) { background: color-mix(in srgb, var(--good) 12%, transparent); }
.metric__zones i:nth-child(2) { background: color-mix(in srgb, var(--fair) 12%, transparent); }
.metric__zones i:nth-child(3) { background: color-mix(in srgb, var(--poor) 12%, transparent); }

.metric__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 55%, transparent), var(--c));
  transform-origin: 0 50%;
  transform: scaleX(0);
}

.metric__val {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--c);
}

/* the detail */
.detail {
  position: relative;
  align-self: start;
  padding: 10px 12px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  box-shadow: inset 0 0 0 1px var(--edge);
  opacity: 0;
  visibility: hidden;
}

.detail__notch {
  position: absolute;
  top: -5px;
  left: 0;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  background: #15171a;
  box-shadow: inset 1px 1px 0 var(--edge);
  border-radius: 2px 0 0 0;
  transform: translateX(var(--nx, 40px)) rotate(45deg);
}

.detail__title {
  color: var(--ink);
  font-weight: 600;
}

.detail__count {
  font-variant-numeric: tabular-nums;
}

.detail__list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
}

.fix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  padding: clamp(6px, 1.5vh, 9px) 0;
  border-top: 1px solid var(--faint);
}

.fix:first-child {
  border-top: 0;
}

.fix__what {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fix__gain {
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--c, var(--fair));
  text-align: right;
}

.fix__where {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fix__bar {
  align-self: center;
  justify-self: end;
  width: 46px;
  height: 3px;
  border-radius: 3px;
  background: var(--faint);
  overflow: hidden;
}

.fix__bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--c, var(--fair));
  transform-origin: 0 50%;
}

@media (hover: hover) and (pointer: fine) {
  .run:hover .run__bg {
    box-shadow: inset 0 1px 0 #ffffff, 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 20px -8px rgba(255, 255, 255, 0.18);
  }
}

@media (max-width: 380px) {
  .metric__long {
    display: none;
  }
  .metric {
    grid-template-columns: 34px minmax(0, 1fr) 46px;
  }
}

/* the ring under the pointer lifts a pixel and its halo brightens */
.ring__dial {
  transition: transform 0.5s cubic-bezier(0.34, 1.8, 0.64, 1), filter 0.4s ease;
}

.ring.is-on .ring__dial {
  transform: translateY(-1px) scale(1.03);
  filter: drop-shadow(0 6px 14px color-mix(in srgb, var(--c) 22%, transparent));
}

@media (prefers-reduced-motion: reduce) {
  .ring__dial {
    transition: filter 0.3s ease;
  }
  .ring.is-on .ring__dial {
    transform: none;
  }
}
