/* Moodozvon — страница профиля /profile/me и /u/<username>.
   Использует токены из style.css. */

html, body { height: auto; overflow: visible; }

.profile-body {
    background: var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

.profile-shell {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 18px 64px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.profile-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
}

.profile-wordmark {
    text-align: center;
    text-decoration: none;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.profile-back { text-decoration: none; }
.profile-header__spacer { width: 88px; } /* визуальная симметрия под кнопку back */

.profile-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.profile-card__loader {
    text-align: center;
    color: var(--text-2);
    padding: 32px 0;
}

.profile-back-cta {
    margin-top: 14px;
    display: inline-flex;
}

/* --- Шапка профиля: аватар + имена --- */

.profile-top {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-avatar {
    position: relative;
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    border-radius: 50%;
    background:
        linear-gradient(135deg,
            color-mix(in oklab, var(--accent) 50%, var(--surface-2)),
            color-mix(in oklab, var(--accent) 15%, var(--surface-2)));
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-ink);
    font-size: 36px;
    font-weight: 700;
    user-select: none;
    border: 1px solid var(--border-strong);
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-avatar__edit {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    color: #fff;
    cursor: pointer;
    transition: opacity 0.15s;
    opacity: 0;
}
.profile-avatar__edit svg { width: 22px; height: 22px; }

.profile-card[data-mode="edit"] .profile-avatar__edit { display: flex; }
.profile-avatar:hover .profile-avatar__edit { opacity: 1; }

.profile-id { min-width: 0; flex: 1; }

.profile-username {
    font-size: 14px;
    font-family: var(--mono);
    color: var(--text-dim);
    margin: 0;
}
.profile-username::before { content: "@"; color: var(--text-dim); margin-right: 1px; }

.profile-display-name {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 2px 0 0;
    line-height: 1.2;
    word-break: break-word;
}
.profile-display-name:empty::before {
    content: attr(data-placeholder);
    color: var(--text-dim);
    font-weight: 500;
}

.profile-meta {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

/* --- Bio, tags --- */

.profile-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-section__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-weight: 600;
}

.profile-bio {
    color: var(--text);
    line-height: 1.55;
    font-size: 15px;
    white-space: pre-wrap;
    word-break: break-word;
}
.profile-bio:empty::before {
    content: attr(data-placeholder);
    color: var(--text-dim);
    font-style: italic;
}

.profile-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    color: var(--text);
    font-size: 13px;
}

.profile-tag__remove {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}
.profile-tag__remove:hover { color: var(--danger); }

/* --- Edit mode --- */

.profile-card[data-mode="view"] .edit-only { display: none !important; }
.profile-card[data-mode="edit"] .view-only { display: none !important; }

.profile-input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    padding: 10px 14px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}
.profile-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
}

textarea.profile-input {
    resize: vertical;
    min-height: 92px;
    line-height: 1.5;
}

.profile-tag-input-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.profile-tag-input-row .profile-input {
    flex: 1;
    min-width: 160px;
}

.profile-hint {
    font-size: 12px;
    color: var(--text-dim);
}

.profile-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 6px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.profile-actions .mz-btn { flex: 1; min-width: 140px; }

/* --- Toast (ошибки/успех) --- */

.profile-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text);
    padding: 12px 18px;
    font-size: 14px;
    /* Поверх модалок (modal-overlay = 1000) и консент-оверлея (9999). */
    z-index: 10000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    max-width: 90vw;
}
.profile-toast.hidden { display: none; }
.profile-toast.is-error {
    background: var(--danger-soft);
    border-color: color-mix(in oklab, var(--danger) 30%, transparent);
    color: var(--danger);
}

@media (max-width: 640px) {
    .profile-shell { padding: 16px 12px 40px; gap: 18px; }
    .profile-card { padding: 20px; border-radius: var(--r-lg); }
    .profile-top { gap: 14px; }
    .profile-avatar { width: 80px; height: 80px; font-size: 30px; }
    .profile-display-name { font-size: 20px; }
    .profile-header__spacer { width: 0; }
}
