﻿/* ==========================================================================
   App shell: top bar, scrolling screen, bottom tab bar
   ========================================================================== */
.app-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 560px;
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
}

.app-shell > .tabs {
    flex: 1 1 auto;
    min-height: 0;
}

.app-topbar {
    position: relative;
    z-index: 50;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: calc(var(--sc-topbar-height) + var(--sc-safe-top));
    padding: var(--sc-safe-top) 16px 0;
    border-bottom: 1px solid var(--sc-line);
    background: rgba(var(--sc-bg-rgb), 0.78);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    backdrop-filter: blur(16px) saturate(1.4);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.app-logo {
    width: 34px;
    height: 34px;
    filter: drop-shadow(0 3px 10px rgba(var(--sc-primary-rgb), 0.35));
}

.app-wordmark {
    font-family: var(--sc-font-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: linear-gradient(90deg, #fff 0%, #bfefff 60%, var(--sc-primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-avatar {
    width: 36px;
    height: 36px;
    padding: 2px;
    border: none;
    border-radius: 50%;
    background: var(--sc-gradient-primary);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.app-avatar:active {
    transform: scale(0.92);
}

.app-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: var(--sc-surface);
}

/* Screen headers */
.screen-header {
    display: flex;
    flex-shrink: 0;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.screen-title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.screen-subtitle {
    margin: 4px 0 0;
    color: var(--sc-text-muted);
    font-size: 14px;
}

.screen-header-actions {
    display: flex;
    gap: 8px;
}

/* ==========================================================================
   Profile hero (Home)
   ========================================================================== */
.file-input {
    display: none;
}

.profile-hero {
    position: relative;
    margin-bottom: 24px;
    overflow: hidden;
    border: 1px solid var(--sc-line-strong);
    border-radius: var(--sc-radius-lg);
    background: var(--sc-surface);
    box-shadow: var(--sc-shadow-lg);
}

.profile-hero .banner-container {
    position: absolute;
    inset: 0;
    z-index: 0;
    height: auto;
}

.profile-hero .banner-overlay {
    z-index: 1;
    background: linear-gradient(180deg, rgba(var(--sc-bg-rgb), 0.1) 0%, rgba(var(--sc-bg-rgb), 0.45) 40%, rgba(21, 28, 51, 0.97) 78%);
}

.profile-hero .banner-image {
    z-index: 0;
    height: 62%;
    border-radius: 0;
}

.profile-hero.is-editing .banner-container {
    cursor: pointer;
}

.profile-hero.is-editing .banner-image {
    animation: profile-banner-edit 1.6s ease-in-out infinite;
}

/* Let taps fall through to the banner (to change it in edit mode), except on actual controls */
.profile-hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 12px 16px 16px;
    pointer-events: none;
}

.profile-hero-content button,
.profile-hero-content input,
.profile-hero-content select,
.profile-hero-content label,
.profile-hero-content img {
    pointer-events: auto;
}

.profile-hero-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.profile-hero-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: auto;
    padding: 6px 12px;
    border-radius: var(--sc-radius-pill);
    background: rgba(var(--sc-bg-rgb), 0.65);
    color: var(--sc-text);
    font-size: 12px;
    font-weight: 600;
}

.profile-hero-main {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    margin-top: 28px;
}

.avatar-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 88px;
    height: 88px;
    padding: 3px;
    border-radius: 50%;
    background: conic-gradient(from 200deg, var(--sc-primary), var(--sc-purple), var(--sc-gold), var(--sc-primary));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 24px rgba(var(--sc-primary-rgb), 0.3);
}

.avatar {
    width: 100%;
    height: 100%;
    border: 3px solid var(--sc-surface);
    border-radius: 50%;
    background: var(--sc-surface-2);
    object-fit: cover;
    cursor: pointer;
}

.avatar-level {
    position: absolute;
    right: -2px;
    bottom: -2px;
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--sc-surface);
    border-radius: var(--sc-radius-pill);
    background: var(--sc-gradient-gold);
    color: #2a1600;
    font-family: var(--sc-font-display);
    font-size: 15px;
    font-weight: 700;
}

.change-overlay {
    position: absolute;
    inset: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    border-radius: 50%;
    background: rgba(var(--sc-bg-rgb), 0.6);
    color: #fff;
    font-size: 28px;
    cursor: pointer;
}

.profile-identity {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding-bottom: 6px;
}

.profile-name {
    margin: 0;
    overflow: hidden;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.profile-title {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--sc-radius-pill);
    background: var(--sc-gold-soft);
    color: var(--sc-gold);
    font-size: 12px;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(255, 200, 61, 0.3);
}

.profile-edit {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.profile-edit .form-control,
.profile-edit .title-select {
    width: 100%;
    min-height: 42px;
    background-color: rgba(var(--sc-bg-rgb), 0.85);
}

.profile-error {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--sc-danger-soft);
    color: #ffc2c2;
    font-size: 14px;
}

.profile-recovery {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--sc-line-strong);
    border-radius: 14px;
    background: rgba(var(--sc-bg-rgb), 0.7);
}

.profile-recovery-icon {
    flex-shrink: 0;
    color: var(--sc-gold);
    font-size: 22px;
}

.profile-recovery-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.profile-recovery-title {
    font-weight: 700;
    font-size: 14px;
}

.profile-recovery-status {
    color: var(--sc-text-muted);
    font-size: 12px;
}

.profile-recovery .btn {
    flex-shrink: 0;
}

.profile-level {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-level-labels {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.profile-level-name {
    font-family: var(--sc-font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--sc-purple);
}

.profile-level-xp {
    color: var(--sc-text-muted);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.profile-quick-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.profile-quick-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-record {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    padding: 4px 12px;
    border-radius: var(--sc-radius-pill);
    font-family: var(--sc-font-display);
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.profile-record small {
    font-size: 11px;
    opacity: 0.8;
}

.profile-record.is-win {
    background: var(--sc-success-soft);
    color: var(--sc-success);
}

.profile-record.is-loss {
    background: var(--sc-danger-soft);
    color: var(--sc-danger);
}

.title-select {
    width: 100%;
    color: var(--sc-text);
}

.title-select option {
    background-color: var(--sc-surface);
    color: var(--sc-text);
}

@keyframes profile-banner-edit {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.app-help {
    width: 34px;
    height: 34px;
    font-size: 18px;
    text-decoration: none;
}

/* Very narrow screens: the logo alone carries the brand so the actions fit */
@media (max-width: 340px) {
    .app-wordmark {
        display: none;
    }
}
