/* The radar chart of AI models compared: the eval card of an invented AI lab on a near black page with two soft
   lights and a little grain. The chart is one SVG in a 260 unit square; the six labels and the tooltip are HTML on
   top of it, placed in pixels by the script (they are measured again on every resize). */
:root {
  --page: #08080a;          /* the page */
  --card: #111115;          /* the body of the card */
  --card-top: #17171d;      /* the top of the card, where the light falls */
  --edge: rgba(255, 255, 255, 0.07); /* the card's edge at rest */
  --ink: #ececf1;           /* the words */
  --muted: #85858f;         /* the small words */
  --violet: #8b7bff;        /* the new model, first colour */
  --cyan: #52d6ff;          /* the new model, second colour and the light */
  --base: #9a9aa6;          /* the model it is compared with */
  --gain: #5fe3b4;          /* the gain */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background:
    radial-gradient(60vmax 40vmax at 18% 8%, rgba(139, 123, 255, 0.12), transparent 70%),
    radial-gradient(50vmax 40vmax at 88% 96%, rgba(82, 214, 255, 0.08), transparent 70%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* a still grain over everything, so the dark gradients never band */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%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");
}

.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: 16px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.card {
  position: relative;
  width: min(100%, 372px);
  padding: clamp(14px, 3.6vh, 22px) clamp(14px, 4.6vw, 22px) clamp(12px, 3.2vh, 18px);
  border-radius: 24px;
  background: linear-gradient(180deg, var(--card-top), var(--card) 46%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 0 0 1px var(--edge),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 12px 24px -10px rgba(0, 0, 0, 0.6),
    0 40px 80px -30px rgba(0, 0, 0, 0.85);
  opacity: 0;
}

/* the edge that catches the beam: a 1px ring lit by a conic gradient turned to the beam's angle (--a, --li) */
.card__rim {
  --a: 0;
  --li: 0;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  opacity: var(--li);
  background: conic-gradient(from calc(var(--a) * 1deg - 60deg) at 50% 54%,
    transparent 0deg,
    color-mix(in srgb, var(--violet) 70%, transparent) 38deg,
    rgba(255, 255, 255, 0.9) 60deg,
    color-mix(in srgb, var(--cyan) 70%, transparent) 82deg,
    transparent 120deg);
  -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);
}

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

.card__title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.card__eyebrow {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.card__name {
  font-size: 17px;
  font-weight: 620;
  font-variation-settings: 'wdth' 106;
  letter-spacing: -0.01em;
}

/* the switch: two buttons on a track, a glass thumb under the chosen one (moved by the script) */
.seg {
  position: relative;
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), inset 0 1px 2px rgba(0, 0, 0, 0.4);
  flex: none;
}

.seg__thumb {
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.07));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 4px 10px -4px rgba(0, 0, 0, 0.8);
}

.seg__btn {
  position: relative;
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

.seg__face {
  display: block;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 560;
  font-variation-settings: 'wdth' 100;
  white-space: nowrap;
  transition: color 0.3s ease, font-variation-settings 0.4s ease;
}

.seg__btn.is-on .seg__face {
  color: var(--ink);
  font-variation-settings: 'wdth' 108;
}

.seg__btn:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 1px;
}

@media (hover: hover) {
  .seg__btn:not(.is-on):hover .seg__face {
    color: #c4c4cc;
  }
}

/* ---------------------------------------------------------------- the radar */
.radar {
  position: relative;
  height: clamp(150px, 50vh, 272px);
  margin: clamp(4px, 1.4vh, 10px) 0;
}

.radar__svg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.radar__rings path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.075);
  stroke-width: 0.9;
}

.radar__rings path:last-child {
  stroke: rgba(255, 255, 255, 0.13);
}

.radar__rings path:first-child {
  fill: rgba(255, 255, 255, 0.012);
}

.radar__axes line {
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 0.9;
}

.radar__beam {
  opacity: 0;
}

.radar__ray {
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.radar__base {
  fill: rgba(255, 255, 255, 0.03);
  stroke: var(--base);
  stroke-opacity: 0.75;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.radar__glow {
  fill: none;
  stroke: var(--violet);
  stroke-width: 6;
  opacity: 0.4;
}

.radar__line {
  fill: none;
  stroke-width: 1.6;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.radar__dot {
  fill: var(--card);
  stroke: #ffffff;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.radar__halo {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 1;
  stroke-opacity: 0.6;
  vector-effect: non-scaling-stroke;
  opacity: 0;
}

/* the six names, placed by the script around the chart */
.radar__labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.lab {
  position: absolute;
  left: 0;
  top: 0;
  appearance: none;
  border: 0;
  background: none;
  padding: 4px 2px;
  margin: 0;
  font: inherit;
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lab--r { transform: translate(0, -50%); }
.lab--l { transform: translate(-100%, -50%); }
.lab--t { transform: translate(-50%, -100%); }
.lab--b { transform: translate(-50%, 0); }

.lab__in {
  display: block;
  font-size: 11px;
  font-weight: 520;
  color: var(--muted);
  font-variation-settings: 'wdth' 100;
  white-space: nowrap;
  transition: color 0.35s ease, font-variation-settings 0.45s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.lab.is-on .lab__in {
  color: var(--ink);
  font-variation-settings: 'wdth' 112;
}

.lab:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 6px;
}

/* the glass tooltip that glides to the vertex */
.tip {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
}

.tip__glass {
  display: grid;
  gap: 3px;
  padding: 8px 10px 9px;
  border-radius: 13px;
  background: rgba(24, 24, 32, 0.62);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  backdrop-filter: blur(12px) saturate(1.3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 10px 24px -8px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

.tip__name {
  font-size: 10.5px;
  font-weight: 540;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.tip__row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.tip__score {
  font-size: 20px;
  line-height: 1;
  font-weight: 640;
  font-variation-settings: 'wdth' 94;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.tip__delta,
.legend__gain {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px 2px 4px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--gain);
  background: color-mix(in srgb, var(--gain) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gain) 22%, transparent);
  font-variant-numeric: tabular-nums;
}

.tip__delta svg,
.legend__gain svg {
  width: 10px;
  height: 10px;
}

.tip__delta path,
.legend__gain path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tip__vs {
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- the legend */
.legend {
  display: flex;
  align-items: center;
  gap: clamp(8px, 3vw, 14px);
  padding-top: clamp(8px, 2vh, 12px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11.5px;
}

.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.legend__swatch {
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  flex: none;
}

.legend__swatch--base {
  background: repeating-linear-gradient(90deg, var(--base) 0 3px, transparent 3px 6px);
}

.legend__name {
  color: var(--muted);
  display: inline-block;
}

.legend__num {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.legend__gain {
  margin-left: auto;
  flex: none;
}

.legend__gain-unit {
  margin-left: 3px;
  font-weight: 500;
  opacity: 0.75;
}

@media (max-width: 360px) {
  .legend__gain-unit {
    display: none;
  }
}
