/* =========================================================================
   Профиль пользователя — дизайн-система CA (тёплая бумага, чернильный акцент).
   Токены --ca-* глобальны (ca-theme.css). Палитра согласована с лобби
   (lobby.css) и каталогом. Разметка/JS не меняются — только оформление.
   ========================================================================= */
.content:has(.profile) {
    background: var(--ca-bg);
    min-height: calc(100vh - 120px);
}

.profile {
    max-width: 880px;
    margin: 0 auto;
    padding: 28px 18px 60px;
    color: var(--ca-text);
    font-family: var(--ca-font);
}

/* ------------------------------ Шапка -------------------------------- */
/* Карточка — вертикальный стек: строка-шапка (аватар + имя) и, ниже, сетка
   действий во всю ширину. Раньше был один flex-row, где кнопки жались в правой
   колонке «лесенкой», а справа зияла пустота. */
.pf-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--ca-surface);
    border: 1px solid var(--ca-line-soft);
    border-radius: 18px;
    padding: 22px 24px;
    margin-bottom: 26px;
    box-shadow: var(--ca-raise);
}
.pf-card__head {
    display: flex;
    align-items: center;
    gap: 22px;
    min-width: 0;
}
.pf-card__ident { min-width: 0; flex: 1 1 auto; }

.pf-avatar {
    position: relative;
    flex: 0 0 auto;
    width: 88px;
    height: 88px;
    border-radius: 20px;
    background: var(--ca-surface-2);
    border: 1px solid var(--ca-line-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    line-height: 1;
    user-select: none;
}
.pf-avatar.is-editable { cursor: pointer; transition: border-color .15s ease, transform .15s ease; }
.pf-avatar.is-editable:hover { border-color: var(--ca-accent); transform: translateY(-1px); }
.pf-avatar__edit {
    position: absolute;
    right: -6px;
    bottom: -6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--ca-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: var(--ca-raise);
}

.pf-card__body { min-width: 0; }
.pf-name-row { display: flex; align-items: center; gap: 10px; }
.pf-name {
    font-family: var(--ca-font);
    font-weight: 700;
    font-size: clamp(24px, 4vw, 34px);
    margin: 0;
    color: var(--ca-text);
    word-break: break-word;
}

/* Действия — сетка равной ширины (по 3 в ряд), кнопки одинакового размера. */
.pf-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
}
.pf-btn {
    border: 1px solid var(--ca-accent-ink);
    border-radius: 10px;
    cursor: pointer;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: var(--ca-accent);
    box-shadow: var(--ca-raise);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 44px;
    transition: background .12s ease, transform .1s ease;
}
.pf-btn:hover { background: var(--ca-accent-ink); transform: translateY(-1px); }
.pf-btn--ghost {
    color: var(--ca-text);
    background: var(--ca-surface);
    border: 1px solid var(--ca-line-soft);
}
.pf-btn--ghost:hover { background: var(--ca-surface-2); border-color: var(--ca-line); color: var(--ca-text); transform: none; }

/* Узкий экран: действия — по 2 в ряд (равная ширина сохраняется). */
@media (max-width: 640px) {
    .pf-actions { grid-template-columns: repeat(2, 1fr); }
}

/* ----------------------- Онбординг новичка --------------------------- */
/* Свой профиль без единого матча: вместо пустого «Ещё нет матчей» — CTA. */
.pf-onboard {
    text-align: center;
    background: var(--ca-surface);
    border: 1px dashed var(--ca-line);
    border-radius: 16px;
    padding: 34px 20px;
    box-shadow: var(--ca-raise);
}
.pf-onboard__icon { font-size: 40px; line-height: 1; margin-bottom: 12px; }
.pf-onboard__title { font-size: 18px; font-weight: 700; color: var(--ca-text); margin-bottom: 6px; }
.pf-onboard__text { font-size: 14px; color: var(--ca-muted); line-height: 1.6; margin: 0 auto 20px; max-width: 380px; }
.pf-onboard__cta { min-height: 44px; padding: 12px 28px; }

/* ---------------------------- Секции --------------------------------- */
.pf-section { margin-bottom: 30px; }
.pf-section__title {
    font-family: var(--ca-font);
    font-weight: 600;
    font-size: 20px;
    margin: 0 0 14px;
    color: var(--ca-text);
}

.pf-empty {
    text-align: center;
    color: var(--ca-muted);
    font-size: 15px;
    padding: 34px 16px;
    border: 1px dashed var(--ca-line);
    border-radius: 16px;
    background: var(--ca-surface);
}

/* --------------------------- Статистика ------------------------------ */
.pf-overall {
    display: flex;
    align-items: center;
    gap: 26px;
    background: var(--ca-surface);
    border: 1px solid var(--ca-line-soft);
    border-radius: 16px;
    padding: 18px 22px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    box-shadow: var(--ca-raise);
}
.pf-overall__main { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.pf-overall__num {
    font-family: var(--ca-font);
    font-weight: 700;
    font-size: 40px;
    color: var(--ca-accent);
}
.pf-overall__label { font-size: 13px; color: var(--ca-muted); text-transform: uppercase; letter-spacing: .04em; }

.pf-wld { display: flex; gap: 18px; flex-wrap: wrap; }
.pf-wld__item { font-size: 14px; color: var(--ca-muted); }
.pf-wld__item b { font-size: 20px; margin-right: 6px; color: var(--ca-text); }
.pf-wld__item--win b, .pf-wld__item--win { color: var(--ca-good); }
.pf-wld__item--loss b, .pf-wld__item--loss { color: var(--ca-bad); }
.pf-wld__item--draw b, .pf-wld__item--draw { color: var(--ca-muted); }

.pf-games {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}
.pf-game {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--ca-surface);
    border: 1px solid var(--ca-line-soft);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: var(--ca-raise);
}
.pf-game__icon { font-size: 28px; line-height: 1; flex: 0 0 auto; }
.pf-game__body { min-width: 0; }
.pf-game__title { font-weight: 700; font-size: 15px; margin-bottom: 4px; color: var(--ca-text); }
.pf-game__meta { display: flex; align-items: baseline; gap: 12px; font-size: 13px; color: var(--ca-muted); flex-wrap: wrap; }
.pf-game__total { color: var(--ca-text); font-weight: 600; }
.pf-game__wld { display: inline-flex; gap: 8px; font-weight: 700; }

/* ---------------------------- История -------------------------------- */
/* Таблица: единый grid-template для всех строк — колонки строго выровнены
   по вертикали. Колонки: [иконка] [игра] [соперники] [счёт] [результат] [дата] [ссылка]. */
.pf-history { display: flex; flex-direction: column; gap: 10px; }
.pf-hist {
    display: grid;
    grid-template-columns: 24px minmax(100px, 1fr) minmax(120px, 1.5fr) 52px 104px 168px auto;
    align-items: center;
    gap: 14px;
    background: var(--ca-surface);
    border: 1px solid var(--ca-line-soft);
    border-radius: 14px;
    padding: 12px 16px;
    box-shadow: var(--ca-raise);
}
.pf-hist__score {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 14px;
    color: var(--ca-text);
    white-space: nowrap;
    text-align: center;
}
.pf-hist__icon { font-size: 22px; line-height: 1; text-align: center; }
.pf-hist__gtitle { font-weight: 700; font-size: 15px; color: var(--ca-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-hist__opps { font-size: 14px; color: var(--ca-text); min-width: 0; }
.pf-hist__opp { display: inline-flex; align-items: center; gap: 4px; }
.pf-hist__opp-link { color: var(--ca-text); text-decoration: none; transition: color .12s ease; }
.pf-hist__opp-link:hover { color: var(--ca-accent); text-decoration: underline; }
.pf-hist__sep { color: var(--ca-faint); }
.pf-hist__solo { color: var(--ca-muted); }
.pf-hist__date { font-size: 13px; color: var(--ca-muted); white-space: nowrap; }
.pf-hist__open {
    color: var(--ca-accent);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
}
.pf-hist__open:hover { text-decoration: underline; }

.pf-badge {
    justify-self: start;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 999px;
    white-space: nowrap;
}
/* color+background всегда из одной пары токенов (--ca-good/--ca-bad + их -soft) —
   раньше цвет и alpha-подложка были голым hex, одинаковым в обеих темах, и в
   «Ночи» сливались (контраст ~2.4:1). См. ca-theme.css. */
.pf-badge--win  { color: var(--ca-good); background: var(--ca-good-soft); }
.pf-badge--loss { color: var(--ca-bad); background: var(--ca-bad-soft); }
.pf-badge--draw { color: var(--ca-muted); background: var(--ca-surface-2); }
.pf-badge--none { color: var(--ca-muted); background: var(--ca-surface-2); }
.pf-badge--live { color: var(--ca-good); background: var(--ca-good-soft); }
.pf-badge--wait { color: var(--ca-muted); background: var(--ca-surface-2); }

/* --------------------------- Текущие матчи ---------------------------- */
.pf-active { display: flex; flex-direction: column; gap: 10px; }
.pf-active__row {
    display: grid;
    grid-template-columns: 24px minmax(100px, 1fr) minmax(120px, 1.5fr) 104px auto;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--ca-surface);
    border: 1px solid var(--ca-line-soft);
    border-radius: 12px;
    box-shadow: var(--ca-raise);
}
.pf-active__actions {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-self: end;
}
.pf-cancel {
    border: 1px solid var(--ca-line-soft);
    background: var(--ca-surface);
    color: var(--ca-bad);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s ease, border-color .12s ease;
}
.pf-cancel:hover { background: var(--ca-bad-soft); border-color: var(--ca-bad); }

.pf-flash {
    margin-bottom: 14px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--ca-surface-2);
    border: 1px solid var(--ca-line-soft);
    color: var(--ca-text);
    font-size: 14px;
}

@media (max-width: 640px) {
    .pf-active__row {
        grid-template-columns: 24px 1fr auto;
    }
    .pf-active__row .pf-hist__icon    { grid-column: 1; grid-row: 1; }
    .pf-active__row .pf-hist__gtitle  { grid-column: 2; grid-row: 1; }
    .pf-active__row .pf-badge         { grid-column: 3; grid-row: 1; justify-self: end; }
    .pf-active__row .pf-hist__opps    { grid-column: 1 / -1; grid-row: 2; }
    .pf-active__row .pf-active__actions { grid-column: 1 / -1; grid-row: 3; justify-self: end; }
}

.pf-more {
    display: block;
    margin: 16px auto 0;
    border: 1px solid var(--ca-line-soft);
    background: var(--ca-surface);
    color: var(--ca-text);
    border-radius: 10px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--ca-raise);
    transition: background .12s ease, border-color .12s ease;
}
.pf-more:hover { background: var(--ca-surface-2); border-color: var(--ca-line); }
.pf-more[disabled] { opacity: .5; cursor: default; }

/* Кружок онлайна (gpDot из app.js) — на бумаге. */
.profile .gp-dot {
    display: inline-block; width: 9px; height: 9px; border-radius: 50%;
    background: var(--ca-line-soft);
    vertical-align: middle; flex: none;
}
.profile .gp-dot--on { background: var(--ca-good); }

/* ----------------------- Мини-модалка аватара ------------------------ */
.pf-avatar-modal { width: 380px; }
.pf-avatar-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pf-avatar-quick__btn {
    width: 44px; height: 44px;
    border: 1px solid var(--ca-line-soft);
    background: var(--ca-surface);
    border-radius: 10px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--ca-raise);
    transition: border-color .12s ease, background .12s ease;
}
.pf-avatar-quick__btn:hover { border-color: var(--ca-accent); background: var(--ca-surface-2); }

/* ------------------------------ Адаптив ------------------------------ */
@media (max-width: 640px) {
    /* Узкий экран: сворачиваем в компактные строки, но с явными позициями,
       чтобы поля не «прыгали». */
    .pf-hist {
        grid-template-columns: 24px 1fr auto;
        gap: 8px 10px;
    }
    .pf-hist__icon   { grid-column: 1; grid-row: 1; }
    .pf-hist__gtitle { grid-column: 2; grid-row: 1; }
    .pf-badge        { grid-column: 3; grid-row: 1; justify-self: end; }
    .pf-hist__opps   { grid-column: 1 / -1; grid-row: 2; }
    .pf-hist__score  { grid-column: 1; grid-row: 3; justify-self: start; text-align: left; }
    .pf-hist__date   { grid-column: 2; grid-row: 3; }
    .pf-hist__open   { grid-column: 3; grid-row: 3; justify-self: end; }
}
