/* Phase 6: standard WordPress news presentation (blog index, category/tag/
   date/author archives, search results, single post). Conditionally
   enqueued — see inc/assets.php kksombor_enqueue_posts_assets() — only on
   the contexts this file actually styles, never on plain pages or the
   static front page (which loads its own on-demand news grid styling via
   assets/css/blocks/core-query.css instead).

   Scope is deliberately the explicit set of listing body classes
   (.blog/.category/.tag/.date/.author/.search) via :is(), never the broader
   .archive, so a future Athlestat custom post type archive can carry its
   own design without fighting these rules. Native archives (blog index,
   category/tag/date/author) only ever list standard posts, so their card
   selectors require article.type-post; body.search can return any public
   post type, so its card selectors target any direct <article> instead —
   see "Archive card" below for the exact split. */

/* ==========================================================================
   Archive / blog index grid
   ========================================================================== */

body:is(.blog, .category, .tag, .date, .author, .search) .site-main {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--wp--preset--spacing--lg);
	max-width: var(--wp--style--global--wide-size);
	margin-inline: auto;
	padding-inline: clamp(1rem, 4vw, 2rem);
}

@media (min-width: 782px) {
	body:is(.blog, .category, .tag, .date, .author, .search) .site-main {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1080px) {
	body:is(.blog, .category, .tag, .date, .author, .search) .site-main {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* Page title, pagination and the empty-results notice span the full grid
   width instead of behaving like a card. */
body:is(.blog, .category, .tag, .date, .author, .search) .site-main > .page-header,
body:is(.blog, .category, .tag, .date, .author, .search) .site-main > .paging-navigation,
body:is(.blog, .category, .tag, .date, .author, .search) .site-main > .no-results {
	grid-column: 1 / -1;
}

body:is(.blog, .category, .tag, .date, .author, .search) .site-main > .page-header {
	margin-block-end: 0;
}

body:is(.blog, .category, .tag, .date, .author, .search) .site-main > .page-header .page-title {
	max-width: var(--wp--style--global--content-size);
}

/* ==========================================================================
   Archive card

   Native archives require article.type-post (they only ever list standard
   posts). body.search can legitimately return pages or other public post
   types alongside posts, so its branch targets any direct <article>
   instead, giving every search result the same card shell regardless of
   post type. Neither branch uses the unscoped body.archive, and a future
   Athlestat archive (which carries neither of these body classes) is
   untouched by both.

   The global .inside-article rule in style.css (wide-size max-width and
   page-level horizontal padding) is intended for a single full-width
   article, not a grid card, so it is overridden here for this scope only.
   The card gets no padding of its own; entry-header/entry-summary/footer
   get their own inline padding instead, so an optional featured image
   (wherever GeneratePress places it) is never trapped inside a padded
   parent and renders edge-to-edge automatically.
   ========================================================================== */

body:is(.blog, .category, .tag, .date, .author) .site-main > article.type-post,
body.search .site-main > article {
	display: flex;
	flex-direction: column;
	min-width: 0;
	box-sizing: border-box;
	margin-block-end: 0;
}

body:is(.blog, .category, .tag, .date, .author) .site-main > article.type-post > .inside-article,
body.search .site-main > article > .inside-article {
	display: flex;
	flex-direction: column;
	flex: 1;
	box-sizing: border-box;
	max-width: none;
	margin-inline: 0;
	margin-block-end: 0;
	padding: 0;
	background-color: var(--base-2);
	border: 1px solid var(--contrast-3);
	border-radius: 0;
	box-shadow: none;
	overflow: hidden;
}

/* GeneratePress renders .post-image after the entry header in the DOM;
   order: -1 moves it to the card's visual top without touching markup or
   adding JavaScript — .inside-article above is already the flex container
   that makes order effective. A card with no featured image at all (most
   pages, or a post without one) simply has one fewer flex child; no
   placeholder is added. */
body:is(.blog, .category, .tag, .date, .author) .site-main > article.type-post > .inside-article > .post-image,
body.search .site-main > article > .inside-article > .post-image {
	display: block;
	order: -1;
	margin: 0;
	aspect-ratio: 16 / 9;
	overflow: hidden;
}

body:is(.blog, .category, .tag, .date, .author) .site-main > article.type-post > .inside-article > .post-image img,
body.search .site-main > article > .inside-article > .post-image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

body:is(.blog, .category, .tag, .date, .author) .site-main > article.type-post > .inside-article > .entry-header,
body.search .site-main > article > .inside-article > .entry-header {
	padding-inline: var(--wp--preset--spacing--md);
	padding-block-start: var(--wp--preset--spacing--md);
	margin-block-end: var(--wp--preset--spacing--sm);
}

body:is(.blog, .category, .tag, .date, .author, .search) .site-main .entry-title {
	font-size: var(--wp--preset--font-size--heading-3);
}

body:is(.blog, .category, .tag, .date, .author, .search) .site-main .entry-title a {
	color: var(--contrast);
	text-decoration: none;
}

body:is(.blog, .category, .tag, .date, .author, .search) .site-main .entry-title a:hover,
body:is(.blog, .category, .tag, .date, .author, .search) .site-main .entry-title a:focus {
	color: var(--accent);
	text-decoration: underline;
}

body:is(.blog, .category, .tag, .date, .author, .search) .site-main .entry-meta {
	font-size: var(--wp--preset--font-size--small);
}

/* flex: 1 grows the excerpt to fill remaining space, so the footer below it
   (categories, when present) stays pinned to the card's bottom edge
   regardless of how much excerpt text a given card has — no fixed/
   min-height involved. A search card with no footer.entry-meta at all
   (e.g. a page result, which has no categories) still ends correctly,
   since nothing below the excerpt is required for this to work. */
body:is(.blog, .category, .tag, .date, .author) .site-main > article.type-post > .inside-article > .entry-summary,
body.search .site-main > article > .inside-article > .entry-summary {
	flex: 1;
	padding-inline: var(--wp--preset--spacing--md);
	margin-block-end: var(--wp--preset--spacing--sm);
}

body:is(.blog, .category, .tag, .date, .author, .search) .site-main .entry-summary .read-more {
	display: inline-block;
	margin-block-start: var(--wp--preset--spacing--xs);
}

/* --contrast-3 (muted), not --base-2: the card surface above is already
   --base-2, so a --base-2 border here would be practically invisible. */
body:is(.blog, .category, .tag, .date, .author) .site-main > article.type-post > .inside-article > footer.entry-meta,
body.search .site-main > article > .inside-article > footer.entry-meta {
	padding-inline: var(--wp--preset--spacing--md);
	padding-block: var(--wp--preset--spacing--sm) var(--wp--preset--spacing--md);
	border-top: 1px solid var(--contrast-3);
}

/* ==========================================================================
   Pagination and no-results
   ========================================================================== */

body:is(.blog, .category, .tag, .date, .author, .search) .paging-navigation {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--wp--preset--spacing--sm);
	margin-block-start: var(--wp--preset--spacing--lg);
}

/* .page-numbers is WordPress core's own paginate_links() class, present on
   both the links and the current-page span regardless of GeneratePress's
   own wrapper markup. */
body:is(.blog, .category, .tag, .date, .author, .search) .paging-navigation .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.5rem;
	min-height: 2.5rem;
	padding-inline: var(--wp--preset--spacing--sm);
	color: var(--contrast);
	background-color: var(--base-2);
	border: 1px solid var(--contrast-3);
	text-decoration: none;
	transition: background-color 180ms ease, color 180ms ease;
}

body:is(.blog, .category, .tag, .date, .author, .search) .paging-navigation a.page-numbers:hover,
body:is(.blog, .category, .tag, .date, .author, .search) .paging-navigation a.page-numbers:focus {
	background-color: var(--accent);
	color: var(--base);
}

body:is(.blog, .category, .tag, .date, .author, .search) .paging-navigation .page-numbers.current {
	background-color: var(--accent);
	color: var(--base);
	border-color: var(--accent);
}

body:is(.blog, .category, .tag, .date, .author, .search) .no-results {
	padding: var(--wp--preset--spacing--xl) var(--wp--preset--spacing--md);
	background-color: var(--base-2);
	border: 1px solid var(--contrast-3);
	color: var(--contrast-2);
	text-align: center;
}

/* ==========================================================================
   Single post
   ========================================================================== */

body.single-post .site-main > article.type-post > .inside-article {
	max-width: var(--wp--style--global--content-size);
}

body.single-post .entry-title {
	font-size: var(--wp--preset--font-size--display);
}

body.single-post .entry-header {
	margin-block-end: var(--wp--preset--spacing--lg);
}

body.single-post .entry-header .entry-meta {
	font-size: var(--wp--preset--font-size--small);
}

/* GeneratePress 3.6.1's single-post featured image markup is
   .featured-image.page-header-image-single (not .post-image, which is
   archive-loop-only — see "Archive card" above), rendered inside
   .inside-article before .entry-header. Only the wrapper's width and the
   spacing before the header are touched; the image itself keeps its
   natural aspect ratio — no aspect-ratio, crop, or object-fit — so real
   photos are never distorted or cropped. */
body.single-post .inside-article > .featured-image.page-header-image-single {
	display: block;
	width: 100%;
	margin: 0 0 var(--wp--preset--spacing--lg) 0;
}

body.single-post .inside-article > .featured-image.page-header-image-single img {
	display: block;
	width: 100%;
	height: auto;
}

body.single-post .entry-content {
	margin-block-end: var(--wp--preset--spacing--lg);
}

body.single-post .inside-article > footer.entry-meta {
	margin-block-start: var(--wp--preset--spacing--lg);
	padding-block-start: var(--wp--preset--spacing--md);
	border-top: 1px solid var(--base-2);
	font-size: var(--wp--preset--font-size--small);
}

/* ==========================================================================
   Single post — basic Gutenberg content styling

   Scoped narrowly to body.single-post .entry-content: only the elements
   realistically used in a news post, no global reset, no button changes.
   ========================================================================== */

body.single-post .entry-content h2,
body.single-post .entry-content h3 {
	margin-block-start: var(--wp--preset--spacing--xl);
	margin-block-end: var(--wp--preset--spacing--md);
}

body.single-post .entry-content h2:first-child,
body.single-post .entry-content h3:first-child {
	margin-block-start: 0;
}

body.single-post .entry-content ul,
body.single-post .entry-content ol {
	padding-inline-start: var(--wp--preset--spacing--lg);
	margin-block: var(--wp--preset--spacing--md);
}

body.single-post .entry-content li + li {
	margin-block-start: var(--wp--preset--spacing--xs);
}

body.single-post .entry-content blockquote {
	margin: var(--wp--preset--spacing--lg) 0;
	padding-inline-start: var(--wp--preset--spacing--md);
	border-inline-start: 4px solid var(--accent);
	color: var(--contrast-2);
	font-style: italic;
}

body.single-post .entry-content blockquote p:last-child {
	margin-block-end: 0;
}

body.single-post .entry-content blockquote cite {
	display: block;
	margin-block-start: var(--wp--preset--spacing--xs);
	color: var(--contrast-3);
	font-style: normal;
	font-size: var(--wp--preset--font-size--small);
}

body.single-post .entry-content img {
	max-width: 100%;
	height: auto;
}

body.single-post .entry-content figcaption {
	margin-block-start: var(--wp--preset--spacing--xs);
	color: var(--contrast-3);
	font-size: var(--wp--preset--font-size--small);
	text-align: center;
}

/* Horizontal overflow is contained to the table's own figure wrapper only,
   never the wider .entry-content column. */
body.single-post .entry-content .wp-block-table {
	overflow-x: auto;
}

body.single-post .entry-content .wp-block-table table {
	width: 100%;
	border-collapse: collapse;
}

body.single-post .entry-content .wp-block-table th,
body.single-post .entry-content .wp-block-table td {
	padding: var(--wp--preset--spacing--xs) var(--wp--preset--spacing--sm);
	border: 1px solid var(--contrast-3);
}

body.single-post .entry-content .wp-block-separator {
	margin-block: var(--wp--preset--spacing--xl);
	border: none;
	border-top: 1px solid var(--base-2);
}

/* Content links already inherit underline (:where(.entry-content, ...) a in
   style.css) and the sitewide :focus-visible outline (also style.css) —
   nothing is duplicated here. */

/* ==========================================================================
   Single post — previous/next navigation
   ========================================================================== */

/* GeneratePress 3.6.1's single-post navigation is <nav class="post-navigation">
   with .nav-previous/.nav-next as direct children — there is no .nav-links
   wrapper on this template (unlike some other GeneratePress navigation
   markup), so the grid is placed directly on .post-navigation itself. */
body.single-post .post-navigation {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: var(--wp--preset--spacing--md);
	max-width: var(--wp--style--global--content-size);
	margin-inline: auto;
	margin-block-start: var(--wp--preset--spacing--2-xl);
	padding-block-start: var(--wp--preset--spacing--lg);
	border-top: 1px solid var(--base-2);
}

/* Explicit grid-column placement, not source order: when only one of the
   two exists (e.g. no previous post), .nav-next still lands in the second
   column instead of collapsing into the first. */
body.single-post .post-navigation .nav-previous {
	grid-column: 1;
}

body.single-post .post-navigation .nav-next {
	grid-column: 2;
}

/* GeneratePress's arrow icon is an SVG sibling of the link, not nested
   inside the <a> — the wrapper itself is the flex row that keeps the icon
   and link text aligned, and the bordered "button" surface, so both stay
   visually grouped even though only the <a> is actually focusable/clickable. */
body.single-post .post-navigation .nav-previous,
body.single-post .post-navigation .nav-next {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--xs);
	min-width: 0;
	padding: var(--wp--preset--spacing--sm) var(--wp--preset--spacing--md);
	background-color: var(--base-2);
	border: 1px solid var(--contrast-3);
	transition: border-color 180ms ease;
}

body.single-post .post-navigation .nav-previous {
	justify-content: flex-start;
}

body.single-post .post-navigation .nav-next {
	justify-content: flex-end;
	text-align: right;
}

body.single-post .post-navigation .nav-previous:hover,
body.single-post .post-navigation .nav-next:hover,
body.single-post .post-navigation .nav-previous:focus-within,
body.single-post .post-navigation .nav-next:focus-within {
	border-color: var(--accent);
}

/* Keyboard focus stays on the link itself — the sitewide a:focus-visible
   outline in style.css already covers it, not duplicated here. */
body.single-post .post-navigation a {
	display: block;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--contrast);
	text-decoration: none;
	transition: color 180ms ease;
}

body.single-post .post-navigation a:hover,
body.single-post .post-navigation a:focus {
	color: var(--accent);
}

body.single-post .post-navigation svg {
	width: 1em;
	height: 1em;
	flex-shrink: 0;
	fill: currentColor;
	color: var(--contrast-3);
}

@media (max-width: 600px) {
	body.single-post .post-navigation {
		grid-template-columns: minmax(0, 1fr);
	}

	/* Reset the explicit desktop column placement so both wrappers stack
	   in natural source order instead of both trying to occupy a grid
	   column that no longer exists at one-column width. */
	body.single-post .post-navigation .nav-previous,
	body.single-post .post-navigation .nav-next {
		grid-column: auto;
	}

	body.single-post .post-navigation .nav-next {
		justify-content: flex-start;
		text-align: left;
	}
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	body:is(.blog, .category, .tag, .date, .author, .search) .paging-navigation .page-numbers,
	body.single-post .post-navigation .nav-previous,
	body.single-post .post-navigation .nav-next,
	body.single-post .post-navigation a {
		transition: none;
	}
}
