/* ============================================================
   USERS.CSS — публичные страницы «Пользователи» и «Топ»
   Тёмная космическая тема, стеклянные карточки, префиксы us- / tp-.
   Зависит от переменных main.css и компонентов ui.css.
   ============================================================ */

/* ---------- Общая шапка страниц ---------- */
.us-page,
.tp-page {
    animation: usPageIn 0.35s ease-out;
}

@keyframes usPageIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.us-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.us-head-info {
    min-width: 0;
}

.us-tabs {
    flex: 0 0 auto;
}

.us-tabs .ui-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* ---------- Поиск ---------- */
.us-search {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.us-search-field {
    position: relative;
    flex: 1 1 280px;
    min-width: 0;
    display: flex;
    align-items: center;
}

.us-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    opacity: 0.6;
    pointer-events: none;
}

.us-search-input {
    padding-left: 40px !important;
    padding-right: 42px !important;
}

/* убираем нативный крестик, у нас свой */
.us-search-input::-webkit-search-cancel-button,
.us-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.us-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ui-muted, #9a9ac0);
    font-size: 12px;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease;
}

.us-search-clear:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.us-search-clear[hidden] {
    display: none;
}

.us-search-submit,
.us-search-reset {
    flex: 0 0 auto;
}

.us-search.is-busy {
    opacity: 0.65;
    pointer-events: none;
}

/* ---------- Сетка карточек ---------- */
.us-results {
    min-height: 120px;
}

.us-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.us-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    padding: 18px;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.us-card:hover {
    transform: translateY(-3px);
    border-color: rgba(168, 85, 247, 0.45);
    box-shadow: var(--ui-shadow, 0 18px 50px rgba(0, 0, 0, 0.45)),
                var(--ui-glow, 0 0 32px rgba(108, 60, 225, 0.18));
}

.us-card-top {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
}

.us-avatar {
    flex: 0 0 auto;
    overflow: hidden;
}

.us-card .us-avatar {
    width: 64px;
    height: 64px;
}

.us-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.us-avatar-initials {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1;
}

.us-card .us-avatar-initials {
    font-size: 20px;
}

.tp-avatar .us-avatar-initials {
    font-size: 22px;
}

.tp-podium-item--1 .tp-avatar .us-avatar-initials {
    font-size: 28px;
}

.tp-rest-avatar .us-avatar-initials {
    font-size: 13px;
}

.us-card-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.us-name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--ui-text, #fff);
    overflow-wrap: anywhere;
    transition: color 0.15s ease;
}

.us-name:hover {
    color: #c9a7ff;
}

.us-position {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.us-position--muted {
    color: var(--ui-dim, #6d6d92);
    font-weight: 600;
}

.us-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 2px;
    min-width: 0;
    max-width: 100%;
}

.us-tag {
    font-size: 10px;
    padding: 3px 8px;
    max-width: 100%;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: anywhere;
}

.us-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    min-width: 0;
}

.us-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--ui-muted, #9a9ac0);
    min-width: 0;
}

.us-stat b {
    font-size: 16px;
    color: var(--ui-text, #fff);
}

.us-stat-icon {
    font-size: 13px;
    line-height: 1;
}

.us-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.us-level {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--ui-gold, #ffd700);
    white-space: nowrap;
}

.us-card-actions {
    display: flex;
}

.us-profile-btn {
    width: 100%;
}

/* ---------- Пагинация ---------- */
.us-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 26px;
}

.us-page-numbers {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.us-page-num,
.us-page-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--ui-border-soft, rgba(255, 255, 255, 0.07));
    background: rgba(255, 255, 255, 0.03);
    color: var(--ui-muted, #9a9ac0);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.us-page-num:hover,
.us-page-arrow:hover {
    color: #fff;
    border-color: rgba(168, 85, 247, 0.45);
    background: rgba(108, 60, 225, 0.18);
}

.us-page-num.is-active {
    color: #fff;
    border-color: rgba(168, 85, 247, 0.6);
    background: rgba(108, 60, 225, 0.32);
    box-shadow: 0 0 18px rgba(108, 60, 225, 0.25);
}

.us-page-arrow.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.us-page-gap {
    color: var(--ui-dim, #6d6d92);
    padding: 0 2px;
    font-weight: 700;
}

/* ---------- Пустые состояния ---------- */
.us-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 46px 20px;
}

.us-empty-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--ui-text, #fff);
}

.us-empty-text {
    max-width: 420px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--ui-muted, #9a9ac0);
}

.us-empty-action {
    margin-top: 10px;
}

/* ---------- Топ: подиум ---------- */
.tp-podium {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
    margin-bottom: 26px;
}

.tp-podium--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
}

.tp-podium--1 {
    grid-template-columns: minmax(0, 460px);
    justify-content: center;
}

.tp-podium-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    min-width: 0;
    padding: 24px 18px 20px;
    text-align: center;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.tp-podium-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--ui-shadow, 0 18px 50px rgba(0, 0, 0, 0.45)),
                var(--ui-glow, 0 0 32px rgba(108, 60, 225, 0.18));
}

.tp-podium-item--1 {
    grid-column: 2;
    grid-row: 1;
    order: 1;
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: var(--ui-shadow, 0 18px 50px rgba(0, 0, 0, 0.45)),
                0 0 42px rgba(255, 215, 0, 0.16);
    transform: translateY(-8px);
}

.tp-podium-item--2 {
    grid-column: 1;
    grid-row: 1;
    order: 2;
    border-color: rgba(203, 213, 225, 0.4);
}

.tp-podium-item--3 {
    grid-column: 3;
    grid-row: 1;
    order: 3;
    border-color: rgba(205, 127, 50, 0.4);
}

/* мало участников — простая раскладка без центра */
.tp-podium--2 .tp-podium-item,
.tp-podium--1 .tp-podium-item {
    transform: none;
}

.tp-podium--2 .tp-podium-item--1 {
    grid-column: 1;
    order: 1;
}

.tp-podium--2 .tp-podium-item--2 {
    grid-column: 2;
    order: 2;
}

.tp-podium--1 .tp-podium-item--1 {
    grid-column: 1;
    order: 1;
}

.tp-medal {
    font-size: 32px;
    line-height: 1;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.tp-podium-item--1 .tp-medal {
    font-size: 44px;
}

.tp-rank-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--ui-muted, #9a9ac0);
}

.tp-avatar {
    margin-top: 2px;
}

.tp-podium-item--1 .tp-avatar {
    border: 2px solid rgba(255, 215, 0, 0.7);
    box-shadow: 0 0 0 6px rgba(255, 215, 0, 0.1), 0 0 26px rgba(255, 215, 0, 0.28);
}

.tp-podium-item--2 .tp-avatar {
    border: 2px solid rgba(203, 213, 225, 0.55);
}

.tp-podium-item--3 .tp-avatar {
    border: 2px solid rgba(205, 127, 50, 0.55);
}

.tp-name {
    font-size: 17px;
    font-weight: 800;
    line-height: 1.25;
    color: var(--ui-text, #fff);
    overflow-wrap: anywhere;
}

.tp-podium-item--1 .tp-name {
    font-size: 20px;
}

.tp-name:hover {
    color: #c9a7ff;
}

.tp-position {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.tp-position--muted {
    color: var(--ui-dim, #6d6d92);
}

.tp-tags {
    justify-content: center;
}

.tp-score {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 7px;
    margin-top: auto;
    padding-top: 10px;
}

.tp-score b {
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
    background: var(--accent-gradient, linear-gradient(135deg, #6c3ce1, #4a90d9));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tp-score span {
    font-size: 10px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--ui-muted, #9a9ac0);
    white-space: nowrap;
}

.tp-profile-btn {
    width: 100%;
    max-width: 210px;
}

/* ---------- Топ: места 4–10 ---------- */
.tp-rest {
    margin-top: 4px;
}

.tp-rest-title {
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--ui-muted, #9a9ac0);
}

.tp-rest-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tp-rest-item {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    padding: 12px 16px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.tp-rest-item:hover {
    transform: translateX(3px);
    border-color: rgba(168, 85, 247, 0.4);
}

.tp-rest-rank {
    flex: 0 0 32px;
    text-align: center;
    font-size: 16px;
    font-weight: 800;
    color: var(--ui-muted, #9a9ac0);
}

.tp-rest-avatar {
    flex: 0 0 auto;
}

.tp-rest-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tp-rest-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--ui-text, #fff);
    overflow-wrap: anywhere;
}

.tp-rest-name:hover {
    color: #c9a7ff;
}

.tp-rest-sub {
    font-size: 12px;
    line-height: 1.4;
    color: var(--ui-muted, #9a9ac0);
    overflow-wrap: anywhere;
}

.tp-rest-dot {
    margin: 0 5px;
    color: var(--ui-dim, #6d6d92);
}

.tp-rest-score {
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.tp-rest-score b {
    font-size: 16px;
    color: var(--ui-text, #fff);
}

.tp-rest-score span {
    font-size: 10px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--ui-muted, #9a9ac0);
    white-space: nowrap;
}

.tp-rest-btn {
    flex: 0 0 auto;
}

/* ---------- Появление карточек (включается из JS) ---------- */
[data-reveal].is-reveal-ready > * {
    opacity: 0;
    transition: opacity 0.32s ease;
}

[data-reveal].is-reveal-ready > .is-revealed {
    opacity: 1;
}

/* ---------- Адаптив ---------- */
@media (max-width: 900px) {
    .us-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 14px;
    }

    .us-card {
        padding: 16px;
    }

    .tp-podium {
        gap: 12px;
    }

    .tp-podium-item {
        padding: 20px 14px 18px;
    }

    .tp-podium-item--1 .tp-name {
        font-size: 18px;
    }
}

@media (max-width: 640px) {
    .us-head {
        align-items: flex-start;
        flex-direction: column;
    }

    /* табы не обрезаются: при нехватке места второй переносится на новую строку */
    .us-tabs {
        width: 100%;
        max-width: 100%;
        flex-wrap: wrap;
        overflow: visible;
    }

    .us-tabs .ui-tab {
        flex: 1 1 auto;
        justify-content: center;
        padding: 8px 10px;
        font-size: 12px;
        white-space: nowrap;
        max-width: 100%;
    }

    .us-search-field {
        flex: 1 1 100%;
    }

    .us-search-submit,
    .us-search-reset {
        flex: 1 1 auto;
    }

    /* списки пользователей — одна колонка */
    .us-grid {
        grid-template-columns: 1fr;
    }

    .us-card {
        padding: 15px;
    }

    .us-card .us-avatar {
        width: 56px;
        height: 56px;
    }

    .us-card .us-avatar-initials {
        font-size: 18px;
    }

    .us-card-actions {
        width: 100%;
    }

    .us-pagination {
        gap: 8px;
    }

    .us-page-num,
    .us-page-arrow {
        min-width: 34px;
        height: 34px;
        padding: 0 9px;
        font-size: 12px;
    }

    .us-page-arrow {
        order: 2;
    }

    .us-page-numbers {
        order: 1;
        flex-wrap: wrap;
        justify-content: center;
    }

    /* подиум — в одну колонку, место 1 сверху */
    .tp-podium,
    .tp-podium--2,
    .tp-podium--1 {
        grid-template-columns: 1fr;
        max-width: none;
    }

    .tp-podium-item,
    .tp-podium--2 .tp-podium-item--1,
    .tp-podium--2 .tp-podium-item--2,
    .tp-podium--1 .tp-podium-item--1 {
        grid-column: auto !important;
        grid-row: auto !important;
        transform: none;
    }

    .tp-podium-item {
        padding: 18px 14px;
    }

    .tp-podium-item--1 {
        order: 1;
    }

    .tp-podium-item--2 {
        order: 2;
    }

    .tp-podium-item--3 {
        order: 3;
    }

    .tp-podium-item--1 .tp-name {
        font-size: 19px;
    }

    .tp-profile-btn {
        max-width: none;
    }

    .tp-rest-item {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px;
    }

    .tp-rest-main {
        flex: 1 1 calc(100% - 92px);
    }

    .tp-rest-score {
        margin-left: auto;
    }

    .tp-rest-btn {
        flex: 0 0 100%;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .us-page,
    .tp-page,
    .us-card,
    .tp-podium-item,
    .tp-rest-item {
        animation: none !important;
        transition: none !important;
    }

    [data-reveal].is-reveal-ready > * {
        opacity: 1 !important;
    }
}
