/* =============================================================================
 * Channel grid header — where the sort control lives.
 * Top-right of the grid section, above the tiles. Title on the left
 * ("Videos 1,234"), sort dropdown on the right.
 * ============================================================================= */
.alts-channel-grid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    max-width: 1600px;    /* align with .alts-channel-grid */
    margin: 0 auto 24px;
    padding: 0;           /* padding lives on .alts-channel-grid-section */
    flex-wrap: wrap;
}

.alts-channel-grid-title {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #ffffff;
}

.alts-channel-grid-title-main {
    color: #ffffff;
}

.alts-channel-grid-title-count {
    font-size: 14px;
    font-weight: 400;
    color: #8a8a8a;
    font-variant-numeric: tabular-nums;
}

/* -----------------------------------------------------------------------------
 * Sort dropdown — a button that reveals a listbox of options.
 * --------------------------------------------------------------------------- */
.alts-sort-control {
    position: relative;
    z-index: 30;   /* above tiles, below the channel header */
}

.alts-sort-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    min-height: 36px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
    white-space: nowrap;
}
.alts-sort-toggle:hover,
.alts-sort-toggle:focus-visible,
.alts-sort-control.is-open .alts-sort-toggle {
    background: rgba(191, 255, 0, 0.08);
    border-color: rgba(191, 255, 0, 0.4);
    color: #BFFF00;
    outline: none;
}

.alts-sort-toggle-label {
    color: #8a8a8a;
    font-weight: 400;
}
.alts-sort-toggle:hover .alts-sort-toggle-label,
.alts-sort-toggle:focus-visible .alts-sort-toggle-label,
.alts-sort-control.is-open .alts-sort-toggle-label {
    color: inherit;
}

.alts-sort-toggle-value {
    font-weight: 600;
    color: #BFFF00;     /* highlight the currently-selected sort */
}

.alts-sort-toggle-caret {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.alts-sort-control.is-open .alts-sort-toggle-caret {
    transform: rotate(180deg);
}

/* -----------------------------------------------------------------------------
 * Dropdown menu (hidden until toggle is pressed).
 * --------------------------------------------------------------------------- */
.alts-sort-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    list-style: none;
    margin: 0;
    padding: 6px;
    background: #0f0f0f;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    box-shadow:
        0 12px 32px -8px rgba(0, 0, 0, 0.85),
        0 0 0 1px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    transition:
        opacity 0.15s ease,
        transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.alts-sort-menu[hidden] {
    display: none;
}
.alts-sort-control.is-open .alts-sort-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.alts-sort-option {
    display: grid;
    grid-template-columns: 18px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s ease, color 0.12s ease;
    color: #e5e5e5;
}
.alts-sort-option:hover,
.alts-sort-option:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    outline: none;
}
.alts-sort-option.is-active {
    color: #BFFF00;
}

.alts-sort-check {
    opacity: 0;
    color: #BFFF00;
    transition: opacity 0.12s ease;
}
.alts-sort-option.is-active .alts-sort-check {
    opacity: 1;
}

.alts-sort-option-label {
    font-size: 14px;
    font-weight: 500;
}

.alts-sort-option-hint {
    font-size: 12px;
    color: #8a8a8a;
    grid-column: 2;
    font-weight: 400;
    /* subtle — appears below the label on narrower lines */
}
.alts-sort-option.is-active .alts-sort-option-hint {
    color: rgba(191, 255, 0, 0.6);
}

/* -----------------------------------------------------------------------------
 * FLIP animation for tile re-ordering.
 * Tiles get a transform during the "invert" phase, then smoothly transition
 * back to transform: none during the "play" phase.
 * --------------------------------------------------------------------------- */
.alts-channel-tile.is-flipping {
    /* smooth slide into new position */
    transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
    /* Float above neighbors during animation so overlaps look clean */
    z-index: 2;
}

/* -----------------------------------------------------------------------------
 * Mobile responsive — sort control stacks below title, goes full-width.
 * --------------------------------------------------------------------------- */
@media (max-width: 640px) {
    .alts-channel-grid-header {
        gap: 12px;
    }
    .alts-sort-control {
        width: 100%;
    }
    .alts-sort-toggle {
        width: 100%;
        justify-content: space-between;
    }
    .alts-sort-menu {
        left: 0;
        right: 0;
        min-width: 0;
    }
}
