/**
 * Courses page (/courses/) and class pages (/class/{slug}/) — Phase 10.2–10.3.
 * Loaded only there (inc/assets.php). The course card itself is in components.css (10.1).
 */

/* ---- Course list section (10.2.2); the grid itself is in components.css. */
.pgs-courses {
	padding-top: clamp(40px, 6vw, 64px);
}

/* ---- Result count + clear search (10.2.3) ---- */
.pgs-courses__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 16px;
	margin-bottom: 24px;
}

.pgs-courses__count {
	margin: 0;
	color: var(--pgs-text-muted);
	font-size: var(--pgs-fs-small);
}

.pgs-courses__count strong {
	color: var(--pgs-text);
}

.pgs-courses__clear {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	color: var(--pgs-link);
	font-size: var(--pgs-fs-small);
	font-weight: 600;
}

.pgs-courses__clear .pgs-icon {
	width: 16px;
	height: 16px;
}

/* ---- Help band (10.2.5): mint strip under the list ---- */
.pgs-courses:has(+ [data-course-help] .pgs-courses-help) {
	padding-bottom: clamp(32px, 5vw, 48px);
}

.pgs-courses-help {
	padding-top: 0;
}

.pgs-help-band {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	align-items: center;
	gap: 16px 20px;
	padding: clamp(20px, 4vw, 32px);
	border: 1px solid var(--pgs-accent-border);
	border-radius: var(--pgs-radius);
	background: var(--pgs-mint);
}

.pgs-help-band__icon {
	display: grid;
	place-items: center;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: #fff;
	color: var(--pgs-accent);
	box-shadow: var(--pgs-shadow);
}

.pgs-help-band__icon .pgs-icon {
	width: 24px;
	height: 24px;
}

.pgs-help-band__title {
	margin: 0 0 4px;
	font-size: var(--pgs-fs-h3);
}

.pgs-help-band__text {
	margin: 0;
	color: var(--pgs-text-body);
}

.pgs-help-band__actions {
	grid-column: 1 / -1;
}

/* Phones / tablets: the icon lines up with the title, not the middle of the text. */
@media (max-width: 899px) {
	.pgs-help-band__icon {
		align-self: start;
	}
}

@media (min-width: 900px) {
	.pgs-help-band {
		grid-template-columns: auto minmax(0, 1fr) auto;
	}

	.pgs-help-band__actions {
		grid-column: auto;
		flex-wrap: nowrap;
	}
}

/* ---- Class pills (10.3.1): sticky under the header; a scrolling row on small screens.
   Header: 65px below 1024px, 77px from 1024px; it sits under the WordPress admin bar for
   logged-in users, except ≤ 600px where the admin bar scrolls away (layout.css). */
.pgs-class-tabs {
	--pgs-tabs-top: calc(var(--wp-admin--admin-bar--height, 0px) + 65px);
	position: sticky;
	top: var(--pgs-tabs-top);
	z-index: 40;
	border-bottom: 1px solid var(--pgs-border);
	background: rgba(255, 255, 255, .94);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
}

@media (max-width: 600px) {
	.pgs-class-tabs {
		--pgs-tabs-top: 65px;
	}
}

@media (min-width: 1024px) {
	.pgs-class-tabs {
		--pgs-tabs-top: calc(var(--wp-admin--admin-bar--height, 0px) + 77px);
	}
}

.pgs-class-tabs__list {
	/* Positioned, so the hidden screen-reader counts (position: absolute) are clipped by this
	   scrolling row instead of stretching the page sideways on phones. */
	position: relative;
	display: flex;
	gap: 8px;
	margin: 0;
	padding: 12px 0;
	overflow-x: auto;
	list-style: none;
	scrollbar-width: none;
}

/* Phones / tablets: the row runs to the screen edges, so the first / last pill is never cut
   against the page margin while it scrolls. (No scroll-snap: it pulled the current pill back
   out of view.) */
@media (max-width: 767px) {
	.pgs-class-tabs__list {
		margin-inline: -16px;
		padding-inline: 16px;
	}
}

.pgs-class-tabs__list::-webkit-scrollbar {
	display: none;
}

.pgs-class-tabs__list li {
	flex: 0 0 auto;
}

.pgs-class-tabs__pill {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 16px;
	border: 1px solid var(--pgs-border);
	border-radius: var(--pgs-radius-pill);
	background: var(--pgs-surface);
	color: var(--pgs-text);
	font-size: var(--pgs-fs-small);
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
	transition: border-color var(--pgs-duration) var(--pgs-ease), background-color var(--pgs-duration) var(--pgs-ease);
}

.pgs-class-tabs__pill:hover {
	border-color: var(--pgs-green);
	background: var(--pgs-tint-green);
}

.pgs-class-tabs__pill.is-active {
	border-color: var(--pgs-navy);
	background: var(--pgs-navy);
	color: #fff;
}

.pgs-class-tabs__count {
	display: inline-grid;
	place-items: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: var(--pgs-radius-pill);
	background: var(--pgs-fill);
	color: var(--pgs-text-muted);
	font-size: 12px;
}

.pgs-class-tabs__pill.is-active .pgs-class-tabs__count {
	background: rgba(255, 255, 255, .18);
	color: #fff;
}

/* The grid starts closer under the pills. */
.pgs-class-tabs + .pgs-courses {
	padding-top: clamp(24px, 4vw, 40px);
}

/* ---- Filters + sort (10.3.2): one row of fields on wide screens, two columns on phones
   (a slide-up panel replaces it on phones in 10.3.6). ---- */
.pgs-filters {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	align-items: end;
	gap: 12px 16px;
	margin-bottom: 24px;
	padding: 16px;
	border: 1px solid var(--pgs-border);
	border-radius: var(--pgs-radius);
	background: var(--pgs-bg-alt);
}

@media (min-width: 900px) {
	.pgs-filters {
		grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
		padding: 16px 20px;
	}
}

.pgs-filters__field {
	min-width: 0;
	margin: 0;
}

.pgs-filters__field .pgs-select {
	width: 100%;
}

.pgs-filters__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 16px;
	grid-column: 1 / -1;
}

@media (min-width: 900px) {
	.pgs-filters__actions {
		grid-column: auto;
	}
}

.pgs-filters__reset {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	color: var(--pgs-link);
	font-size: var(--pgs-fs-small);
	font-weight: 600;
}

@media (max-width: 899px) {
	.pgs-filters__sort {
		grid-column: 1 / -1;
	}
}

/* ---- Results updating without a reload (10.3.3) ---- */
.pgs-courses__results {
	transition: opacity var(--pgs-duration) var(--pgs-ease);
}

.pgs-courses__results[aria-busy="true"] {
	opacity: .45;
	pointer-events: none;
}

/* With JavaScript the filters apply as soon as they change. */
.pgs-js .pgs-filters [data-filters-apply] {
	display: none;
}

/* ---- "Load more" (10.3.4): with JavaScript it replaces the page links ---- */
.pgs-load-more {
	display: none;
	justify-content: center;
	margin-top: clamp(32px, 5vw, 48px);
}

.pgs-js .pgs-load-more {
	display: flex;
}

.pgs-js .pgs-courses .pgs-pagination {
	display: none;
}

.pgs-load-more [data-load-more][aria-busy="true"] {
	opacity: .7;
	cursor: progress;
}

/* ---- Phone filter panel (10.3.6): below 900px with JavaScript a "Filters (2)" button opens the
   form as a sheet sliding up from the bottom (a dialog). Wide screens / no JavaScript: inline. */
.pgs-filters-toggle,
.pgs-filters-panel__head,
.pgs-filters-panel__foot {
	display: none;
}

@media (max-width: 899px) {
	.pgs-js .pgs-filters-toggle {
		display: inline-flex;
		margin-bottom: 20px;
	}

	.pgs-filters-toggle__count {
		display: inline-grid;
		place-items: center;
		min-width: 22px;
		height: 22px;
		padding: 0 6px;
		border-radius: var(--pgs-radius-pill);
		background: var(--pgs-navy);
		color: #fff;
		font-size: 12px;
	}

	.pgs-filters-toggle__count[hidden] {
		display: none;
	}

	/* Closed: the form lives in the panel, out of sight. */
	.pgs-js .pgs-filters-panel {
		display: none;
	}

	.pgs-js .pgs-filters-panel.is-open {
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 110; /* above the header (80), WhatsApp float (90) and the backdrop (105) */
		display: flex;
		flex-direction: column;
		max-height: 85vh;
		max-height: 85dvh;
		border-radius: var(--pgs-radius-lg) var(--pgs-radius-lg) 0 0;
		background: var(--pgs-surface);
		box-shadow: 0 -20px 50px rgba(0, 19, 56, .25);
		animation: pgs-sheet-up var(--pgs-duration) var(--pgs-ease);
	}

	.pgs-filters-panel.is-open .pgs-filters-panel__head {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		padding: 16px 16px 8px 20px;
	}

	.pgs-filters-panel__title {
		margin: 0;
		color: var(--pgs-text);
		font-family: var(--pgs-font-head);
		font-size: var(--pgs-fs-h3);
		font-weight: 700;
	}

	.pgs-filters-panel__close {
		display: grid;
		place-items: center;
		width: 44px;
		height: 44px;
		border: 0;
		border-radius: 50%;
		background: var(--pgs-fill);
		color: var(--pgs-text);
		cursor: pointer;
	}

	.pgs-filters-panel.is-open .pgs-filters {
		flex: 1;
		grid-template-columns: minmax(0, 1fr);
		margin: 0;
		padding: 8px 20px 16px;
		overflow-y: auto;
		border: 0;
		border-radius: 0;
		background: none;
	}

	.pgs-filters-panel.is-open .pgs-filters-panel__foot {
		display: block;
		padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
		border-top: 1px solid var(--pgs-border);
	}

	.pgs-filters-backdrop {
		position: fixed;
		inset: 0;
		z-index: 105;
		background: rgba(0, 19, 56, .55);
		animation: pgs-fade-in var(--pgs-duration) var(--pgs-ease);
	}
}

@keyframes pgs-sheet-up {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

@keyframes pgs-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

/* While the panel is open the page behind does not scroll. */
.pgs-filters-open,
.pgs-filters-open body {
	overflow: hidden;
}
