/*
 * Croator Webstudio Addons — blog index.
 *
 * Ported from CROATOR-FULL-REDESIGN/Croator Blog.dc.html. Kept in its own stylesheet
 * rather than appended to croator-widgets.css so a landing page carrying only a hero
 * never downloads the ~9 KB of listing CSS, and vice versa.
 *
 * Same two departures from the source as the rest of the pack: base styles live in
 * classes so the intended hovers actually fire, and the reduced-motion reset is scoped
 * to this widget instead of every animation on the page.
 *
 * The source hard-codes `position:sticky;top:68px` on the filter bar, which assumes its
 * own 68px header. Here the offset is --cws-blog-sticky-top, driven by a control.
 */

/* ---------------------------------------------------------------- keyframes */

@keyframes cws-blog-spin {
	to { transform: rotate(360deg); }
}

@keyframes cws-blog-shimmer {
	0% { background-position: 150% 0; }
	100% { background-position: -50% 0; }
}

/* -------------------------------------------------------------------- shell */

.cws-blog {
	font-family: var(--cws-font-body);
	color: var(--cws-tx);

	/* Tunable through Elementor controls. Defaults are the source values. */
	--cws-blog-sticky-top: 0px;
	--cws-blog-card-min: 290px;
	--cws-blog-gap: clamp(18px, 2.2vw, 26px);
	--cws-blog-radius: 20px;
}

.cws-blog *,
.cws-blog *::before,
.cws-blog *::after {
	box-sizing: border-box;
}

.cws-blog [hidden] {
	display: none !important;
}

.cws-blog__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* --------------------------------------------------------------- filter bar */

.cws-blog__bar {
	display: flex;
	align-items: center;
	gap: 12px;
	background: var(--cws-pg);
	border-bottom: 1px solid var(--cws-bd);
	padding: 12px 0;
}

.cws-blog--sticky .cws-blog__bar {
	position: sticky;
	top: var(--cws-blog-sticky-top);
	z-index: 40;
}

.cws-blog__chips {
	display: flex;
	align-items: center;
	gap: 9px;
	flex: 1 1 auto;
	min-width: 0;
	overflow-x: auto;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.cws-blog__chips::-webkit-scrollbar {
	display: none;
}

.cws-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	flex: none;
	white-space: nowrap;
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	padding: 12px 16px;
	border: 1.5px solid var(--cws-bd);
	border-radius: 999px;
	background: var(--cws-card);
	color: var(--cws-tx);
	cursor: pointer;
	text-decoration: none;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cws-chip:hover,
.cws-chip:focus-visible {
	border-color: var(--cws-brand);
	color: var(--cws-tx);
}

.cws-chip.is-active,
.cws-chip.is-active:hover {
	border-color: var(--cws-brand);
	background: var(--cws-brand);
	color: #fff;
}

.cws-chip__count {
	font-size: 12px;
	font-weight: 700;
	color: var(--cws-tx3);
}

.cws-chip.is-active .cws-chip__count {
	color: rgba(255, 255, 255, 0.75);
}

/* ------------------------------------------------------------------- search */

.cws-blog__search {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 0 0 300px;
	margin: 0;
	padding: 3px 6px 3px 14px;
	background: var(--cws-card);
	border: 1.5px solid var(--cws-bd);
	border-radius: 14px;
	box-shadow: 0 14px 30px -26px rgba(14, 17, 22, 0.8);
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

/*
 * The source tracks focus in component state purely to restyle this wrapper.
 * :focus-within does the same thing with no JavaScript and also covers the clear button.
 */
.cws-blog__search:focus-within {
	border-color: var(--cws-brand);
	box-shadow: 0 0 0 4px rgba(219, 68, 55, 0.14);
}

.cws-blog__search-icon {
	flex: none;
	color: var(--cws-brand);
}

.cws-blog__search-input {
	flex: 1;
	min-width: 0;
	margin: 0;
	padding: 11px 0;
	border: 0;
	outline: none;
	background: transparent;
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	color: var(--cws-tx);
	box-shadow: none;
}

.cws-blog__search-input::placeholder {
	color: var(--cws-tx3);
	font-weight: 600;
}

/* Chrome's own clear affordance would sit next to ours. */
.cws-blog__search-input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.cws-blog__clear {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 11px;
	background: var(--cws-s1);
	color: var(--cws-tx2);
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
}

.cws-blog__clear:hover {
	color: var(--cws-tx);
}

/* ----------------------------------------------------------------- featured */

.cws-blog__featured {
	display: grid;
	/* min(100%, 300px) so the media column never forces a horizontal scrollbar. */
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
	margin-top: clamp(34px, 5vw, 60px);
	background: var(--cws-card);
	border: 1px solid var(--cws-bd);
	border-radius: 24px;
	overflow: hidden;
	color: inherit;
	text-decoration: none;
	box-shadow: 0 34px 80px -50px rgba(14, 17, 22, 0.45);
	transition: border-color 0.18s ease;
}

.cws-blog__featured:hover,
.cws-blog__featured:focus-visible {
	border-color: var(--cws-brand);
	color: inherit;
}

.cws-blog__featured-media {
	position: relative;
	min-height: 280px;
	background: var(--cws-s1);
}

.cws-blog__ribbon {
	position: absolute;
	top: 18px;
	left: 18px;
	z-index: 1;
	padding: 7px 12px;
	border-radius: 8px;
	background: var(--cws-brand);
	color: #fff;
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 1px;
}

.cws-blog__featured-body {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 16px;
	padding: clamp(28px, 3.4vw, 44px);
}

.cws-blog__featured-title {
	margin: 0;
	font-family: var(--cws-font-display);
	font-weight: 700;
	font-size: clamp(25px, 2.7vw, 34px);
	line-height: 1.16;
	letter-spacing: -0.9px;
	color: var(--cws-tx);
	text-wrap: pretty;
}

.cws-blog__featured-excerpt {
	margin: 0;
	max-width: 620px;
	font-size: 16px;
	line-height: 1.68;
	font-weight: 500;
	color: var(--cws-tx2);
	text-wrap: pretty;
}

.cws-blog__featured .cws-blog__meta {
	margin-top: 4px;
	padding-top: 0;
	border-top: 0;
}

.cws-blog__featured .cws-blog__avatar {
	width: 38px;
	height: 38px;
	font-size: 14px;
}

.cws-blog__featured .cws-blog__author,
.cws-blog__featured .cws-blog__more-link {
	font-size: 14px;
}

.cws-blog__featured .cws-blog__pill {
	padding: 5px 11px;
	font-size: 13px;
}

/* ----------------------------------------------------------- section header */

.cws-blog__head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 16px;
	margin: clamp(32px, 4.5vw, 54px) 0 26px;
}

.cws-blog__heading {
	margin: 0;
	font-family: var(--cws-font-display);
	font-weight: 700;
	font-size: clamp(22px, 2.2vw, 28px);
	letter-spacing: -0.7px;
	color: var(--cws-tx);
}

.cws-blog__count {
	font-size: 14px;
	font-weight: 600;
	color: var(--cws-tx3);
}

/* --------------------------------------------------------------- posts grid */

.cws-blog__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--cws-blog-card-min)), 1fr));
	gap: var(--cws-blog-gap);
}

.cws-card {
	display: flex;
	flex-direction: column;
	background: var(--cws-card);
	border: 1px solid var(--cws-bd);
	border-radius: var(--cws-blog-radius);
	overflow: hidden;
	color: inherit;
	text-decoration: none;
	transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.cws-card:hover,
.cws-card:focus-visible {
	transform: translateY(-4px);
	border-color: var(--cws-brand);
	box-shadow: 0 26px 50px -34px rgba(14, 17, 22, 0.5);
	color: inherit;
}

.cws-card__media {
	position: relative;
	aspect-ratio: 16 / 10;
	background: var(--cws-s1);
	border-bottom: 1px solid var(--cws-bd);
}

/* Covers both the real thumbnail and the empty-state fill. */
.cws-blog__media-fill,
.cws-card__media img,
.cws-blog__featured-media img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cws-blog__media-fill {
	background: var(--cws-media-bg);
}

.cws-card__body {
	display: flex;
	flex-direction: column;
	flex: 1;
	gap: 12px;
	padding: 22px;
}

.cws-blog__terms {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 9px;
	font-size: 12px;
	font-weight: 700;
	color: var(--cws-tx3);
}

.cws-blog__pill {
	padding: 4px 10px;
	border-radius: 999px;
	background: var(--cws-tint);
	color: var(--cws-acc);
}

.cws-card__title {
	margin: 0;
	font-family: var(--cws-font-display);
	font-weight: 700;
	font-size: 19px;
	line-height: 1.28;
	letter-spacing: -0.4px;
	color: var(--cws-tx);
	text-wrap: pretty;
}

.cws-card__excerpt {
	margin: 0;
	font-size: 14.5px;
	line-height: 1.62;
	font-weight: 500;
	color: var(--cws-tx2);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.cws-blog__meta {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: auto;
	padding-top: 14px;
	border-top: 1px solid var(--cws-bd);
}

.cws-blog__avatar {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	overflow: hidden;
	background: var(--cws-tint);
	color: var(--cws-acc);
	font-weight: 800;
	font-size: 12px;

	/* The initial is upper-cased here rather than in PHP — see cws_first_letter(). */
	text-transform: uppercase;
}

.cws-blog__avatar img {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
}

.cws-blog__author {
	font-size: 13px;
	font-weight: 700;
	color: var(--cws-tx);
}

.cws-blog__more-link {
	margin-left: auto;
	font-size: 13px;
	font-weight: 800;
	color: var(--cws-brand);
}

/* -------------------------------------------------------------- empty state */

.cws-blog__empty {
	padding: 56px 24px;
	text-align: center;
	background: var(--cws-s1);
	border: 1px dashed var(--cws-bd);
	border-radius: var(--cws-blog-radius);
}

.cws-blog__empty-title {
	margin: 0 0 8px;
	font-family: var(--cws-font-display);
	font-weight: 700;
	font-size: 20px;
	letter-spacing: -0.5px;
	color: var(--cws-tx);
}

.cws-blog__empty-text {
	margin: 0 0 20px;
	font-size: 15px;
	font-weight: 500;
	color: var(--cws-tx2);
}

.cws-blog__reset {
	padding: 12px 20px;
	border: 1.5px solid var(--cws-brand);
	border-radius: 12px;
	background: var(--cws-brand);
	color: #fff;
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	text-decoration: none;
	display: inline-block;
}

.cws-blog__reset:hover {
	border-color: var(--cws-brand-hover);
	background: var(--cws-brand-hover);
	color: #fff;
}

/* ------------------------------------------------------- paging & feedback  */

.cws-blog__sentinel {
	height: 1px;
}

.cws-blog__loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-top: 40px;
	font-size: 14px;
	font-weight: 700;
	color: var(--cws-tx3);
}

.cws-blog__spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid var(--cws-bd);
	border-top-color: var(--cws-brand);
	border-radius: 50%;
	animation: cws-blog-spin 0.7s linear infinite;
}

.cws-blog__more {
	display: flex;
	justify-content: center;
	margin-top: 40px;
}

.cws-blog__more-btn {
	padding: 13px 24px;
	border: 1.5px solid var(--cws-bd);
	border-radius: 12px;
	background: var(--cws-card);
	color: var(--cws-tx);
	font-family: inherit;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	text-decoration: none;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.cws-blog__more-btn:hover {
	border-color: var(--cws-brand);
	color: var(--cws-tx);
}

.cws-blog__more-btn[disabled] {
	opacity: 0.55;
	cursor: default;
}

.cws-blog__end {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-top: 44px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.5px;
	color: var(--cws-tx3);
}

.cws-blog__end::before,
.cws-blog__end::after {
	content: "";
	flex: 1;
	height: 1px;
	background: var(--cws-bd);
}

/* ---------------------------------------------------------------- skeletons */

.cws-blog__skeleton {
	background: var(--cws-card);
	border: 1px solid var(--cws-bd);
	border-radius: var(--cws-blog-radius);
	overflow: hidden;
}

.cws-blog__skeleton-body {
	display: flex;
	flex-direction: column;
	gap: 13px;
	padding: 22px;
}

.cws-blog__shimmer {
	background: linear-gradient(90deg, var(--cws-s1) 25%, var(--cws-bd) 40%, var(--cws-s1) 60%);
	background-size: 300% 100%;
	animation: cws-blog-shimmer 1.5s ease-in-out infinite;
}

.cws-blog__skeleton-media {
	aspect-ratio: 16 / 10;
	border-bottom: 1px solid var(--cws-bd);
}

.cws-blog__skeleton-pill {
	width: 120px;
	height: 22px;
	border-radius: 999px;
}

.cws-blog__skeleton-line {
	height: 17px;
	border-radius: 6px;
}

.cws-blog__skeleton-line--1 { width: 94%; }
.cws-blog__skeleton-line--2 { width: 64%; }

.cws-blog__skeleton-text {
	height: 11px;
	border-radius: 6px;
}

.cws-blog__skeleton-text--1 { width: 100%; margin-top: 4px; }
.cws-blog__skeleton-text--2 { width: 88%; }
.cws-blog__skeleton-text--3 { width: 46%; }

/* ------------------------------------------------------------------ compact */

/*
 * 860px is the source's own breakpoint — the point at which its JS switched the bar to
 * flex-wrap and pushed the search field onto its own row. Done here in CSS, so it tracks
 * the container rather than the viewport-width state of a React component.
 */
@media (max-width: 860px) {
	.cws-blog__bar {
		flex-wrap: wrap;
	}

	.cws-blog__search {
		flex: 1 1 100%;
		order: 2;
	}
}

@media (max-width: 600px) {
	.cws-blog__featured-media {
		min-height: 0;
		aspect-ratio: 16 / 10;
	}
}

/* ---------------------------------------------------------- reduced motion  */

@media (prefers-reduced-motion: reduce) {
	.cws-blog *,
	.cws-blog *::before,
	.cws-blog *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}

	.cws-card:hover,
	.cws-card:focus-visible {
		transform: none;
	}

	/* The spinner is the one place motion carries meaning; keep it, just slower. */
	.cws-blog__spinner {
		animation: cws-blog-spin 1.6s linear infinite !important;
	}
}
