/*
 * Header rank: one badge for the player's current siege rank, which upgrades as they improve.
 * Tapping it shows the whole ladder; ranking up gets a short celebration.
 */

.rank-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 2px 10px 3px;
  border: 1px solid rgba(255, 210, 90, .4);
  border-radius: 14px;
  background: rgba(14, 10, 22, .72);
  color: #fff;
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}

.rank-badge:hover {
  border-color: rgba(255, 210, 90, .85);
  transform: translateY(-1px);
}

.rank-badge-art {
  position: relative;
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  flex: none;
}

.rank-badge-art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(255, 200, 60, .55));
}

.rank-badge.is-locked .rank-badge-art img {
  filter: grayscale(1) brightness(.5);
}

.rank-badge-lock {
  position: absolute;
  right: -2px;
  bottom: 0;
  font-size: .9rem;
}

.rank-badge-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.rank-badge-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: .05em;
  line-height: 1.05;
  color: #ffe08a;
  text-shadow: 0 2px 0 #3a2400;
}

.rank-badge.is-locked .rank-badge-name {
  color: #c9c3d8;
}

.rank-badge.is-rank-up .rank-badge-art {
  animation: rank-badge-flip .9s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes rank-badge-flip {
  0% { transform: rotateY(0) scale(1); }
  45% { transform: rotateY(180deg) scale(1.35); filter: brightness(2); }
  100% { transform: rotateY(360deg) scale(1); }
}

/* Rank up celebration. */
.rank-up {
  position: fixed;
  left: 50%;
  top: 40%;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: rank-up-in .6s cubic-bezier(.34, 1.56, .64, 1) both;
}

.rank-up .core-reward-rays {
  top: 75px;
  background: repeating-conic-gradient(rgba(255, 210, 90, .4) 0 8deg, transparent 8deg 22deg);
}

.rank-up-badge {
  position: relative;
  width: 150px;
  height: 150px;
  object-fit: contain;
  filter: drop-shadow(0 0 24px rgba(255, 200, 60, .9));
}

.rank-up-title {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  color: #fff3c4;
  text-shadow: 0 0 18px rgba(255, 190, 40, .9), 0 4px 0 #4a2c00;
}

.rank-up-name {
  position: relative;
  font-weight: 900;
  letter-spacing: .14em;
  color: #ffd84a;
  text-shadow: 0 2px 6px #000;
}

.rank-up.is-leaving {
  opacity: 0;
  transform: translate(-50%, -60%) scale(.9);
  transition: opacity .5s ease, transform .5s ease;
}

@keyframes rank-up-in {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* The full ladder, shown when the badge is tapped. */
.rank-ladder {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(3, 4, 10, .78);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.rank-ladder-panel {
  width: min(560px, 92vw);
  padding: 20px 22px 18px;
  border: 1px solid rgba(255, 210, 90, .5);
  border-radius: 18px;
  background: linear-gradient(180deg, #1c1530, #0d0a18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  text-align: center;
}

.rank-ladder-title {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: #ffe08a;
}

.rank-ladder-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank-ladder-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  padding: 6px 12px 6px 6px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
  text-align: left;
}

.rank-ladder-item img {
  grid-row: 1 / 3;
  width: 56px;
  height: 56px;
  object-fit: contain;
  filter: grayscale(1) brightness(.4);
}

.rank-ladder-item strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: #a9a2bd;
}

.rank-ladder-item span {
  font-size: .75rem;
  color: rgba(220, 214, 236, .7);
}

.rank-ladder-item em {
  grid-column: 3;
  grid-row: 1 / 3;
  font-style: normal;
  font-size: .65rem;
  font-weight: 900;
  letter-spacing: .1em;
  color: rgba(220, 214, 236, .45);
}

.rank-ladder-item.is-earned img { filter: drop-shadow(0 0 8px rgba(255, 200, 60, .6)); }
.rank-ladder-item.is-earned strong { color: #ffe08a; }
.rank-ladder-item.is-earned em { color: #7dffa8; }

.rank-ladder-item.is-next {
  border-color: rgba(255, 210, 90, .55);
  background: rgba(255, 200, 60, .08);
}

.rank-ladder-item.is-next img { filter: grayscale(.4) brightness(.8); }
.rank-ladder-item.is-next em { color: #ffd84a; }

.rank-ladder-close {
  margin-top: 14px;
  padding: 9px 26px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe27a, #f3a512);
  color: #2a1700;
  font-family: var(--font-display);
  font-size: 1.05rem;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .rank-badge.is-rank-up .rank-badge-art,
  .rank-up {
    animation: none;
  }
}

/* After a siege: the career rank, with progress to the next one. */
.results-badges .rank-result {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(100%, 440px);
  margin: 0 auto;
  padding: 12px 16px;
  border: 1px solid rgba(255, 210, 90, .35);
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(40, 30, 10, .65), rgba(16, 12, 26, .9));
  text-align: left;
}

.results-badges .rank-result.is-rank-up {
  border-color: #ffd65a;
  box-shadow: 0 0 24px rgba(255, 200, 60, .45);
}

.rank-result-badge {
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .5));
}

.rank-result.is-rank-up .rank-result-badge {
  animation: rank-result-pop .7s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes rank-result-pop {
  0% { opacity: 0; transform: scale(.3) rotate(-20deg); }
  100% { opacity: 1; transform: none; }
}

.rank-result-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.rank-result-label,
.rank-result-tag {
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .14em;
  color: var(--muted);
}

.rank-result-tag {
  align-self: flex-start;
  padding: 2px 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd65a, #e0960f);
  color: #2a1700;
}

.rank-result-name {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: .05em;
  line-height: 1;
  color: var(--gold);
}

.rank-result-next {
  font-size: .82rem;
  color: rgba(245, 240, 255, .85);
}

.rank-result-track {
  display: block;
  height: 8px;
  margin-top: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
}

.rank-result-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e0960f, #ffd65a);
  box-shadow: 0 0 8px rgba(255, 200, 60, .6);
}

.rank-result-count {
  font-size: .72rem;
  font-weight: 800;
  color: #ffe4a2;
  font-variant-numeric: tabular-nums;
}

/* Vault upgrade celebration: the new vault art, larger than a badge. */
.vault-up .core-reward-rays {
  top: 110px;
}

.vault-up::before {
  content: '';
  position: absolute;
  inset: -100vmax;
  z-index: -1;
  background: radial-gradient(circle at 50% 50%, rgba(20, 14, 4, .55), rgba(3, 4, 10, .86) 35%);
}

.vault-up-art {
  position: relative;
  width: auto;
  height: min(240px, 34vh);
  object-fit: contain;
  filter: drop-shadow(0 0 28px rgba(255, 200, 60, .85));
}

/* Map piece found: the map (or the ship, for the final sector) instead of a vault. */
.map-up-art {
  position: relative;
  font-size: min(150px, 22vh);
  line-height: 1;
  filter: drop-shadow(0 0 26px rgba(170, 110, 255, .9));
  animation: map-up-spin .9s cubic-bezier(.34, 1.56, .64, 1) both;
}

@keyframes map-up-spin {
  from { transform: rotate(-25deg) scale(.3); opacity: 0; }
  to { transform: none; opacity: 1; }
}
