/* Games modal. Borrows the homepage's centred column and search shell, with
   everything centre-aligned rather than the left-aligned header the old page
   used. Sits below the browser overlay so launching a game covers it. */

.games,
.games *,
.games *::before,
.games *::after {
    box-sizing: border-box;
}

.games {
    position: fixed;
    inset: 0;
    z-index: 324897;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px 24px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
}

.games[hidden] {
    display: none;
}

body.games-open {
    overflow: hidden;
}

/* Never taller than the window: the header and pager stay put and only the
   grid scrolls. */
.games-panel {
    position: relative;
    display: flex;
    width: min(100%, 940px);
    max-height: 100%;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 26px 26px 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--bg-1);
}

.games-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--accent-muted);
    font-size: 0.78rem;
    cursor: pointer;
    transition: background-color 130ms ease, color 130ms ease;
}

.games-close:hover {
    background: var(--bg-3);
    color: var(--text-bright);
}

.games-title {
    margin: 0;
    color: var(--text-bright);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-align: center;
}

.games-count {
    margin: -12px 0 0;
    color: var(--accent-muted);
    font-size: 0.72rem;
    text-align: center;
}

.games-source {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-muted);
    font-size: 0.72rem;
}

.games-source-label {
    color: var(--accent-muted);
}

.games-source .dropdown {
    width: 116px;
}

.games-source .dropdown-trigger {
    height: 34px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-2);
    font-size: 0.78rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.games-source .dropdown-trigger:hover,
.games-source .dropdown.is-open .dropdown-trigger {
    border-color: var(--border-4);
    background: var(--bg-3);
}

.games-source .dropdown-trigger:focus-visible {
    border-color: var(--border-4);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

/* Same shell as the homepage search, sized down for the modal. */
.games-search {
    width: min(100%, 420px);
    min-height: 40px;
    padding-left: 14px;
}

.games-search .search-key {
    display: none;
}

.games-search-input {
    position: relative;
    z-index: 4;
    min-width: 0;
    flex: 1;
    padding: 4px 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text-bright);
    font-family: inherit;
    font-size: 0.88rem;
}

.games-search-input::placeholder {
    color: var(--accent-muted);
    opacity: 1;
}

.games-grid {
    display: grid;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
    grid-auto-rows: max-content;
    align-content: start;
    gap: 10px;
    justify-items: center;
    /* room for the hover lift, which the scroll box would otherwise clip */
    padding: 4px 4px 2px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}

.games-card {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    min-height: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-2);
    color: var(--accent-2);
    font-family: inherit;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 140ms ease;
}

.games-page-view {
    min-height: 100%;
    overflow: auto;
    background: var(--bg-1);
}

.games-page-panel {
    width: min(100%, 1080px);
    min-height: 100vh;
    max-height: none;
    margin: 0 auto;
    padding: 42px clamp(18px, 4vw, 52px) 28px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.games-page-panel .games-close {
    display: none;
}

.games-page-panel .games-grid {
    overflow: visible;
}

.games-card:hover,
.games-card:focus-visible {
    border-color: var(--border-4);
    outline: none;
}

.games-card.is-opening {
    opacity: 0.5;
    cursor: default;
}

.games-card-art {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--bg-4);
}

.games-card-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* The title is hidden until hover so the grid reads as pure cover art. */
.games-card-label {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 18px 7px 7px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 30%, rgba(0, 0, 0, 0));
    color: var(--text-bright);
    font-size: 0.66rem;
    line-height: 1.2;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 140ms ease, transform 140ms ease;
}

.games-card:hover .games-card-label,
.games-card:focus-visible .games-card-label {
    opacity: 1;
    transform: translateY(0);
}

.games-load-more {
    min-height: 34px;
    padding: 8px 14px;
    color: var(--accent-muted);
    font-size: 0.72rem;
    text-align: center;
}

.games-status {
    margin: 0;
    color: var(--accent-muted);
    font-size: 0.76rem;
    text-align: center;
}

.games-status[hidden] {
    display: none;
}

.games-status.is-error {
    color: #ff8a8a;
}

@media (max-width: 540px) {
    .games {
        padding: 12px;
    }

    .games-panel {
        padding: 22px 14px 18px;
        border-radius: 14px;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    }
}
