/* ==========================================================================
   Достижения (module_page_achievements), префикс ach
   ========================================================================== */

.ach {
  --ach-bronze-1: #f0a66a;
  --ach-bronze-2: #8c4a22;
  --ach-silver-1: #f1f5f9;
  --ach-silver-2: #7f8b99;
  --ach-gold-1: #ffe08a;
  --ach-gold-2: #c27c0e;
  --ach-locked-1: rgba(255, 255, 255, 0.10);
  --ach-locked-2: rgba(255, 255, 255, 0.03);
  --ach-tone: 255, 255, 255;
  color: var(--text-default);
}

.ach__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.ach__main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.ach__side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 16px;
}

@media (max-width: 1199px) {
  .ach__layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .ach__side {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

/* ---------- Шапка ---------- */

.ach-hero {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 24px;
  padding: 18px 20px;
  flex-wrap: wrap;
}

.ach-hero__player {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 240px;
  color: inherit;
  text-decoration: none;
}

.ach-hero__avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--br-12, 12px);
  object-fit: cover;
  flex-shrink: 0;
}

.ach-hero__who {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ach-hero__name {
  font-size: var(--font-size-xl, 20px);
  font-weight: var(--font-weight-7, 700);
  color: var(--text-custom);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ach-hero__sub,
.ach-hero__label {
  font-size: var(--font-size-s, 12px);
  color: var(--text-secondary);
}

.ach-hero__stats {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 2 1 360px;
}

.ach-hero__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ach-hero__value {
  font-size: var(--font-size-2xl, 24px);
  font-weight: var(--font-weight-7, 700);
  color: var(--text-custom);
  line-height: 1.1;
}

.ach-hero__value small {
  font-size: var(--font-size-m, 14px);
  color: var(--text-secondary);
  font-weight: var(--font-weight-5, 500);
}

.ach-hero__progress {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 140px;
}

.ach-hero__refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.ach-hero__refresh svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ach-hero__refresh.is-loading svg {
  animation: ach-spin 0.8s linear infinite;
}

@keyframes ach-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Прогресс-бар ---------- */

.ach-bar {
  position: relative;
  height: 6px;
  border-radius: 6px;
  background: var(--transparent-5-w, rgba(255, 255, 255, 0.06));
  overflow: hidden;
}

.ach-bar > span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: var(--span);
  transition: width 0.6s ease;
}

/* ---------- Фильтр ---------- */

.ach-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ach-filter button {
  padding: 0 16px;
  height: 36px;
  border-radius: var(--br-12, 12px);
  background: var(--card);
  color: var(--text-secondary);
}

.ach-filter button:hover {
  color: var(--text-custom);
}

.ach-filter button.is-active {
  background: var(--span);
  color: #fff;
}

/* ---------- Раздел ---------- */

.ach-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ach-section[hidden] {
  display: none;
}

.ach-section__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ach-section__title {
  margin: 0;
  font-size: var(--font-size-xl, 20px);
  font-weight: var(--font-weight-7, 700);
  color: var(--text-custom);
}

.ach-section__count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--br-8, 8px);
  background: var(--card);
  color: var(--text-secondary);
  font-size: var(--font-size-m, 14px);
  font-weight: var(--font-weight-6, 600);
}

.ach-section__count svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

@media (max-width: 575px) {
  .ach-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Карточка ---------- */

.ach-card {
  position: relative;
  display: flex;
  gap: 16px;
  padding: 16px;
  border-radius: var(--br-16, 16px);
  background: var(--card);
  border: 1px solid transparent;
  overflow: hidden;
  scroll-margin-top: 90px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.ach-card[hidden] {
  display: none;
}

.ach-card:hover {
  transform: translateY(-2px);
}

.ach-card--bronze {
  --ach-tone: 208, 128, 72;
}

.ach-card--silver {
  --ach-tone: 190, 204, 220;
}

.ach-card--gold {
  --ach-tone: 255, 196, 64;
}

.ach-card.is-unlocked {
  border-color: rgba(var(--ach-tone), 0.35);
  background:
    radial-gradient(120% 140% at 0% 50%, rgba(var(--ach-tone), 0.16), transparent 60%),
    var(--card);
}

.ach-card.is-unlocked .ach-bar > span {
  background: linear-gradient(90deg, rgba(var(--ach-tone), 0.7), rgb(var(--ach-tone)));
}

.ach-card:target {
  animation: ach-flash 1.6s ease 2;
}

@keyframes ach-flash {
  50% {
    box-shadow: 0 0 0 2px rgba(var(--ach-tone), 0.6);
  }
}

.ach-card__medal {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
}

.ach-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ach-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.ach-card__title {
  margin: 0;
  font-size: var(--font-size-default, 16px);
  font-weight: var(--font-weight-7, 700);
  color: var(--text-custom);
  line-height: 1.3;
}

.ach-card__desc {
  margin: 0;
  font-size: var(--font-size-m, 14px);
  color: var(--text-secondary);
  line-height: 1.4;
}

.ach-card__progress {
  margin-top: auto;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ach-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--font-size-s, 12px);
  color: var(--text-secondary);
}

.ach-card__count b {
  color: var(--text-custom);
  font-weight: var(--font-weight-6, 600);
}

.ach-card.is-complete .ach-card__count {
  color: rgb(var(--ach-tone));
  font-weight: var(--font-weight-6, 600);
}

/* ---------- Уровни ---------- */

.ach-tiers {
  display: inline-flex;
  gap: 4px;
}

.ach-tiers__pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--transparent-5-w, rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ach-tiers__pip--bronze.is-on {
  background: linear-gradient(135deg, var(--ach-bronze-1), var(--ach-bronze-2));
}

.ach-tiers__pip--silver.is-on {
  background: linear-gradient(135deg, var(--ach-silver-1), var(--ach-silver-2));
}

.ach-tiers__pip--gold.is-on {
  background: linear-gradient(135deg, var(--ach-gold-1), var(--ach-gold-2));
}

/* ---------- Держатели ---------- */

.ach-holders {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding-left: 6px;
}

.ach-holders__item,
.ach-holders__more {
  width: 24px;
  height: 24px;
  margin-left: -6px;
  border-radius: 50%;
  border: 2px solid var(--card);
  overflow: hidden;
  flex-shrink: 0;
}

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

.ach-holders__more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--button, #2a2a35);
  color: var(--text-default);
  font-size: 9px;
  font-weight: var(--font-weight-7, 700);
}

/* ---------- Медаль ---------- */

.ach-medal {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.ach-medal__ring {
  fill: rgba(0, 0, 0, 0.18);
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1.5;
}

.ach-medal__icon {
  fill: none;
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ach-medal--bronze .ach-medal__c1 { stop-color: var(--ach-bronze-1); }
.ach-medal--bronze .ach-medal__c2 { stop-color: var(--ach-bronze-2); }
.ach-medal--silver .ach-medal__c1 { stop-color: var(--ach-silver-1); }
.ach-medal--silver .ach-medal__c2 { stop-color: var(--ach-silver-2); }
.ach-medal--gold .ach-medal__c1 { stop-color: var(--ach-gold-1); }
.ach-medal--gold .ach-medal__c2 { stop-color: var(--ach-gold-2); }

.ach-medal--bronze .ach-medal__seal,
.ach-medal--silver .ach-medal__seal,
.ach-medal--gold .ach-medal__seal {
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}

.ach-medal--silver .ach-medal__icon {
  stroke: #36404c;
}

.ach-medal--silver .ach-medal__ring {
  stroke: rgba(54, 64, 76, 0.35);
  fill: rgba(255, 255, 255, 0.25);
}

.ach-medal--locked .ach-medal__c1 { stop-color: var(--ach-locked-1); }
.ach-medal--locked .ach-medal__c2 { stop-color: var(--ach-locked-2); }

.ach-medal--locked .ach-medal__seal {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.ach-medal--locked .ach-medal__ring {
  fill: rgba(0, 0, 0, 0.12);
  stroke: rgba(255, 255, 255, 0.08);
}

.ach-medal--locked .ach-medal__icon {
  stroke: var(--text-secondary);
  opacity: 0.7;
}

/* ---------- Боковая колонка ---------- */

.ach-side .card-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ach-side__empty,
.ach-empty {
  color: var(--text-secondary);
  font-size: var(--font-size-m, 14px);
  text-align: center;
  padding: 12px 0;
}

.ach-empty {
  background: var(--card);
  border-radius: var(--br-16, 16px);
  padding: 32px 16px;
}

.ach-leaders {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ach-leaders__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--br-12, 12px);
  color: var(--text-default);
  text-decoration: none;
  transition: background 0.2s ease;
}

.ach-leaders__row:hover,
.ach-leaders__row.is-current {
  background: var(--transparent-5-w, rgba(255, 255, 255, 0.05));
}

.ach-leaders__row img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.ach-leaders__place {
  width: 18px;
  text-align: center;
  font-weight: var(--font-weight-7, 700);
  color: var(--text-secondary);
}

.ach-leaders li:nth-child(1) .ach-leaders__place { color: var(--ach-gold-1); }
.ach-leaders li:nth-child(2) .ach-leaders__place { color: var(--ach-silver-1); }
.ach-leaders li:nth-child(3) .ach-leaders__place { color: var(--ach-bronze-1); }

.ach-leaders__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-m, 14px);
}

.ach-leaders__value {
  font-weight: var(--font-weight-7, 700);
  color: var(--text-custom);
}

.ach-legend__row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--font-size-m, 14px);
}

.ach-legend__row .ach-medal {
  width: 32px;
  height: 32px;
}

.ach-legend__hint {
  margin: 4px 0 0;
  font-size: var(--font-size-s, 12px);
  color: var(--text-secondary);
  line-height: 1.4;
}
