/* ═══════════════════════════════════════
   Профиль: одна страница в двух режимах

   Сюда переехало всё, что жило в модалке профиля: секции-аккордеоны,
   уведомления, переключатель темы, контекстное меню аватара и оверлей зума.
   Имена `.profile-modal__*` стали `.profile__*` — модалки больше нет;
   `.notifications__*`, `.avatar-context-menu*` и `.avatar-zoom-overlay*` имена
   сохранили: они не про модалку.
   ═══════════════════════════════════════ */
.profile {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--space-3xl) var(--space-xl);
}

/* Карточка профиля — .paper-card; всё содержимое страницы внутри неё, и
   секции, статы и химеры — внутренние блоки с тонкой рамкой, а не вложенные
   карточки с тенью. */
.profile__card {
    padding: var(--space-2xl);
}

.profile__header {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
    margin-bottom: var(--space-2xl);
}

/* Кнопка: аватар нажимают (меню своего, зум чужого), и с клавиатуры тоже.
   Кнопочные стили сброшены — вид прежний. */
.profile__avatar {
    padding: 0;
    border: none;
    font: inherit;
    cursor: pointer;
    width: 96px;
    height: 96px;
    border-radius: var(--radius-full);
    outline: var(--border-ink) solid var(--ink);
    box-shadow: var(--shadow-control);
    background: var(--accent);
    color: var(--text-on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 600;
    overflow: hidden;
}

.profile__avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* Логин и почта столбиком. Правило нужно, потому что в чужом профиле почты нет
   вовсе: без flex-колонки одинокий заголовок прижимался бы к аватару иначе, чем
   пара «логин + почта», и шапка прыгала бы между режимами. */
.profile__title {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    min-width: 0;
}

.profile__username {
    margin: 0;
    overflow-wrap: anywhere;
}

.profile__email {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

/* Шапка держит место с первого кадра: логин и почта приходят ответом, а
   пустые строки нулевой высоты на телефоне (шапка — колонка) давали ей рост
   на ~58 px. Пустые держат по строке своим шрифтом — невидимым пробелом. У
   чужого профиля строки почты нет с первого кадра (hidden от сервера). */
.profile__username:empty::before,
.profile__email:empty::before {
    content: "\a0";
}

.profile__details {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-xl);
}

.profile__row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    justify-content: space-between;
}

.profile__label {
    color: var(--text-secondary);
    font-size: var(--font-md);
}

.profile__value {
    color: var(--text-primary);
    font-size: var(--font-md);
}

/* Заглушка бирки статуса до ответа профиля: строка «Статус аккаунта» видна с
   первого кадра, и заглушка держит ей высоту настоящей бирки (`.tag` выше
   строки текста) — строки ниже не съезжают, когда бирка встаёт. Сценарий
   заменяет её биркой. */
.profile__status-placeholder {
    visibility: hidden;
}

.profile__value--success { color: var(--success); }
.profile__value--warning { color: var(--warning); }

/* Кнопка-ссылка внутри строки: «Прислать письмо», «Прислать письмо для сброса» */
.profile__inline-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    cursor: pointer;
    font-size: var(--font-sm);
    text-decoration: underline;
}

.profile__section-title {
    margin-bottom: var(--space-md);
}

/* Второй и дальнейшие заголовки секций («Химеры» после статистики) —
   с отступом сверху: без него заголовок прилипал к карточке статистики. */
.profile__section-title:not(:first-child) {
    margin-top: var(--space-lg);
}

.profile__hint {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-top: var(--space-sm);
}

/* ═══════════════════════════════════════
   Профиль: секции-аккордеоны
   ═══════════════════════════════════════ */

.profile__section {
    padding: var(--space-lg);
    border: var(--border-ink-thin) solid var(--ink);
    border-radius: var(--radius-sm);
    margin-top: var(--space-lg);
}

/* Заголовок секции — кнопка (Enter и Space раскрывают её, aria-expanded
   говорит положение); кнопочные стили сброшены — вид прежний. */
.profile__toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: var(--space-sm) 0;
    border: none;
    background: none;
    font: inherit;
    color: inherit;
    text-align: left;
    text-align-last: auto;
    cursor: pointer;
    /* Секция — цель прокрутки («Задать пароль» раскрывает её и прокручивает):
       заголовок не прячется под липким навбаром в несколько рядов. */
    scroll-margin-top: calc(var(--navbar-height) + var(--space-md));
}

.profile__toggle:hover .profile__chevron {
    color: var(--accent);
}

/* Фигура — общий .chevron из global.css: символ U+25B6 Safari рисует эмодзи. */
.profile__chevron {
    font-size: var(--font-xl);
    color: var(--text-primary);
    transition: transform 0.2s ease, color 0.2s ease;
}

.profile__chevron--open {
    transform: rotate(90deg);
}

.profile__form {
    margin-top: var(--space-lg);
}

/* ═══════════════════════════════════════
   Уведомления: секция в профиле
   ═══════════════════════════════════════ */
.profile__notifications {
    margin-top: var(--space-lg);
}

.notifications__group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.notifications__group-label {
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.notifications__toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-xs) 0 var(--space-xs) var(--space-md);
}

.notifications__channel-label {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════
   Строки-переключатели: тема и звук
   ═══════════════════════════════════════ */
.profile__switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: var(--space-sm) 0;
}

/* ═══════════════════════════════════════
   Контекстное меню аватара
   ═══════════════════════════════════════ */

.profile__avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.avatar-context-menu {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    padding: var(--space-xs) 0;
    min-width: 160px;
    margin-top: var(--space-xs);
}

.avatar-context-menu__item {
    display: block;
    width: 100%;
    padding: var(--space-sm) var(--space-lg);
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    text-align-last: auto;
    font-size: var(--font-md);
    color: var(--text-primary);
    transition: background var(--transition-base);
}

.avatar-context-menu__item:hover {
    background: var(--bg-hover);
}

.avatar-context-menu__item--danger {
    color: var(--danger);
}

.avatar-context-menu__item--danger:hover {
    background: var(--bg-danger-soft);
}

/* ═══════════════════════════════════════
   Оверлей увеличения аватара
   ═══════════════════════════════════════ */

.avatar-zoom-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: var(--overlay-scrim-strong);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-zoom-overlay__img {
    width: 80vmin;
    height: 80vmin;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.avatar-zoom-overlay__close {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    background: none;
    border: none;
    color: var(--text-on-accent);
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

/* ═══════════════════════════════════════
   Чужой профиль: краткая статистика
   ═══════════════════════════════════════ */
.profile__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-md);
}

.profile__stat {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    padding: var(--space-lg);
    border: var(--border-ink-thin) solid var(--ink);
    border-radius: var(--radius-sm);
}

.profile__stat-title {
    font-weight: 700;
    color: var(--text-primary);
}

/* Цифры статистики — голосом игры. */
.profile__stat-numbers {
    font-family: var(--font-display);
}

.profile__stat-numbers,
.profile__stat-total {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

/* ═══════════════════════════════════════
   Дружба на чужом профиле
   ═══════════════════════════════════════ */

/*
 * Блок один на все четыре состояния: текст и кнопки ставит JS. Под строкой
 * статуса — столбец кнопок во всю ширину блока на любом экране (решение
 * 2026-10-16): «Смотреть бой», «Позвать в бой», кнопки дружбы последними.
 * Перенос flex-строки здесь не годился: он зависел от ширины текста статуса,
 * и с коротким «в сети» «Удалить из соратников» стояла в одной строке со
 * статусом, упираясь в край карточки, а «Позвать в бой» падала под неё одна
 * и короткая.
 */
.profile__friendship {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

/* Статус и присутствие — одной строкой, через точку. */
.profile__friendship-head {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: baseline;
}

.profile__friendship-status {
    color: var(--text-secondary);
}

/* Кнопок дружбы одна или две — каждая своей строкой во всю ширину. */
.profile__friendship-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/*
 * «Смотреть бой» и «Позвать в бой» — ссылки с видом кнопки: прячутся
 * атрибутом hidden, а не классом — элемент и так <a hidden>, и второй способ
 * прятать то же самое разошёлся бы с первым.
 */
.profile__friendship-link {
    display: flex;
    text-decoration: none;
}

/* ═══════════════════════════════════════
   Свой профиль: действия
   ═══════════════════════════════════════ */
.profile__actions {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    margin-top: var(--space-xl);
}

/* ═══════════════════════════════════════
   Способы входа и первый пароль
   ═══════════════════════════════════════ */

/* Строка: значок, название со статусом, кнопка. */
.login-methods {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.login-methods__row {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: var(--space-md);
}

.login-methods__icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
}

.login-methods__logo {
    width: 24px;
    height: 24px;
}

.login-methods__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.login-methods__name {
    font-weight: 700;
    color: var(--text-primary);
}

.login-methods__status {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

.login-methods__status--ok {
    color: var(--success);
}

.login-methods__status--paused {
    color: var(--warning);
}

/* Кнопки строк — одной ширины: «Привязать», «Отвязать» и «Задать пароль»
   встают ровным столбцом, а не прыгают по длине подписи (решение
   2026-10-19). */
.login-methods__action {
    width: 9.5em;
    min-height: 34px;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-sm);
}

/* Пояснение окна пароля перед привязкой — с отступом до поля. */
.link-password__hint {
    margin-bottom: var(--space-lg);
}

.set-password__steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.set-password__sent {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

/* ═══════════════════════════════════════
   Адаптивность
   ═══════════════════════════════════════ */
@media (max-width: 600px) {
    .profile {
        padding: var(--space-xl) var(--space-md);
    }

    /* Кнопка строки — под названием: на телефоне третьей колонке места
       нет. */
    .login-methods__row {
        grid-template-columns: 24px 1fr;
    }

    .login-methods__action {
        grid-column: 2;
        justify-self: start;
    }

    .profile__header {
        flex-direction: column;
        text-align: center;
        text-align-last: center;
    }

    .profile__actions {
        flex-direction: column;
    }
}

/* Признак «в сети» или «в бою» рядом с состоянием дружбы, через точку. */
.profile__presence {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

.profile__presence::before {
    margin-right: var(--space-sm);
    color: var(--text-muted);
    content: '·';
}

.profile__presence[data-online="yes"] {
    color: var(--success);
}

/* Химеры чужого игрока. */
.profile__chimeras {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Карточка химеры — ссылка на её страницу: цвет текста свой, без подчёркивания.
   Аватар — сверху, на линии имени, а не посередине: текст под именем
   растёт со способностями и составом, и аватар по центру уезжал бы от имени
   вниз. */
.profile__chimera {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border: var(--border-ink-thin) solid var(--ink);
    border-radius: var(--radius-sm);
    color: inherit;
    text-decoration: none;
}

.profile__chimera:hover {
    background: var(--bg-hover);
}

/* Геометрия жетона — в .chimera-avatar из global.css, здесь только размер. */
.profile__chimera-avatar {
    width: 48px;
    height: 48px;
}

/* Имя, уровень и мощь — данные, а не проза: элемент `div`, а не `<p>`, и
   правило прозы строку не растягивает (profile.js). */
.profile__chimera-name {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 400;
}

.profile__chimera-record,
.profile__chimera-abilities,
.profile__chimera-problem {
    margin: var(--space-xs) 0 0;
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

@media (max-width: 600px) {
    .profile__chimera-avatar {
        width: 40px;
        height: 40px;
    }
}

.profile__chimera-body {
    min-width: 0;
}

.profile__chimera-parts {
    list-style: none;
    margin: var(--space-xs) 0 0;
    padding: 0;
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

.profile__chimera-problem {
    color: var(--danger);
}
