/* The internet speed test with a spring needle: one panel on warm graphite with light and grain. The dial is an SVG in
   thin lines; the needle is moved by a small physics simulation in script.js (a mass on a spring, damping, knocks and a
   stop pin), the arc of light follows it, and three thin cards collect ping, download and upload. */
:root {
  --page: #0c0b0a;                    /* the page */
  --panel: #151311;                   /* the body of the panel */
  --panel-top: #1b1916;               /* its top, where the light falls */
  --edge: rgba(255, 238, 214, 0.08);  /* the 1px edges */
  --ink: #f1ece4;                     /* the words */
  --muted: #8e877d;                   /* the small words */
  --faint: #4f4a43;                   /* the scale at rest */
  --accent: #ffa94a;                  /* the tungsten light */
  --accent-deep: #9c4a1a;             /* where the arc begins */
  --accent-hot: #ffe3b8;              /* the hot end of the light */
  --button: #f1ece4;                  /* Test again */
  --button-ink: #13110f;              /* its words */
  --heat: 0;                          /* 0 to 1: how far the needle is up (set by script.js) */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(ellipse 70% 55% at 50% 38%, rgba(255, 169, 74, 0.07), transparent 70%),
    radial-gradient(ellipse 60% 50% at 12% 0%, rgba(255, 236, 210, 0.05), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* the grain over everything */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.11;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vh, 32px) 0;
}

/* ---- the panel ---- */
.panel {
  position: relative;
  width: min(740px, 92vw);
  padding: clamp(12px, 2.6vh, 24px) clamp(14px, 3vw, 26px) clamp(12px, 2.4vh, 22px);
  border-radius: clamp(18px, 3vh, 26px);
  background: linear-gradient(180deg, var(--panel-top), var(--panel) 46%);
  border: 1px solid var(--edge);
  box-shadow:
    0 1px 0 rgba(255, 240, 220, 0.06) inset,
    0 2px 4px rgba(0, 0, 0, 0.35),
    0 18px 40px -12px rgba(0, 0, 0, 0.7),
    0 60px 120px -40px rgba(0, 0, 0, 0.85);
  isolation: isolate;
  overflow: hidden;
}

/* the edge on top catches the light */
.panel::before {
  content: '';
  position: absolute;
  inset: 0 12% auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 226, 184, calc(0.18 + var(--heat) * 0.4)), transparent);
}

/* the glow behind the dial, warmer the higher the needle goes */
.panel__light {
  position: absolute;
  left: 50%;
  top: 8%;
  width: 90%;
  aspect-ratio: 1.5;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 55%, rgba(255, 169, 74, 0.2), rgba(255, 169, 74, 0.05) 45%, transparent 70%);
  opacity: calc(0.25 + var(--heat) * 0.75);
  pointer-events: none;
  z-index: -1;
}

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

.brand,
.status {
  margin: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(12px, 1.9vh, 14px);
  white-space: nowrap;
}

.brand__mark {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linecap: round;
}

.brand__name {
  font-weight: 640;
  font-stretch: 108%;
  letter-spacing: -0.01em;
}

.brand__page {
  color: var(--muted);
  font-weight: 420;
  padding-left: 9px;
  border-left: 1px solid var(--edge);
}

.status {
  position: relative;
  height: 24px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  border-radius: 99px;
  border: 1px solid var(--edge);
  background: rgba(255, 240, 220, 0.03);
  overflow: hidden;
  font-size: 11.5px;
  font-weight: 520;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
}

.status__in {
  display: block;
}

/* ---- the dial ---- */
.dial {
  position: relative;
  width: min(480px, 100%, 80vh);
  margin: clamp(2px, 1vh, 10px) auto 0;
  container-type: inline-size;
}

.gauge {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.track {
  fill: none;
  stroke: rgba(255, 238, 214, 0.09);
  stroke-width: 6;
  stroke-linecap: round;
}

.track--inner {
  stroke: rgba(255, 238, 214, 0.1);
  stroke-width: 0.7;
}

.arc,
.arc-glow {
  fill: none;
  stroke: url(#g-fill);
  stroke-linecap: round;
  stroke-dasharray: 0 1;
}

.arc {
  stroke-width: 6;
}

.arc-glow {
  stroke-width: 14;
  opacity: 0.55;
}

/* the thin light that runs along the scale while it connects */
.sweep {
  fill: none;
  stroke: var(--accent-hot);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 0.06 1;
  stroke-dashoffset: 0.06;
  opacity: 0;
}

.tick {
  stroke: var(--faint);
  stroke-width: 1;
  stroke-linecap: round;
  transition: stroke 0.35s ease;
}

.tick--major {
  stroke-width: 1.4;
}

.tick.is-lit {
  stroke: var(--accent);
  transition-duration: 0.08s;
}

.tick--major.is-lit {
  stroke: var(--accent-hot);
}

.label {
  fill: var(--muted);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 480;
  font-stretch: 92%;
  text-anchor: middle;
  dominant-baseline: central;
  transition: fill 0.4s ease;
}

.label.is-lit {
  fill: var(--ink);
  transition-duration: 0.1s;
}

.pin {
  fill: #3a352f;
  stroke: rgba(255, 238, 214, 0.25);
  stroke-width: 0.6;
}

.needle__shadow {
  fill: rgba(0, 0, 0, 0.75);
}

.needle__glow {
  fill: var(--accent);
  opacity: calc(0.15 + var(--heat) * 0.6);
}

.needle__blade {
  fill: url(#g-needle);
}

.needle__tail {
  fill: #6d665d;
}

.needle__weight {
  fill: #2c2824;
  stroke: rgba(255, 238, 214, 0.28);
  stroke-width: 0.7;
}

.cap {
  fill: url(#g-cap);
}

.cap__ring {
  fill: none;
  stroke: rgba(255, 244, 228, 0.35);
  stroke-width: 0.6;
}

.cap__dot {
  fill: #191613;
}

/* ---- the number under the pivot ---- */
.readout {
  position: absolute;
  left: 0;
  right: 0;
  margin-inline: auto;
  width: max-content;
  top: 71.9%;
  display: grid;
  justify-items: center;
  gap: 2px;
  pointer-events: none;
}

.readout__num {
  margin: 0;
  display: flex;
  font-size: clamp(26px, 12cqw, 58px);
  line-height: 1;
  font-weight: 300;
  font-stretch: 88%;
  letter-spacing: -0.02em;
}

.col {
  display: block;
  width: 0.6em;
  height: 1em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent);
  transition: width 0.45s cubic-bezier(0.3, 1.25, 0.5, 1), opacity 0.3s ease;
}

.col.is-off {
  width: 0;
  opacity: 0;
}

.strip {
  display: block;
}

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

.readout__unit {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: clamp(9.5px, 2.7cqw, 12.5px);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.readout__phase {
  color: var(--accent);
}

.readout__sep,
.foot__sep {
  width: 1px;
  height: 9px;
  background: var(--edge);
  background: rgba(255, 238, 214, 0.18);
}

/* ---- Test again ---- */
.again {
  position: absolute;
  left: 0;
  right: 0;
  margin-inline: auto;
  width: max-content;
  top: 73.8%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--button-ink);
  cursor: pointer;
  visibility: hidden;
  -webkit-tap-highlight-color: transparent;
}

.again__glow {
  position: absolute;
  inset: -10px -16px;
  border-radius: 99px;
  background: radial-gradient(closest-side, rgba(255, 169, 74, 0.45), transparent);
  opacity: 0.6;
  filter: blur(6px);
  pointer-events: none;
}

.again__face {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: clamp(30px, 8.6cqw, 42px);
  padding: 0 clamp(13px, 3.8cqw, 20px);
  border-radius: 99px;
  background: linear-gradient(180deg, #fbf7f1, var(--button));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 -1px 0 rgba(0, 0, 0, 0.12) inset,
    0 8px 22px -6px rgba(255, 169, 74, 0.5),
    0 2px 5px rgba(0, 0, 0, 0.4);
  font-size: clamp(11.5px, 3cqw, 14px);
  font-weight: 600;
  font-stretch: 100%;
  white-space: nowrap;
  transition: font-stretch 0.45s cubic-bezier(0.3, 1.6, 0.5, 1), padding 0.45s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.again__icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .again:hover .again__face {
    font-stretch: 114%;
    padding: 0 clamp(16px, 4.6cqw, 24px);
  }
}

.again:focus-visible .again__face {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---- the three cards ---- */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(6px, 1.4vw, 10px);
  margin-top: clamp(6px, 1.6vh, 14px);
}

.metric {
  position: relative;
  padding: clamp(7px, 1.4vh, 12px) clamp(8px, 1.6vw, 13px) clamp(6px, 1.2vh, 10px);
  border-radius: clamp(10px, 1.8vh, 14px);
  border: 1px solid var(--edge);
  background: linear-gradient(180deg, rgba(255, 240, 220, 0.035), rgba(255, 240, 220, 0.012));
  transition: border-color 0.5s ease, background 0.5s ease, box-shadow 0.5s ease;
  min-width: 0;
}

.metric.is-active {
  border-color: rgba(255, 169, 74, 0.38);
  background: linear-gradient(180deg, rgba(255, 169, 74, 0.08), rgba(255, 169, 74, 0.015));
  box-shadow: 0 0 0 3px rgba(255, 169, 74, 0.05), 0 10px 24px -14px rgba(255, 169, 74, 0.6);
}

.metric__head {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: clamp(9.5px, 1.6vh, 11.5px);
  font-weight: 520;
  color: var(--muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.metric__icon,
.metric__check {
  width: 12px;
  height: 12px;
  flex: none;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.metric__icon {
  stroke: var(--muted);
  transition: stroke 0.4s ease;
}

.metric.is-active .metric__icon,
.metric.is-done .metric__icon {
  stroke: var(--accent);
}

.metric__check {
  margin-left: auto;
  stroke: var(--accent-hot);
}

.metric__check path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.metric__value {
  margin: clamp(2px, 0.6vh, 5px) 0 clamp(3px, 0.8vh, 7px);
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: clamp(16px, 4vh, 25px);
  line-height: 1;
  font-weight: 420;
  font-stretch: 92%;
  letter-spacing: -0.015em;
  color: var(--faint);
  transition: color 0.4s ease;
}

.metric.is-active .metric__value,
.metric.is-done .metric__value {
  color: var(--ink);
}

.metric__value [data-value] {
  display: inline-block;
}

.metric__unit {
  font-size: 0.46em;
  font-weight: 500;
  font-stretch: 100%;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.spark {
  display: block;
  width: 100%;
  height: clamp(14px, 4.4vh, 30px);
  overflow: visible;
}

.spark__base {
  fill: none;
  stroke: rgba(255, 238, 214, 0.1);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 2 3;
}

.spark__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.spark__area {
  fill: rgba(255, 169, 74, 0.14);
}

/* ---- the line at the bottom ---- */
.foot {
  margin: clamp(8px, 1.6vh, 14px) 0 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

@media (max-height: 520px) {
  .foot {
    display: none;
  }
}

@media (max-width: 400px) {
  .brand__page {
    display: none;
  }
}

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