/* Medals: the levels of an achievement branch, struck in the metal of their
   rank; the branch drawn as a ladder; and the moment a new one is earned.
   Everything here reads the theme's own tokens (--bg, --ink, --line), so it
   follows every theme in dark and in light. */

/* the angle the light falls from: turning it moves the reflections */
@property --medal-turn {
  syntax: '<angle>';
  inherits: true;
  initial-value: 0deg;
}

:is(.medal, .medal-step, .earned-card, .earned-stage, .rank-dot) {
  --m-hi: #f6d6b3;
  --m-mid: #bf7d44;
  --m-lo: #76431e;
  --m-deep: #40240f;
  --m-ink: #4b2a12;
  --m-cut: rgba(255, 228, 200, 0.62);
}

:is(.medal, .medal-step, .earned-card, .earned-stage, .rank-dot)[data-rank='silver'] {
  --m-hi: #fbfcfd;
  --m-mid: #b6bdc5;
  --m-lo: #6c747d;
  --m-deep: #394047;
  --m-ink: #39414a;
  --m-cut: rgba(255, 255, 255, 0.78);
}

:is(.medal, .medal-step, .earned-card, .earned-stage, .rank-dot)[data-rank='gold'] {
  --m-hi: #fff5cc;
  --m-mid: #e4b33d;
  --m-lo: #9a6a10;
  --m-deep: #573905;
  --m-ink: #694607;
  --m-cut: rgba(255, 247, 208, 0.82);
}

:is(.medal, .medal-step, .earned-card, .earned-stage, .rank-dot)[data-rank='platinum'] {
  --m-hi: #ffffff;
  --m-mid: #dae3e9;
  --m-lo: #92a1ac;
  --m-deep: #55636f;
  --m-ink: #4d5c68;
  --m-cut: rgba(255, 255, 255, 0.92);
}

:is(.medal, .medal-step, .earned-card, .earned-stage, .rank-dot)[data-rank='titanium'] {
  --m-hi: #b2bccd;
  --m-mid: #474f5d;
  --m-lo: #1d212a;
  --m-deep: #0b0d12;
  --m-ink: #e3e9f4;
  --m-cut: rgba(0, 0, 0, 0.66);
}

/* ---------- the medal ---------- */

.medal {
  --medal: 64px;
  position: relative;
  display: inline-block;
  flex: none;
  width: var(--medal);
  height: var(--medal);
  /* everything inside is measured against the medal */
  font-size: var(--medal);
  line-height: 0;
  filter: drop-shadow(0 0.03em 0.045em rgba(0, 0, 0, 0.42));
}

.medal-body {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 50%;
  background: conic-gradient(
    from calc(215deg + var(--medal-turn)),
    var(--m-hi),
    var(--m-mid) 9%,
    var(--m-lo) 22%,
    var(--m-mid) 35%,
    var(--m-hi) 48%,
    var(--m-mid) 60%,
    var(--m-lo) 74%,
    var(--m-mid) 88%,
    var(--m-hi)
  );
}

/* the rim catches light on its upper edge */
.medal-body::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0.014em 0 rgba(255, 255, 255, 0.5), inset 0 -0.014em 0 rgba(0, 0, 0, 0.32);
}

/* the field: sunk a little, brushed the other way round */
.medal-field {
  position: absolute;
  inset: 12%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.32), transparent 54%),
    conic-gradient(
      from calc(35deg - var(--medal-turn)),
      var(--m-mid),
      var(--m-lo) 14%,
      var(--m-mid) 30%,
      var(--m-hi) 46%,
      var(--m-mid) 62%,
      var(--m-lo) 78%,
      var(--m-mid)
    );
  box-shadow:
    inset 0 0.022em 0.03em rgba(0, 0, 0, 0.5),
    inset 0 -0.012em 0.012em rgba(255, 255, 255, 0.38),
    0 0 0 0.009em var(--m-deep);
}

/* the emblem is cut into the metal: a dark line with a lit lower lip */
.medal-emblem {
  width: 56%;
  height: 56%;
  color: var(--m-ink);
  filter: drop-shadow(0 0.012em 0 var(--m-cut));
}

.medal-emblem svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* silver: a reeded edge */
.medal[data-rank='silver'] .medal-body::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(0, 0, 0, 0.3) 0 3deg, transparent 3deg 7.5deg);
  -webkit-mask: radial-gradient(closest-side, transparent 88.5%, #000 90%);
  mask: radial-gradient(closest-side, transparent 88.5%, #000 90%);
}

/* platinum: eight sides, cut like a stone, each catching the light its own way */
.medal[data-rank='platinum'] .medal-body {
  background:
    repeating-conic-gradient(from -22.5deg, rgba(255, 255, 255, 0.55) 0 45deg, rgba(96, 116, 132, 0.26) 45deg 90deg),
    conic-gradient(from calc(215deg + var(--medal-turn)), var(--m-hi), var(--m-mid) 9%, var(--m-lo) 22%, var(--m-mid) 35%, var(--m-hi) 48%, var(--m-mid) 60%, var(--m-lo) 74%, var(--m-mid) 88%, var(--m-hi));
}

/* titanium: dark plate, with the cold blue the metal takes when it is heated */
.medal[data-rank='titanium'] .medal-body {
  background:
    conic-gradient(
      from calc(200deg + var(--medal-turn)),
      rgba(92, 146, 232, 0.44),
      transparent 14%,
      rgba(66, 164, 196, 0.3) 33%,
      transparent 48%,
      rgba(92, 146, 232, 0.36) 64%,
      transparent 82%,
      rgba(92, 146, 232, 0.44)
    ),
    conic-gradient(from calc(215deg + var(--medal-turn)), var(--m-hi), var(--m-mid) 9%, var(--m-lo) 22%, var(--m-mid) 35%, var(--m-hi) 48%, var(--m-mid) 60%, var(--m-lo) 74%, var(--m-mid) 88%, var(--m-hi));
}

.medal[data-rank='titanium'] .medal-field {
  box-shadow:
    inset 0 0.022em 0.03em rgba(0, 0, 0, 0.7),
    inset 0 -0.012em 0.012em rgba(190, 210, 255, 0.22),
    0 0 0 0.011em rgba(196, 214, 255, 0.55);
}

/* a blank: the shape of the medal, not struck yet */
.medal.is-blank {
  filter: none;
}

.medal.is-blank .medal-body {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  box-shadow: inset 0 0 0 1px var(--line-2);
}

.medal.is-blank .medal-body::before {
  content: none;
}

.medal.is-blank .medal-field {
  background: none;
  box-shadow: inset 0 0 0 1px var(--line);
}

.medal.is-blank .medal-emblem {
  color: var(--ink-3);
  opacity: 0.6;
  filter: none;
}

/* a band of light that crosses the medal once */
.medal-glint {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 50%;
  pointer-events: none;
}

.medal-glint::before {
  content: '';
  position: absolute;
  inset: -20% -60%;
  background: linear-gradient(105deg, transparent 43%, rgba(255, 255, 255, 0.8) 50%, transparent 57%);
  opacity: 0;
  transform: translateX(-70%);
}

@keyframes medal-glint {
  0% {
    opacity: 0;
    transform: translateX(-70%);
  }

  18%,
  82% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateX(70%);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .medal.is-glinting .medal-glint::before,
  :is(.achievement, .medal-shelf-item, .showcase-pick):hover .medal:not(.is-blank) .medal-glint::before {
    animation: medal-glint 1.05s cubic-bezier(0.3, 0, 0.2, 1) 0.1s both;
  }
}

/* a rank named in a line of text: the metal as a dot, the words in ink */
.rank-dot {
  display: inline-block;
  width: 0.72em;
  height: 0.72em;
  margin-right: 0.5em;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--m-hi), var(--m-mid) 46%, var(--m-lo));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--m-deep) 45%, transparent);
  vertical-align: -0.02em;
}

/* ---------- the branch as a ladder ---------- */

.medal-ladder {
  display: flex;
  align-items: flex-start;
  margin: 0;
  padding: 0;
  list-style: none;
}

.medal-step {
  --fill: 0;
  position: relative;
  display: grid;
  flex: 1 1 0;
  min-width: 0;
  justify-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* the way up to this step, filled as far as the member has come */
.medal-step::before {
  content: '';
  position: absolute;
  top: 6px;
  right: calc(50% + 11px);
  left: calc(-50% + 11px);
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--ink-2) calc(var(--fill) * 100%), var(--line-2) 0);
}

.medal-step:first-child::before {
  left: 0;
}

.medal-pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--m-mid) 50%, var(--ink-3));
}

.medal-step.is-earned .medal-pip {
  background: linear-gradient(135deg, var(--m-hi), var(--m-mid) 46%, var(--m-lo));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--m-deep) 50%, transparent), 0 1px 2px rgba(0, 0, 0, 0.3);
}

.medal-step.is-earned,
.medal-step.is-next {
  color: var(--ink-2);
}

.medal-step.is-next .medal-goal {
  color: var(--ink);
  font-weight: 650;
}

/* ---------- a branch on the profile ---------- */

.achievement.is-branch {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: start;
  gap: 4px 16px;
  padding: 20px 22px;
}

.achievement.is-branch > .medal {
  grid-row: 1 / span 3;
  align-self: start;
}

.achievement.is-branch .achievement-rank {
  display: block;
  margin: 2px 0 0;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.achievement.is-branch h3 {
  margin: 0;
}

.achievement.is-branch .achievement-caption {
  min-height: 0;
  margin: 0;
}

.achievement.is-branch .medal-ladder {
  grid-column: 1 / -1;
  margin-top: 16px;
}

.achievement-next {
  display: flex;
  grid-column: 1 / -1;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 0;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.45;
}

/* one's own profile: keep a branch from others */
.achievement.is-branch {
  position: relative;
}

.branch-eye {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s, background 0.18s, color 0.18s;
}

.branch-eye .i {
  width: 17px;
  height: 17px;
}

.achievement:is(:hover, :focus-within) .branch-eye,
.branch-eye[aria-pressed='true'] {
  opacity: 1;
}

.branch-eye:hover {
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--ink);
}

.branch-eye:focus-visible {
  outline: 2px solid var(--focus, var(--ink));
  outline-offset: 2px;
  opacity: 1;
}

/* the rank line leaves room for the eye */
.branch-eye ~ .achievement-rank {
  padding-right: 30px;
}

/* a touch screen has no hover: the eye is always there */
@media (hover: none) {
  .branch-eye {
    opacity: 1;
  }
}

.achievement.is-hidden > :not(.branch-eye) {
  opacity: 0.55;
}

.achievement.is-hidden .achievement-rank {
  opacity: 1;
}

/* who can see a list, as a button on its card (own profile) */
.card-visibility {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0 -8px;
  padding: 5px 9px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.card-visibility .i {
  width: 14px;
  height: 14px;
}

.card-visibility:hover {
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--ink);
}

.card-visibility:focus-visible {
  outline: 2px solid var(--focus, var(--ink));
  outline-offset: 2px;
}

/* what the medal on the card was given for */
.achievement-have {
  display: flex;
  grid-column: 1 / -1;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.achievement-have small {
  flex: none;
  color: var(--ink-3);
  font-size: 11.5px;
  font-weight: 500;
}

.achievement-have + .achievement-next {
  margin-top: 4px;
}

.achievement-next b {
  flex: none;
  color: var(--ink-2);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.achievement.is-branch .achievement-date {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.branch-group + .branch-group {
  margin-top: 30px;
}

.branch-group > h3 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 14px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.branch-group > h3 small {
  color: var(--ink-3);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

/* ---------- the showcase: the medals a member puts first ---------- */

.medal-showcase {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 26px 0 0;
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-2);
}

.medal-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.medal-shelf-item {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 2px;
  width: 124px;
  padding: 8px 6px;
  border: 0;
  border-radius: var(--r-2);
  background: none;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  line-height: 1.25;
  text-align: center;
  transition: background 0.18s, transform 0.25s var(--ease, ease);
}

.medal-shelf-item:hover {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  transform: translateY(-2px);
}

.medal-shelf-item:focus-visible {
  outline: 2px solid var(--focus, var(--ink));
  outline-offset: 2px;
}

.medal-shelf-item b {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 9px;
  font-size: 12.5px;
  font-weight: 600;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.medal-shelf-item small {
  color: var(--ink-3);
  font-size: 11px;
}

/* a branch the showcase has just pointed at */
.achievement.is-pointed {
  outline: 2px solid color-mix(in srgb, var(--ink) 55%, transparent);
  outline-offset: 3px;
}

/* choosing them */
.showcase-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  max-height: min(52vh, 460px);
  padding: 2px;
  overflow-y: auto;
}

.showcase-pick {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 2px;
  padding: 14px 8px 12px;
  border: 0;
  border-radius: var(--r-2);
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  line-height: 1.25;
  text-align: center;
}

.showcase-pick b {
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 600;
}

.showcase-pick small {
  color: var(--ink-3);
  font-size: 11px;
}

.showcase-pick.is-chosen {
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.showcase-pick:disabled {
  cursor: default;
  opacity: 0.45;
}

.showcase-pick:focus-visible {
  outline: 2px solid var(--focus, var(--ink));
  outline-offset: 2px;
}

.showcase-order {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- the profile as a home: the ring, the pinned list ---------- */

/* a wide picture of the member's own across the top of the profile; it lets go into the page */
.profile-banner {
  height: clamp(150px, 24vw, 260px);
  margin: -20px 0 0;
  overflow: hidden;
  border-radius: 24px;
  -webkit-mask: linear-gradient(#000 52%, transparent);
  mask: linear-gradient(#000 52%, transparent);
}

.profile-banner img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* the heading stands on the banner's foot */
.profile-heading.has-banner {
  position: relative;
  margin-top: clamp(-96px, -9vw, -56px);
  padding-inline: clamp(8px, 2vw, 26px);
}

/* ---------- choosing a picture and a banner (the profile editor) ----------
   The picture, and beside it what can be done about it; the banner as it will lie across the profile, and under it
   the same. The pictures that come with the site are behind a button, in a window of their own. */
.avatar-editor {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px 18px;
}

.avatar-editor .profile-avatar {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  font-size: 32px;
}

.avatar-actions,
.banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.banner-editor {
  display: grid;
  gap: 10px;
}

/* the window of ready-made pictures: thirty-six, six to a row, each large enough to press */
.dialog.ready-pictures {
  width: min(452px, calc(100vw - 28px));
}

.avatar-presets {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 4px 0 6px;
}

.avatar-presets > .hint {
  grid-column: 1 / -1;
  margin: 0;
}

.avatar-preset {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 24%;
  background: var(--bg-3);
  cursor: pointer;
  transition: transform 0.2s var(--ease);
}

.avatar-preset img {
  display: block;
  width: 100%;
  height: 100%;
}

.avatar-preset:hover {
  transform: translateY(-2px);
}

.avatar-preset:active {
  transform: scale(0.96);
}

.avatar-preset[aria-pressed='true'] {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.avatar-preset:focus-visible {
  outline: 2px solid var(--focus, var(--ink));
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .avatar-editor {
    align-items: start;
    gap: 12px 14px;
  }

  .avatar-editor .profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 19px;
    font-size: 27px;
  }

  /* one under another: two long words do not fit side by side here */
  .avatar-actions {
    display: grid;
    justify-items: start;
  }

  .avatar-presets {
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .avatar-preset {
    transition: none;
  }
}

.banner-preview {
  display: grid;
  height: 84px;
  overflow: hidden;
  place-items: center;
  border-radius: var(--r-2);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-3);
  font-size: 12.5px;
}

.banner-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* a branch's name worn under one's own */
.profile-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
  font-size: 15px;
  font-weight: 600;
}

.profile-title small {
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
}

/* the frame of a member's standing, laid over their picture at any size */
.avatar-frame {
  position: relative;
  display: inline-grid;
  flex: none;
  vertical-align: middle;
}

.frame-art {
  position: absolute;
  top: -11%;
  left: -11%;
  width: 122%;
  height: 122%;
  overflow: visible;
  pointer-events: none;
}

/* the last rank is lit */
.avatar-frame[data-standing='7'] .frame-art {
  filter: drop-shadow(0 0 5px rgba(255, 221, 130, 0.5));
}

/* the profile's heading sizes the picture; the frame takes the picture's place in it */
.profile-heading > .avatar-frame {
  margin: 8px;
}

@media (max-width: 820px) {
  .profile-heading > .avatar-frame > .profile-avatar {
    width: 76px;
    height: 76px;
    border-radius: 22px;
    font-size: 32px;
  }
}

/* the name of the rank, beside the handle: it opens what the rank stands on */
.standing-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 10px;
  padding: 3px 10px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--ink-2);
  cursor: pointer;
  font: 600 11.5px / 1.4 var(--font-ui);
  letter-spacing: 0;
  transition: background 0.18s, color 0.18s;
}

.standing-pill:hover {
  background: color-mix(in srgb, var(--ink) 16%, transparent);
  color: var(--ink);
}

.standing-pill:focus-visible {
  outline: 2px solid var(--focus, var(--ink));
  outline-offset: 2px;
}

.standing {
  display: grid;
  gap: 26px;
}

.standing-now {
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 6px 8px;
}

.standing-now .profile-avatar {
  width: 92px;
  height: 92px;
  border-radius: 28px;
  font-size: 36px;
}

.standing-now > .avatar-frame {
  margin: 8px;
}

.standing-now > div {
  display: grid;
  flex: 1;
  gap: 5px;
  min-width: 0;
}

.standing-now small {
  color: var(--ink-3);
  font-size: 12px;
}

.standing-now b {
  font: 650 26px / 1.1 var(--font-display);
  letter-spacing: -0.02em;
}

.standing-now span {
  color: var(--ink-2);
  font-size: 13px;
}

.standing-bar {
  height: 4px;
  margin: 6px 0 2px;
  overflow: hidden;
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
}

.standing-bar i {
  display: block;
  width: calc(var(--done) * 100%);
  height: 100%;
  border-radius: 4px;
  background: var(--ink);
}

.standing-ladder {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.standing-ladder li {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 18px 4px 12px;
  border-radius: var(--r-2);
  color: var(--ink-3);
  font-size: 11.5px;
  text-align: center;
}

.standing-ladder li.is-reached {
  color: var(--ink-2);
}

.standing-ladder li.is-current {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  box-shadow: inset 0 0 0 1px var(--line-2);
  color: var(--ink);
}

.standing-ladder li:not(.is-reached) .avatar-frame,
.standing-ladder li:not(.is-reached) > .profile-avatar {
  opacity: 0.5;
}

.standing-ladder .profile-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  font-size: 18px;
}

.standing-ladder b {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.standing-roads {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 20px;
  margin: 0;
  font-size: 14px;
}

.standing-roads dt {
  color: var(--ink-2);
}

.standing-roads dd {
  margin: 0;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@media (max-width: 700px) {
  .standing-ladder {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* how many members hold the rank on the card */
.achievement-rarity {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--ink-3);
  font-size: 12px;
}

.profile-featured {
  display: grid;
  grid-template-columns: minmax(180px, 0.42fr) minmax(0, 1fr);
  align-items: center;
  gap: 26px;
  margin: 18px 0 0;
  padding: 22px 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-2);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.3s var(--ease, ease);
}

.profile-featured:hover {
  transform: translateY(-2px);
}

.profile-featured:focus-visible {
  outline: 2px solid var(--focus, var(--ink));
  outline-offset: 3px;
}

.featured-text small {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.featured-text h2 {
  margin: 8px 0 6px;
  font: 650 clamp(20px, 2.2vw, 28px) / 1.15 var(--font-display);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.featured-text p {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
}

/* the top of the list, in the order it is ranked; the row is cut where the tray ends */
.featured-row {
  display: flex;
  gap: 10px;
  min-width: 0;
  -webkit-mask: linear-gradient(90deg, #000 82%, transparent);
  mask: linear-gradient(90deg, #000 82%, transparent);
}

.featured-cover {
  flex: none;
  height: 132px;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: var(--tile-r, 3px);
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  box-shadow: 0 10px 22px -14px rgba(0, 0, 0, 0.7);
}

.profile-featured[data-aspect='square'] .featured-cover {
  aspect-ratio: 1;
  height: 116px;
}

.profile-featured[data-aspect='wide'] .featured-cover {
  aspect-ratio: 16 / 9;
  height: 84px;
}

.featured-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.featured-cover b {
  display: -webkit-box;
  height: 100%;
  padding: 10% 10% 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  background: linear-gradient(160deg, hsl(var(--hue) 46% 30%), hsl(var(--hue) 48% 14%));
  color: #f2f4f2;
  font: 650 13px / 1.12 var(--font-display);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  .profile-featured {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
  }

  .featured-cover {
    height: 104px;
  }

  .profile-featured[data-aspect='square'] .featured-cover {
    height: 92px;
  }
}

/* ---------- earned: the quiet card ---------- */

.earned-card {
  position: fixed;
  inset: auto 22px 84px auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: min(380px, calc(100vw - 44px));
  margin: 0;
  padding: 12px 10px 12px 14px;
  border: 0;
  border-radius: var(--r-3);
  background: var(--bg-2);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line), 0 22px 44px -20px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  font: inherit;
  text-align: left;
  animation: earned-card-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.earned-card.is-leaving {
  animation: earned-card-out 0.28s ease-in forwards;
}

.earned-card small {
  display: block;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.earned-card b {
  display: block;
  margin: 3px 0 2px;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.25;
}

.earned-card p {
  margin: 0;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.4;
}

.earned-card-x {
  display: grid;
  align-self: start;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}

.earned-card-x:hover {
  background: color-mix(in srgb, var(--ink) 9%, transparent);
  color: var(--ink);
}

.earned-card-x .i {
  width: 15px;
  height: 15px;
}

@keyframes earned-card-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
}

@keyframes earned-card-out {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ---------- earned: the close-up ---------- */

.earned-stage {
  position: fixed;
  inset: 0;
  display: grid;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 24px;
  overflow: hidden;
  place-items: center;
  border: 0;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(0.8);
  backdrop-filter: blur(16px) saturate(0.8);
  color: var(--ink);
  animation: earned-veil 0.4s ease both;
}

.earned-stage:not([open]) {
  display: none;
}

.earned-stage::backdrop {
  background: none;
}

.earned-stage.is-leaving {
  animation: earned-veil 0.3s ease reverse forwards;
}

.earned-scene {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(520px, 100%);
  text-align: center;
}

/* light behind the medal, in the tint of its metal */
.earned-rays {
  position: absolute;
  top: calc(var(--coin) / 2);
  left: 50%;
  width: min(150vmin, 1100px);
  aspect-ratio: 1;
  margin: calc(min(150vmin, 1100px) / -2) 0 0 calc(min(150vmin, 1100px) / -2);
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--m-mid) 24%, transparent) 0 4deg, transparent 4deg 20deg);
  -webkit-mask: radial-gradient(closest-side, #000 6%, rgba(0, 0, 0, 0.4) 32%, transparent 72%);
  mask: radial-gradient(closest-side, #000 6%, rgba(0, 0, 0, 0.4) 32%, transparent 72%);
  opacity: 0.55;
  pointer-events: none;
  animation: earned-rays-in 1.4s cubic-bezier(0.16, 1, 0.3, 1) 0.5s both, earned-rays-turn 90s linear infinite;
}

/* one ring leaves the medal as it lands */
.earned-ring {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--coin);
  height: var(--coin);
  margin-left: calc(var(--coin) / -2);
  border-radius: 50%;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--m-mid) 70%, transparent);
  opacity: 0;
  pointer-events: none;
  animation: earned-ring 1.3s cubic-bezier(0.2, 0.7, 0.2, 1) 1.2s forwards;
}

.earned-coin-space {
  --coin: clamp(150px, 34vmin, 230px);
  position: relative;
  width: var(--coin);
  height: var(--coin);
  perspective: 900px;
}

.earned-scene {
  --coin: clamp(150px, 34vmin, 230px);
}

.earned-coin {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  animation: earned-coin 1.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.earned-coin.is-landed {
  animation: none;
  transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.earned-coin .medal {
  --medal: var(--coin) !important;
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  filter: drop-shadow(0 0.05em 0.09em rgba(0, 0, 0, 0.5));
}

.earned-coin .medal.is-reverse {
  transform: rotateY(180deg);
}

.earned-coin .medal-emblem svg {
  stroke-width: 1.2;
}

/* the reverse carries the number of the level */
.medal-numeral {
  color: var(--m-ink);
  font: 700 0.3em/1 var(--font-display);
  letter-spacing: 0.04em;
  filter: drop-shadow(0 0.012em 0 var(--m-cut));
}

.earned-rank {
  margin: 30px 0 0;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.earned-title {
  margin: 10px 0 0;
  font: 650 clamp(28px, 4.6vw, 42px) / 1.1 var(--font-display);
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.earned-caption {
  max-width: 44ch;
  margin: 12px 0 0;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.5;
  text-wrap: balance;
}

.earned-rule {
  margin: 14px 0 0;
  color: var(--ink-3);
  font-size: 13px;
}

.earned-more {
  margin: 8px 0 0;
  color: var(--ink-3);
  font-size: 13px;
}

.earned-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
}

.earned-scene > :is(.earned-rank, .earned-title, .earned-caption, .earned-rule, .earned-more, .earned-actions) {
  position: relative;
  animation: earned-rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.earned-scene > .earned-rank {
  animation-delay: 0.95s;
}

.earned-scene > .earned-title {
  animation-delay: 1.05s;
}

.earned-scene > .earned-caption {
  animation-delay: 1.15s;
}

.earned-scene > .earned-rule,
.earned-scene > .earned-more {
  animation-delay: 1.25s;
}

.earned-scene > .earned-actions {
  animation-delay: 1.4s;
}

/* platinum and titanium: a few points of light around the medal */
.earned-spark {
  position: absolute;
  width: 14px;
  height: 14px;
  background: color-mix(in srgb, var(--m-hi) 45%, var(--ink));
  clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
  opacity: 0;
  pointer-events: none;
  animation: earned-spark 2.6s ease-in-out infinite;
}

@keyframes earned-veil {
  from {
    opacity: 0;
  }
}

@keyframes earned-coin {
  0% {
    opacity: 0;
    transform: translateY(60px) scale(0.5) rotateY(-900deg);
    --medal-turn: -200deg;
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotateY(0deg);
    --medal-turn: 0deg;
  }
}

@keyframes earned-rays-in {
  from {
    opacity: 0;
    scale: 0.55;
  }
}

@keyframes earned-rays-turn {
  to {
    rotate: 1turn;
  }
}

@keyframes earned-ring {
  0% {
    opacity: 0.9;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(2.3);
  }
}

@keyframes earned-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

@keyframes earned-spark {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(0deg);
  }

  50% {
    opacity: 0.95;
    transform: scale(1) rotate(45deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .earned-stage,
  .earned-card,
  .earned-coin,
  .earned-rays,
  .earned-scene > * {
    animation: none !important;
  }

  .earned-ring,
  .earned-spark {
    display: none;
  }
}

@media (max-width: 560px) {
  .achievement.is-branch {
    gap: 3px 13px;
    padding: 16px;
  }

  .achievement.is-branch > .medal {
    --medal: 56px !important;
  }

  .earned-card {
    inset: auto 12px 76px 12px;
    width: auto;
    max-width: none;
  }

  .medal-showcase {
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .medal-shelf {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .medal-shelf-item {
    width: auto;
  }
}

/* ---------- Account settings: how medals are announced ---------- */

.celebrate-choice {
  display: grid;
  gap: 6px;
}

.celebrate-choice label {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.celebrate-choice .hint {
  margin: 0;
}

/* small marks keep a finger-sized target around them */
.standing-pill::before, .branch-eye::before { content: ''; position: absolute; inset: -11px -6px; }
