/**
 * Creative Listing – Frontend styles
 * Responsive grid, equal-height cards, modern layout
 *
 * @package Creative_Listing
 */

/* Container */
.creative-listing {
	--cl-cols-desktop: 3;
	--cl-cols-tablet: 2;
	--cl-cols-mobile: 1;
	--cl-border-radius: 8px;
	--cl-border-color: #e0e0e0;
	--cl-bg-color: #ffffff;
	--cl-gap: 24px;
	--cl-desc-lines: 3;
	box-sizing: border-box;
	margin-bottom: 2em;
}

.creative-listing *,
.creative-listing *::before,
.creative-listing *::after {
	box-sizing: border-box;
}

/* Listing header – search (left) and sort (right) */
.cl-listing-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1em;
	margin-bottom: 0.75em;
	flex-wrap: wrap;
}

.cl-search-bar {
	display: flex;
	align-items: center;
	gap: 0.4em;
	flex: 1;
	min-width: 120px;
	max-width: 320px;
}

.cl-search-label {
	font-size: 0.75rem;
	color: #50575e;
	flex-shrink: 0;
}

.cl-search-input {
	flex: 1;
	min-width: 0;
	padding: 0.25em 0.5em;
	border: 1px solid var(--cl-border-color);
	border-radius: 6px;
	background: #fff;
	font-size: 0.8125rem;
	line-height: 1.4;
	color: #1d2327;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cl-search-input::placeholder {
	color: #a7aaad;
}

.cl-search-input:hover {
	border-color: #c3c4c7;
}

.cl-search-input:focus {
	border-color: #2271b1;
	outline: none;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.25);
}

.cl-sort-bar {
	display: flex;
	align-items: center;
	flex-shrink: 0;
	margin-left: auto;
}

.cl-sort-label {
	margin-right: 0.4em;
	font-size: 0.75rem;
	color: #50575e;
}

.cl-sort-select {
	display: inline-block;
	width: fit-content;
	min-width: 8em;
	max-width: 160px;
	padding: 0.25em 1.75em 0.25em 0.5em;
	border: 1px solid var(--cl-border-color);
	border-radius: 6px;
	background: #fff;
	font-size: 0.8125rem;
	line-height: 1.4;
	cursor: pointer;
	appearance: none;
	flex-shrink: 0;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%2350575e' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.4em center;
	color: #1d2327;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cl-sort-select:hover {
	border-color: #c3c4c7;
}

.cl-sort-select:focus {
	border-color: #2271b1;
	outline: none;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.25);
}

/* Grid – stretch cards so each row has equal card height; image section has fixed aspect ratio */
.cl-grid {
	display: grid;
	grid-template-columns: repeat(var(--cl-cols-mobile), 1fr);
	gap: var(--cl-gap);
	align-items: stretch;
}

@media (min-width: 600px) {
	.cl-grid {
		grid-template-columns: repeat(var(--cl-cols-tablet), 1fr);
	}
}

@media (min-width: 1024px) {
	.cl-grid {
		grid-template-columns: repeat(var(--cl-cols-desktop), 1fr);
	}
}

/* Card – equal height in each row (fills grid cell) */
.cl-card {
	display: flex;
	min-height: 0;
	height: 100%;
}

.cl-card-inner {
	display: flex;
	flex-direction: column;
	width: 100%;
	min-height: 100%;
	background: var(--cl-bg-color);
	border: 1px solid var(--cl-border-color);
	border-radius: var(--cl-border-radius);
	overflow: hidden;
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.creative-listing.cl-shadow-1 .cl-card-inner {
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.creative-listing.cl-shadow-2 .cl-card-inner {
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.creative-listing.cl-shadow-3 .cl-card-inner {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.cl-card-inner:hover {
	border-color: #c3c4c7;
}

.creative-listing.cl-shadow-1 .cl-card-inner:hover,
.creative-listing.cl-shadow-2 .cl-card-inner:hover,
.creative-listing.cl-shadow-3 .cl-card-inner:hover {
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* Image – fixed aspect ratio, never stretched; only the text block below grows for equal-height cards */
.cl-card-image {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 10;
	background: #ffffff;
	flex: 0 0 auto;
	overflow: hidden;
}

.cl-card-image img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: contain;
	object-position: center;
}

/* Content area – flex grow so equal height works */
.cl-card-content {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
	padding: 1.25em 1.25em 1.5em;
	border-top: 1px solid #f0f0f1; /* subtle divider below image, same style as line above Contact */
}

.cl-card-header {
	font-size: 1.125em;
	font-weight: 700;
	line-height: 1.35;
	margin-bottom: 0.5em;
	color: #1d2327;
	word-wrap: break-word;
}

.cl-card-header:empty {
	display: none;
}

/* Description – fixed min-height for equal cards, line-clamp for long text */
.cl-card-description {
	flex: 1;
	min-height: 4.5em;
	position: relative;
	font-size: 0.9375em;
	line-height: 1.5;
	color: #50575e;
	margin-bottom: 0.75em;
}

.cl-card-description .cl-description-inner {
	word-wrap: break-word;
}

/* Line clamp (number of lines set via data-lines / inline style) */
.cl-card-description.cl-line-clamp .cl-description-inner {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--cl-desc-lines, 3);
	overflow: hidden;
}

.cl-card-description.cl-line-clamp.is-expanded .cl-description-inner {
	-webkit-line-clamp: unset;
	overflow: visible;
}

.cl-read-more {
	display: inline-block;
	margin-top: 0.35em;
	padding: 0;
	background: none;
	border: none;
	color: #2271b1;
	font-size: 0.9em;
	cursor: pointer;
	text-decoration: underline;
	appearance: none;
}

.cl-read-more:hover {
	color: #135e96;
}

.cl-read-more:focus {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.cl-card-description.is-expanded .cl-read-more {
	display: none;
}

/* Tags – small pills above contact */
.cl-card-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35em;
	margin-bottom: 0.5em;
}

.cl-card-tags .cl-tag {
	display: inline-block;
	padding: 0.2em 0.5em;
	font-size: 0.75rem;
	line-height: 1.3;
	color: #50575e;
	background: #f0f0f1;
	border-radius: 4px;
}

/* Contact */
.cl-card-contact {
	font-size: 0.9em;
	line-height: 1.45;
	color: #50575e;
	margin-top: auto;
	padding-top: 0.5em;
	border-top: 1px solid #f0f0f1;
	word-wrap: break-word;
}

.cl-card-contact:empty {
	display: none;
}

/* Image overrides – fix a consistent image band height and center logos without distortion */
.cl-card-image {
	height: 180px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.cl-card-image img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
}

/* Loading state when sorting via AJAX */
.cl-grid.is-loading {
	opacity: 0.6;
	pointer-events: none;
}

.cl-grid.is-loading::after {
	content: "";
	position: absolute;
	inset: 0;
	background: transparent;
}
