/* Каркас портала «Графит» и общие элементы страниц для игроков:
   левая панель, шапка, логотип «Глаза», подвал, вкладки на телефоне,
   кнопки, чипы, значки, заголовки, превью 16:9. Подключается поверх
   main.css только на страницах портала (styles.ejs, header.ejs).
   Макеты и решения — project_docs/portal_redesign.md. */

/* ===================== СТРАНИЦА ===================== */

.portal-body {
    display: block;
    font-family: var(--font-portal);
    font-size: 15px;
    line-height: 1.5;
    background-color: var(--layer-bg);
}

.portal-body a:hover {
    opacity: 1;
    color: var(--text-light);
}

.portal-body :focus-visible {
    outline: 2px solid var(--color-xp);
    outline-offset: 3px;
}

.portal-body button,
.portal-body input,
.portal-body textarea,
.portal-body select {
    font-family: inherit;
}

.portal {
    display: flex;
    min-height: 100vh;
}

.portal-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Колонка контента: одна ширина и одни поля у шапки, страниц и подвала. */
.wrap {
    width: 100%;
    max-width: 1320px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 40px;
    padding-right: 40px;
}

.page {
    flex: 1 0 auto;
    padding-top: 28px;
}

/* ===================== ЛОГОТИП ===================== */

.logo-link {
    color: var(--text-light);
}

.logo-word {
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.logo-dot {
    color: var(--color-xp);
}

/* Сам знак .logo-mark — в main.css: он же стоит в меню редактора. */

/* ===================== ЛЕВАЯ ПАНЕЛЬ ===================== */

.pp {
    position: sticky;
    top: 0;
    align-self: flex-start;
    flex: 0 0 auto;
    width: 250px;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 20px;
    background-color: var(--layer-basement);
    border-right: 1px solid var(--layer-2);
    transition: width 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.rail-closed .pp {
    width: 76px;
}

.pp-text {
    white-space: nowrap;
    transition: opacity 0.15s ease;
}

.rail-closed .pp-text {
    opacity: 0;
    pointer-events: none;
}

.pp-logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 72px;
    padding: 0 20px;
    font-size: 20px;
}

.pp-group {
    display: flex;
    flex-direction: column;
}

.pp-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 44px;
    padding: 0 28px;
    border: 0;
    background: transparent;
    color: var(--text-mute);
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.pp-item:hover,
.pp-item.is-active {
    color: var(--text-light);
    background-color: var(--layer-2);
}

.pp-item.is-active::after {
    content: "";
    position: absolute;
    right: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 3px 0 0 3px;
    background-color: var(--color-xp);
}

.portal-body .pp-item-projects {
    color: var(--color-attention);
}

.pp-icon {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pp-toggle {
    font-size: 13px;
}

.pp-toggle-icon {
    transition: transform 0.25s ease;
}

.rail-closed .pp-toggle-icon {
    transform: rotate(180deg);
}

.pp-library {
    gap: 2px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--layer-2);
}

.pp-head {
    margin: 0 20px 2px;
    font-size: 13px;
    font-weight: 800;
}

.pp-sub {
    margin: 8px 20px 2px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-mute);
}

/* Строка библиотеки: превью 48×27 — свёрнутая панель (76 px) вмещает
   его ровно с полями по 14 px. */
.pp-game {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 3px 14px;
    color: var(--text-light);
}

.pp-game:hover {
    background-color: var(--layer-1);
}

.pp-game-img {
    flex: 0 0 48px;
    width: 48px;
    height: 27px;
    border-radius: 5px;
}

.pp-game-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.pp-game-name,
.pp-game-author {
    overflow: hidden;
    text-overflow: ellipsis;
}

.pp-game-name {
    font-size: 13px;
    font-weight: 700;
}

.pp-game-author {
    font-size: 12px;
    color: var(--text-mute);
}

.pp-more {
    margin: 6px 20px 0;
    font-size: 13px;
    font-weight: 700;
}

.pp-guest p {
    margin: 12px 20px;
    font-size: 13px;
    color: var(--text-mute);
    white-space: normal;
}

.rail-closed .pp-guest {
    display: none;
}

.pp-bottom {
    margin-top: auto;
    padding-top: 16px;
}

/* ===================== ШАПКА ===================== */

.pt {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 18px 40px 0;
}

/* Логотип в шапке — только на телефоне, где нет панели. */
.pt-logo {
    display: none;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 18px;
}

.pt-logo .logo-mark {
    font-size: 32px;
}

.pt-tagline {
    font-size: 13px;
    color: var(--text-mute);
}

.pt-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-weight: 700;
}

.pt-user,
.pt-login {
    margin-left: auto;
}

.pt-user {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 14px 0 6px;
    border-radius: 8px;
    background-color: var(--layer-1);
    color: var(--text-light);
    font-weight: 700;
}

.pt-user:hover,
.pt-user.is-active {
    background-color: var(--layer-3);
}

.pt-avatar {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background-color: var(--layer-5);
    display: grid;
    place-items: center;
    font-weight: 800;
    object-fit: cover;
}

/* ===================== ПОДВАЛ ===================== */

.pf {
    margin-top: 80px;
    border-top: 1px solid var(--layer-2);
    background-color: var(--layer-basement);
}

.pf-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 32px 56px;
    padding-top: 44px;
    padding-bottom: 28px;
}

.pf-brand {
    flex: 2 1 280px;
}

.pf-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    font-size: 22px;
}

.pf-logo .logo-mark {
    font-size: 28px;
}

.pf-tagline {
    margin: 0;
    max-width: 44ch;
    font-size: 14px;
    color: var(--text-mute);
}

.pf-column {
    flex: 1 1 150px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pf-column a {
    color: var(--text-light);
}

.portal-body .pf-column a:hover {
    color: var(--color-corporate);
}

.pf-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-mute);
}

.pf-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    padding-top: 16px;
    padding-bottom: 26px;
    border-top: 1px solid var(--layer-2);
    font-size: 13px;
    color: var(--text-mute);
}

.pf-up {
    font-weight: 700;
}

/* Вкладки снизу — только на телефоне (медиазапрос ниже). */
.ptabs {
    display: none;
}

/* ===================== ОБЩИЕ ЭЛЕМЕНТЫ ===================== */

.page-title {
    margin: 0;
    font-size: 36px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.section-title {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    margin-bottom: 14px;
}

.muted {
    color: var(--text-mute);
}

.card {
    border-radius: 12px;
    background-color: var(--layer-1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 8px;
    background-color: var(--layer-3);
    color: var(--text-light);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: filter 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
    filter: brightness(1.12);
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.45;
    cursor: default;
    filter: none;
}

.btn-primary {
    background-color: var(--color-xp);
}

.btn-quiet {
    background-color: var(--layer-1);
}

.btn-icon {
    width: 44px;
    padding: 0;
}

.btn svg,
.icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn svg.is-fill {
    fill: currentColor;
    stroke: none;
}

/* Переключатель вариантов: «Все игры / Избранное», периоды топа,
   вкладки библиотеки. Выбранный — фиолетовый (aria-pressed/selected). */
.seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border-radius: 10px;
    background-color: var(--layer-1);
}

.seg-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-mute);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.seg-btn:hover {
    color: var(--text-light);
}

.seg-btn[aria-pressed="true"],
.seg-btn[aria-selected="true"],
.seg-btn.is-active {
    background-color: var(--color-xp);
    color: var(--text-light);
}

.seg-count {
    padding: 0 6px;
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.25);
    font-size: 12px;
}

/* Ряд кнопок-вкладок без подложки: сортировки, таблицы рекордов. */
.tabs-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tabs-row .seg-btn {
    background-color: var(--layer-1);
}

.tabs-row .seg-btn[aria-pressed="true"],
.tabs-row .seg-btn[aria-selected="true"] {
    background-color: var(--color-xp);
}

/* Чип: категория, фильтр. */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 16px;
    background-color: var(--layer-3);
    color: var(--text-light);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

a.chip:hover {
    background-color: var(--layer-4);
}

.chip-count {
    font-size: 12px;
    opacity: 0.7;
}

/* Значки на карточках: «Новинка», «Топ», «Для стримов». */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border-radius: 4px;
    background-color: var(--layer-5);
    color: var(--text-light);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.6;
    white-space: nowrap;
}

.badge-new {
    background-color: var(--color-xp);
}

.badge-updated {
    background-color: var(--color-corporate);
}

/* Тёмная плашка с синей рамкой — читается и на картинке, и на карточке. */
.badge-stream {
    background-color: var(--layer-basement);
    box-shadow: inset 0 0 0 1px var(--color-corporate);
}

.badge-stream svg {
    width: 12px;
    height: 12px;
    fill: none;
    stroke: var(--color-corporate);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Превью игры — всегда 16:9 целиком (project_docs/portal_redesign.md):
   меняется только ширина рамки. */
.preview-16x9 {
    display: block;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background-color: var(--layer-1);
}

.empty {
    margin: 0;
    padding: 44px 24px;
    border-radius: 12px;
    background-color: var(--layer-1);
    color: var(--text-mute);
    font-weight: 700;
    text-align: center;
}

.pager {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
}

.pager-btn {
    min-width: 44px;
    height: 44px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background-color: var(--layer-1);
    color: var(--text-light);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.pager-btn.is-active {
    background-color: var(--color-xp);
}

.pager-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.pager-gap {
    padding: 0 4px;
    color: var(--text-mute);
}

/* Появление блоков при загрузке страницы. */
@keyframes portal-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

/* backwards, не both: застывшая на последнем кадре анимация transform
   делает блок рамкой для position: fixed — развёрнутая сцена игры
   (js/game/player.js) встала бы внутри него, а не на весь экран. */
.rise {
    animation: portal-rise 0.48s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.v-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ===================== ТЕЛЕФОН =====================
   Панели нет: логотип в шапке, разделы — вкладками снизу; поля 16 px,
   ряды кнопок листаются вбок. */

@media (max-width: 760px) {
    .pp,
    .pt-tagline,
    .pt-user-name {
        display: none;
    }

    .pt-logo {
        display: inline-flex;
    }

    .pt {
        column-gap: 12px;
    }

    .pt-user {
        padding: 0 6px;
    }

    .pt-login {
        padding: 0 14px;
    }

    .wrap,
    .pt {
        padding-left: 16px;
        padding-right: 16px;
    }

    .portal-main {
        padding-bottom: 64px;
    }

    .ptabs {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        height: 64px;
        background-color: var(--layer-basement);
        border-top: 1px solid var(--layer-2);
    }

    .ptab {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: var(--text-mute);
        font-size: 11px;
        font-weight: 700;
    }

    .ptab.is-active {
        color: var(--text-light);
    }

    .ptab.is-active::before {
        content: "";
        position: absolute;
        top: 0;
        left: 50%;
        width: 32px;
        height: 3px;
        margin-left: -16px;
        border-radius: 0 0 3px 3px;
        background-color: var(--color-xp);
    }

    .ptab-icon {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .portal-body .cookie-bar {
        bottom: 64px;
    }

    .page-title {
        font-size: 28px;
    }

    .section-title {
        font-size: 22px;
    }

    .scroll-x {
        flex-wrap: nowrap;
        max-width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .scroll-x > * {
        flex: 0 0 auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .portal-body *,
    .portal-body *::before,
    .portal-body *::after {
        animation: none !important;
        transition: none !important;
    }
}
