/*
 * Blog post layouts.
 *
 * Four shapes off one markup structure — the layout class on the wrapper is
 * the only difference — so a post card looks the same wherever it appears and
 * switching layout in Elementor never changes the styling of the card itself.
 *
 * Colours come from custom properties the widget's Style tab writes to, and
 * fall back to the theme's tokens when nothing is set.
 */

.csk-posts {
	--csk-surface: #ffffff;
	--csk-ink: var(--ch-ink, #0f172a);
	--csk-body: #334155;
	--csk-muted: var(--ch-muted, #64748b);
	--csk-accent: var(--ch-brand, #0b5ea8);
	--csk-line: var(--ch-line, #e2e8f0);

	display: grid;
	gap: 24px;
}

.csk-post {
	--csk-radius: 10px;

	display: flex;
	flex-direction: column;
	min-width: 0;
	background: var(--csk-surface);
	border: 1px solid var(--csk-line);
	border-radius: var(--csk-radius);
	overflow: hidden;
	/* Border and shadow only — a transform would shift the grid on hover. */
	transition: border-color .18s ease, box-shadow .18s ease;
}

.csk-post:hover {
	border-color: color-mix(in srgb, var(--csk-accent) 40%, var(--csk-line));
	box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
}

.csk-post-thumb {
	display: block;
	aspect-ratio: 1 / .62;
	overflow: hidden;
	background: color-mix(in srgb, var(--csk-line) 60%, transparent);
}

.csk-post-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.csk-post-body {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 18px 20px 20px;
	flex: 1 1 auto;
}

.csk-post-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin: 0;
	font-size: .78rem;
	color: var(--csk-muted);
}

.csk-post-cat {
	color: var(--csk-accent);
	text-decoration: none;
	font-weight: 600;
}
.csk-post-cat:hover { text-decoration: underline; }
.csk-dot { color: var(--csk-line); }

.csk-post-title {
	margin: 0;
	font-size: 1.12rem;
	line-height: 1.35;
	font-weight: 650;
	text-wrap: balance;
}

.csk-post-title a {
	color: var(--csk-ink);
	text-decoration: none;
}
.csk-post-title a:hover { color: var(--csk-accent); }

.csk-post-excerpt {
	margin: 0;
	color: var(--csk-body);
	font-size: .92rem;
	line-height: 1.6;
}

.csk-post-more {
	margin-top: auto;
	padding-top: 4px;
	align-self: flex-start;
	color: var(--csk-accent);
	font-size: .88rem;
	font-weight: 600;
	text-decoration: none;
}
.csk-post-more:hover { text-decoration: underline; }

.csk-post-more::after {
	content: " →";
	/* Keeps the arrow from wrapping onto its own line. */
	white-space: nowrap;
}

/* --- Grid --------------------------------------------------------------- */

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

/* --- List --------------------------------------------------------------- */

.csk-posts-list { grid-template-columns: minmax(0, 1fr); }

.csk-posts-list .csk-post { flex-direction: row; align-items: stretch; }

.csk-posts-list .csk-post-thumb {
	flex: 0 0 34%;
	aspect-ratio: auto;
	min-height: 100%;
}

/* --- Spotlight ---------------------------------------------------------- */

.csk-posts-spotlight { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.csk-posts-spotlight .csk-post.is-lead {
	grid-column: span 2;
	grid-row: span 2;
}

.csk-posts-spotlight .csk-post.is-lead .csk-post-title {
	font-size: 1.6rem;
	line-height: 1.25;
}

.csk-posts-spotlight .csk-post.is-lead .csk-post-thumb { aspect-ratio: 1 / .5; }

/* --- Minimal ------------------------------------------------------------ */

.csk-posts-minimal {
	grid-template-columns: minmax(0, 1fr);
	gap: 0;
}

.csk-posts-minimal .csk-post {
	border: 0;
	border-bottom: 1px solid var(--csk-line);
	border-radius: 0;
	background: none;
}
.csk-posts-minimal .csk-post:last-child { border-bottom: 0; }
.csk-posts-minimal .csk-post:hover { box-shadow: none; }
.csk-posts-minimal .csk-post-body { padding: 14px 0; gap: 4px; }

.csk-posts-minimal .csk-post-title { font-size: 1rem; }

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

@media (max-width: 1024px) {
	.csk-posts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.csk-posts-spotlight { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.csk-posts-spotlight .csk-post.is-lead { grid-column: span 2; grid-row: auto; }
}

@media (max-width: 767px) {
	.csk-posts-grid,
	.csk-posts-spotlight { grid-template-columns: minmax(0, 1fr); }
	.csk-posts-spotlight .csk-post.is-lead { grid-column: auto; }

	/* Side-by-side becomes unreadable on a phone. */
	.csk-posts-list .csk-post { flex-direction: column; }
	.csk-posts-list .csk-post-thumb { flex: none; aspect-ratio: 1 / .55; min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.csk-post { transition: none; }
}

.csk-empty {
	padding: 24px;
	text-align: center;
	border: 1px dashed var(--csk-line);
	border-radius: 8px;
	color: var(--csk-muted);
	font-size: .9rem;
}

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

.csk-pagination { margin-top: 32px; }
.csk-pagination ul {
	display: flex; flex-wrap: wrap; gap: 6px;
	list-style: none; margin: 0; padding: 0; justify-content: center;
}
.csk-pagination li { margin: 0; }
.csk-pagination a,
.csk-pagination span {
	display: flex; align-items: center; justify-content: center;
	/* 44px is the minimum comfortable touch target; page numbers are the
	   easiest thing in a blog to make too small to hit. */
	min-width: 44px; min-height: 44px; padding: 0 12px;
	border: 1px solid var(--csk-line, #e2e8f0);
	border-radius: 6px; text-decoration: none;
	font-size: 14px; line-height: 1;
	color: var(--csk-ink, #0f172a);
	background: var(--csk-surface, #fff);
	transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}
.csk-pagination a:hover { border-color: var(--csk-accent, #0b5ea8); color: var(--csk-accent, #0b5ea8); }
.csk-pagination a:focus-visible {
	outline: 2px solid var(--csk-accent, #0b5ea8); outline-offset: 2px;
}
.csk-pagination .current {
	background: var(--csk-accent, #0b5ea8);
	border-color: var(--csk-accent, #0b5ea8);
	color: var(--csk-accent-ink, #fff);
	font-weight: 600;
}
.csk-pagination .dots { border-color: transparent; background: none; }

@media (prefers-reduced-motion: reduce) {
	.csk-pagination a { transition: none; }
}

/* The article ------------------------------------------------------------- */

/*
 * One measure variable drives the whole page. Full-width body text is the
 * single most reliable way a well-written article gets abandoned: at 120
 * characters the eye loses its place returning to the left margin, and the
 * reader blames the writing.
 *
 * Set from the template settings, with a sane default if the plugin is gone.
 */
.csk-prose {
	--measure: var(--csk-measure, 68ch);
	font-size: var(--csk-base, 17px);
	line-height: 1.72;
}
.csk-prose > * { max-width: var(--measure); margin-left: auto; margin-right: auto; }

/* Things that earn the full width back. */
.csk-prose > figure,
.csk-prose > .wp-block-image,
.csk-prose > table,
.csk-prose > pre,
.csk-prose > .csk-toc { max-width: min(100%, 46rem); }

.csk-prose p { margin: 0 0 1.15em; }
.csk-prose h2 {
	margin: 2.1em 0 .5em;
	font-size: clamp(1.35rem, 1.1rem + 1.1vw, 1.7rem);
	line-height: 1.25; font-weight: 700;
	scroll-margin-top: 90px; /* clears a sticky header when jumped to */
}
.csk-prose h3 {
	margin: 1.7em 0 .4em;
	font-size: clamp(1.1rem, 1rem + .6vw, 1.28rem);
	line-height: 1.3; font-weight: 650;
	scroll-margin-top: 90px;
}
.csk-prose ul, .csk-prose ol { margin: 0 auto 1.2em; padding-left: 1.4em; }
.csk-prose li { margin-bottom: .45em; }

.csk-prose img { height: auto; border-radius: var(--csk-radius, 8px); }
.csk-prose figure { margin: 1.8em auto; }
.csk-prose figcaption {
	margin-top: .55em; font-size: .84rem; line-height: 1.5;
	color: var(--csk-muted, #5b6b7c);
}

/* The pull quote. A left rule rather than giant quotation marks: this is a
   useful sentence from the article, not a testimonial. */
.csk-prose blockquote {
	margin: 1.9em auto; padding: .2em 0 .2em 1.3em;
	border-left: 3px solid var(--csk-accent, #0b5ea8);
	font-size: 1.14em; line-height: 1.55; font-weight: 500;
	color: var(--csk-ink, #0f172a);
}
.csk-prose blockquote p:last-child { margin-bottom: 0; }

.csk-prose table { width: 100%; border-collapse: collapse; margin: 1.6em auto; font-size: .95em; }
.csk-prose th, .csk-prose td {
	padding: 10px 12px; text-align: left;
	border-bottom: 1px solid var(--csk-line, #e2e8f0);
}
.csk-prose th { font-weight: 650; }

/* A wide table has to scroll inside itself; the page must never scroll
   sideways on a phone. */
.csk-prose .csk-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.csk-article-meta {
	display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline;
	margin: 0 auto 1.6em;
	font-size: .88rem; color: var(--csk-muted, #5b6b7c);
}
.csk-updated { font-style: italic; }

/* Contents ---------------------------------------------------------------- */

.csk-toc {
	margin: 0 auto 2em; padding: 16px 20px;
	background: var(--csk-ground, #f6f8fa);
	border: 1px solid var(--csk-line, #e2e8f0);
	border-radius: var(--csk-radius, 8px);
}
.csk-toc-heading {
	margin: 0 0 8px; font-size: .78rem; font-weight: 700;
	letter-spacing: .07em; text-transform: uppercase;
	color: var(--csk-muted, #5b6b7c);
}
.csk-toc ol { margin: 0; padding: 0; list-style: none; counter-reset: toc; }
.csk-toc li { margin: 0; }
.csk-toc a {
	display: block; padding: 7px 0; line-height: 1.4;
	color: var(--csk-ink, #0f172a); text-decoration: none;
	border-bottom: 1px solid transparent;
}
.csk-toc a:hover { color: var(--csk-accent, #0b5ea8); }
.csk-toc a:focus-visible { outline: 2px solid var(--csk-accent, #0b5ea8); outline-offset: 2px; }
.csk-toc-l3 a { padding-left: 16px; font-size: .93em; color: var(--csk-muted, #5b6b7c); }

/* Related ----------------------------------------------------------------- */

.csk-related { margin: 44px 0 8px; }
.csk-related-heading { margin: 0 0 4px; font-size: 1.25rem; font-weight: 700; }
.csk-related-note { margin: 0 0 16px; font-size: .9rem; color: var(--csk-muted, #5b6b7c); }
.csk-related-list {
	display: grid; gap: 18px; margin: 0; padding: 0; list-style: none;
	/* auto-fit so three items fill a wide screen and one fills a phone,
	   without a media query per breakpoint. */
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}
.csk-related-item a {
	display: flex; flex-direction: column; gap: 10px;
	height: 100%; text-decoration: none;
	color: var(--csk-ink, #0f172a);
}
.csk-related-item img {
	width: 100%; aspect-ratio: 16 / 10; object-fit: cover;
	border-radius: var(--csk-radius, 8px);
	background: var(--csk-ground, #f6f8fa);
}
.csk-related-title { font-weight: 650; line-height: 1.35; }
.csk-related-item a:hover .csk-related-title { color: var(--csk-accent, #0b5ea8); }
.csk-related-item a:focus-visible { outline: 2px solid var(--csk-accent, #0b5ea8); outline-offset: 3px; border-radius: 4px; }

@media (max-width: 600px) {
	.csk-prose { line-height: 1.68; }
	.csk-toc { padding: 14px 16px; }
}

@media (prefers-reduced-motion: reduce) {
	.csk-toc a, .csk-related-title { transition: none; }
	html { scroll-behavior: auto; }
}

/* ====================================================================
 * Elementor widgets on an article
 *
 * Not our markup — the loop grid and the table of contents are built in
 * Elementor's single-post template. But both land inside an article we
 * are styling, and both arrive with a layout problem that no Elementor
 * setting fixes, so they are corrected here.
 *
 * Scoped to .csk-article on purpose: this stylesheet loads site-wide,
 * and reshaping every loop grid on the site from a blog stylesheet
 * would be a surprise waiting to happen.
 * ================================================================== */

/*
 * Cards of unequal height.
 *
 * The cause is not the grid, it is the pictures. Each card is a flex
 * column of image, date, title, and the featured image keeps whatever
 * proportions the photo happened to have — a 4:3 photo makes a card
 * taller than a 16:9 one beside it, so the dates and titles below them
 * never line up. Nothing in the widget's settings crops the image.
 *
 * Fixing the ratio fixes the row. object-fit keeps the subject framed
 * rather than squashed.
 */
.csk-article .e-loop-item .elementor-widget-theme-post-featured-image img {
	aspect-ratio: 16 / 10;
	width: 100%;
	height: auto;
	object-fit: cover;
	display: block;
}

/* Stretch the cards to the tallest in the row rather than to their own
 * content, so the white panel behind them ends at the same line. */
.csk-article .elementor-loop-container.elementor-grid { align-items: stretch; }

.csk-article .e-loop-item {
	height: 100%;
	display: flex;
	flex-direction: column;
}

/*
 * Titles of one and two lines make cards of two different heights. Two
 * lines, always: clamped so a long one cannot run to three, and floored
 * so a short one still occupies two.
 */
.csk-article .e-loop-item .elementor-widget-theme-post-title .elementor-heading-title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: calc(2 * 1.35em);
	line-height: 1.35;
}

/*
 * The table of contents, when it is set to follow the scroll.
 *
 * A sticky box is only sticky until it is taller than the screen; past
 * that it simply covers whatever it is scrolling over, which is how it
 * ended up sitting on top of the cards. Give it a ceiling and let the
 * list scroll inside itself instead.
 *
 * overscroll-behavior stops the page from scrolling on underneath once
 * the list reaches its end — without it, reaching the bottom of the
 * contents throws you down the page.
 */
.csk-article .elementor-widget-table-of-contents .elementor-toc__body {
	max-height: min(60vh, 420px);
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* On a short screen the header alone can fill the viewport; keep the
 * whole widget inside it so it can never cover the page. */
@media (max-height: 600px) {
	.csk-article .elementor-widget-table-of-contents .elementor-toc__body {
		max-height: 40vh;
	}
}
