/* ─── Page header ────────────────────────────────────────────────────────── */

.page-list__header {
    padding: var(--space-8) 0 var(--space-6);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--space-8);
}

/* Mobile-first: title + search hidden on phones (≤768px block below) —
   Filters and Sort share a row instead. */
.page-list__topbar {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.page-list__title {
    font-family: var(--font-heading);
    font-size: var(--text-3xl);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

/* ─── Search ──────────────────────────────────────────────────────────────── */

.page-list__search {
    display: flex;
    align-items: center;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    transition: border-color var(--duration-fast) var(--ease);
}

.page-list__search:focus-within {
    border-color: var(--accent-gold);
}

.page-list__search-input {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0 var(--space-3);
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.page-list__search-input::placeholder {
    color: var(--text-muted);
}

.page-list__search-input::-webkit-search-cancel-button {
    display: none;
}

.page-list__search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    color: var(--text-muted);
    border-left: 1px solid var(--border-light);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    transition:
        color            var(--duration-fast) var(--ease),
        background-color var(--duration-fast) var(--ease),
        border-color     var(--duration-fast) var(--ease);
}

/* Divider inside the focused search bar softens to match the gold ring */
.page-list__search:focus-within .page-list__search-btn {
    border-color: var(--border-medium);
}

.page-list__search-btn:hover {
    color: var(--text-primary);
    background-color: var(--surface-hover);
}

.page-list__search-btn:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: -2px;
}

/* ─── Sort ────────────────────────────────────────────────────────────────── */

.page-list__sort-form {
    display: flex;
}

/* Override the shared form-field__select's width: 100% so it sizes to its
   content within the row. padding-block (rather than a fixed height) keeps
   it sizing the same way the shared component does, so its border,
   background and arrow stay aligned with the text at every breakpoint. */
.page-list__sort {
    width: auto;
    padding-block: var(--space-2);
    font-size: var(--text-sm);
}

/* ─── Desktop: single row ─────────────────────────────────────────────────── */

@media (min-width: 769px) {
    .page-list__topbar {
        flex-direction: row;
        align-items: center;
        gap: var(--space-4);
    }

    .page-list__title {
        flex-shrink: 0;
    }

    .page-list__search {
        flex: 1;
    }

    .page-list__sort-form {
        flex-shrink: 0;
    }
}

/* ─── Phones (≤768px): title + search give way to the navbar search icon —
   Filters and Sort fill the row 50/50 at a consistent touch-friendly
   height. ──────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .page-list__title,
    .page-list__search {
        display: none;
    }

    .page-list__topbar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-3);
    }

    .page-list__topbar .filter-toolbar__toggle {
        width: 100%;
        justify-content: center;
    }

    .page-list__sort-form,
    .page-list__sort {
        width: 100%;
    }
}

/* ─── HTMX results loading indicator ─────────────────────────────────────── */

.results-loading-bar {
    /* Thin bar that spans the full results column width. */
    height: 2px;
    background-color: var(--accent-gold);
    /* Hidden by default — HTMX adds .htmx-request while a request is in flight. */
    width: 0;
    opacity: 0;
    transition:
        opacity var(--duration-fast) var(--ease),
        width 600ms var(--ease);
}

.results-loading-bar.htmx-request {
    opacity: 1;
    width: 100%;
}

/* ─── Body layout ─────────────────────────────────────────────────────────── */

.page-list__body {
    padding-bottom: var(--space-16);
}

.page-list__sidebar { display: none; }

@media (min-width: 1024px) {
    .page-list__body {
        display: grid;
        grid-template-columns: var(--width-sidebar) 1fr;
        gap: var(--space-12);
        align-items: start;
    }

    /* Allow the results column to shrink below its content's intrinsic
       width — otherwise the single-row chip scroller (which never wraps)
       forces this grid track, and the whole page, to overflow horizontally. */
    .page-list__results {
        min-width: 0;
    }

    .page-list__sidebar {
        display: block;
        position: sticky;
        /* Clear the fixed navbar (--navbar-height) plus breathing room */
        top: calc(var(--navbar-height) + var(--space-4));
        max-height: calc(100vh - var(--navbar-height) - var(--space-8));
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--border-medium) transparent;
        padding-right: var(--space-2);
    }
}
