/*
 * Route `services` — the services hub (category grid + business listing).
 *
 * Ported from `pca-web/services-hub.html`. Card metrics, radii, borders and
 * both of the prototype's grid breakpoints are unchanged; the substitutions are
 * the ones every page stylesheet in this build makes — raw hex becomes the
 * semantic tokens from public.css so dark mode works, and physical directions
 * become logical properties so the page mirrors in Arabic.
 *
 * Two deliberate differences from the prototype:
 *
 * - The category grid is the shared `.pca-grid` (5 desktop / 3 tablet /
 *   2 mobile, spec file 07 §4), so nothing here sets its columns. Only the
 *   card's own appearance is defined below.
 * - The prototype's `<select>` picker became a real search form. Its styling
 *   reuses the field tokens rather than inventing new colours.
 *
 * `.ar` marks the *secondary* line, which is English once the visitor switches
 * the site to Arabic, so direction is never hard-coded here: the per-node `dir`
 * attribute emitted by the template is the single source of truth.
 */

/* ==========================================================================
   1. Page heading
   ========================================================================== */

.services-intro {
	padding: 40px 0 10px;
}

.section-heading-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 14px;
	flex-wrap: wrap;
}

.section-heading-row h1,
.section-heading-row h2 {
	font-size: clamp(20px, 3vw, 30px);
	font-weight: 900;
	color: var(--heading-ink);
	margin: 0;
}

.section-heading-row .ar {
	font-size: clamp(17px, 2.6vw, 24px);
	font-weight: 800;
	color: var(--blue-bright);
}

/* The listing view repeats the heading under the back link, where it sits
   tighter to the grid — the prototype's inline `margin-bottom:22px`. */
.section-heading-row.is-compact {
	margin-block-end: 22px;
}

.section-heading-row.is-compact h2 {
	font-size: clamp(19px, 2.7vw, 26px);
}

/* ==========================================================================
   2. Search form
   ========================================================================== */

.services-search-section {
	padding: 20px 0 4px;
}

.services-search {
	max-width: 620px;
}

.search-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--field-bg);
	border: 1.8px solid var(--field-border);
	border-radius: 999px;
	padding-block: 5px;
	padding-inline: 16px 6px;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-bar:focus-within {
	border-color: var(--blue-bright);
	box-shadow: 0 0 0 3px rgba(0, 156, 222, 0.18);
}

.search-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	color: var(--blue-bright);
}

.search-icon svg {
	width: 19px;
	height: 19px;
}

.search-bar input[type='search'] {
	flex: 1 1 auto;
	min-width: 0;
	border: none;
	background: transparent;
	font-family: inherit;
	font-size: 14.5px;
	font-weight: 600;
	color: var(--body-ink);
	padding: 10px 0;
}

.search-bar input[type='search']:focus {
	outline: none;
}

/* The native clear affordance is a WebKit control that ignores our tokens. */
.search-bar input[type='search']::-webkit-search-cancel-button {
	cursor: pointer;
}

.search-submit {
	flex: 0 0 auto;
	padding: 10px 22px;
	font-size: 14px;
}

/* ==========================================================================
   3. Category grid
   ========================================================================== */

.services-results-section {
	padding: 20px 0 40px;
}

.categories-grid {
	margin-block-end: 26px;
}

.group-heading {
	margin: 26px 0 14px;
	font-size: clamp(16px, 2.2vw, 20px);
	font-weight: 900;
	color: var(--heading-ink);
	display: flex;
	align-items: baseline;
	gap: 10px;
	flex-wrap: wrap;
}

.group-heading:first-child {
	margin-block-start: 4px;
}

.group-heading .group-heading-secondary {
	font-size: 0.78em;
	font-weight: 800;
	color: var(--blue-bright);
}

.category-card {
	/* `--heading-ink` is `--navy-deep` in light mode, so this is the prototype's
	   2px navy outline exactly; in dark mode it flips to a legible hairline
	   instead of vanishing into the background. */
	border: 2px solid var(--heading-ink);
	border-radius: 18px;
	background: var(--card-bg);
	padding: 18px 12px;
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.category-card:hover {
	transform: translateY(-4px);
	box-shadow: var(--shadow);
}

.category-icon {
	width: 46px;
	height: 46px;
	border-radius: 13px;
	background: var(--blue-pale);
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
}

.category-icon svg {
	width: 24px;
	height: 24px;
	color: var(--heading-ink);
}

.category-name {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.category-name .name-primary {
	font-weight: 800;
	font-size: 13.5px;
	color: var(--heading-ink);
	line-height: 1.3;
}

.category-name .name-secondary {
	font-weight: 700;
	font-size: 11px;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.2px;
	line-height: 1.3;
}

.category-count {
	font-size: 11px;
	font-weight: 700;
	color: var(--blue-bright);
}

/* ==========================================================================
   4. Business listing
   ========================================================================== */

.back-to-categories {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-weight: 800;
	color: var(--blue-bright);
	font-size: 13.5px;
	margin-block-end: 20px;
}

.back-to-categories:hover {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.back-to-categories svg {
	width: 15px;
	height: 15px;
}

/* The chevron points back, which is the other way round in an RTL page. */
[dir='rtl'] .back-to-categories svg {
	transform: scaleX(-1);
}

/* The prototype's own 3 / 2 / 1 listing grid, breakpoints unchanged. */
.businesses-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 22px;
}

@media (max-width: 900px) {
	.businesses-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 560px) {
	.businesses-grid {
		grid-template-columns: 1fr;
	}
}

.business-card {
	border: 2px solid var(--heading-ink);
	border-radius: var(--radius);
	background: var(--card-bg);
	padding: 18px;
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.business-card:hover {
	transform: translateY(-4px);
	box-shadow: var(--shadow);
}

.business-card .name {
	display: block;
	width: 100%;
}

.business-card .name .name-primary {
	display: block;
	font-weight: 800;
	color: var(--heading-ink);
	font-size: 15.5px;
	line-height: 1.25;
}

.business-card .name .name-secondary {
	display: block;
	font-weight: 700;
	color: var(--muted);
	font-size: 12px;
	margin-block-start: 2px;
	text-transform: uppercase;
	letter-spacing: 0.2px;
}

.business-card .photo {
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	border-radius: 14px;
	overflow: hidden;
	margin-block-start: 12px;
	background: var(--blue-pale);
}

.business-card .photo img,
.business-card .photo picture {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* A listing with no photo keeps the card's proportions rather than collapsing
   the row, so a mixed grid still lines up. */
.business-card .photo.is-empty {
	background: var(--blue-pale);
}

.business-meta {
	display: block;
	margin-block-start: 10px;
	font-size: 11.5px;
	font-weight: 800;
	color: var(--blue-bright);
	background: var(--blue-pale);
	padding: 3px 12px;
	border-radius: 999px;
}

.no-results {
	font-weight: 700;
}

/* ==========================================================================
   5. Pagination
   ========================================================================== */

.services-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	flex-wrap: wrap;
	margin-block-start: 30px;
}

.services-pagination .btn {
	padding: 10px 22px;
	font-size: 14px;
}

.services-pagination-status {
	font-size: 13px;
	font-weight: 800;
	color: var(--muted);
}

/* ==========================================================================
   6. Small screens
   ========================================================================== */

@media (max-width: 639px) {
	.services-intro {
		padding-block-start: 28px;
	}

	.category-card {
		padding: 14px 8px;
		gap: 8px;
		border-radius: 16px;
	}

	.category-icon {
		width: 40px;
		height: 40px;
		border-radius: 11px;
	}

	.category-name .name-primary {
		font-size: 12.5px;
	}

	.category-name .name-secondary {
		font-size: 10px;
	}

	.search-submit {
		padding: 10px 16px;
		font-size: 13px;
	}
}
