/**
 * 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;
	--cl-sidebar-width: 280px;
	box-sizing: border-box;
	margin: 10px 10px 32px 10px;
}

/* Two-column layout: filters + main (matches exhibitor-directory style) */
.creative-listing.cl-layout--with-sidebar {
	display: flex;
	align-items: flex-start;
	gap: 1.75rem;
	flex-wrap: wrap;
}

.creative-listing.cl-layout--with-sidebar .cl-filters-sidebar {
	flex: 0 0 var(--cl-sidebar-width);
	max-width: 100%;
	min-width: min(100%, 240px);
}

.creative-listing.cl-layout--with-sidebar .cl-main-column {
	flex: 1 1 0;
	min-width: 0;
}

@media (max-width: 782px) {
	.creative-listing.cl-layout--with-sidebar {
		flex-direction: column;
	}

	.creative-listing.cl-layout--with-sidebar .cl-filters-sidebar {
		flex: 1 1 auto;
		width: 100%;
	}
}

/* Filter sidebar */
.cl-filters-sidebar {
	padding: 0 1rem 1rem 0;
	border-right: 1px solid #dcdcde;
}

@media (max-width: 782px) {
	.cl-filters-sidebar {
		border-right: none;
		border-bottom: 1px solid #dcdcde;
		padding-right: 0;
		padding-bottom: 1.25rem;
		margin-bottom: 0.5rem;
	}
}

.cl-result-count {
	margin: 0 0 0.75rem;
	font-size: 0.9375rem;
	font-weight: 600;
	color: #1d2327;
}

/* Search in left column (when filter sidebar is enabled) */
.cl-filters-sidebar .cl-search-bar.cl-search-bar--sidebar {
	max-width: 320px;
	width: 100%;
	margin-bottom: 1rem;
}

.cl-filters-sidebar .cl-search-bar.cl-search-bar--sidebar .cl-search-label {
	min-width: 0;
}

.cl-filters-heading {
	margin: 0 0 1rem;
	font-size: 1rem;
	font-weight: 700;
	color: #1d2327;
}

.cl-filter-section {
	border: 1px solid var(--cl-border-color);
	border-radius: var(--cl-border-radius);
	margin-bottom: 0.75rem;
	background: #fff;
	overflow: hidden;
}

.cl-filter-section-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	margin: 0;
	padding: 0.65rem 0.85rem;
	font: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	text-align: left;
	color: #1d2327;
	background: #f6f7f7;
	border: none;
	cursor: pointer;
	transition: background 0.15s ease;
}

.cl-filter-section-toggle:hover {
	background: #f0f0f1;
}

.cl-filter-section-icon {
	display: inline-block;
	width: 1.25rem;
	height: 1.25rem;
	flex-shrink: 0;
	margin-left: 0.5rem;
	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: center;
	transition: transform 0.2s ease;
}

.cl-filter-section.is-collapsed .cl-filter-section-icon {
	transform: rotate(-90deg);
}

.cl-filter-section-panel {
	padding: 0.5rem 0.65rem 0.75rem;
}

.cl-filter-section.is-collapsed .cl-filter-section-panel {
	display: none;
}

.cl-filter-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.cl-filter-item {
	margin: 0;
	padding: 0.2rem 0;
}

.cl-filter-label {
	display: flex;
	align-items: flex-start;
	flex-wrap: nowrap;
	gap: 0;
	cursor: pointer;
	font-size: 0.8125rem;
	line-height: 1.4;
	color: #50575e;
}

.cl-filter-label input {
	margin: 0.15rem 0.35rem 0 0;
	flex-shrink: 0;
}

.cl-filter-label-text {
	flex: 1 1 auto;
	min-width: 0;
}

.cl-filter-count {
	color: #787c82;
	font-weight: 400;
	white-space: nowrap;
}

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

/* Listing header – search left, sort right; minimal and modern */
.cl-listing-header {
	display: flex;
	align-items: center;
	gap: 0;
	margin-bottom: 1em;
	flex-wrap: wrap;
}

.cl-search-bar {
	display: flex;
	align-items: center;
	gap: 0.5em;
	flex: 0 1 auto;
	order: 1;
	min-width: 0;
	width: 240px;
	max-width: 320px;
}

.cl-search-bar .cl-search-input {
	width: 100%;
	min-width: 0;
	flex: 1;
}

/* Unified label style for search and sort */
.cl-search-label,
.cl-sort-label {
	font-size: 0.8125rem;
	font-weight: 600;
	color: #1d2327;
	flex-shrink: 0;
	line-height: 1.4;
}

.cl-search-label {
	min-width: 3.5em;
}

.cl-sort-label {
	margin-right: 0.5em;
}

/* Shared control height and style for search input and sort select */
.cl-search-input,
.cl-sort-select {
	height: 2.25rem;
	padding: 0 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 {
	flex: 1;
	min-width: 0;
}

.creative-listing .cl-search-input {
	padding: 0 0.5em 0 2.25rem;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a7aaad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: 0.65rem center;
}

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

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

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

/* Divider between search and sort when both present */
.cl-listing-header .cl-search-bar + .cl-sort-bar {
	margin-left: 1.25em;
	padding-left: 1.25em;
	border-left: 1px solid #dcdcde;
}

.cl-sort-bar {
	display: flex;
	align-items: center;
	flex-shrink: 0;
	order: 2;
}

.cl-sort-select {
	display: inline-block;
	width: auto;
	min-width: 9em;
	max-width: 180px;
	padding-right: 2em;
	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.5em center;
}

/* Responsive: stack on small screens and give search full width */
@media (max-width: 599px) {
	.cl-listing-header {
		flex-direction: column;
		align-items: stretch;
		gap: 0.75em;
	}

	.cl-search-bar {
		width: 100%;
		max-width: none;
	}

	.cl-listing-header .cl-search-bar + .cl-sort-bar {
		margin-left: 0;
		padding-left: 0;
		border-left: none;
		border-top: 1px solid #dcdcde;
		padding-top: 0.75em;
	}
}

/* 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 – grid stacks <img> and overlay <a> in one cell so the link box matches the image (no stray line box / no taller-than-image overlay). */
.cl-card-image {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: minmax(0, 1fr);
	width: 100%;
	min-width: 0;
	height: var(--cl-image-height, 150px);
	overflow: hidden;
	background: #ffffff;
	flex: 0 0 auto;
	line-height: 0;
	box-sizing: border-box;
	isolation: isolate;
}

.cl-card-image-img {
	grid-area: 1 / 1;
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	object-fit: contain;
	align-self: stretch;
	justify-self: stretch;
}

/* Clicks must reach the overlay <a>; the <img> often stacks above it and would steal pointer events. */
.cl-card-image--has-link .cl-card-image-img {
	pointer-events: none;
	user-select: none;
}

.cl-card-image-link {
	grid-area: 1 / 1;
	align-self: stretch;
	justify-self: stretch;
	position: relative;
	min-width: 0;
	min-height: 0;
	display: block;
	width: 100%;
	z-index: 5;
	text-decoration: none;
	color: transparent;
	cursor: pointer;
	box-sizing: border-box;
	pointer-events: auto;
}

/* Non-empty child so themes using a:empty { display:none } cannot hide the hit target; fills the stretched grid cell. */
.cl-card-image-link-fill {
	position: absolute;
	inset: 0;
	display: block;
}

.cl-card-image-link:focus {
	outline: none;
}

.cl-card-image-link:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: -2px;
	z-index: 6;
}

/* 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 – flex grow fills available space; line-clamp for long text */
.cl-card-description {
	flex: 1;
	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;
}

/* Category badges – shown at top of card content when enabled */
.cl-card-categories {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3em;
	margin-bottom: 0.55em;
}

.cl-category-badge {
	display: inline-block;
	padding: 0.2em 0.6em;
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	line-height: 1.4;
	border-radius: 999px;
	background: #eef2ff;
	color: #3451b2;
	border: 1px solid #c0cefc;
}

/* 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;
}

/* Neutralize Tailwind v4 preflight: html :where([style*=border-color]) { border-style: solid }
   Plugin inline style outputs --cl-border-color which contains "border-color" substring,
   triggering that selector. Reset border-style on .creative-listing itself and its children. */
.creative-listing[style*="border-color"],
.creative-listing [style*="border-color"] {
	border-style: none;
}

/* 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;
}
