/* The achievement medals swinging on their ribbons: the achievements screen of Pacewell, an invented running app, on a
   near black page. Every medal is a pendulum drawn in 2D: the swing (.medal__swing) is turned by the script around
   the pivot on the rod; inside it the ribbon, the ring, the edge of the coin and the body. The body is squeezed
   sideways to turn the medal over (a fake width, no 3D) and the edge, a darker disc shifted to one side, gives it
   its thickness. Sizes come from the script in pixels (--r, --rw, --lr, --top) and are measured again on resize. */
:root {
  --page: #0b0b0d;           /* the page */
  --card: #141519;           /* the card */
  --card-low: #0f1013;       /* the bottom of the card */
  --edge: rgba(255, 255, 255, 0.07); /* the card's edge */
  --ink: #f1eee8;            /* the words */
  --muted: #8d8f97;          /* the small words */
  --accent: #ff6b2c;         /* the colour of Pacewell: the stripe on the ribbons, the progress bar */
  --ribbon: #1c2232;         /* the cloth of the ribbons */
  --ribbon-light: #ece5d6;   /* the pale stripe of the ribbons */
  --gold-1: #fdeab0;         /* brushed gold: light, middle, dark */
  --gold-2: #d6a542;
  --gold-3: #7d5214;
  --silver-1: #f7f9fb;       /* silver */
  --silver-2: #b6bdc6;
  --silver-3: #59606a;
  --bronze-1: #f6c7a2;       /* bronze */
  --bronze-2: #b46c3b;
  --bronze-3: #582b11;
  --ti-1: #e3e9f6;           /* anodised titanium, the medal still to unlock */
  --ti-2: #7484ad;
  --ti-3: #252a40;
  --ti-tint: #b892ff;        /* the violet of the anodising */
}

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

/* the page: a warm light from above, like a display case, and a fine grain */
.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  background:
    radial-gradient(60% 46% at 50% 0%, rgba(255, 196, 140, 0.09), transparent 70%),
    radial-gradient(80% 60% at 50% 110%, rgba(90, 110, 170, 0.07), transparent 70%),
    var(--page);
}

.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* the card */
.card {
  position: relative;
  z-index: 1;
  width: min(640px, 92vw, 100%, 120vh);
  container-type: inline-size;
  padding: clamp(14px, min(4.4cqi, 3.6vh), 28px);
  border-radius: clamp(20px, 4vmin, 28px);
  background: linear-gradient(180deg, var(--card), var(--card-low));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 0 0 1px var(--edge),
    0 12px 24px -12px rgba(0, 0, 0, 0.7),
    0 50px 90px -40px rgba(0, 0, 0, 0.95);
  user-select: none;
  -webkit-user-select: none;
}

/* the light of the case falling on the back of the card, behind the medals */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(70% 55% at 50% 30%, rgba(255, 230, 200, 0.06), transparent 70%);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: clamp(13px, 2.5cqi, 16px);
  font-weight: 600;
  font-stretch: 112%;
  letter-spacing: 0.01em;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.32em;
  padding: 5px 10px 5px 10px;
  border-radius: 99px;
  font-size: clamp(11.5px, 2.15cqi, 14px);
  font-weight: 550;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  font-variant-numeric: tabular-nums;
}

.chip__roll {
  position: relative;
  display: inline-block;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
  color: var(--ink);
}

.chip__roll > span {
  display: block;
}

.card__title {
  position: relative;
  margin: clamp(6px, 1.6vh, 12px) 0 0;
  font-size: clamp(19px, min(5.8cqi, 5.2vh), 36px);
  font-weight: 640;
  font-stretch: 118%;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

/* the rack: the rod and the medals hanging from it */
.rack {
  --r: 30px;
  --rw: 26px;
  --lr: 90px;
  --top: 96px;
  position: relative;
  height: min(50vh, 380px, 66cqi);
  margin-top: clamp(4px, 1.2vh, 10px);
  touch-action: pan-y;
}

.rod {
  position: absolute;
  left: 2%;
  right: 2%;
  top: 4px;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(180deg, #fbe2a6 0%, #c79a44 40%, #6e4813 100%);
  box-shadow: 0 4px 8px -2px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.05);
  z-index: 3;
}

.rod__cap {
  position: absolute;
  left: -5px;
  top: -2.5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3cf, #c9973c 45%, #5a3a0e);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.rod__cap--end {
  left: auto;
  right: -5px;
}

.medal {
  position: absolute;
  left: 0;
  top: 0;
  --m1: var(--gold-1);
  --m2: var(--gold-2);
  --m3: var(--gold-3);
}

.medal[data-metal='silver'] {
  --m1: var(--silver-1);
  --m2: var(--silver-2);
  --m3: var(--silver-3);
}

.medal[data-metal='bronze'] {
  --m1: var(--bronze-1);
  --m2: var(--bronze-2);
  --m3: var(--bronze-3);
}

.medal[data-metal='titanium'] {
  --m1: var(--ti-1);
  --m2: var(--ti-2);
  --m3: var(--ti-3);
}

/* the soft shadow the medal throws on the back of the card: it does not turn, the script moves it */
.medal__shadow {
  position: absolute;
  left: calc(var(--r) * -1);
  top: calc(var(--r) * -1);
  width: calc(var(--r) * 2);
  height: calc(var(--r) * 2);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.25) 60%, transparent);
  filter: blur(6px);
  z-index: 1;
  pointer-events: none;
}

.medal__swing {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 2;
}

/* the ribbon: grosgrain cloth with two accent stripes and a pale one in the middle, cut to a point */
.ribbon {
  position: absolute;
  left: calc(var(--rw) / -2);
  top: 0;
  width: var(--rw);
  height: var(--lr);
  transform-origin: 50% 0;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--rw) * 0.55), 50% 100%, 0 calc(100% - var(--rw) * 0.55));
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 16%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.42), rgba(255, 255, 255, 0.06) 30%, rgba(255, 255, 255, 0.1) 50%, rgba(0, 0, 0, 0.05) 70%, rgba(0, 0, 0, 0.42)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.07) 0 1px, rgba(0, 0, 0, 0.12) 1px 2px),
    linear-gradient(90deg, var(--ribbon) 0 24%, var(--accent) 24% 34%, var(--ribbon) 34% 44%, var(--ribbon-light) 44% 56%, var(--ribbon) 56% 66%, var(--accent) 66% 76%, var(--ribbon) 76%);
}

.medal[data-metal='silver'] .ribbon {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 16%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.42), rgba(255, 255, 255, 0.06) 30%, rgba(255, 255, 255, 0.1) 50%, rgba(0, 0, 0, 0.05) 70%, rgba(0, 0, 0, 0.42)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.07) 0 1px, rgba(0, 0, 0, 0.12) 1px 2px),
    linear-gradient(90deg, var(--ribbon) 0 38%, var(--accent) 38% 62%, var(--ribbon) 62%);
}

.medal[data-metal='bronze'] .ribbon {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 16%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.42), rgba(255, 255, 255, 0.06) 30%, rgba(255, 255, 255, 0.1) 50%, rgba(0, 0, 0, 0.05) 70%, rgba(0, 0, 0, 0.42)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.07) 0 1px, rgba(0, 0, 0, 0.12) 1px 2px),
    linear-gradient(90deg, var(--ribbon-light) 0 14%, var(--ribbon) 14% 86%, var(--ribbon-light) 86%);
}

.medal[data-metal='titanium'] .ribbon {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 16%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.42), rgba(255, 255, 255, 0.06) 30%, rgba(255, 255, 255, 0.1) 50%, rgba(0, 0, 0, 0.05) 70%, rgba(0, 0, 0, 0.42)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.07) 0 1px, rgba(0, 0, 0, 0.12) 1px 2px),
    linear-gradient(90deg, var(--ribbon) 0 18%, var(--ribbon-light) 18% 26%, var(--accent) 26% 74%, var(--ribbon-light) 74% 82%, var(--ribbon) 82%);
}

/* the shade that runs over the cloth when the ribbon twists */
.ribbon__fold {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.1) 60%, rgba(255, 255, 255, 0.12));
  opacity: 0;
}

/* the jump ring between the ribbon and the medal */
.medal__ring {
  position: absolute;
  left: calc(var(--r) * -0.15);
  top: calc(var(--lr) - var(--r) * 0.22);
  width: calc(var(--r) * 0.3);
  height: calc(var(--r) * 0.36);
  border-radius: 50%;
  border: max(1.5px, calc(var(--r) * 0.06)) solid var(--m2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 1px 1px rgba(0, 0, 0, 0.5);
}

/* the edge of the coin: a darker milled disc behind the body, shifted aside while it turns */
.medal__edge,
.medal__body {
  position: absolute;
  left: calc(var(--r) * -1);
  top: var(--top);
  width: calc(var(--r) * 2);
  height: calc(var(--r) * 2);
  border-radius: 50%;
  transform-origin: 50% 0;
}

.medal__edge {
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.28) 0 1px, rgba(255, 255, 255, 0.14) 1px 2px),
    linear-gradient(90deg, var(--m3), var(--m2) 50%, var(--m3));
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.5);
}

.medal__body {
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

/* the faces: brushed metal, a domed light, a raised rim and an engraved ring */
.face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--m3);
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 40%),
    radial-gradient(circle at 70% 82%, rgba(0, 0, 0, 0.28), transparent 46%),
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 255, 255, 0.09) 0deg 0.6deg, rgba(0, 0, 0, 0.07) 0.6deg 1.3deg),
    conic-gradient(from 210deg, var(--m3), var(--m1) 38deg, var(--m2) 86deg, var(--m3) 150deg, var(--m2) 196deg, var(--m1) 246deg, var(--m2) 300deg, var(--m3));
  box-shadow:
    inset 0 0 0 calc(var(--r) * 0.07) var(--m2),
    inset 0 0 0 calc(var(--r) * 0.1) rgba(0, 0, 0, 0.28),
    inset 0 1.5px 1px rgba(255, 255, 255, 0.7),
    inset 0 -2px 3px rgba(0, 0, 0, 0.4);
}

.face--back {
  opacity: 0;
  background:
    radial-gradient(circle at 66% 26%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 42%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0 1px, rgba(0, 0, 0, 0.07) 1px 2px),
    linear-gradient(160deg, var(--m1), var(--m2) 45%, var(--m3) 100%);
}

.medal[data-metal='titanium'] .face {
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 40%),
    radial-gradient(circle at 70% 82%, rgba(0, 0, 0, 0.3), transparent 46%),
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 255, 255, 0.09) 0deg 0.6deg, rgba(0, 0, 0, 0.07) 0.6deg 1.3deg),
    conic-gradient(from 210deg, var(--m3), var(--m1) 38deg, var(--ti-tint) 70deg, var(--m2) 100deg, var(--m3) 150deg, var(--m2) 196deg, var(--m1) 246deg, var(--ti-tint) 276deg, var(--m2) 310deg, var(--m3));
  color: #1b1f33;
}

.medal[data-metal='titanium'] .face--back {
  background:
    radial-gradient(circle at 66% 26%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 42%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0 1px, rgba(0, 0, 0, 0.07) 1px 2px),
    linear-gradient(160deg, var(--m1), var(--ti-tint) 40%, var(--m2) 62%, var(--m3) 100%);
}

.face__ring {
  position: absolute;
  inset: 15%;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.22);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* the engraving: dark letters with a lit lower lip, as if cut into the metal */
.face__big,
.face__small,
.face__line,
.face__time {
  position: relative;
  line-height: 1;
  text-shadow: 0 0.06em 0 rgba(255, 255, 255, 0.32);
  font-variant-numeric: tabular-nums;
}

.face__big {
  font-size: calc(var(--r) * 0.62);
  font-weight: 760;
  font-stretch: 112%;
  letter-spacing: -0.03em;
}

.face__small {
  margin-top: calc(var(--r) * 0.08);
  font-size: calc(var(--r) * 0.21);
  font-weight: 650;
  font-stretch: 125%;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

.face__line {
  font-size: calc(var(--r) * 0.18);
  font-weight: 650;
  font-stretch: 125%;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}

.face__time {
  margin: calc(var(--r) * 0.07) 0;
  font-size: calc(var(--r) * 0.44);
  font-weight: 720;
  font-stretch: 105%;
  letter-spacing: -0.02em;
}

/* the reflection of the case light, moved by the script as the medal swings */
.medal__glint {
  position: absolute;
  left: -60%;
  top: -10%;
  width: 220%;
  height: 120%;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 38%, rgba(255, 255, 255, 0.5) 48%, rgba(255, 255, 255, 0.08) 54%, transparent 62%);
  mix-blend-mode: soft-light;
  opacity: 0.8;
}

/* the band of light that runs over the titanium when it unlocks */
.medal__sweep {
  position: absolute;
  left: -100%;
  top: -20%;
  width: 70%;
  height: 140%;
  pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.85) 50%, transparent);
  mix-blend-mode: overlay;
  opacity: 0;
}

/* the frosted glass over the medal still to unlock */
.frost {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, 0.32), transparent 45%),
    linear-gradient(160deg, rgba(210, 220, 240, 0.26), rgba(120, 130, 160, 0.16));
  -webkit-backdrop-filter: blur(2.6px) saturate(0.6);
  backdrop-filter: blur(2.6px) saturate(0.6);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.28),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.45),
    inset 0 -6px 12px rgba(0, 0, 0, 0.25);
}

.frost::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0.35;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.8 0'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
  mix-blend-mode: overlay;
}

.lock {
  position: relative;
  z-index: 1;
  width: calc(var(--r) * 0.62);
  height: calc(var(--r) * 0.62);
  fill: none;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
  overflow: visible;
}

.lock__shackle {
  transform-box: fill-box;
  transform-origin: 100% 100%;
}

/* the little flash where two medals knock: six short strokes */
.spark {
  position: absolute;
  left: -10px;
  top: -10px;
  width: 20px;
  height: 20px;
  z-index: 4;
  opacity: 0;
  pointer-events: none;
}

.spark svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: #fff6df;
  stroke-width: 1.4;
  stroke-linecap: round;
}

/* the drawn pointer of the walk on its own */
.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  margin: -4px 0 0 -5px;
  z-index: 6;
  opacity: 0;
  pointer-events: none;
}

.cursor svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: #fff;
  stroke: #0b0b0d;
  stroke-width: 1.3;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.55));
}

/* the line under the rack: the next goal, then the time that climbs */
.goal {
  position: relative;
  margin-top: clamp(4px, 1vh, 10px);
  padding-top: clamp(10px, 2vh, 14px);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.goal__text {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.goal__label,
.goal__value {
  display: block;
  overflow: hidden;
  white-space: nowrap;
}

.goal__label > span,
.goal__value > span {
  display: block;
}

.goal__label {
  flex: none;
  font-size: clamp(11.5px, 2.15cqi, 14px);
  font-weight: 550;
  color: var(--muted);
}

.goal__value {
  min-width: 0;
  text-overflow: ellipsis;
  font-size: clamp(12.5px, 3.1cqi, 19px);
  font-weight: 600;
  font-stretch: 108%;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}

.goal__bar {
  position: relative;
  display: block;
  height: clamp(3px, 0.6cqi, 4px);
  margin-top: clamp(8px, 1.8cqi, 12px);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.goal__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-origin: 0 50%;
  transform: scaleX(0.88);
  background: linear-gradient(90deg, #c4471a, var(--accent) 70%, #ffb38a);
}

@media (hover: hover) {
  .medal__body:hover {
    filter: brightness(1.06);
  }
}
