/* MegaMasterok — system views: archives (category, tag, date, author),
   search results and 404. Scoped by the `megam-listing` body class.
   PHP: inc/listing.php, archive.php, search.php, 404.php,
   template-parts/listing/. Breadcrumbs come from content.css. */

/* Frame: same container as the header and footer, no boxed article, no sidebar. */
.megam-listing .site.grid-container {
	box-sizing: border-box;
	max-width: calc(var(--megam-content) + 2 * var(--megam-gutter));
	padding-inline: var(--megam-gutter);
}

/* Body class doubled to outrank GP's `.separate-containers.no-sidebar .site-main`. */
.megam-listing.megam-listing .site-main {
	max-width: none;
	margin: 0;
	padding: 20px 0 40px;
}

/* Header ------------------------------------------------------------------ */

.megam-listing-head {
	margin-bottom: 20px;
	padding-bottom: 18px;
	border-bottom: 1px solid var(--megam-line);
}

.megam-listing-head > * {
	max-width: 54rem;
}

.megam-listing-head__label {
	margin: 0 0 6px;
	color: var(--megam-muted);
	font-size: var(--megam-fs-sm);
	font-weight: 500;
	line-height: 1.35;
}

.megam-listing .megam-listing-head__title {
	margin: 0;
	color: var(--megam-ink);
	font-family: var(--megam-font);
	font-size: clamp(1.75rem, 1.15rem + 1.9vw, 2.5rem);
	font-weight: 800;
	line-height: 1.14;
	letter-spacing: -0.018em;
	text-wrap: pretty;
	overflow-wrap: anywhere;
}

.megam-listing-head__description,
.megam-listing-head__text {
	margin-top: 10px;
	color: var(--megam-text);
	font-size: var(--megam-fs-md);
	line-height: 1.55;
	max-width: 46rem;
}

.megam-listing-head__text {
	margin-bottom: 0;
}

.megam-listing-head__description > :last-child {
	margin-bottom: 0;
}

.megam-listing-head__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 2px 16px;
	margin: 10px 0 0;
	color: var(--megam-muted);
	font-size: var(--megam-fs-sm);
	line-height: 1.4;
}

.megam-listing-head__search {
	max-width: 44rem;
	margin-top: 16px;
}

/* Calm in-page search: line border, no elevation (the hero keeps its shadow). */
.megam-search.megam-search--page {
	padding: 4px;
	border-color: var(--megam-line-strong);
	box-shadow: none;
}

.megam-search.megam-search--page:focus-within {
	border-color: var(--megam-blue);
	box-shadow: var(--megam-focus);
}

.megam-search--page .megam-search__icon {
	padding-left: 10px;
	color: var(--megam-muted);
}

.megam-search--page input.megam-search__input {
	height: 42px;
}

.megam-search.megam-search--page .megam-search__submit {
	height: 42px;
	padding: 0 24px;
	box-shadow: none;
}

/* Results ----------------------------------------------------------------- */

/* Two columns of horizontal cards on desktop: dense, short lines, calmer than the homepage. */
.megam-results {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.megam-result {
	position: relative;
	display: grid;
	grid-template-columns: 200px minmax(0, 1fr);
	min-width: 0;
	margin: 0;
	overflow: hidden;
	border: 1px solid var(--megam-line);
	border-radius: var(--megam-radius);
	background: var(--megam-surface);
	transition: border-color 0.15s ease;
}

.megam-result--no-media {
	grid-template-columns: minmax(0, 1fr);
}

.megam-result:hover {
	border-color: var(--megam-line-strong);
}

.megam-result__media {
	position: relative;
	min-height: 134px;
	overflow: hidden;
	background: var(--megam-surface-alt);
}

.megam-result__img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: 50% 45%;
}

/* Local/development only: the image file is not on this machine. Neutral, unlabelled. */
.megam-result__media--placeholder {
	background: var(--megam-placeholder);
	box-shadow: inset -1px 0 0 var(--megam-placeholder-line);
}

.megam-result__body {
	display: flex;
	flex-direction: column;
	min-width: 0;
	padding: 14px 16px 12px;
}

.megam-listing .megam-result__title {
	margin: 0;
	color: var(--megam-ink);
	font-family: var(--megam-font);
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.28;
	letter-spacing: -0.005em;
}

.megam-result__title a {
	display: -webkit-box;
	overflow: hidden;
	color: inherit;
	text-decoration: none;
	overflow-wrap: anywhere;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 4;
}

/* The whole card is the title link's hit area. */
.megam-result__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: var(--megam-radius);
}

.megam-result:hover .megam-result__title a {
	color: var(--megam-accent-strong);
}

.megam-result__excerpt {
	display: -webkit-box;
	margin: 6px 0 0;
	overflow: hidden;
	color: var(--megam-muted);
	font-size: var(--megam-fs-sm);
	line-height: 1.45;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.megam-result__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 12px;
	margin-top: auto;
	padding-top: 10px;
	color: var(--megam-muted);
	font-size: var(--megam-fs-xs);
	line-height: 1.4;
}

.megam-result__meta:empty {
	display: none;
}

/* Category: a real link above the card's stretched title link (same tag as the homepage cards). */
.megam-result__tag {
	position: relative;
	z-index: 1;
	display: inline-block;
	max-width: 100%;
	padding: 2px 8px;
	overflow: hidden;
	border-radius: 4px;
	background: var(--megam-blue-soft);
	color: var(--megam-blue);
	font-weight: 500;
	text-decoration: none;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.megam-result__tag:hover {
	background: color-mix(in srgb, var(--megam-blue) 16%, #fff);
	color: var(--megam-blue);
}

.megam-result__title a:focus-visible,
.megam-result__tag:focus-visible {
	outline: none;
}

.megam-result__title a:focus-visible::after,
.megam-result__tag:focus-visible {
	box-shadow: var(--megam-focus);
}

/* Pagination (WordPress the_posts_pagination() markup) ---------------------------- */

.megam-pager {
	margin-top: 24px;
}

.megam-pager .nav-links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.megam-pager .page-numbers {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	box-sizing: border-box;
	min-width: 40px;
	height: 40px;
	padding: 0 10px;
	border: 1px solid var(--megam-line);
	border-radius: var(--megam-radius-sm);
	background: var(--megam-surface);
	color: var(--megam-ink);
	font-size: var(--megam-fs-sm);
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.megam-pager a.page-numbers:hover {
	border-color: var(--megam-line-strong);
	color: var(--megam-accent-strong);
}

.megam-pager a.page-numbers:focus-visible {
	outline: none;
	box-shadow: var(--megam-focus);
}

.megam-pager .page-numbers.current {
	border-color: var(--megam-ink);
	background: var(--megam-ink);
	color: #fff;
}

.megam-pager .page-numbers.dots {
	min-width: 0;
	padding: 0 2px;
	border-color: transparent;
	background: none;
	color: var(--megam-muted);
}

.megam-pager .prev,
.megam-pager .next {
	padding: 0 12px;
}

.megam-pager .prev {
	padding-left: 8px;
}

.megam-pager .next {
	padding-right: 8px;
}

.megam-pager .megam-icon {
	color: var(--megam-muted);
}

.megam-pager__arrow--prev .megam-icon {
	transform: scaleX(-1);
}

/* Empty states, sections list, 404 ---------------------------------------- */

.megam-empty__title,
.megam-listing .megam-sections__title {
	margin: 0;
	color: var(--megam-ink);
	font-family: var(--megam-font);
	font-size: 1.25rem;
	font-weight: 800;
	line-height: 1.25;
}

.megam-empty__text {
	max-width: 46rem;
	margin: 6px 0 0;
	color: var(--megam-text);
	font-size: var(--megam-fs-base);
	line-height: 1.55;
}

.megam-empty__search {
	max-width: 44rem;
	margin-top: 16px;
}

.megam-sections {
	margin-top: 28px;
}

.megam-empty--404 .megam-sections {
	margin-top: 4px;
}

.megam-sections__list {
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 8px;
	margin: 12px 0 0;
	padding: 0;
	list-style: none;
}

.megam-sections__list li {
	margin: 0;
}

.megam-sections__link {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	min-height: 44px;
	box-sizing: border-box;
	padding: 11px 14px;
	border: 1px solid var(--megam-line);
	border-radius: var(--megam-radius-sm);
	background: var(--megam-surface);
	color: var(--megam-ink);
	font-size: var(--megam-fs-base);
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.megam-sections__link:hover {
	border-color: var(--megam-line-strong);
	color: var(--megam-accent-strong);
}

.megam-sections__link:focus-visible,
.megam-empty__home a:focus-visible {
	outline: none;
	box-shadow: var(--megam-focus);
}

.megam-sections__count {
	color: var(--megam-subtle);
	font-size: var(--megam-fs-xs);
	font-weight: 500;
}

.megam-empty__home {
	margin: 20px 0 0;
	font-size: var(--megam-fs-base);
}

.megam-empty__home a {
	color: var(--megam-blue);
	font-weight: 600;
	text-decoration: underline;
	text-decoration-color: color-mix(in srgb, var(--megam-blue) 35%, transparent);
	text-underline-offset: 3px;
}

.megam-empty__home a:hover {
	color: var(--megam-accent-strong);
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 1100px) {
	.megam-result {
		grid-template-columns: 160px minmax(0, 1fr);
	}

	.megam-result--no-media {
		grid-template-columns: minmax(0, 1fr);
	}

	.megam-sections__list {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* Tablet: one column, summaries back to full width of the card. */
@media (max-width: 900px) {
	.megam-results {
		grid-template-columns: minmax(0, 1fr);
		gap: 10px;
	}

	.megam-result {
		grid-template-columns: 180px minmax(0, 1fr);
	}

	.megam-sections__list {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* Mobile: compact rows (small image left, title and meta right, no summary). */
@media (max-width: 600px) {
	.megam-listing.megam-listing .site-main {
		padding: 14px 0 28px;
	}

	.megam-listing-head {
		margin-bottom: 14px;
		padding-bottom: 14px;
	}

	.megam-listing-head__description,
	.megam-listing-head__text {
		font-size: var(--megam-fs-base);
	}

	.megam-listing-head__search {
		margin-top: 12px;
	}

	.megam-search.megam-search--page .megam-search__submit {
		padding: 0 16px;
	}

	.megam-search--page .megam-search__icon {
		display: none;
	}

	.megam-search--page input.megam-search__input {
		padding-left: 8px;
	}

	.megam-result {
		grid-template-columns: 96px minmax(0, 1fr);
	}

	.megam-result--no-media {
		grid-template-columns: minmax(0, 1fr);
	}

	.megam-result__media {
		min-height: 84px;
	}

	.megam-result__body {
		padding: 10px 12px;
	}

	.megam-listing .megam-result__title {
		font-size: 0.9375rem;
		line-height: 1.3;
	}

	.megam-result__excerpt {
		display: none;
	}

	.megam-result__meta {
		padding-top: 6px;
	}

	.megam-pager {
		margin-top: 18px;
	}

	.megam-pager .nav-links {
		gap: 4px;
	}

	.megam-pager .page-numbers {
		min-width: 36px;
		height: 40px;
		padding: 0 6px;
	}

	.megam-pager .prev,
	.megam-pager .next {
		padding: 0 8px;
	}

	/* Prev/next keep their text for assistive technology; the chevron carries them visually. */
	.megam-pager__label {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}

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

	.megam-sections__link {
		padding: 11px 12px;
		font-size: var(--megam-fs-sm);
	}
}

@media (prefers-reduced-motion: reduce) {
	.megam-result,
	.megam-pager .page-numbers,
	.megam-sections__link {
		transition: none;
	}
}
