/* ============================================================
   GAME LISTING — rules only /listing/games uses
   ============================================================
   Loaded after gaming-theme.css, and before the first paint only on
   that page (Helpers/PageStyles.cs). A rule belongs here while every
   class it needs is used by this page alone; once another page uses
   one, the rule moves to gaming-theme.css (PageStylesTests).
   ============================================================ */

/* --- Facet index (listing page internal linking) ---------- */
.gl-facet-index {
    max-width: 1280px;
    margin: 2rem auto 0;
    padding: 2rem 1.25rem;
    border-top: 1px solid var(--border);
}

.gl-facet-index-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 1.25rem;
    letter-spacing: -0.01em;
}

.gl-facet-index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem 2.5rem;
}

.gl-facet-index-heading {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0 0 0.65rem;
}

.gl-facet-index-list {
    list-style: none;
    padding: 0;
    margin: 0;
    columns: 2;
    column-gap: 1.25rem;
}

.gl-facet-index-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    break-inside: avoid;
    padding: 0.22rem 0;
}

.gl-facet-index-list a {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gl-facet-index-list a:hover { color: var(--accent); }

.gl-facet-index-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
    .gl-facet-index-list { columns: 1; }
}

/* --- Active filter chips bar ------------------------------ */
.gl-chips-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 2rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.gl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex: 1;
}

.gl-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-xl);
    background: rgba(124, 58, 237, 0.18);
    border: 1px solid rgba(124, 58, 237, 0.35);
    color: #c4b5fd;
    font-size: 0.775rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.gl-chip:hover { background: rgba(124, 58, 237, 0.28); border-color: rgba(124,58,237,0.55); }
.gl-chip span  { color: #a78bfa; font-size: 0.9rem; line-height: 1; }





.gl-clear-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.gl-clear-btn:hover { color: var(--text-secondary); }

/* --- Two-column layout ------------------------------------ */
.gl-layout {
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: 0;
    max-width: 1440px;
    margin: 0 auto;
    align-items: start;
    min-height: 60vh;
}

/* --- Sidebar ---------------------------------------------- */
/* The column surface is a pseudo-element that stretches the whole row, so
   the sidebar itself can be as tall as its content (and stick when it fits). */
.gl-layout::before {
    content: "";
    grid-column: 1;
    grid-row: 1;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
}

.gl-sidebar {
    position: relative;
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    padding: 0.5rem 0 2rem;
}

/* Added by gfStickyFit while the whole sidebar fits under the navbar: it then
   follows the visitor down the page. No inner scroll area in either state. */
.gl-sidebar.gl-sidebar-fits {
    position: sticky;
    top: 60px; /* below navbar */
    align-self: start;
}

/* Sidebar body wraps filter groups (flex child on mobile, plain block on desktop) */
.gl-sidebar-body { display: block; }

/* Mobile-only sidebar header, footer, backdrop — hidden on desktop */
.gl-sidebar-header,
.gl-sidebar-footer,
.gl-sidebar-backdrop { display: none; }

/* --- Filter groups as pills --------------------------------
   A group is a title row and a wrap of toggle pills (name + compact count).
   Selected = filled accent. Secondary groups fold behind a header row that
   shows what is selected while closed. */
.gl-sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 1.25rem 0.4rem; }
.gl-sidebar-top-title { font-family: 'Rajdhani', sans-serif; font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }

.gl-fg { padding: 0.6rem 1.25rem 0.9rem; border-bottom: 1px solid var(--border); }
.gl-fg-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.55rem; }
.gl-fg-title { margin: 0; font-family: 'Rajdhani', sans-serif; font-size: 1rem; font-weight: 700; letter-spacing: 0.01em; color: var(--text-primary); }
.gl-fg-clear { background: none; border: 0; padding: 0; font: inherit; font-size: 0.75rem; font-weight: 600; color: var(--accent-cyan); cursor: pointer; white-space: nowrap; }
.gl-fg-clear:hover { text-decoration: underline; }
.gl-fg-clear:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; border-radius: 3px; }

/* collapsible header */
.gl-fg-toggle { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; width: 100%; padding: 0.25rem 0; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; color: var(--text-primary); }
.gl-fg-toggle-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.gl-fg-summary { font-size: 0.75rem; color: var(--accent-cyan); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gl-fg-chevron { flex: none; width: 0.5rem; height: 0.5rem; border-right: 1.5px solid var(--text-muted); border-bottom: 1.5px solid var(--text-muted); transform: rotate(-45deg); transition: transform 0.15s; margin-right: 0.25rem; }
.gl-fg.is-open .gl-fg-chevron { transform: rotate(45deg); }
.gl-fg-toggle:hover .gl-fg-title { color: var(--accent-cyan); }
.gl-fg-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.gl-fg-toggle + .gl-fg-body { margin-top: 0.6rem; }
.gl-pill-score { min-width: 3.1rem; justify-content: center; font-variant-numeric: tabular-nums; }
.gl-fg-more { margin-top: 0.55rem; background: none; border: 0; padding: 0; font: inherit; font-size: 0.78rem; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.gl-fg-more:hover { color: var(--text-primary); }
.gl-fg-more:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; border-radius: 3px; }
.gl-fg-empty { display: block; font-size: 0.8rem; color: var(--text-muted); padding: 0.25rem 0; }

/* --- Year range inputs ------------------------------------- */
.gl-year-row { display: flex; align-items: flex-end; gap: 0.5rem; margin-top: 0.6rem; }
.gl-year-field { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.72rem; color: var(--text-muted); }
.gl-year-dash { color: var(--text-muted); padding-bottom: 0.55rem; }
.gl-year-input {
    width: 100%; height: 2.1rem; padding: 0 0.6rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-bright);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    -moz-appearance: textfield;
}
.gl-year-input::-webkit-inner-spin-button,
.gl-year-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.gl-year-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }

/* --- Main results area ------------------------------------- */
.gl-main {
    padding: 1.5rem 2rem 3rem;
    min-width: 0;
}

/* --- Results bar ------------------------------------------ */
.gl-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.gl-results-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.gl-results-count strong { color: var(--text-primary); font-weight: 600; }

.gl-shimmer-inline {
    display: inline-block;
    width: 60px;
    height: 1em;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--bg-elevated) 0%, var(--bg-card) 50%, var(--bg-elevated) 100%);
    background-size: 200% 100%;
    animation: gl-shimmer 1.4s linear infinite;
}

.gl-sort-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8375rem;
    color: var(--text-muted);
}

.gl-sort-select {
    appearance: none;
    -webkit-appearance: none;
    height: 2.25rem;
    background: var(--bg-elevated)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a96' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
        no-repeat right 0.7rem center;
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.8375rem;
    font-family: inherit;
    line-height: 1;
    padding: 0 2rem 0 0.75rem;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.gl-sort-select:focus { border-color: var(--accent); }
.gl-sort-select option { background: var(--bg-elevated); }

/* Counts are hidden while the sidebar still shows catalogue-wide numbers
   (the contextual ones arrive right after the circuit connects) */
.gl-facets-pending .gl-pill-count { visibility: hidden; }

/* Previous results stay visible, dimmed, while the next query runs */
.gl-grid-loading {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* --- Card meta helper ------------------------------------- */

/* --- Mobile filter toggle button (listing page) ----------- */
/* Hidden on desktop, shown on mobile via media query */
.gl-mobile-filter-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.25rem;
    padding: 0 0.875rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-bright);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.8375rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.gl-mobile-filter-btn.active {
    border-color: var(--accent);
    color: var(--accent-cyan);
    background: rgba(124,58,237,0.1);
}
.gl-mobile-filter-btn svg { flex-shrink: 0; }

/* ============================================================
   RESPONSIVE — TABLET  (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
    /* Listing layout: sidebar stacks above results */
    .gl-layout { grid-template-columns: 1fr; }

    .gl-layout::before { display: none; }
    .gl-sidebar,
    .gl-sidebar.gl-sidebar-fits {
        position: static;
        grid-column: auto;
        grid-row: auto;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border);
        top: auto;
    }
}

@media (max-width: 640px) {

    /* Sidebar becomes a full-screen overlay sheet when toggled; the sheet has
       its own header, so the desktop title row is hidden */
    .gl-sidebar-top { display: none; }
    .gl-sidebar {
        display: none;
        border-bottom: none;
        border-right: none;
    }
    .gl-sidebar.gl-sidebar-open,
    .gl-sidebar.gl-sidebar-open.gl-sidebar-fits {
        display: flex;
        flex-direction: column;
        position: fixed;
        align-self: auto;                     /* let top/bottom stretch the sheet */
        top: 56px;                            /* below mobile nav */
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 85;
        padding: 0;
        background: var(--bg-surface);
        border: none;
        animation: gl-sheet-up 0.22s ease;
    }
    .gl-sidebar.gl-sidebar-open .gl-sidebar-body {
        display: block;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.25rem 0 0.5rem;
    }

    /* Sidebar header + footer become visible on mobile */
    .gl-sidebar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.875rem 1.25rem;
        border-bottom: 1px solid var(--border);
        background: var(--bg-surface);
        position: sticky;
        top: 0;
        z-index: 2;
    }
    .gl-sidebar-header-title {
        font-family: 'Rajdhani', sans-serif;
        font-size: 1.1rem;
        font-weight: 700;
        letter-spacing: 0.01em;
    }
    .gl-sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: var(--radius-md);
        border: 1px solid var(--border);
        background: var(--bg-elevated);
        color: var(--text-secondary);
        cursor: pointer;
        padding: 0;
        transition: var(--transition);
    }
    .gl-sidebar-close:hover {
        color: var(--text-primary);
        border-color: var(--border-bright);
    }

    .gl-sidebar-footer {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
        border-top: 1px solid var(--border);
        background: var(--bg-surface);
        position: sticky;
        bottom: 0;
    }
    .gl-sidebar-clear-btn {
        flex-shrink: 0;
        padding: 0.75rem 0.875rem;
        background: transparent;
        border: 1px solid var(--border-bright);
        color: var(--text-secondary);
        font-size: 0.875rem;
        font-family: inherit;
        font-weight: 500;
        border-radius: var(--radius-md);
        cursor: pointer;
        transition: var(--transition);
    }
    .gl-sidebar-clear-btn:hover:not(:disabled) {
        color: var(--text-primary);
        border-color: var(--border-bright);
        background: var(--bg-elevated);
    }
    .gl-sidebar-clear-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }
    .gl-sidebar-apply-btn {
        flex: 1;
        justify-content: center;
        padding: 0.85rem 1.25rem;
        font-size: 0.95rem;
    }

    /* Backdrop behind the sheet */
    .gl-sidebar-backdrop {
        display: block;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(2px);
        z-index: 84;
        animation: gn-fade-in 0.15s ease;
    }
    .gl-fg { padding: 0.85rem 1.25rem 1.1rem; }
    .gl-fg-toggle { padding: 0.4rem 0; }
    .gl-year-input { padding: 0.625rem 0.75rem; font-size: 16px; }

    /* Show mobile filter toggle button */
    .gl-mobile-filter-btn { display: flex; }

    /* Main area */
    .gl-main { padding: 1rem 0.875rem 2rem; }

    /* Results bar */
    /* Results bar on phones: the count on its own line, then the Filters
       button and the sort dropdown side by side at the same height. */
    .gl-results-bar { gap: 0.625rem; }
    .gl-results-count { order: -1; flex: 1 0 100%; }
    .gl-mobile-filter-btn { flex: 0 0 auto; }
    .gl-sort-wrap { flex: 1 1 auto; min-width: 0; }
    .gl-sort-wrap label { display: none; } /* hide "Sort:" label */
    .gl-sort-select { width: 100%; }

    /* Active chips: smaller text */
    .gl-chip { font-size: 0.725rem; padding: 0.2rem 0.5rem; }
    .gl-chips-bar { padding: 0.5rem 1rem; }
}
