/* =========================================================================
   PSTrophy — дизайн-токены и базовые компоненты (header, theme, search).
   Стили страниц добавляются inline в .cshtml.
   ========================================================================= */

/* ── DARK THEME (default) ──────────────────────────────────────── */
:root {
    /* surfaces */
    --bg:          #0b0b0e;
    --surface:     #131318;
    --card:        #1a1a21;
    --card-hi:     #20202a;
    --border:      #2a2a36;
    --border-hi:   #3a3a48;

    /* text */
    --text:        #f3f3f5;
    --text-2:      #c7c7d0;
    --text-3:      #8d8d99;
    --text-4:      #5a5a66;

    /* brand */
    --accent:      #ff6a3d;
    --accent-2:    #ff8b66;

    /* trophy palette */
    --platinum:    #e6e6f0;
    --gold:        #ffc74a;
    --silver:      #c8ccd2;
    --bronze:      #cd7f3f;

    /* metal-as-text (readable ink variants) — dark theme: same as the metal */
    --platinum-ink: #e6e6f0;
    --silver-ink:   #c8ccd2;

    /* radii */
    --r-sm:   8px;
    --r-md:   12px;
    --r-lg:   16px;
    --r-xl:   22px;
    --r-pill: 999px;

    /* overlays / shadows */
    --hero-glow:  rgba(255, 106, 61, .08);
    --vis-shadow: 0 30px 60px -20px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.02) inset;
    --hm-empty:   #1c1c24;
    --me-bg:      rgba(255, 106, 61, .08);
    --me-border:  rgba(255, 106, 61, .25);
}

/* ── LIGHT THEME ───────────────────────────────────────────────── */
[data-theme="light"] {
    --bg:          #f5f3ec;
    --surface:     #ffffff;
    --card:        #ffffff;
    --card-hi:     #f3f0e8;
    --border:      #e4e0d6;
    --border-hi:   #cdc8bc;

    --text:        #161618;
    --text-2:      #44444c;
    --text-3:      #7a7a82;
    --text-4:      #b0b0b6;

    --accent:      #d4561f;
    --accent-2:    #ec6c34;

    /* metal-as-text — light theme: darker steel/graphite so metals stay readable on cream */
    --platinum-ink: #5c5c78;
    --silver-ink:   #8a8f99;

    --hero-glow:  rgba(212, 86, 31, .07);
    --vis-shadow: 0 24px 48px -20px rgba(40,30,20,.18), 0 0 0 1px rgba(0,0,0,.02) inset;
    --hm-empty:   #ece9df;
    --me-bg:      rgba(212, 86, 31, .08);
    --me-border:  rgba(212, 86, 31, .3);
}

/* ── BASE ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "ss01", "cv11";
}

body { min-height: 100vh; }

/* Место под полосу прокрутки зарезервировано всегда: модалки на время показа
   вешают body { overflow: hidden }, и без этого страница под оверлеем
   прыгала бы вбок на ширину исчезнувшего скроллбара. */
html { scrollbar-gutter: stable; }

a { color: inherit; }

/* ── APP CONTAINER ─────────────────────────────────────────────── */
.psn-app {
    max-width: 1440px;
    margin: 0 auto;
    background: var(--bg);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.psn-app > main { flex: 1 0 auto; }

/* ── APP FOOTER ────────────────────────────────────────────────── */
.psn-footer {
    flex-shrink: 0;
    margin-top: 48px;
    padding: 28px 22px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px 24px;
}
.psn-footer__brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font: 700 14px "Space Grotesk", "Inter", sans-serif;
    letter-spacing: -.01em;
    color: var(--text);
}
.psn-footer__star { color: var(--accent); }
.psn-footer__nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 20px;
}
.psn-footer__nav a {
    font: 500 13px "Inter", sans-serif;
    color: var(--text-3);
    text-decoration: none;
    transition: color .15s;
}
.psn-footer__nav a:hover { color: var(--text); }
.psn-footer__copy {
    font: 400 12px "JetBrains Mono", monospace;
    color: var(--text-4);
    letter-spacing: .02em;
    white-space: nowrap;
}

@media (max-width: 560px) {
    .psn-footer { flex-direction: column; align-items: flex-start; gap: 16px; }
}

/* ── APP HEADER ────────────────────────────────────────────────── */
.psn-header {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 22px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* logo */
.psn-logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    text-decoration: none;
    color: inherit;
}
.psn-logo__mark {
    width: 40px; height: 40px; border-radius: 11px;
    background: var(--text); color: var(--bg);
    display: inline-flex; align-items: center; justify-content: center;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 800; font-size: 24px;
    line-height: 1; letter-spacing: -.02em;
    position: relative;
}
.psn-logo__star {
    position: absolute; top: 5px; right: 6px;
    color: var(--accent); font-size: 11px; line-height: 1;
}
.psn-logo__col { display: flex; flex-direction: column; }
.psn-logo__name {
    font-family: "Inter", sans-serif;
    font-weight: 800; font-size: 19px;
    letter-spacing: -.015em; line-height: 1;
}

/* primary nav */
.psn-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.psn-nav a {
    font-family: "Inter", sans-serif;
    font-weight: 600; font-size: 14px;
    color: var(--text-2);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--r-pill);
    line-height: 1;
    transition: .15s;
}
.psn-nav a:hover { background: var(--card); color: var(--text); }
.psn-nav a.active { color: var(--text); background: var(--card); }

/* search */
.psn-search {
    flex: 1; max-width: 540px; margin: 0 auto;
    display: flex; align-items: center; gap: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    padding: 9px 16px;
    font-family: "Inter", sans-serif;
    font-size: 13.5px; color: var(--text-3);
    transition: .15s;
    position: relative;
}
.psn-search:focus-within,
.psn-search:hover {
    border-color: var(--border-hi);
    background: var(--card-hi);
}
.psn-search > svg { flex-shrink: 0; color: var(--text-3); }
.psn-search input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text); font: inherit; padding: 0;
}
.psn-search input::placeholder { color: var(--text-3); }
/* нативный крестик очистки (Chrome/Edge) — красим в цвет темы вместо синего дефолта */
.psn-search input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    width: 13px; height: 13px;
    cursor: pointer;
    background-color: var(--text-3);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6 18 18M18 6 6 18' stroke='black' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6 18 18M18 6 6 18' stroke='black' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: background-color .15s;
}
.psn-search input[type="search"]::-webkit-search-cancel-button:hover { background-color: var(--text); }

/* search dropdown — переписан под токены */
.header-search__dropdown {
    position: absolute;
    top: calc(100% + 6px); left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--vis-shadow);
    max-height: 460px;
    overflow-y: auto;
    z-index: 200;
    display: none;
    padding: 6px 0;
}
.header-search__dropdown--visible { display: block; }
.header-search__section-title {
    font-family: "JetBrains Mono", monospace;
    font-size: 9.5px;
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: .12em;
    color: var(--text-3);
    padding: 8px 16px 4px;
}
.header-search__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    color: var(--text);
    text-decoration: none;
    transition: .1s;
}
.header-search__item:hover,
.header-search__item--active {
    background: var(--card-hi);
    color: var(--text);
}
.header-search__icon {
    width: 32px; height: 32px;
    border-radius: var(--r-sm);
    object-fit: cover;
    background: var(--card-hi);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.header-search__icon--round { border-radius: 50%; }
.header-search__item-name {
    font-weight: 500; font-size: 13.5px;
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* колонка платформ игры — прижата к правому краю строки */
.header-search__plats {
    display: flex; gap: 4px; flex-wrap: wrap;
    justify-content: flex-end;
    flex-shrink: 0;
    max-width: 45%;
}
.header-search__plat {
    font: 700 8.5px "JetBrains Mono", monospace;
    letter-spacing: .06em;
    color: var(--text-3);
    background: var(--card-hi);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    white-space: nowrap;
}
.header-search__empty {
    padding: 16px;
    color: var(--text-3);
    text-align: center;
    font-size: 12.5px;
}
.header-search__hint {
    padding: 0 16px 8px;
    color: var(--text-3);
    text-align: center;
    font-size: 11.5px;
}
.header-search__add {
    display: block;
    width: calc(100% - 24px);
    margin: 0 12px 8px;
    padding: 9px 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-sm);
    font: 600 12.5px "Inter", sans-serif;
    cursor: pointer;
    transition: .15s;
}
.header-search__add:hover,
.header-search__add.header-search__item--active { background: var(--accent-2); }
.header-search__add:disabled { opacity: .6; cursor: default; }

/* header right */
.psn-header__right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* icon-btn (theme toggle, bell) */
.psn-icon-btn {
    width: 36px; height: 36px;
    border-radius: var(--r-pill);
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: .15s;
    position: relative;
    padding: 0;
    text-decoration: none;
}
.psn-icon-btn:hover {
    background: var(--card-hi);
    color: var(--text);
    border-color: var(--border-hi);
}
.psn-icon-btn__dot {
    position: absolute; top: 7px; right: 8px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface);
}

/* btn */
.psn-btn {
    font-family: "Inter", sans-serif;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: -.005em;
    padding: 9px 18px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    transition: .15s;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    text-decoration: none;
}
.psn-btn:hover {
    background: var(--card-hi);
    border-color: var(--border-hi);
    color: var(--text);
}
.psn-btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.psn-btn--primary:hover {
    background: var(--accent-2);
    border-color: var(--accent-2);
    color: #fff;
}
.psn-btn--lg { font-size: 14px; padding: 13px 22px; }
.psn-btn svg { width: 14px; height: 14px; }

/* user-pill */
.psn-user {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 3px 11px 3px 3px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--card);
    cursor: pointer;
    transition: .15s;
    text-decoration: none;
    color: inherit;
    font: inherit;
}
.psn-user:hover {
    background: var(--card-hi);
    border-color: var(--border-hi);
}
.psn-menu.open .psn-user {
    background: var(--card-hi);
    border-color: var(--border-hi);
}
.psn-user__av {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-family: "Inter", sans-serif;
    font-weight: 700;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.psn-user__av img {
    width: 100%; height: 100%; object-fit: cover;
}
.psn-user__col { display: flex; flex-direction: column; line-height: 1.15; }
.psn-user__nm { font-weight: 600; font-size: 13.5px; letter-spacing: -.01em; color: var(--text); }
.psn-user__lv {
    font-family: "JetBrains Mono", monospace;
    font-size: 9.5px;
    color: var(--text-3);
    letter-spacing: .08em;
    margin-top: 1px;
}
.psn-user__plan {
    font-family: "JetBrains Mono", monospace;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .1em;
    padding: 3px 7px;
    border-radius: 5px;
    line-height: 1;
    text-transform: uppercase;
}
.psn-user__plan--premium {
    background: linear-gradient(135deg, #ffd66b, #f0a63c);
    color: #3a2607;
    box-shadow: 0 0 0 1px rgba(240,166,60,.35);
}
.psn-user__plan--free {
    background: var(--card-hi);
    color: var(--text-3);
    box-shadow: inset 0 0 0 1px var(--border-hi);
}
.psn-user__chev { color: var(--text-3); font-size: 9px; margin-left: 1px; transition: transform .15s; }
.psn-menu.open .psn-user__chev { transform: rotate(180deg); }

/* logout form внутри user-pill, ничего не сломаем */
.psn-logout-form {
    display: inline; margin: 0; padding: 0;
}

/* ── USER-MENU DROPDOWN ────────────────────────────────────────── */
.psn-menu { position: relative; display: inline-flex; }
.psn-dd {
    position: absolute; top: calc(100% + 8px); right: 0; min-width: 236px; z-index: 60;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg);
    box-shadow: 0 12px 32px rgba(0,0,0,.28); padding: 14px;
    opacity: 0; visibility: hidden; transform: translateY(-4px) scale(.98);
    transition: opacity .14s, transform .14s, visibility .14s;
}
[data-theme="light"] .psn-dd { box-shadow: 0 12px 32px rgba(40,30,20,.14); }
.psn-menu.open .psn-dd { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.psn-dd__label {
    font-family: "JetBrains Mono", monospace; font-size: 9.5px; font-weight: 600; letter-spacing: .1em;
    color: var(--text-3); text-transform: uppercase; padding: 0 2px 10px;
}
.psn-dd__accounts { display: flex; gap: 10px; padding: 0 2px 4px; flex-wrap: wrap; }
.psn-dd__acc {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-decoration: none; width: 56px; flex-shrink: 0;
}
.psn-dd__acc-ic {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: "Inter", sans-serif; font-weight: 700; font-size: 15px; color: #fff;
    border: 2px solid transparent; transition: .15s; overflow: hidden; position: relative;
}
.psn-dd__acc-ic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.psn-dd__acc:hover .psn-dd__acc-ic { border-color: var(--border-hi); transform: translateY(-1px); }
.psn-dd__acc.is-main .psn-dd__acc-ic { box-shadow: 0 0 0 2px var(--me-bg), 0 0 0 3px var(--me-border); }
.psn-dd__acc-tx {
    font-family: "JetBrains Mono", monospace; font-size: 9.5px; color: var(--text-3);
    max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.psn-dd__acc:hover .psn-dd__acc-tx { color: var(--text-2); }
.psn-dd__acc--add .psn-dd__acc-ic {
    background: none; border: 1.5px dashed var(--border-hi); color: var(--text-3); font-size: 19px; font-weight: 300;
}
.psn-dd__acc--add:hover .psn-dd__acc-ic { border-color: var(--accent); color: var(--accent); transform: none; }
.psn-dd__acc--locked .psn-dd__acc-ic {
    background: repeating-linear-gradient(135deg, var(--card-hi) 0 6px, var(--bg) 6px 12px);
    border: 1.5px dashed var(--border-hi); color: var(--text-3);
}
.psn-dd__acc--locked .psn-dd__acc-ic svg { width: 15px; height: 15px; }
.psn-dd__acc--locked:hover .psn-dd__acc-ic { border-color: var(--accent); color: var(--accent); transform: none; }
.psn-dd__acc--locked .psn-dd__acc-tx { color: var(--accent); }
.psn-dd__sep { height: 1px; background: var(--border); margin: 10px 2px; }
.psn-dd__logout { margin: 0; }
.psn-dd__item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 10px; border-radius: var(--r-md);
    background: none; border: none; text-decoration: none; cursor: pointer; text-align: left;
    font-family: "Inter", sans-serif; font-weight: 600; font-size: 13.5px; color: var(--text-2); transition: .12s;
}
.psn-dd__item svg { flex-shrink: 0; color: var(--text-3); transition: .12s; }
.psn-dd__item:hover { background: var(--card-hi); color: var(--text); }
.psn-dd__item:hover svg { color: var(--text); }
.psn-dd__item--danger:hover { background: rgba(255,90,90,.1); color: #ff6a6a; }
.psn-dd__item--danger:hover svg { color: #ff6a6a; }

/* ── THEME TOGGLE ICONS ────────────────────────────────────────── */
.psn-theme-toggle .ic-sun  { display: none; }
.psn-theme-toggle .ic-moon { display: block; }
[data-theme="light"] .psn-theme-toggle .ic-sun  { display: block; }
[data-theme="light"] .psn-theme-toggle .ic-moon { display: none; }

/* ── RESPONSIVE ────────────────────────────────────────────────── */
@media (max-width: 820px) {
    .psn-header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 14px;
    }
    .psn-logo { order: 1; }
    .psn-logo__mark {
        width: 36px; height: 36px;
        font-size: 21px; border-radius: 10px;
    }
    .psn-logo__star { font-size: 9px; top: 4px; right: 5px; }
    .psn-logo__name { font-size: 16px; }

    .psn-nav { display: none; }

    .psn-header__right { order: 2; margin-left: auto; gap: 6px; }
    .psn-icon-btn { width: 34px; height: 34px; }
    .psn-btn { font-size: 12.5px; padding: 8px 14px; }
    .psn-btn--primary { padding: 8px 16px; }
    .psn-user { padding: 4px; }
    .psn-user__col, .psn-user__nm, .psn-user__plan, .psn-user__chev { display: none; }
    .psn-dd { right: -6px; }

    .psn-search {
        order: 3;
        flex-basis: 100%;
        max-width: 100%;
        margin: 0;
        padding: 8px 14px;
        font-size: 13px;
    }
    /* iOS Safari масштабирует страницу при фокусе на input с font-size < 16px.
       Сам инпут держим на 16px (визуально почти как 13px контейнера), иконка/лейаут — из .psn-search. */
    .psn-search input { font-size: 16px; }
}

@media (max-width: 520px) {
    .psn-icon-btn { width: 32px; height: 32px; }
    .psn-btn { font-size: 12px; padding: 7px 12px; }
}
