/*
 * Ranked: the emblems (ui/rank-emblem.js), the Ranks screen, a ranked room in
 * place of the lobby, and the ranked line on the results. Layout follows
 * docs/mockups/ranks-screen.html; the emblems' motion follows the locked spec,
 * docs/mockups/rank-emblems-bit-depth.html. The Ladder tab is ranks-ladder.css,
 * the other parts ranks-parts.css, and phone rules ranks-phone.css (on its side,
 * ranks-landscape.css).
 */

/* Emblems ------------------------------------------------------------------ */

.emblem-wrap {
  display: block;
  flex: none;
}

.emblem-wrap text {
  font-family: var(--font-mono);
}

.emblem-wrap svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* Overclocked's outer line hums, slow and soft. */
@keyframes rank-hum {
  0%,
  100% {
    opacity: 0.78;
  }
  50% {
    opacity: 1;
  }
}

/* Its inner border is still almost always, then twitches for a few frames.
   Two loops of different length, so it never feels like a beat. */
@keyframes rank-jitter {
  0%,
  88%,
  100% {
    transform: translate(0, 0);
  }
  88.6% {
    transform: translate(0.7px, 0);
  }
  89.2% {
    transform: translate(-0.5px, 0.3px);
  }
  89.8% {
    transform: translate(0.3px, 0);
  }
  90.4% {
    transform: translate(0, 0);
  }
}

@keyframes rank-ghost {
  0%,
  93%,
  100% {
    opacity: 0;
    transform: translate(0, 0);
  }
  93.5% {
    opacity: 0.35;
    transform: translate(1.2px, 0);
  }
  94.2% {
    opacity: 0.2;
    transform: translate(-0.8px, 0);
  }
  94.8% {
    opacity: 0;
    transform: translate(0, 0);
  }
}

.emblem-wrap .pulse {
  animation: rank-hum 6s ease-in-out infinite;
}

.emblem-wrap .glitch {
  animation: rank-jitter 5.3s linear infinite;
}

.emblem-wrap .glitch-ghost {
  opacity: 0;
  animation: rank-ghost 7.1s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion='full']) .emblem-wrap :is(.pulse, .glitch, .glitch-ghost) {
    animation: none;
  }
}

:root[data-motion='reduced'] .emblem-wrap :is(.pulse, .glitch, .glitch-ghost) {
  animation: none;
}

.is-up {
  color: var(--ok);
}

.is-down {
  color: var(--danger);
}

/* The Ranks screen: one fixed box. Nothing scrolls, nothing moves between tabs. */

.dialog.ranks {
  width: min(94vw, 62rem);
  max-width: none;
  height: min(88dvh, 39rem);
  max-height: none;
  padding: var(--space-4) var(--space-5);
  overflow: hidden;
  border-color: var(--line-strong);
}

.dialog.ranks[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--space-4);
}

.ranks__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-5);
}

.ranks__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: 0.3em;
}

.ranks__tabs {
  display: flex;
  gap: var(--space-1);
}

.ranks__tab {
  min-height: var(--target);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    color var(--dur-quick) var(--ease-standard),
    border-color var(--dur-quick) var(--ease-standard),
    background var(--dur-quick) var(--ease-standard);
}

.ranks__tab:hover {
  color: var(--text);
  border-color: var(--line);
}

.ranks__tab[aria-selected='true'] {
  color: var(--text);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.ranks__tab:focus-visible,
.ranks [role='tabpanel']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ranks__body {
  min-height: 0;
  display: grid;
}

.ranks__body > [hidden] {
  display: none;
}
