/**
 * Q8tly Core — Area Hubs + Areas Index (Module 4)
 *
 * Variants A (district hub), B (governorate hub), E (areas index).
 * Plugin-rendered surface (includes/area-hubs.php + templates/area-hub-template.php).
 * Adapted from the Area Hubs spec v1 wireframes (§4.5 / §5.5 / §8.3) to the live
 * --ekg-* token system. First-pass: category/district tile grid, alphabetical
 * list, map placeholder. EN/LTR (AR fenced).
 *
 * Depends on q8tly-tokens.
 */

.q8tly-areas__main {
	background: var(--ekg-archive-bg, #fff);
}

.q8tly-areas__wrap {
	max-width: 1120px;
	margin: 0 auto;
	padding: 28px 20px 64px;
}

/* Breadcrumb */
.q8tly-areas__crumb {
	font-family: 'JetBrains Mono', monospace;
	font-size: 12px;
	color: var(--ekg-archive-muted);
	margin-bottom: 18px;
}
.q8tly-areas__crumb a {
	color: var(--ekg-archive-muted);
	text-decoration: none;
}
.q8tly-areas__crumb a:hover {
	color: var(--ekg-archive-ink);
}
.q8tly-areas__crumb .sep {
	margin: 0 6px;
	opacity: 0.6;
}
.q8tly-areas__crumb [aria-current="page"] {
	color: var(--ekg-archive-ink);
}

/* Header */
.q8tly-areas__header {
	margin-bottom: 28px;
}
.q8tly-areas__h1 {
	font-family: var(--font-serif);
	font-size: 44px;
	font-weight: 600;
	line-height: 1.08;
	letter-spacing: -0.015em;
	color: var(--ekg-archive-ink);
	margin: 0 0 8px;
}
.q8tly-areas__sub {
	font-size: 16px;
	color: var(--ekg-archive-muted);
	margin: 0;
}

/* Block titles */
.q8tly-areas__block-title {
	font-family: var(--font-display);
	font-size: 22px;
	font-weight: 600;
	letter-spacing: -0.02em;
	color: var(--ekg-archive-ink);
	margin: 40px 0 16px;
}

/* Tile grid (category tiles, governorate cards, district cards) */
.q8tly-areas__cat-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 14px;
}
.q8tly-areas__cat-tile {
	background: var(--ekg-archive-surface);
	border: 1px solid var(--ekg-archive-border);
	border-radius: 10px;
	padding: 20px;
	text-decoration: none;
	color: var(--ekg-archive-ink);
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-height: 92px;
	transition: border-color 0.15s, box-shadow 0.15s;
}
.q8tly-areas__cat-tile:hover {
	border-color: var(--ekg-archive-ink);
	box-shadow: var(--ekg-archive-card-shadow, 0 2px 10px rgba(34, 28, 22, 0.06));
}
.q8tly-areas__cat-tile .cat-name {
	font-family: var(--font-display);
	font-size: 18px;
	font-weight: 600;
	letter-spacing: -0.01em;
}
.q8tly-areas__cat-tile .cat-count {
	font-family: 'JetBrains Mono', monospace;
	font-size: 11px;
	color: var(--ekg-archive-muted);
}

/* Map placeholder (static + interactive both deferred) */
.q8tly-areas__map {
	background: var(--ekg-archive-soft);
	border: 1px dashed var(--ekg-archive-muted);
	border-radius: 12px;
	aspect-ratio: 16 / 9;
	display: grid;
	place-items: center;
	margin: 28px 0 8px;
}
.q8tly-areas__map-label {
	font-family: 'JetBrains Mono', monospace;
	font-size: 12px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ekg-archive-muted);
}

/* Nearby (sibling districts) */
.q8tly-areas__nearby {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}
.q8tly-areas__nearby a {
	display: inline-block;
	padding: 8px 14px;
	border: 1px solid var(--ekg-archive-border);
	border-radius: 999px;
	background: var(--ekg-archive-surface);
	color: var(--ekg-archive-ink);
	text-decoration: none;
	font-size: 14px;
}
.q8tly-areas__nearby a:hover {
	border-color: var(--ekg-archive-ink);
}

/* Alphabetical district list (index) */
.q8tly-areas__alpha {
	list-style: none;
	margin: 0;
	padding: 0;
	columns: 4;
	column-gap: 24px;
}
.q8tly-areas__alpha li {
	break-inside: avoid;
	margin-bottom: 8px;
}
.q8tly-areas__alpha a {
	color: var(--ekg-archive-ink);
	text-decoration: none;
	font-size: 15px;
}
.q8tly-areas__alpha a:hover {
	text-decoration: underline;
}

.q8tly-areas__empty {
	color: var(--ekg-archive-muted);
	font-size: 15px;
}

/* Responsive */
@media (max-width: 1024px) {
	.q8tly-areas__cat-grid { grid-template-columns: repeat(3, 1fr); }
	.q8tly-areas__alpha { columns: 3; }
}
@media (max-width: 768px) {
	.q8tly-areas__cat-grid { grid-template-columns: repeat(2, 1fr); }
	.q8tly-areas__alpha { columns: 2; }
	.q8tly-areas__h1 { font-size: 32px; }
}
@media (max-width: 480px) {
	.q8tly-areas__cat-grid { grid-template-columns: 1fr; }
	.q8tly-areas__alpha { columns: 1; }
}

/* Container hub (D-144, D-142 Phase 2): a responsive grid of .q8tly-card archive
   cards (cards bring their own styling from archive.css). auto-fill + minmax keeps
   it responsive without breakpoints — single-listing containers show one card. */
.q8tly-container__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 16px;
	align-items: start;
}

/* ══════════════════════════════════════════════════════════════════
 * DISTRICT MOSAIC — the /en/areas/ redesign (owner ruling 2026-08-30,
 * Prompt-2 design). Laws applied from the start: minmax(0,1fr) columns,
 * @media blocks AFTER their base rules, [hidden] paint guards at the end.
 * RTL rides logical properties only.
 * ══════════════════════════════════════════════════════════════════ */

.q8tly-mosaic__header {
	margin-block-end: 26px;
}

.q8tly-mosaic__progress {
	margin: 6px 0 14px;
	font-family: var(--font-mono, 'JetBrains Mono'), monospace;
	font-size: 11px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #9CA3AF;
}

.q8tly-mosaic__filter {
	display: flex;
	align-items: center;
	gap: 9px;
	max-width: 420px;
	padding: 10px 14px;
	border: 1px solid var(--rule, #E5E7EB);
	border-radius: 12px;
	background: #fff;
	color: #9CA3AF;
}

.q8tly-mosaic__filter input {
	flex: 1 1 auto;
	min-width: 0;
	border: 0;
	outline: none;
	background: transparent;
	font-family: var(--font-body);
	font-size: 15px;
	color: #16213D;
}

.q8tly-mosaic__filter input::placeholder {
	color: #9CA3AF;
}

/* ── Featured row: the 6 biggest, navy tiles, red top edge ── */

.q8tly-mosaic__featured {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 14px;
	margin-block-end: 34px;
}

.q8tly-mosaic__hero-tile {
	display: flex;
	flex-direction: column;
	gap: 3px;
	padding: 20px 18px 16px;
	background: #16213D;
	border-block-start: 3px solid #FF4747;
	border-radius: 14px;
	text-decoration: none;
	transition: transform 130ms ease, box-shadow 130ms ease;
}

.q8tly-mosaic__hero-tile:hover,
.q8tly-mosaic__hero-tile:focus-visible {
	transform: translateY(-3px);
	box-shadow: 0 12px 28px rgba(22, 33, 61, 0.22);
}

.q8tly-mosaic__hero-tile:focus-visible {
	outline: 2px solid #FF4747;
	outline-offset: 2px;
}

.q8tly-mosaic__hero-name {
	font-size: 19px;
	font-weight: 700;
	color: #fff;
}

.q8tly-mosaic__hero-alt {
	font-size: 13px;
	color: rgba(255, 255, 255, 0.62);
}

.q8tly-mosaic__hero-meta {
	margin-block-start: 10px;
	font-size: 12px;
	color: rgba(255, 255, 255, 0.78);
}

/* ── Governorate sections ── */

.q8tly-mosaic__gov {
	margin-block-end: 30px;
	scroll-margin-block-start: 90px; /* the #gov-{slug} anchor lands clear of the sticky header. */
}

.q8tly-mosaic__gov-head {
	display: flex;
	align-items: baseline;
	gap: 12px;
	margin-block-end: 12px;
}

.q8tly-mosaic__gov-name {
	margin: 0;
	font-size: 17px;
	font-weight: 700;
	color: #16213D;
}

.q8tly-mosaic__gov-meta {
	font-size: 12px;
	color: #9CA3AF;
}

.q8tly-mosaic__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 10px;
}

.q8tly-mosaic__tile {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 11px 13px;
	background: #FFF1EE;
	border-radius: 16px;
	text-decoration: none;
	color: #FF4747; /* the pin rides currentColor. */
}

.q8tly-mosaic__tile:hover,
.q8tly-mosaic__tile:focus-visible {
	background: #FFE4DE;
}

.q8tly-mosaic__tile:focus-visible {
	outline: 2px solid #16213D;
	outline-offset: 1px;
}

.q8tly-mosaic__tile svg {
	flex: 0 0 auto;
	width: 15px;
	height: 15px;
}

.q8tly-mosaic__tile-name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: 14px;
	font-weight: 500;
	color: #16213D;
}

.q8tly-mosaic__tile-count {
	margin-inline-start: auto;
	font-size: 12px;
	color: #9CA3AF;
}

/* Zero-count: muted 50%, never hidden, still linked (the ruled state). */
.q8tly-mosaic__tile.is-muted {
	opacity: 0.5;
}

/* ── Mobile (AFTER the base rules — the .402 law) ── */

@media (max-width: 780px) {
	/* Featured → horizontal snap-scroll (the ruled mobile behavior). */
	.q8tly-mosaic__featured {
		display: flex;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		padding-block-end: 8px;
	}

	.q8tly-mosaic__hero-tile {
		flex: 0 0 240px;
		scroll-snap-align: start;
	}

	.q8tly-mosaic__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* ── Paint guards for the filter (the .407 lesson: author display rules beat
 * UA [hidden]; these sit AFTER every display rule they guard). ── */

.q8tly-mosaic__hero-tile[hidden],
.q8tly-mosaic__tile[hidden],
.q8tly-mosaic__gov[hidden],
.q8tly-mosaic__featured[hidden] {
	display: none;
}
