/*
 * Blog archive styles.
 * Assumes global CSS variables already defined in the parent stylesheet:
 * --color-text, --color-bg, --color-surface, --color-border, --color-primary,
 * --color-primary-contrast, --color-muted, --font-heading, --font-body,
 * --radius, --space-1..--space-8, --container-width.
 * This file does not redefine any of them.
 *
 * Written with logical properties (margin-inline-*, border-inline-*,
 * text-align: start/end, etc.) throughout instead of left/right, so it
 * mirrors correctly under [dir="rtl"] with no extra overrides needed.
 */

.container {
	width: 100%;
	max-width: var(--container-width, 1200px);
	margin-inline: auto;
	padding-inline: var(--space-4, 1rem);
}

.container--narrow {
	max-width: 720px;
}

/* Widen the container progressively on very large screens so the post
   grid can grow past 3 columns instead of just stretching card width. */
@media (min-width: 1600px) {

	.archive-main .container,
	.single-main .container--with-rail,
	.faq-main .container {
		max-width: 1600px;
	}
}

@media (min-width: 2200px) {

	.archive-main .container,
	.single-main .container--with-rail,
	.faq-main .container {
		max-width: 1920px;
	}
}

/* Breadcrumbs -------------------------------------------------------- */

.breadcrumbs {
	margin-block: var(--space-4, 1rem) var(--space-2, 0.5rem);
	font-size: 0.875rem;
	color: var(--color-muted, #666);
}

.breadcrumbs__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35em;
	list-style: none;
	margin: 0;
	padding: 0;
}

.breadcrumbs__item:not(:last-child)::after {
	content: '/';
	margin-inline-start: 0.35em;
	color: var(--color-border, #ccc);
}

.breadcrumbs__item a {
	color: var(--color-muted, #666);
	text-decoration: none;
}

.breadcrumbs__item a:hover,
.breadcrumbs__item a:focus-visible {
	color: var(--link-hover-color, var(--link-color));
}

/* Archive header ------------------------------------------------------ */

.archive-header {
	padding-block: var(--space-6, 2rem) var(--space-4, 1rem);
	border-block-end: 1px solid var(--color-border, #e5e5e5);
	margin-block-end: var(--space-6, 2rem);
}

.archive-header--author {
	display: flex;
	align-items: center;
	gap: var(--space-4, 1rem);
}

.archive-header__avatar {
	border-radius: 50%;
	flex-shrink: 0;
	object-fit: cover;
}

.archive-header__avatar--fallback {
	padding: 0.5rem;
	background: var(--color-bg, #f5f5f5);
	object-fit: contain;
}

.archive-header__avatar--placeholder {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--color-bg, #f5f5f5);
	color: var(--color-muted, #999);
	flex-shrink: 0;
}

.archive-header__eyebrow {
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--color-primary, #2563eb);
	margin: 0 0 0.25em;
}

.archive-header__title {
	font-family: var(--font-heading, inherit);
	font-size: clamp(1.75rem, 4vw, 2.5rem);
	line-height: 1.15;
	margin: 0 0 0.5em;
}

.archive-header__description,
.archive-header__count {
	color: var(--color-muted, #666);
	max-width: 65ch;
}

/* Post grid --------------------------------------------------------------
 * auto-fill keeps columns proportional to available width rather than
 * hard-coding a column count per breakpoint, so it scales cleanly from a
 * single column on mobile up through 3 columns around 1200-1600px (FHD-ish
 * container widths) and 4+ columns once the container widens further on
 * large/UHD displays (see the .container max-width bumps above).
 * ------------------------------------------------------------------------ */

.post-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--space-6, 2rem);
	list-style: none;
	margin: 0 0 var(--space-8, 3rem);
	padding: 0;
}

@media (min-width: 560px) {
	.post-grid {
		grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	}
}

.badge:hover,
.badge:focus-visible {
	background: color-mix(in srgb, var(--color-primary, #2563eb) 22%, transparent);
}

.post-card__author a:hover,
.post-card__author a:focus-visible {
	color: var(--link-hover-color, var(--link-color));
}

/* Empty state ----------------------------------------------------------- */

.empty-state {
	text-align: center;
	padding: var(--space-8, 3rem) var(--space-4, 1rem);
	border: 1px dashed var(--color-border, #ccc);
	border-radius: var(--radius, 0.5rem);
	margin-block-end: var(--space-8, 3rem);
}

.empty-state__title {
	margin-block-start: 0;
}

.empty-state__text {
	color: var(--color-muted, #666);
	max-width: 45ch;
	margin-inline: auto;
}

.button {
	display: inline-block;
	margin-block-start: var(--space-4, 1rem);
	padding: 0.6em 1.4em;
	background: var(--color-primary, #2563eb);
	color: var(--color-primary-contrast, #fff);
	border-radius: var(--radius, 0.5rem);
	text-decoration: none;
	font-weight: 600;
}

.button:hover,
.button:focus-visible {
	filter: brightness(0.92);
}

/* Pagination -------------------------------------------------------------- */

.pagination {
	margin-block: var(--space-6, 2rem);
}

.pagination__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4em;
	list-style: none;
	margin: 0;
	padding: 0;
	justify-content: center;
}

.pagination__list a,
.pagination__list span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.25em;
	min-height: 2.25em;
	padding: 0.2em 0.6em;
	border-radius: var(--radius, 0.5rem);
	border: 1px solid var(--color-border, #e5e5e5);
	text-decoration: none;
	color: var(--color-text, #111);
}

.pagination__list a:hover,
.pagination__list a:focus-visible {
	border-color: var(--focus-color);
	background: var(--hover-surface);
	color: var(--hover-text);
	transform: var(--lift);
}

/* The current page: the filled pair (on-primary on the brand colour is
   guaranteed; the link colour behind on-primary was not — 3.4:1 on Peach). */
.pagination__list [aria-current="page"] {
	background: var(--filled-bg);
	color: var(--filled-text);
	border-color: var(--filled-bg);
}

/* Focus visibility everywhere in this template family ------------------ */

.archive-main a:focus-visible,
.archive-main button:focus-visible {
	outline: 2px solid var(--color-primary, #2563eb);
	outline-offset: 2px;
}

/*manaul */
.main-header {
	margin: var(--spacing-xl);
}

.post {
	margin: var(--spacing-xl);
}

.entry-content {
	padding: var(--spacing-md);
}

/* Full on-primary: an opacity here dimmed it below AA on light presets.
   Hover/focus: the brand-surface look (theme.css, "Interaction states" 5c). */
.entry-header a {
	color: var(--on-primary, var(--text-color-light));
}

body {
	background: none;
}

/* Article cards on the blog index and generic archives (index.php,
   archive.php). This used to be a grid on <main> itself, which broke as soon
   as anything else (a container, the filters) sat inside <main>. */
.post-grid--articles {
	display: grid;
	/* The shop's card width and gap, so article and product listings share
	   one layout (3 columns beside the filters on desktop, more on wide screens). */
	grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-min)), 1fr));
	justify-content: start;
	gap: var(--grid-gap, 1.5rem);
}

/* Cards in the grid (blog, archives, search). These used to live in
   filters.css, which loads only with the filter panel: on a search page the
   cards kept .post's 2rem margin (offset from the others), page cards had
   square corners while post cards were rounded, and heights differed. */
.post-grid--articles > article {
    display: flex;
    flex-direction: column;
    width: auto;
    min-width: 0;
    height: 100%;
    margin: 0;
    border-radius: var(--border-radius-lg);
}

/* Headers of a row share one height (a card with a "last updated" line or a
   longer title no longer makes its neighbours' bodies start higher): each
   card spans two rows of the grid — header, body — and takes them over with
   subgrid. Browsers without subgrid keep the flex column above. */
@supports (grid-template-rows: subgrid) {
    .post-grid--articles {
        row-gap: 0;
    }

    .post-grid--articles > article {
        display: grid;
        grid-row: span 2;
        grid-template-rows: subgrid;
        row-gap: 0;
        height: auto;
        margin-bottom: var(--grid-gap, 1.5rem);
    }
}

.post-grid--articles > article > .entry-header {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* The meta line keeps room for its second line ("Last updated"), so cards
   with and without it look alike. */
.post-grid--articles > article > .entry-header > .entry-meta {
    min-width: 0;
    min-height: calc(2lh + var(--spacing-sm));
    margin-top: auto;
    /* The header is padded already: no second inset for the meta line. */
    padding-inline: 0;
    padding-bottom: 0;
}

/* "Last updated …" may wrap in a narrow card (it is nowrap elsewhere). */
.post-grid--articles > article > .entry-header .updated-on {
    white-space: normal;
}

.post-grid--articles > article > .entry-header > * {
    min-width: 0;
    overflow-wrap: anywhere;
}

.post-grid--articles > article > .entry-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.post-grid--articles .entry-body > .entry-content,
.post-grid--articles .entry-body > .entry-summary {
    flex: 1 1 auto;
}

/* The content in a card is a preview: long articles (headings, lists,
   paragraphs) scroll inside it instead of making a tall card. Focusable
   (tabindex="0" in content.php) so it can be scrolled from the keyboard. */
.post-grid--articles .entry-body > .entry-content {
    max-height: 16rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

/* Code in a preview wraps instead of running out of the card. */
.post-grid--articles .entry-body > .entry-content pre,
.post-grid--articles .entry-body > .entry-content code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.post-grid--articles .entry-body > .entry-content :is(img, video, iframe, table) {
    max-width: 100%;
}

.post-grid--articles .entry-body > .entry-content:focus-visible {
    outline: var(--focus-ring-width, 2px) solid var(--focus-color);
    outline-offset: -2px;
}

.post-grid--articles .entry-body > .entry-content h2,
.post-grid--articles .entry-body > .entry-content h3,
.post-grid--articles .entry-body > .entry-content h4 {
    margin: 0.75em 0 0.35em;
    font-size: 1.05rem;
    line-height: 1.35;
}

.post-grid--articles .entry-body > .entry-footer {
    margin-top: auto;
}

/* Category, tag, author and date cards: same height in a row, the meta line
   (author, date, reading time) at the bottom. */
.post-grid > li > .post-card__inner,
.post-grid > li > article {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Search results (search.php): products as shop cards, then articles and pages. */
.search-group {
    margin: 0 0 var(--spacing-xl);
}

.search-group__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--spacing-xs) var(--spacing-md);
    margin: 0 0 var(--spacing-md);
}

.search-group__title {
    margin: 0;
    font-size: 1.35rem;
}

.search-result__type {
    margin: 0 0 var(--spacing-xs);
    font-size: var(--font-size-small);
    font-weight: 600;
    letter-spacing: 0.02em;
    opacity: 0.9;
}

.search-main .archive-header .search-form {
    margin-top: var(--spacing-md);
}

/* Results bar above the articles, like the shop's (count and sort order). */
.archive-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--spacing-sm) var(--spacing-md);
	margin: 0 0 var(--spacing-lg);
}

.archive-toolbar p {
	margin: 0;
}

.archive-toolbar__count {
	font-size: var(--font-size-small);
	color: var(--text-color);
}

.archive-toolbar__sort select {
	font-family: var(--font-family);
	font-size: var(--font-size-small);
	padding: var(--spacing-sm) var(--spacing-md);
	border: 1px solid var(--border-color);
	border-radius: var(--border-radius-sm);
	background-color: var(--input-bg);
	color: var(--input-text);
	cursor: pointer;
}

/* The listing header: breadcrumb, then the title — as on the shop. */
.archive-container > .main-header.archive-header,
.archive-container > .page-header.archive-header {
	padding: var(--spacing-md) 0 var(--spacing-lg);
}

.archive-container > .archive-header .page-title {
	font-size: 2rem;
	margin-top: var(--spacing-sm);
}

article {
	width: 100%;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

	transition:
		transform 0.2s ease,
		box-shadow 0.2s ease;
}

article:hover {
	transform: translateY(-5px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}