/*
 * Croator Webstudio Addons — projects grid.
 *
 * Ported from the "Istaknuti radovi" section of Croator Homepage.dc.html. Its own sheet,
 * like the listing and the related band, so a page carrying only a hero never downloads it.
 *
 * The one part worth reading carefully is the swipe rail at the bottom of this file.
 *
 * The design source decides between two completely different layouts in JavaScript: it keeps
 * a `narrow` flag in component state, listens on window resize, and swaps `projGridStyle`
 * between a CSS grid and a horizontally scrolling flex row. That is fine in a prototype and
 * wrong on a real page — the first paint happens before the flag is read, so a phone briefly
 * renders the desktop grid, and every resize re-renders the whole section.
 *
 * Here it is one media query. The rail is the same rail: the same scroll-snap, the same
 * full-bleed through the section's side padding, and the same sliver of the next card left
 * visible at the right edge so the row reads as swipeable rather than as one wide card. The
 * three numbers the source hard-codes (14px gap, 24px bleed, 58px peek) are custom properties
 * driven by controls, and the breakpoint is a modifier class rather than a stored pixel value,
 * because a media query cannot read a custom property.
 */

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

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

	/* Tunable through Elementor controls. Defaults are the source values. */
	--cws-projects-max: 1200px;
	--cws-projects-pad: 24px;
	--cws-projects-pad-y: clamp(64px, 8vw, 110px);
	--cws-projects-card-min: 300px;
	--cws-projects-gap: 22px;
	--cws-projects-radius: 18px;
	--cws-projects-ratio: 16 / 11;

	/* Swipe rail only. */
	--cws-projects-swipe-gap: 14px;
	--cws-projects-peek: 58px;
}

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

/* The button's wrapper is a flex row, which would otherwise outrank the attribute. */
.cws-projects [hidden] {
	display: none !important;
}

/* The optional tinted full-width strip. Off by default: the homepage design runs this
 * section on the page background, between two bands that are tinted. */
.cws-projects--band {
	background: var(--cws-s1);
	border-top: 1px solid var(--cws-bd);
	border-bottom: 1px solid var(--cws-bd);
}

.cws-projects__inner {
	max-width: var(--cws-projects-max);
	margin-inline: auto;
	padding-block: var(--cws-projects-pad-y);
	padding-inline: var(--cws-projects-pad);
}

/* ------------------------------------------------------------------ heading */

.cws-projects__head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 14px;
	margin-bottom: 38px;
}

/*
 * min-width: 0 so a long heading wraps inside its own column instead of pushing the archive
 * link off the row. The design gets away without it because its heading is two words.
 */
.cws-projects__headings {
	min-width: 0;
}

.cws-projects__eyebrow {
	display: block;
	margin-bottom: 12px;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	color: var(--cws-acc);
}

.cws-projects__title {
	margin: 0;
	font-family: var(--cws-font-display);
	font-weight: 700;
	font-size: clamp(30px, 3.6vw, 44px);
	line-height: 1.1;
	letter-spacing: -1px;
	color: var(--cws-tx);
	text-wrap: balance;
}

.cws-projects__all {
	font-family: inherit;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--cws-brand);
	text-decoration: none;
	white-space: nowrap;
	transition: color 0.15s ease;
}

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

/* Separate element rather than a ::after, so the label control never has to contain an
 * arrow the editor might delete or duplicate. */
.cws-projects__all-arrow {
	margin-left: 6px;
}

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

/*
 * auto-fit, so five cards plus the CTA panel stretch to fill the row instead of leaving a
 * gap where a further column would have been.
 */
.cws-projects__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--cws-projects-card-min)), 1fr));
	gap: var(--cws-projects-gap);
}

/* -------------------------------------------------------------------- cards */

.cws-projects__card {
	display: flex;
	flex-direction: column;
	background: var(--cws-card);
	border: 1px solid var(--cws-bd);
	border-radius: var(--cws-projects-radius);
	overflow: hidden;
	color: inherit;
	text-decoration: none;
	box-shadow: 0 1px 2px rgba(14, 17, 22, 0.04);
	transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.cws-projects__card:hover,
.cws-projects__card:focus-visible {
	transform: translateY(-4px);
	box-shadow: 0 18px 34px -18px rgba(14, 17, 22, 0.28);
	border-color: #e6b3ad;
	color: inherit;
}

.cws-projects__media {
	position: relative;
	width: 100%;
	aspect-ratio: var(--cws-projects-ratio);
	overflow: hidden;
	background: var(--cws-media-bg);
	border-bottom: 1px solid var(--cws-bd);
}

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

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

/*
 * Deliberately not themed: the pill sits on top of a screenshot, which is a light image in
 * either theme, so it keeps its light ground and dark text in dark mode too — exactly as the
 * source does. backdrop-filter is a progressive enhancement over an already 92% opaque
 * background, so nothing is lost where it is unsupported.
 */
.cws-projects__badge {
	position: absolute;
	top: 12px;
	left: 12px;
	padding: 5px 10px;
	border-radius: 99px;
	background: rgba(255, 255, 255, 0.92);
	backdrop-filter: blur(4px);
	color: #0e1116;
	font-size: 11px;
	font-weight: 800;
	line-height: 1.35;
	letter-spacing: 0.6px;
	text-transform: uppercase;
}

.cws-projects__body {
	display: flex;
	flex-direction: column;
	flex: 1;
	padding: 16px 18px 17px;
}

.cws-projects__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.cws-projects__ident {
	display: block;
	min-width: 0;
}

.cws-projects__name {
	display: block;
	font-family: var(--cws-font-display);
	font-weight: 700;
	font-size: 18px;
	line-height: 1.25;
	letter-spacing: -0.3px;
	color: var(--cws-tx);
	text-wrap: pretty;
}

.cws-projects__year {
	display: block;
	margin-top: 3px;
	font-size: 13.5px;
	font-weight: 500;
	line-height: 1.35;
	color: var(--cws-tx3);
}

.cws-projects__arrow {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 99px;
	background: var(--cws-tint);
	color: var(--cws-brand);
	font-size: 15px;
	font-weight: 800;
	line-height: 1;
	transition: background 0.2s ease, transform 0.2s ease;
}

.cws-projects__card:hover .cws-projects__arrow,
.cws-projects__card:focus-visible .cws-projects__arrow {
	transform: translateX(2px);
}

/* Off by default — the homepage cards carry no summary. The portfolio page does. */
.cws-projects__excerpt {
	margin: 12px 0 0;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.55;
	color: var(--cws-tx2);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ----------------------------------------------------------------- CTA panel */

/*
 * A grid cell like any card, which is what makes it swipe along with them on a phone rather
 * than being stranded below the rail.
 */
.cws-projects__cta {
	position: relative;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 14px;
	padding: 30px 28px;
	border: 1px solid var(--cws-panel);
	border-radius: var(--cws-projects-radius);
	background: var(--cws-panel);
	color: #fff;
	box-shadow: 0 14px 30px -20px rgba(14, 17, 22, 0.5);
}

.cws-projects__cta-glow {
	position: absolute;
	top: -70px;
	right: -60px;
	width: 210px;
	height: 210px;
	border-radius: 50%;
	background: radial-gradient(circle, rgba(219, 68, 55, 0.32), rgba(219, 68, 55, 0) 70%);
	pointer-events: none;
}

/* Everything after the glow needs a stacking context of its own to sit above it. */
.cws-projects__cta > *:not(.cws-projects__cta-glow) {
	position: relative;
}

.cws-projects__cta-eyebrow {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 11.5px;
	font-weight: 800;
	line-height: 1.3;
	letter-spacing: 0.9px;
	text-transform: uppercase;
	color: #f0796b;
}

.cws-projects__cta-dot {
	flex: none;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
}

.cws-projects__cta-title {
	display: block;
	font-family: var(--cws-font-display);
	font-weight: 700;
	font-size: 24px;
	line-height: 1.18;
	letter-spacing: -0.5px;
	color: #fff;
}

.cws-projects__cta-text {
	margin: 0;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.55;
	color: #9aa4b0;
}

.cws-projects__cta-btn {
	align-self: flex-start;
	display: inline-flex;
	align-items: center;
	gap: 9px;
	padding: 12px 16px 12px 18px;
	border-radius: 11px;
	background: var(--cws-brand);
	color: #fff;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	text-decoration: none;
	box-shadow: 0 8px 18px -10px rgba(219, 68, 55, 0.85);
	transition: background 0.2s ease, transform 0.2s ease;
}

.cws-projects__cta-btn::after {
	content: "\2192";
	font-size: 15px;
	font-weight: 800;
}

.cws-projects__cta-btn:hover,
.cws-projects__cta-btn:focus-visible {
	background: var(--cws-brand-hover);
	color: #fff;
	transform: translateY(-2px);
}

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

.cws-projects__empty {
	margin: 0;
	padding: 26px;
	border: 1.5px dashed var(--cws-bd);
	border-radius: var(--cws-projects-radius);
	background: var(--cws-card);
	font-size: 15px;
	font-weight: 500;
	line-height: 1.6;
	color: var(--cws-tx2);
	text-align: center;
}

/* ---------------------------------------------------------------- load more */

/*
 * Not in the design, which has no more projects than fit. Styled as the blog listing's
 * Load-more button, so the two read as one system: a quiet outlined button that takes the
 * brand colour on hover, never a second primary CTA competing with the dark panel above it.
 */
.cws-projects__more {
	display: flex;
	justify-content: center;
	margin-top: 40px;
}

.cws-projects__more-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	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;
	line-height: 1.3;
	cursor: pointer;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.cws-projects__more-btn:hover,
.cws-projects__more-btn:focus-visible {
	border-color: var(--cws-brand);
	background: var(--cws-card);
	color: var(--cws-tx);
}

.cws-projects__more-btn:focus-visible {
	outline: 2px solid var(--cws-brand);
	outline-offset: 3px;
}

.cws-projects__more-btn[aria-disabled="true"] {
	opacity: 0.6;
	cursor: default;
}

.cws-projects__spinner {
	display: none;
	flex: none;
	width: 16px;
	height: 16px;
	border: 2px solid var(--cws-bd);
	border-top-color: var(--cws-brand);
	border-radius: 50%;
	animation: cws-projects-spin 0.7s linear infinite;
}

.cws-projects__more-btn.is-loading .cws-projects__spinner {
	display: inline-block;
}

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

/* Screen-reader only while it announces a batch; a failed request shows on screen too. */
.cws-projects__status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.cws-projects__status.is-error {
	position: static;
	width: auto;
	height: auto;
	margin: 14px 0 0;
	overflow: visible;
	clip: auto;
	white-space: normal;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.5;
	text-align: center;
	color: var(--cws-tx2);
}

/*
 * No fill-mode: once the entrance ends the card falls back to its own rules, so the hover
 * lift above keeps working. With `both` the last keyframe's transform would pin it in place.
 */
.cws-projects__card.is-new {
	animation: cws-projects-in 0.4s ease;
}

@keyframes cws-projects-in {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
}

/* --------------------------------------------------------------- swipe rail */

/*
 * The mobile layout from the source, one rule set shared by both breakpoint options.
 *
 * The negative inline margin is exactly the inner column's own side padding, so the rail
 * starts flush with the screen edge and cannot overflow the section: the two cancel out. The
 * matching padding-left puts the first card back under the heading, and the padding-right is
 * the peek — the reason a sliver of card two stays on screen, which is the only affordance
 * telling a thumb there is anything to swipe to.
 *
 * The cards themselves are laid out here rather than in the card rule above, because
 * `width: 100%` means something different in a flex rail (the rail's content box, i.e. the
 * screen minus bleed and peek) than it does in a grid cell.
 */
@media (max-width: 759.98px) {
	.cws-projects--swipe-sm .cws-projects__grid {
		display: flex;
		gap: var(--cws-projects-swipe-gap);
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		margin-inline: calc(var(--cws-projects-pad) * -1);
		padding-inline: var(--cws-projects-pad) var(--cws-projects-peek);
		padding-bottom: 6px;
	}

	.cws-projects--swipe-sm .cws-projects__grid::-webkit-scrollbar {
		display: none;
	}

	.cws-projects--swipe-sm .cws-projects__card,
	.cws-projects--swipe-sm .cws-projects__cta {
		flex: 0 0 auto;
		width: 100%;
		scroll-snap-align: start;
	}
}

@media (max-width: 1024.98px) {
	.cws-projects--swipe-md .cws-projects__grid {
		display: flex;
		gap: var(--cws-projects-swipe-gap);
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		margin-inline: calc(var(--cws-projects-pad) * -1);
		padding-inline: var(--cws-projects-pad) var(--cws-projects-peek);
		padding-bottom: 6px;
	}

	.cws-projects--swipe-md .cws-projects__grid::-webkit-scrollbar {
		display: none;
	}

	.cws-projects--swipe-md .cws-projects__card,
	.cws-projects--swipe-md .cws-projects__cta {
		flex: 0 0 auto;
		/*
		 * A tablet is wide enough for the one-card-per-screen rail of the phone layout to
		 * look broken, so the card is capped and two sit side by side with the third
		 * peeking — the same affordance, at a width that suits the viewport.
		 */
		width: min(100%, var(--cws-projects-card-min));
		scroll-snap-align: start;
	}
}

@media (max-width: 759.98px) {
	.cws-projects--swipe-md .cws-projects__card,
	.cws-projects--swipe-md .cws-projects__cta {
		width: 100%;
	}
}

/*
 * A rail is reachable with a thumb but not with a keyboard unless it can take focus, and a
 * focused scroll container needs a visible ring like anything else.
 */
.cws-projects__grid:focus-visible {
	outline: 2px solid var(--cws-brand);
	outline-offset: 4px;
}

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

@media (prefers-reduced-motion: reduce) {
	.cws-projects *,
	.cws-projects *::before,
	.cws-projects *::after {
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}

	.cws-projects__card:hover,
	.cws-projects__card:focus-visible,
	.cws-projects__cta-btn:hover,
	.cws-projects__cta-btn:focus-visible {
		transform: none;
	}

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

	.cws-projects__card.is-new {
		animation: none;
	}

	/* Slowed rather than stopped: a frozen spinner reads as a hung page. */
	.cws-projects__spinner {
		animation-duration: 1.6s;
	}
}
