/*
 * SS Blogs - card grid + infinite scroll.
 *
 * Colours live ONLY in the custom properties below (the Elementor style controls
 * override them per widget). Never hardcode a colour further down - add a variable
 * and set it in BOTH themes.
 *
 * Selectors are scoped under .ssb-blogs (and a few carry an extra element/class) so
 * they out-rank the reset/kit styles Hello Elementor and the Elementor kit put on
 * bare a / h3 / p / button / img.
 */

/* ---------------------------------------------------------------- variables */
.ssb-blogs {
	--ssb-cols: 3;
	--ssb-gap: 28px;
	--ssb-ratio: 16 / 10;
	--ssb-pad: 24px;
	--ssb-radius: 14px;
	--ssb-btn-radius: 100px;

	--ssb-accent: #e02a27;
	--ssb-card-bg: #ffffff;
	--ssb-card-border: #e5e7eb;
	--ssb-card-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
	--ssb-title: #111827;
	/* Hovering a card only zooms its image; the title changes colour only if someone sets this in Elementor. */
	--ssb-title-hover: var(--ssb-title);
	--ssb-text: #4b5563;
	--ssb-muted: #6b7280;
	--ssb-chip-bg: #fdecec;
	--ssb-chip-text: #b3201d;
	--ssb-media-bg: #f3f4f6;
	--ssb-ph-icon: #9ca3af;
	--ssb-btn-bg: #e02a27;
	--ssb-btn-text: #ffffff;
	--ssb-btn-bg-hover: #111827;
	--ssb-btn-text-hover: #ffffff;
	--ssb-spinner-track: #e5e7eb;
}

/* Dark: black cards / white pill buttons, like the site's existing blog list. */
.ssb-blogs.ssb-blogs--dark {
	--ssb-card-bg: #0d0d0e;
	--ssb-card-border: #26272b;
	--ssb-card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
	--ssb-title: #ffffff;
	--ssb-text: #c9ccd3;
	--ssb-muted: #a3a8b3;
	--ssb-chip-bg: #2a2b30;
	--ssb-chip-text: #ffffff;
	--ssb-media-bg: #1b1c20;
	--ssb-ph-icon: #5b5f6a;
	--ssb-btn-bg: #ffffff;
	--ssb-btn-text: #000000;
	--ssb-btn-bg-hover: #e02a27;
	--ssb-btn-text-hover: #ffffff;
	--ssb-spinner-track: #26272b;
}

/* ------------------------------------------------------------------- layout */
.ssb-blogs,
.ssb-blogs *,
.ssb-blogs *::before,
.ssb-blogs *::after {
	box-sizing: border-box;
}

.ssb-blogs {
	width: 100%;
	font-family: inherit;
}

.ssb-blogs [hidden] {
	display: none !important;
}

.ssb-blogs .ssb-grid {
	display: grid;
	/* minmax(0, 1fr): tracks may shrink below their content width, so a long word can't blow the grid out. */
	grid-template-columns: repeat(var(--ssb-cols), minmax(0, 1fr));
	gap: var(--ssb-gap);
}

/* Fallback so the grid is sane even before Elementor's generated CSS arrives. Elementor's
   own per-widget rules have higher specificity and win whenever they exist. */
@media (max-width: 1024px) {
	.ssb-blogs {
		--ssb-cols: 2;
	}
}

@media (max-width: 767px) {
	.ssb-blogs {
		--ssb-cols: 1;
	}
}

/* --------------------------------------------------------------------- card */
.ssb-blogs .ssb-card {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	background: var(--ssb-card-bg);
	border: 1px solid var(--ssb-card-border);
	border-radius: var(--ssb-radius);
	box-shadow: var(--ssb-card-shadow);
}

.ssb-blogs .ssb-card--enter {
	animation: ssb-rise 0.45s ease both;
}

@keyframes ssb-rise {
	from {
		opacity: 0;
		transform: translateY(14px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* image - by default the WHOLE picture is shown at its own proportions (nothing is cropped) */
.ssb-blogs .ssb-card__media {
	position: relative;
	display: block;
	overflow: hidden;
	background: var(--ssb-media-bg);
}

.ssb-blogs .ssb-card__media .ssb-card__img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	transition: transform 0.5s ease;
}

/* posts without a featured image keep a placeholder of the chosen ratio */
.ssb-blogs .ssb-card--no-image .ssb-card__media {
	aspect-ratio: var(--ssb-ratio);
}

/* optional: put every image into the same ratio box, either whole (contain) or cropped (cover) */
.ssb-blogs.ssb-fit-contain .ssb-card__media,
.ssb-blogs.ssb-fit-cover .ssb-card__media {
	aspect-ratio: var(--ssb-ratio);
}

.ssb-blogs.ssb-fit-contain .ssb-card__media .ssb-card__img,
.ssb-blogs.ssb-fit-cover .ssb-card__media .ssb-card__img {
	position: absolute;
	inset: 0;
	height: 100%;
	max-width: none;
}

.ssb-blogs.ssb-fit-contain .ssb-card__media .ssb-card__img {
	object-fit: contain;
}

.ssb-blogs.ssb-fit-cover .ssb-card__media .ssb-card__img {
	object-fit: cover;
}

/* the only hover effect: a slow zoom of the image inside its frame */
.ssb-blogs .ssb-card:hover .ssb-card__img {
	transform: scale(1.05);
}

.ssb-blogs .ssb-card__ph {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	color: var(--ssb-ph-icon);
}

/* body */
.ssb-blogs .ssb-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 12px;
	padding: var(--ssb-pad);
}

.ssb-blogs .ssb-card__cats {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.ssb-blogs a.ssb-chip {
	position: relative; /* above the card's stretched link so chips stay clickable */
	z-index: 2;
	display: inline-block;
	padding: 4px 12px;
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1.5;
	letter-spacing: 0.02em;
	color: var(--ssb-chip-text);
	text-decoration: none;
	background: var(--ssb-chip-bg);
	border-radius: 100px;
	transition: filter 0.2s ease;
}

.ssb-blogs a.ssb-chip:hover,
.ssb-blogs a.ssb-chip:focus-visible {
	color: var(--ssb-chip-text);
	filter: brightness(0.94);
}

.ssb-blogs .ssb-card__title {
	margin: 0;
	padding: 0;
	font-size: 1.25rem;
	font-weight: 600;
	line-height: 1.3;
	color: var(--ssb-title);
	overflow-wrap: anywhere;
}

.ssb-blogs .ssb-card__title a.ssb-card__link {
	color: inherit;
	text-decoration: none;
	transition: color 0.2s ease;
}

/* Stretched link: the whole card is one click target, one tab stop, one screen-reader link. */
.ssb-blogs .ssb-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	border-radius: inherit;
}

.ssb-blogs .ssb-card:hover .ssb-card__title a.ssb-card__link,
.ssb-blogs .ssb-card__title a.ssb-card__link:focus-visible {
	color: var(--ssb-title-hover);
}

.ssb-blogs .ssb-card__link:focus-visible {
	outline: none;
}

.ssb-blogs .ssb-card__link:focus-visible::after {
	outline: 3px solid var(--ssb-accent);
	outline-offset: -3px;
}

.ssb-blogs .ssb-card__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 16px;
	font-size: 0.875rem;
	line-height: 1.4;
	color: var(--ssb-muted);
}

.ssb-blogs .ssb-meta {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.ssb-blogs .ssb-meta svg {
	flex: none;
}

.ssb-blogs .ssb-card__excerpt {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	font-size: 1rem;
	line-height: 1.6;
	color: var(--ssb-text);
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
}

/* "Read more" is decorative (the title link is the real link) - styled like the buttons. */
.ssb-blogs .ssb-card__more {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	gap: 8px;
	margin-top: auto;
	padding: 10px 20px;
	font-size: 0.9375rem;
	font-weight: 500;
	line-height: 1.2;
	color: var(--ssb-btn-text);
	background: var(--ssb-btn-bg);
	border-radius: var(--ssb-btn-radius);
}

/* ------------------------------------------------------------------- footer */
.ssb-blogs .ssb-foot {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
	margin-top: 32px;
}

.ssb-blogs .ssb-sentinel {
	height: 1px;
	margin-top: -1px;
}

.ssb-blogs .ssb-loader {
	display: flex;
	justify-content: center;
}

.ssb-blogs .ssb-spinner {
	width: 30px;
	height: 30px;
	border: 3px solid var(--ssb-spinner-track);
	border-top-color: var(--ssb-accent);
	border-radius: 50%;
	animation: ssb-spin 0.8s linear infinite;
}

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

.ssb-blogs .ssb-status {
	min-height: 1.5em;
	margin: 0;
	font-size: 0.9375rem;
	line-height: 1.5;
	text-align: center;
	color: var(--ssb-muted);
}

.ssb-blogs .ssb-status:empty {
	display: none;
}

.ssb-blogs .ssb-nav {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 12px;
}

/* Buttons (anchors before JS / with no JS, <button> once JS takes over). */
.ssb-blogs a.ssb-btn,
.ssb-blogs button.ssb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 12px 28px;
	font-family: inherit;
	font-size: 1rem;
	font-weight: 500;
	line-height: 1.2;
	color: var(--ssb-btn-text);
	text-decoration: none;
	cursor: pointer;
	background: var(--ssb-btn-bg);
	border: 0;
	border-radius: var(--ssb-btn-radius);
	box-shadow: none;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.ssb-blogs a.ssb-btn:hover,
.ssb-blogs button.ssb-btn:hover,
.ssb-blogs a.ssb-btn:focus-visible,
.ssb-blogs button.ssb-btn:focus-visible {
	color: var(--ssb-btn-text-hover);
	background: var(--ssb-btn-bg-hover);
}

.ssb-blogs a.ssb-btn:focus-visible,
.ssb-blogs button.ssb-btn:focus-visible {
	outline: 3px solid var(--ssb-accent);
	outline-offset: 3px;
}

.ssb-blogs button.ssb-btn[disabled] {
	cursor: progress;
	opacity: 0.6;
}

.ssb-blogs .ssb-empty {
	margin: 0;
	padding: 48px 16px;
	text-align: center;
	color: var(--ssb-muted);
}

/* ------------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
	.ssb-blogs .ssb-card__img,
	.ssb-blogs a.ssb-btn,
	.ssb-blogs button.ssb-btn {
		transition: none;
	}

	.ssb-blogs .ssb-card:hover .ssb-card__img {
		transform: none;
	}

	.ssb-blogs .ssb-card--enter {
		animation: none;
	}
}
