/*
 * Achievements page (EXPLOSION wave — redesign for 1000+ badges).
 *
 * A calm, scannable roster: a summary hero with a progress meter, a sticky filter
 * bar (search + state segments), collapsible category sections, compact badge cards
 * with clear locked / unlocked / almost states, and a leaderboard panel. Theme-aware
 * via the shared tokens; no external assets.
 */

.gtx-ach {
    --ach-gap: 14px;
}

/* --- summary hero -------------------------------------------------------- */
.gtx-ach-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    padding: 22px 24px;
    border: 1px solid var(--gtx-border, #2a2f3a);
    border-radius: 16px;
    background:
        radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--gtx-accent, #e07b39) 14%, transparent), transparent 60%),
        var(--gtx-surface, #16181d);
    margin-bottom: 22px;
}
.gtx-ach-hero__meter {
    --pct: 0;
    position: relative;
    flex: 0 0 auto;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: conic-gradient(var(--gtx-accent, #e07b39) calc(var(--pct) * 1%), var(--gtx-surface-2, #262a33) 0);
    display: grid;
    place-items: center;
}
.gtx-ach-hero__meter::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: var(--gtx-surface, #16181d);
}
.gtx-ach-hero__pct {
    position: relative;
    z-index: 1;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--gtx-text, #e7e9ee);
}
.gtx-ach-hero__body { flex: 1 1 240px; min-width: 0; }
.gtx-ach-hero__title { margin: 0 0 4px; font-size: 1.5rem; }
.gtx-ach-hero__sub { margin: 0 0 8px; color: var(--gtx-text-dim, #9aa1ad); max-width: 60ch; }
.gtx-ach-hero__counts { display: flex; flex-wrap: wrap; gap: 8px; }
.gtx-ach-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600;
    background: var(--gtx-surface-2, #262a33); color: var(--gtx-text, #e7e9ee);
    border: 1px solid var(--gtx-border, #2a2f3a);
}
.gtx-ach-chip--ok { color: #7bd88f; }
.gtx-ach-chip--warn { color: #f3c969; }

/* --- filter bar ---------------------------------------------------------- */
.gtx-ach-filter {
    position: sticky; top: 0; z-index: 20;
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    padding: 10px 0; margin-bottom: 14px;
    background: var(--gtx-bg, #0e0f13);
}
.gtx-ach-filter__search {
    flex: 1 1 220px; min-width: 160px;
}
.gtx-ach-segments { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.gtx-ach-seg {
    padding: 6px 12px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--gtx-border, #2a2f3a);
    background: var(--gtx-surface, #16181d); color: var(--gtx-text-dim, #9aa1ad);
    font-size: .85rem; font-weight: 600;
}
.gtx-ach-seg[aria-pressed="true"] {
    background: var(--gtx-accent, #e07b39); color: #10120f; border-color: transparent;
}

/* --- category sections --------------------------------------------------- */
.gtx-ach-cat { margin-bottom: 16px; border: 1px solid var(--gtx-border, #2a2f3a); border-radius: 12px; overflow: hidden; }
.gtx-ach-cat[hidden] { display: none; }
.gtx-ach-cat__head {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    padding: 12px 16px; background: var(--gtx-surface, #16181d);
    font-weight: 700; list-style: none;
}
.gtx-ach-cat__head::-webkit-details-marker { display: none; }
.gtx-ach-cat__head::before {
    content: "▸"; color: var(--gtx-text-dim, #9aa1ad); transition: transform .15s ease;
}
.gtx-ach-cat[open] .gtx-ach-cat__head::before { transform: rotate(90deg); }
.gtx-ach-cat__count { margin-left: auto; font-weight: 600; font-size: .8rem; color: var(--gtx-text-dim, #9aa1ad); }
.gtx-ach-grid {
    display: grid; gap: var(--ach-gap); padding: 14px 16px;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

/* --- badge card ---------------------------------------------------------- */
.gtx-ach-card {
    display: flex; gap: 12px; padding: 12px 14px;
    border: 1px solid var(--gtx-border, #2a2f3a); border-radius: 12px;
    background: var(--gtx-surface-2, #1b1e25);
}
.gtx-ach-card[hidden] { display: none; }
.gtx-ach-card--locked { opacity: .62; }
.gtx-ach-card--unlocked { border-color: color-mix(in srgb, var(--gtx-accent, #e07b39) 55%, var(--gtx-border, #2a2f3a)); }
.gtx-ach-card--almost { border-color: color-mix(in srgb, #f3c969 45%, var(--gtx-border, #2a2f3a)); }
.gtx-ach-card__icon {
    flex: 0 0 auto; width: 42px; height: 42px; border-radius: 10px;
    display: grid; place-items: center; font-size: 1.5rem; line-height: 1;
    background: var(--gtx-surface, #16181d); border: 1px solid var(--gtx-border, #2a2f3a);
}
.gtx-ach-card--unlocked .gtx-ach-card__icon {
    background: color-mix(in srgb, var(--gtx-accent, #e07b39) 20%, var(--gtx-surface, #16181d));
}
.gtx-ach-card__body { min-width: 0; flex: 1 1 auto; }
.gtx-ach-card__name { font-weight: 700; font-size: .95rem; margin: 0 0 2px; }
.gtx-ach-card__desc { margin: 0 0 6px; font-size: .8rem; color: var(--gtx-text-dim, #9aa1ad); }
.gtx-ach-card__meta { font-size: .72rem; color: var(--gtx-text-dim, #9aa1ad); }
.gtx-ach-bar { height: 5px; border-radius: 3px; background: var(--gtx-surface, #16181d); overflow: hidden; margin: 4px 0 2px; }
.gtx-ach-bar__fill { height: 100%; background: var(--gtx-accent, #e07b39); }
.gtx-ach-card--almost .gtx-ach-bar__fill { background: #f3c969; }

.gtx-ach-empty { padding: 20px; text-align: center; color: var(--gtx-text-dim, #9aa1ad); }

/* --- leaderboard --------------------------------------------------------- */
.gtx-ach-board { border: 1px solid var(--gtx-border, #2a2f3a); border-radius: 12px; overflow: hidden; margin: 8px 0 24px; }
.gtx-ach-board__head { padding: 12px 16px; font-weight: 700; background: var(--gtx-surface, #16181d); }
.gtx-ach-board__row {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    border-top: 1px solid var(--gtx-border, #2a2f3a);
}
.gtx-ach-board__rank {
    flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; font-size: .8rem;
    background: var(--gtx-surface-2, #1b1e25); color: var(--gtx-text-dim, #9aa1ad);
}
.gtx-ach-board__row--1 .gtx-ach-board__rank { background: #f3c969; color: #10120f; }
.gtx-ach-board__row--2 .gtx-ach-board__rank { background: #c7ccd4; color: #10120f; }
.gtx-ach-board__row--3 .gtx-ach-board__rank { background: #cd8b5b; color: #10120f; }
.gtx-ach-board__name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gtx-ach-board__count { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--gtx-text-dim, #9aa1ad); }
.gtx-ach-board__count strong { color: var(--gtx-accent, #e07b39); }

@media (prefers-color-scheme: light) {
    .gtx-ach-hero, .gtx-ach-cat__head, .gtx-ach-board__head, .gtx-ach-card__icon { background: #f4f5f7; }
    .gtx-ach-card { background: #fbfbfc; }
}
