/* The lesson rating with the slider that changes the question: a white card at the end of a lesson in Parlowe, an
   invented language app. The fill of the track is a window on one fixed gradient as wide as the whole track, so the
   colour under the thumb is always the colour of that score; the script reads the same stops to tint the thumb, the
   word and the soft light at the top of the card. */
:root {
  --page: #ffffff;          /* the page */
  --card: #ffffff;          /* the card */
  --ink: #14161c;           /* the words */
  --muted: #7b808c;         /* the small words */
  --line: #eceef2;          /* the empty track and the thin lines */
  --low: #ef5d4a;           /* the colour of a 1 */
  --mid: #f2a83a;           /* the colour of a 5 */
  --high: #1fae7a;          /* the colour of a 10 */
  --button: #14161c;        /* the send button */
  --button-ink: #ffffff;    /* the words on the button */
  --tint: #f2a83a;          /* set by the script: the colour of the current score */
}

* {
  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: 12px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- the card */
.rate {
  position: relative;
  width: min(92vw, 392px);
  border-radius: 24px;
  background: var(--card);
  box-shadow:
    inset 0 0 0 1px rgba(20, 22, 28, 0.07),
    0 1px 1px rgba(20, 22, 28, 0.04),
    0 4px 10px -2px rgba(20, 22, 28, 0.05),
    0 24px 48px -18px rgba(20, 22, 28, 0.16);
  overflow: hidden;
  opacity: 0;
  isolation: isolate;
}

/* the soft light at the top that takes the colour of the score */
.rate::before {
  content: '';
  position: absolute;
  left: -20%;
  right: -20%;
  top: -60%;
  height: 100%;
  background: radial-gradient(50% 50% at 50% 50%, color-mix(in srgb, var(--tint) 16%, transparent), transparent 72%);
  pointer-events: none;
  z-index: -1;
}

/* a hair of light on the top edge */
.rate::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--tint) 55%, #ffffff), transparent);
  opacity: 0.8;
  pointer-events: none;
}

.rate__body {
  padding: clamp(14px, 3.6vh, 22px) clamp(16px, 5vw, 22px) clamp(14px, 3.4vh, 20px);
}

/* ---------------------------------------------------------------- the head */
.rate__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rate__app {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #23262f, #0f1116);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 2px 6px -2px rgba(20, 22, 28, 0.4);
}

.rate__app svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.rate__app-wave {
  stroke: var(--tint);
}

.rate__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.rate__course {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.rate__lesson {
  font-size: 13px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
}

.rate__xp {
  margin-left: auto;
  flex: none;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 4px 9px;
  border-radius: 999px;
  color: #6b5a14;
  background: linear-gradient(180deg, #fff6d6, #fdeaa8);
  box-shadow: inset 0 0 0 1px rgba(160, 120, 20, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.rate__title {
  margin: clamp(12px, 3vh, 18px) 0 0;
  font-size: clamp(17px, min(5vw, 4.6vh), 20px);
  line-height: 1.2;
  font-weight: 620;
  font-variation-settings: 'wdth' 102;
  letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------- the number on its drum */
.rate__score {
  margin-top: clamp(4px, 1.2vh, 8px);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  --num: clamp(40px, min(13vw, 11.5vh), 54px);
}

.rate__drum {
  position: relative;
  display: block;
  height: var(--num);
  font-size: var(--num);
  line-height: 1;
  overflow: hidden;
  font-weight: 660;
  font-variation-settings: 'wdth' 92;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
  width: 0.62em;
}

.rate__col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.rate__col span {
  display: block;
  height: 1em;
  white-space: nowrap;
}

.rate__of {
  margin-left: 2px;
  padding-bottom: 0.32em;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.rate__word {
  margin-left: auto;
  align-self: center;
  margin-bottom: 4px;
  position: relative;
  display: block;
  height: 26px;
  overflow: hidden;
  border-radius: 999px;
}

.rate__word-in {
  display: block;
  height: 26px;
  line-height: 26px;
  padding: 0 11px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 999px;
  color: color-mix(in srgb, var(--tint) 70%, #14161c);
  background: color-mix(in srgb, var(--tint) 12%, #ffffff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tint) 24%, transparent);
}

/* ---------------------------------------------------------------- the slider */
.rate__slider {
  position: relative;
  margin-top: clamp(8px, 2vh, 12px);
  height: 34px;
  cursor: pointer;
  touch-action: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.rate__slider:focus-visible .rate__knob {
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px var(--tint), 0 4px 10px -2px rgba(20, 22, 28, 0.3);
}

.rate__track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 8px;
  margin-top: -4px;
  border-radius: 8px;
  background: var(--line);
  box-shadow: inset 0 1px 2px rgba(20, 22, 28, 0.08);
}

/* the fill is a window: inside it the gradient is as wide as the whole track (its width set by the script) */
.rate__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: 8px;
  overflow: hidden;
}

.rate__fill-grad {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 300px;
  background: linear-gradient(90deg, var(--low) 0%, var(--mid) 44%, var(--high) 100%);
}

.rate__fill-grad::after {
  content: '';
  position: absolute;
  inset: 0 0 50% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0));
}

.rate__shine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 60px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  opacity: 0;
}

.rate__ticks {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% + 9px);
  height: 5px;
  pointer-events: none;
}

.rate__tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 5px;
  margin-left: -0.5px;
  background: #d5d8de;
  transform-origin: 50% 0;
}

.rate__thumb {
  position: absolute;
  left: 0;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.rate__halo {
  position: absolute;
  left: -22px;
  top: -22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--tint) 34%, transparent), transparent);
  opacity: 0.5;
}

.rate__knob {
  position: absolute;
  left: -13px;
  top: -13px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff, #f3f4f6);
  box-shadow:
    inset 0 0 0 1px rgba(20, 22, 28, 0.06),
    0 0 0 2.5px var(--tint),
    0 1px 2px rgba(20, 22, 28, 0.16),
    0 6px 14px -4px color-mix(in srgb, var(--tint) 60%, rgba(20, 22, 28, 0.3));
  display: grid;
  place-items: center;
}

.rate__grip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, color-mix(in srgb, var(--tint) 60%, #ffffff), var(--tint));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.rate__ends {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- the follow-up question */
.rate__follow {
  position: relative;
  margin-top: clamp(10px, 2.6vh, 16px);
  padding-top: clamp(10px, 2.6vh, 14px);
  border-top: 1px solid var(--line);
  height: calc(clamp(10px, 2.6vh, 14px) + 96px);
}

.rate__ask {
  position: absolute;
  left: 0;
  right: 0;
  top: clamp(10px, 2.6vh, 14px);
}

.rate__q {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 100;
}

.rate__pills {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.rate__pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #f5f6f8;
  color: #3a3e48;
  font: inherit;
  font-size: 12.5px;
  font-weight: 540;
  font-variation-settings: 'wdth' 100;
  box-shadow: inset 0 0 0 1px rgba(20, 22, 28, 0.07);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, font-variation-settings 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rate__pill:focus-visible {
  outline: 2px solid var(--tint);
  outline-offset: 2px;
}

@media (hover: hover) {
  .rate__pill:hover {
    background: #eef0f3;
  }
}

.rate__pill[aria-pressed='true'] {
  color: color-mix(in srgb, var(--pill) 72%, #14161c);
  background: color-mix(in srgb, var(--pill) 13%, #ffffff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pill) 40%, transparent), 0 2px 8px -3px color-mix(in srgb, var(--pill) 50%, transparent);
  font-variation-settings: 'wdth' 108;
}

.rate__pill-check {
  width: 0;
  height: 12px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.rate__pill-check path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* ---------------------------------------------------------------- send */
.rate__send {
  display: block;
  width: 100%;
  height: 48px;
  margin-top: clamp(10px, 2.4vh, 14px);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.rate__send-face {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, #2a2d36, var(--button) 60%);
  color: var(--button-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 0 0 1px rgba(0, 0, 0, 0.4), 0 8px 18px -8px rgba(20, 22, 28, 0.55);
}

.rate__send:focus-visible {
  outline: 2px solid var(--tint);
  outline-offset: 3px;
}

.rate__send-words {
  font-size: 14px;
  font-weight: 600;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (hover: hover) {
  .rate__send:hover .rate__send-words {
    font-variation-settings: 'wdth' 112;
  }

  .rate__send:hover .rate__send-icon {
    transform: translateX(2px);
  }
}

.rate__send-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------------------------------------------------------------- thanks */
.rate__thanks {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  visibility: hidden;
}

.rate__seal {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--tint) 18%, #ffffff), color-mix(in srgb, var(--tint) 8%, #ffffff));
  box-shadow: 0 10px 26px -10px color-mix(in srgb, var(--tint) 70%, transparent);
}

.rate__seal svg {
  width: 48px;
  height: 48px;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rate__seal-ring {
  stroke: var(--tint);
  stroke-width: 1.5;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transform: rotate(-90deg);
  transform-origin: 24px 24px;
}

.rate__seal-check {
  stroke: color-mix(in srgb, var(--tint) 80%, #14161c);
  stroke-width: 2.6;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.rate__thanks-title {
  margin: 14px 0 0;
  font-size: 19px;
  font-weight: 640;
  font-variation-settings: 'wdth' 104;
}

.rate__thanks-line {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  max-width: 26ch;
}

.rate__bonus {
  margin-top: 16px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  color: #6b5a14;
  background: linear-gradient(180deg, #fff6d6, #fdeaa8);
  box-shadow: inset 0 0 0 1px rgba(160, 120, 20, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
