/**
 * Latest Articles — matches mockup card grid.
 */

.afj-latest {
	--afj-bg: #ffffff;
	--afj-ink: #0a0a0a;
	--afj-muted: #757575;
	--afj-line: #cfcbc3;
	--afj-pill-bg: rgba(255, 255, 255, 0.92);
	--afj-radius: 1.35rem;
	--afj-ease: cubic-bezier(0.22, 1, 0.36, 1);

	width: 100vw !important;
	max-width: 100vw !important;
	margin-top: 0 !important;
	margin-block-start: 0 !important;
	margin-left: calc(50% - 50vw) !important;
	margin-right: calc(50% - 50vw) !important;
	box-sizing: border-box;
	background: var(--afj-bg);
	color: var(--afj-ink);
	padding: clamp(2.25rem, 4vw, 3rem) 0 clamp(4.5rem, 8vw, 6.5rem);
	font-family: var(--afj-font-body, "Plus Jakarta Sans", system-ui, sans-serif);
	overflow: hidden;
}

.afj-latest__inner {
	width: min(1120px, calc(100% - 3rem));
	margin-inline: auto;
}

/* ---------- Header ---------- */
.afj-latest__header {
	display: flex;
	align-items: center;
	gap: 1rem;
	margin-bottom: clamp(1.75rem, 3.5vw, 2.5rem);
}

.afj-latest__eyebrow {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	min-width: 0;
	flex: 1;
}

.afj-latest__heading {
	margin: 0;
	font-size: 0.68rem;
	font-weight: 800;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--afj-ink);
}

.afj-latest__line {
	display: block;
	height: 1px;
	width: 120px;
	max-width: 120px;
	flex: 0 0 120px;
	background: var(--afj-line);
	transform-origin: left center;
	animation: afj-latest-line 0.8s var(--afj-ease) both;
}

.afj-latest__view-all {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	flex-shrink: 0;
	font-size: 0.9rem;
	font-weight: 500;
	color: var(--afj-ink);
	text-decoration: none;
	white-space: nowrap;
	transition: gap 0.3s var(--afj-ease), opacity 0.3s var(--afj-ease);
}

.afj-latest__view-all:hover {
	gap: 0.55rem;
	opacity: 0.7;
}

.afj-latest__view-arrow {
	display: inline-flex;
	transition: transform 0.3s var(--afj-ease);
}

.afj-latest__view-all:hover .afj-latest__view-arrow {
	transform: translateX(3px);
}

/* ---------- Grid ---------- */
.afj-latest__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: clamp(1.35rem, 2.8vw, 2rem);
	align-items: stretch;
}

.afj-latest__card {
	min-width: 0;
	animation: afj-latest-in 0.65s var(--afj-ease) both;
	animation-delay: var(--afj-delay, 0s);
}

.afj-latest__card-link {
	display: flex;
	flex-direction: column;
	height: 100%;
	color: inherit;
	text-decoration: none;
}

/* Image + overlapping category pill */
.afj-latest__visual {
	position: relative;
	margin-bottom: 1.35rem; /* room for half-pill below the image */
}

.afj-latest__media {
	overflow: hidden;
	border-radius: var(--afj-radius);
	height: 200px;
	max-height: 200px;
	background: #e6e2d8;
}

.afj-latest__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.65s var(--afj-ease);
}

.afj-latest__img--placeholder {
	background: linear-gradient(135deg, #ddd8ce, #cfc9bd);
	height: 100%;
}

.afj-latest__card-link:hover .afj-latest__img,
.afj-latest__card-link:focus-visible .afj-latest__img {
	transform: scale(1.05);
}

/* Sits outside media — half over the image, half below */
.afj-latest__pill {
	position: absolute;
	left: 0.85rem;
	bottom: 0;
	z-index: 2;
	transform: translateY(50%);
	padding: 0.42rem 0.85rem;
	border-radius: 999px;
	background: var(--afj-pill-bg);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	font-size: 0.62rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--afj-ink);
	line-height: 1;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
	white-space: nowrap;
	transition: transform 0.35s var(--afj-ease);
}

.afj-latest__card-link:hover .afj-latest__pill {
	transform: translateY(calc(50% - 2px));
}

.afj-latest__title {
	margin: 0.35rem 0 1.25rem;
	font-family: var(--afj-font-heading, "Plus Jakarta Sans", system-ui, sans-serif);
	font-size: clamp(1.05rem, 1.45vw, 1.2rem);
	font-weight: 800;
	line-height: 1.28;
	letter-spacing: -0.02em;
	flex: 1;
	color: var(--afj-ink);
}

.afj-latest__meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-top: auto;
	padding-top: 0.15rem;
}

.afj-latest__read {
	font-size: 0.86rem;
	color: var(--afj-muted);
	font-weight: 400;
}

.afj-latest__go {
	width: 2.2rem;
	height: 2.2rem;
	border-radius: 999px;
	border: 1.25px solid var(--afj-ink);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--afj-ink);
	background: transparent;
	flex-shrink: 0;
	transition:
		background 0.35s var(--afj-ease),
		color 0.35s var(--afj-ease),
		transform 0.35s var(--afj-ease);
}

.afj-latest__go svg {
	width: 14px;
	height: 14px;
	transition: transform 0.35s var(--afj-ease);
}

.afj-latest__card-link:hover .afj-latest__go,
.afj-latest__card-link:focus-visible .afj-latest__go {
	background: var(--afj-ink);
	color: #fff;
	transform: translateX(2px);
}

.afj-latest__card-link:hover .afj-latest__go svg,
.afj-latest__card-link:focus-visible .afj-latest__go svg {
	transform: translateX(2px);
}

.afj-latest__card-link:focus-visible {
	outline: none;
}

.afj-latest__card-link:focus-visible .afj-latest__media {
	outline: 2px solid var(--afj-ink);
	outline-offset: 3px;
}

.afj-latest__empty {
	margin: 0;
	color: var(--afj-muted);
}

@keyframes afj-latest-line {
	from { transform: scaleX(0); opacity: 0; }
	to { transform: scaleX(1); opacity: 1; }
}

@keyframes afj-latest-in {
	from {
		opacity: 0;
		transform: translateY(14px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media (prefers-reduced-motion: reduce) {
	.afj-latest *,
	.afj-latest *::before,
	.afj-latest *::after {
		animation: none !important;
		transition-duration: 0.01ms !important;
	}
}

@media (max-width: 960px) {
	.afj-latest__grid {
		grid-template-columns: 1fr 1fr;
	}

}

@media (max-width: 640px) {
	.afj-latest__inner {
		width: calc(100% - 2rem);
	}

	.afj-latest__header {
		flex-wrap: wrap;
	}

	.afj-latest__eyebrow {
		width: 100%;
		order: 1;
	}

	.afj-latest__view-all {
		order: 2;
	}

	.afj-latest__grid {
		grid-template-columns: 1fr;
		gap: 2rem;
	}

	.afj-latest__media {
		height: 200px;
		max-height: 200px;
	}
}
