/* Матч&мяч v89 — коллекция наград: медали, витрина в шапке профиля, экран получения.
 *
 * Значки — готовые картинки со своей рамкой. CSS отвечает за состояние вокруг
 * них: серый вид закрытых, кольцо прогресса, плашку уровня и свечение.
 */

/* ---------- Значок ---------- */

.ach-medal {
    --ach-size: 72px;
    position: relative;
    display: grid;
    place-items: center;
    width: var(--ach-size);
    height: var(--ach-size);
    flex: 0 0 auto;
}
.ach-medal img {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform .25s ease, filter .25s ease;
}
/* С кольцом значок чуть меньше: кольцо идёт снаружи и не должно его резать. */
.ach-medal.has-ring img { width: 78%; height: 78%; }

.ach-medal.is-locked img { filter: grayscale(1) brightness(.46) contrast(1.08); }

.ach-medal.is-glow::before {
    content: "";
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent, #C6F24E) 38%, transparent), transparent 68%);
    filter: blur(14px);
}

.ach-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.ach-ring circle { fill: none; stroke-width: 3; }
.ach-ring-track { stroke: color-mix(in srgb, var(--text, #F2F4F0) 12%, transparent); }
.ach-ring-fill { stroke: var(--accent, #C6F24E); stroke-linecap: round; }

/* Плашка уровня: одна картинка медали служит всем её уровням, поэтому уровень
   и порог показываем поверх — металлом и числом. */
.ach-tier {
    position: absolute;
    left: 50%;
    bottom: -3px;
    transform: translateX(-50%);
    min-width: 22px;
    padding: 1px 7px;
    border-radius: 999px;
    font: 800 max(9px, calc(var(--ach-size) * .13)) / 1.35 var(--font-mono, ui-monospace, monospace);
    font-variant-numeric: tabular-nums;
    text-align: center;
    white-space: nowrap;
    color: #15180F;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.ach-tier-bronze { background: linear-gradient(180deg, #F0B98A, #B87342); }
.ach-tier-silver { background: linear-gradient(180deg, #F4F7F9, #A9B3BA); }
.ach-tier-gold   { background: linear-gradient(180deg, #FFE59A, #D6A437); }
.ach-tier-legend { background: linear-gradient(180deg, #E9FFB0, #B7E23C); }
.ach-medal.is-locked .ach-tier { filter: grayscale(.85) brightness(.75); }

/* ---------- Раздел «Награды» ---------- */

.ach-head { align-items: flex-end; }
.ach-head-side { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.ach-total { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.ach-total b { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.ach-total span { color: var(--text-faint, #6B7266); font-size: 13px; }

.ach-collection { padding: 20px; display: grid; gap: 18px; }

.ach-progress { display: grid; gap: 8px; }
.ach-progress-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim, #98A093); }
.ach-progress-row b { color: var(--text, #F2F4F0); }
.ach-progress-track { height: 8px; border-radius: 999px; background: var(--bg-secondary, rgba(255, 255, 255, .06)); overflow: hidden; }
.ach-progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--accent, #C6F24E); }

.ach-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.ach-tabs button {
    font: 700 12.5px var(--font-body, inherit);
    color: var(--text-dim, #98A093);
    background: var(--bg-secondary, rgba(255, 255, 255, .04));
    border: 1px solid var(--border, rgba(255, 255, 255, .08));
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
}
.ach-tabs button[aria-pressed="true"] { background: var(--accent, #C6F24E); border-color: var(--accent, #C6F24E); color: #15180F; }
.ach-tabs button:disabled { opacity: .45; cursor: default; }

.ach-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(144px, 1fr));
    gap: 20px 10px;
}
.ach-item {
    appearance: none;
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 7px;
    padding: 12px 6px 10px;
    border: 1px solid transparent;
    border-radius: 18px;
    background: none;
    color: inherit;
    text-align: center;
    cursor: pointer;
}
.ach-item[hidden] { display: none; }
.ach-item:hover .ach-medal img { transform: translateY(-2px) scale(1.03); }
.ach-item.is-active { border-color: var(--border, rgba(255, 255, 255, .1)); background: var(--bg-secondary, rgba(255, 255, 255, .03)); }
.ach-item:focus-visible { outline: 2px solid var(--accent, #C6F24E); outline-offset: 2px; }
.ach-item-title { font-size: 13.5px; font-weight: 700; line-height: 1.25; margin-top: 4px; }
.ach-item-sub { font: 600 11.5px var(--font-mono, ui-monospace, monospace); color: var(--text-faint, #6B7266); }
.ach-item.is-near .ach-item-sub { color: var(--accent, #C6F24E); }
.ach-item:not(.is-earned) .ach-item-title { color: var(--text-dim, #98A093); }

.ach-detail {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--bg-secondary, rgba(255, 255, 255, .03));
    border: 1px solid var(--border, rgba(255, 255, 255, .08));
}
.ach-detail-copy { display: grid; gap: 4px; min-width: 0; }
.ach-detail-copy h3 { margin: 0; font-size: 16px; font-weight: 800; }
.ach-detail-copy h3 span { color: var(--text-dim, #98A093); font-weight: 600; }
.ach-detail-copy p { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--text-dim, #98A093); }
.ach-detail-copy small { font: 600 11px var(--font-mono, ui-monospace, monospace); color: var(--text-faint, #6B7266); }
.ach-steps { display: flex; gap: 4px; max-width: 240px; margin-top: 4px; }
.ach-steps i { flex: 1; height: 5px; border-radius: 9px; background: color-mix(in srgb, var(--text, #F2F4F0) 12%, transparent); }
.ach-steps i.is-on { background: var(--accent, #C6F24E); }

/* ---------- Витрина в шапке профиля ---------- */

/* Полка: тёмная ниша с лаймовым светом сверху — медали стоят «под софитом».
   Выделяем именно нишей, а не рамкой: вокруг и так много карточек с рамками. */
.ach-showcase-shelf {
    position: relative;
    margin: 14px 0 12px;
    padding: 12px 10px 14px;
    border-radius: 20px;
    background:
        radial-gradient(90% 70% at 50% 0%, color-mix(in srgb, var(--accent, #C6F24E) 16%, transparent), transparent 62%),
        linear-gradient(180deg, rgba(0, 0, 0, .18), rgba(0, 0, 0, .34));
    border: 1px solid color-mix(in srgb, var(--accent, #C6F24E) 20%, transparent);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--accent, #C6F24E) 22%, transparent);
    overflow: hidden;
}
/* Софит: тонкая яркая линия по верхнему краю. */
.ach-showcase-shelf::before {
    content: "";
    position: absolute;
    left: 18%;
    right: 18%;
    top: 0;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--accent, #C6F24E), transparent);
    opacity: .8;
}
.ach-showcase-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 6px 4px;
    font: 700 10.5px var(--font-mono, ui-monospace, monospace);
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text-faint, #6B7266);
}
.ach-showcase-edit {
    appearance: none;
    border: 1px solid var(--border, rgba(255, 255, 255, .12));
    background: rgba(0, 0, 0, .2);
    color: var(--text, #F2F4F0);
    font: 700 11px var(--font-body, inherit);
    letter-spacing: 0;
    text-transform: none;
    padding: 5px 11px;
    border-radius: 999px;
    cursor: pointer;
}
.ach-showcase-edit:hover { border-color: var(--accent, #C6F24E); color: var(--accent, #C6F24E); }

.ach-showcase {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}
.ach-showcase-item {
    appearance: none;
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 6px 2px 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    min-width: 0;
}
/* Пьедестал: мягкое световое пятно под медалью. */
.ach-showcase-stage { position: relative; display: grid; place-items: center; }
.ach-showcase-stage::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -6px;
    width: 76%;
    height: 14px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(ellipse, color-mix(in srgb, var(--accent, #C6F24E) 34%, transparent), transparent 70%);
    filter: blur(3px);
    pointer-events: none;
}
.ach-showcase-item.is-empty .ach-showcase-stage::after { display: none; }
.ach-showcase-item:hover .ach-medal img { transform: translateY(-3px) scale(1.05); }
.ach-showcase-name {
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
    text-wrap: balance;
}
.ach-showcase-item.is-empty .ach-showcase-name { color: var(--text-faint, #6B7266); font-weight: 600; }
.ach-showcase-slot {
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    border: 1.5px dashed var(--border, rgba(255, 255, 255, .18));
    color: var(--text-faint, #6B7266);
    font-size: 26px;
}

/* ---------- Выбор витрины ---------- */

.modal.ach-picker-modal { max-width: 560px; }
.ach-picker h3 { margin: 0 0 6px; }
.ach-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin: 16px 0 6px;
    max-height: min(56vh, 520px);
    overflow-y: auto;
    padding: 2px;
}
.ach-pick {
    appearance: none;
    position: relative;
    display: grid;
    justify-items: center;
    gap: 5px;
    padding: 14px 8px 12px;
    border-radius: 18px;
    border: 1.5px solid var(--border, rgba(255, 255, 255, .1));
    background: var(--bg-secondary, rgba(255, 255, 255, .03));
    color: inherit;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, opacity .15s ease;
}
.ach-pick[aria-pressed="true"] {
    border-color: var(--accent, #C6F24E);
    background: color-mix(in srgb, var(--accent, #C6F24E) 9%, transparent);
}
.ach-pick.is-disabled { opacity: .45; }
.ach-pick:focus-visible { outline: 2px solid var(--accent, #C6F24E); outline-offset: 2px; }
.ach-pick-title { font-size: 13px; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.ach-pick-sub { font-size: 11px; color: var(--text-faint, #6B7266); }
.ach-pick-order {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font: 800 12px var(--font-mono, ui-monospace, monospace);
    color: #15180F;
    background: var(--accent, #C6F24E);
}
.ach-pick-order:empty { display: none; }

/* ---------- Экран получения ---------- */

.modal.ach-unlock-modal { max-width: 440px; }
.ach-unlock {
    display: grid;
    justify-items: center;
    gap: 12px;
    text-align: center;
    padding: 8px 4px 4px;
}
.ach-unlock-kicker {
    font: 700 11px var(--font-mono, ui-monospace, monospace);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--accent, #C6F24E);
}
.ach-unlock h3 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.03em; text-wrap: balance; }
.ach-unlock p { margin: 0; max-width: 34ch; font-size: 14px; line-height: 1.5; color: var(--text-dim, #98A093); }
.ach-unlock-medal { position: relative; display: grid; place-items: center; padding: 6px 0; }
.ach-unlock-medal::before {
    content: "";
    position: absolute;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent 0 8deg, color-mix(in srgb, var(--accent, #C6F24E) 16%, transparent) 8deg 12deg, transparent 12deg 30deg);
    -webkit-mask: radial-gradient(circle, transparent 30%, #000 32%, transparent 70%);
    mask: radial-gradient(circle, transparent 30%, #000 32%, transparent 70%);
    animation: ach-spin 26s linear infinite;
}
.ach-unlock-medal .ach-medal { animation: ach-pop .6s cubic-bezier(.2, 1.4, .4, 1) both; }
.ach-unlock-xp {
    font: 700 13px var(--font-mono, ui-monospace, monospace);
    color: var(--accent, #C6F24E);
    padding: 6px 12px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent, #C6F24E) 14%, transparent);
}
.ach-unlock-actions { display: grid; gap: 8px; width: 100%; margin-top: 8px; }
.ach-unlock-actions .btn { width: 100%; justify-content: center; }

.ach-intro-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 8px;
    width: 100%;
    margin-top: 6px;
}
.ach-intro-grid figure { margin: 0; display: grid; justify-items: center; gap: 6px; animation: ach-pop .5s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--i, 0) * 90ms); }
.ach-intro-grid figcaption { font-size: 12px; font-weight: 700; line-height: 1.2; }
.ach-intro-more { font-size: 12px; color: var(--text-faint, #6B7266); }

@keyframes ach-spin { to { transform: rotate(1turn); } }
@keyframes ach-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .ach-unlock-medal::before,
    .ach-unlock-medal .ach-medal,
    .ach-intro-grid figure { animation: none; }
}

@media (max-width: 640px) {
    .ach-collection { padding: 16px 12px; }
    .ach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 6px; }
    .ach-grid .ach-medal { --ach-size: 112px !important; }
    .ach-showcase .ach-medal { --ach-size: 84px !important; }
    .ach-showcase-slot { width: 84px; height: 84px; }
    .ach-picker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ach-head-side { justify-content: flex-start; }
    .ach-detail { grid-template-columns: 1fr; justify-items: center; text-align: center; }
    .ach-steps { margin-inline: auto; width: 100%; }
}
