/**
 * TBB Quiz Relabel — course listings.
 *
 * Loaded only on the three listing surfaces (Test Series page, quiz-category
 * archives, course-tag archives) and scoped to the `tbb-quiz-listing` body
 * class added by TBB_Quiz_Relabel, so a stray enqueue elsewhere applies nothing.
 *
 * One job: hide Tutor's sort dropdown ("Release Date (newest first)",
 * "Course Title (a-z)", …) while leaving the left filter sidebar alone.
 *
 * ---------------------------------------------------------------------------
 * THE MARKUP (Tutor 4.0.4, archive-course.php — verified in DevTools)
 * ---------------------------------------------------------------------------
 *   <div class="tutor-course-filter" style="text-align: right;" tutor-course-filter>
 *     <form style="display: inline-block;">
 *       <select class="tutor-form-select" name="course_order" style="display:none">…</select>
 *       <div class="tutor-form-control tutor-form-select tutor-js-form-select">…</div>
 *     </form>
 *   </div>
 *   <br>
 *
 * Two things that cost two failed attempts, so read them before editing:
 *
 * 1. ⚠️ `.tutor-course-filter` ALONE IS NOT THE SORT DROPDOWN. Tutor puts that
 *    class on two elements: this wrapper, and one inside the left sidebar that
 *    holds the Exam/Subject checkboxes (the sidebar's outer column is
 *    `.tutor-course-filter-container`). A bare `.tutor-course-filter
 *    { display: none }` hides the checkbox filters too.
 *
 * 2. The <select> is a GRANDCHILD — it sits inside a <form>, not directly in
 *    the wrapper — so a `> select` child selector matches nothing.
 *
 * What reliably identifies the sort control is `name="course_order"`. The
 * sidebar filter is checkboxes, so neither rule below can reach it.
 *
 * The node is hidden rather than removed in PHP because Tutor's own source
 * comment on it says "Do not remove tutor-course-filter attr. It required by
 * _archive.js for filter function." — it has to stay in the DOM for the sidebar
 * filters and pagination to keep working.
 *
 * The trailing <br> is deliberately left alone (a few px of blank line above
 * the first card), and the wrapper is hidden with `visibility` rather than
 * `display` so the card grid keeps its original vertical position — see the
 * rule comments below.
 */

/**
 * Hide the sort control but KEEP ITS ~40px BOX IN FLOW.
 *
 * ⚠️ `visibility: hidden`, not `display: none` — deliberate, don't "tidy" it.
 * This wrapper is the first thing in the right-hand column, so removing it from
 * layout pulls the whole card grid up by its height while the left sidebar
 * stays where it is, and the two columns stop lining up. `visibility` keeps the
 * space, so the page looks exactly as it did before the control was hidden.
 * Hidden this way it is also unclickable and out of the tab order.
 *
 * !important is belt-and-braces: Tutor's script sets inline *display* on this
 * wrapper at some breakpoints and never touches visibility, so a plain rule
 * would do — but the two properties are easy to confuse when editing.
 */
.tbb-quiz-listing .tutor-course-filter:has( select[name="course_order"] ) {
	visibility: hidden !important;
}

/**
 * Fallback for browsers without :has() (Chrome < 105, Safari < 15.4,
 * Firefox < 121).
 *
 * Tutor's JS hides the native <select> and renders `.tutor-js-form-select` as
 * its next sibling — that div is the thing actually on screen. A plain sibling
 * combinator needs no :has() support, and being anchored to the course_order
 * select it still cannot touch the sidebar.
 *
 * Also `visibility`, for the same reason as above: the div keeps its box, so
 * the wrapper keeps its height and the grid does not shift on old browsers
 * either. (Where :has() works this rule is redundant — visibility inherits from
 * the hidden wrapper — but it costs nothing.)
 */
.tbb-quiz-listing select[name="course_order"] ~ .tutor-js-form-select {
	visibility: hidden !important;
}
