/*
 * Catalogue grid.
 *
 * Self-contained: every colour, size and icon this file needs ships with the
 * plugin. Nothing is read from the active theme, so installing the plugin is
 * all it takes for the shortcodes to look right anywhere.
 *
 * The values below are the defaults. To match a different palette, set the
 * same custom properties on .v4aae from your own stylesheet — no need to
 * fork anything:
 *
 *   .v4aae { --v4aae-accent: #0d6efd; --v4aae-line: #dde1e6; }
 *
 * No build step: this is the file that ships and the file you edit.
 */

.v4aae {
	--v4aae-accent: #f67d32;
	--v4aae-on-accent: #fffaf7;
	--v4aae-text: #18181b;
	--v4aae-muted: #52525c;
	--v4aae-surface: #fff;
	--v4aae-line: #e1d6ca;
	--v4aae-hover: rgb(246 125 50 / 15%);
	--v4aae-tip-bg: #f8e1cd;
	--v4aae-inset: #f9f2e8;
	--v4aae-radius: 16px;
	--v4aae-radius-sm: 12px;
	--v4aae-gap: clamp(.75rem, .59rem + .8vw, 1.25rem);
	--v4aae-row-gap: clamp(.75rem, .59rem + .8vw, .875rem);
	--v4aae-card-min: 172px;
	--v4aae-dur: .24s;
	--v4aae-ease: cubic-bezier(.4, 0, .2, 1);

	color: var(--v4aae-text);
	font-size: 16px;
}

/* Visually hidden, still announced. The plugin ships its own rather than
   relying on the theme's .screen-reader-text existing. */
.v4aae-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	white-space: nowrap;
	clip-path: inset(50%);
}

/* ------------------------------------------------------------- search bar */


.v4aae__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1.5rem;
}

.v4aae__search {
	position: relative;
	flex: 1 1 15rem;
	max-width: 22rem;
}

.v4aae__search-icon {
	position: absolute;
	inset-inline-start: 1rem;
	top: 50%;
	translate: 0 -50%;
	color: var(--v4aae-muted);
	pointer-events: none;
}

.v4aae__input {
	width: 100%;
	min-height: 48px;
	padding-inline: 2.75rem 1rem;
	border: 1px solid var(--v4aae-line);
	border-radius: 999px;
	background: var(--v4aae-surface);
	color: inherit;
	font: inherit;
}

.v4aae__input:focus-visible {
	outline: 2px solid var(--v4aae-accent);
	outline-offset: 2px;
	border-color: var(--v4aae-accent);
}

/* ------------------------------------------------------------------- tabs */

.v4aae__filters {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem;
}

.v4aae__filter {
	min-height: 39px;
	padding-inline: 1rem;
	border: 1px solid var(--v4aae-line);
	border-radius: 999px;
	background: none;
	color: inherit;
	font: inherit;
	font-size: .9375rem;
	font-weight: 500;
	cursor: pointer;
	transition:
		background-color var(--v4aae-dur) var(--v4aae-ease),
		color var(--v4aae-dur) var(--v4aae-ease),
		border-color var(--v4aae-dur) var(--v4aae-ease);
}

.v4aae__filter:hover {
	border-color: var(--v4aae-accent);
}

.v4aae__filter.is-active {
	border-color: var(--v4aae-accent);
	background: var(--v4aae-accent);
	color: var(--v4aae-on-accent);
}

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

/*
 * auto-fit, so the column count follows the space available rather than a
 * list of breakpoints. This also means the grid adapts inside a narrow
 * Elementor column, which a viewport media query cannot do.
 *
 * min(100%, …) keeps a single card from overflowing a container narrower than
 * the minimum itself.
 */
.v4aae__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--v4aae-card-min)), 1fr));
	column-gap: var(--v4aae-gap);
	row-gap: var(--v4aae-row-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

/*
 * The meta row and the body share one grid cell, stacked. That way the mark
 * and the crown sit in the corners without shifting the glyph off centre.
 * container-type lets the hover panel size its arrow against the card.
 */
.v4aae-card {
	position: relative;
	container-type: inline-size;
	display: grid;
	border: 1px solid var(--v4aae-line);
	border-radius: var(--v4aae-radius);
	background: var(--v4aae-surface);
	color: inherit;
	text-decoration: none;
	transition: background-color var(--v4aae-dur) var(--v4aae-ease);
}

/* Filtered out by the script. */
.v4aae-card[hidden] {
	display: none;
}

.v4aae-card--upcoming {
	opacity: .65;
}

.v4aae-card__meta {
	grid-area: 1 / 1;
	align-self: start;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 15px 18px;
}

.v4aae-card__meta img {
	display: block;
	flex-shrink: 0;
}

.v4aae-card__body {
	grid-area: 1 / 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 20px;
	padding: 32px .5rem;
	text-align: center;
}

/* A mask, so the glyph takes the accent colour on hover. Every icon file has
   to be single-colour for this to work — a mask discards the source colours. */
.v4aae-card__icon {
	flex: none;
	width: 36px;
	height: 36px;
	background-color: var(--v4aae-muted);
	mask: var(--v4aae-icon) center / auto no-repeat;
	-webkit-mask: var(--v4aae-icon) center / auto no-repeat;
	transition: background-color var(--v4aae-dur) var(--v4aae-ease);
}

.v4aae-card__label {
	font-size: .9375rem;
	line-height: 1.5;
	color: var(--v4aae-muted);
}

@media (hover: hover) {
	.v4aae-card:hover {
		z-index: 2;
		background-color: var(--v4aae-hover);
	}

	.v4aae-card:hover .v4aae-card__icon {
		background-color: var(--v4aae-accent);
	}
}

/* A text badge, used only when the crown artwork is missing. */
.v4aae-card__badge {
	padding: 2px .5rem;
	border-radius: 999px;
	background: var(--v4aae-accent);
	color: var(--v4aae-on-accent);
	font-size: .75rem;
	font-weight: 600;
	line-height: 1.5;
}

.v4aae-card__badge--soon {
	background: var(--v4aae-muted);
}

/* ---------------------------------------------------------- hover tooltip */

/*
 * Hidden but present by default, so screen readers and find-in-page still
 * reach the description on a phone, where there is no hover to reveal it.
 */
.v4aae-card__tip {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
}

@media (hover: hover) and (min-width: 1024px) {
	/*
	 * Centred on the card. With auto-fit there is no way to know in CSS which
	 * card ends a row, so the old nth-child(6n) / nth-child(7n) rules could
	 * not survive the switch — library.js measures instead and sets --_nudge
	 * on the one panel that would spill off screen. No JS: still centred,
	 * which is right for every card except the outermost.
	 */
	.v4aae-card__tip {
		left: 50%;
		bottom: calc(100% + 12px);
		z-index: 2;
		width: 282px;
		height: auto;
		margin: 0;
		padding: 1rem;
		overflow: visible;
		clip-path: none;
		border: 1px solid var(--v4aae-line);
		border-radius: var(--v4aae-radius-sm);
		background: var(--v4aae-tip-bg);
		color: var(--v4aae-text);
		font-size: .875rem;
		line-height: 1.5;
		text-align: start;
		opacity: 0;
		transform: translateX(-50%) translateX(var(--_nudge, 0px)) translateY(6px);
		pointer-events: none;
		transition: opacity var(--v4aae-dur) var(--v4aae-ease), transform var(--v4aae-dur) var(--v4aae-ease);
	}

	/*
	 * The tail. A rotated square, not a border triangle, so the panel's own
	 * 1px outline continues round the point instead of stopping at it.
	 *
	 * It sits at the panel's middle, minus whatever the panel was nudged by,
	 * so however far the script pushes the panel back on screen the point
	 * stays over the card it belongs to.
	 */
	.v4aae-card__tip::after {
		content: "";
		position: absolute;
		top: 100%;
		left: calc(50% - var(--_nudge, 0px));
		width: 12px;
		height: 12px;
		translate: -50% -50%;
		rotate: 45deg;
		background: var(--v4aae-tip-bg);
		border-right: 1px solid var(--v4aae-line);
		border-bottom: 1px solid var(--v4aae-line);
		border-bottom-right-radius: 2px;
	}

	.v4aae-card:hover .v4aae-card__tip,
	.v4aae-card:focus-visible .v4aae-card__tip {
		opacity: 1;
		transform: translateX(-50%) translateX(var(--_nudge, 0px));
	}
}

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

.v4aae__empty {
	margin-top: var(--v4aae-gap);
	color: var(--v4aae-muted);
}

.v4aae__empty[hidden] {
	display: none;
}

/* ------------------------------------------------------------------ count */

.v4aae-count__value {
	color: var(--v4aae-accent);
	font-weight: 700;
}

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

/*
 * Masonry, because template screenshots are all different heights and a fixed
 * row grid would either crop them or leave gaps under the short ones. CSS
 * columns flow top-to-bottom within a column, which is what the design shows.
 * Hiding a card during a filter simply reflows the columns.
 */
.v4aae--templates .v4aae__grid,
.v4aae--page-templates .v4aae__grid,
.v4aae--section-templates .v4aae__grid {
	display: block;
	columns: 1;
	column-gap: var(--v4aae-gap);
}

@media (min-width: 600px) {
	.v4aae--templates .v4aae__grid,
	.v4aae--page-templates .v4aae__grid,
	.v4aae--section-templates .v4aae__grid {
		columns: 2;
	}
}

@media (min-width: 900px) {
	.v4aae--templates .v4aae__grid,
	.v4aae--page-templates .v4aae__grid,
	.v4aae--section-templates .v4aae__grid {
		columns: 3;
	}
}

@media (min-width: 1200px) {
	.v4aae--templates .v4aae__grid,
	.v4aae--page-templates .v4aae__grid,
	.v4aae--section-templates .v4aae__grid {
		columns: 4;
	}
}

.v4aae-card--media {
	display: block;
	overflow: hidden;
	margin-bottom: var(--v4aae-gap);
	break-inside: avoid;
	background: var(--v4aae-surface);
}

/* A hidden card must not leave its column gap behind. */
.v4aae-card--media[hidden] {
	display: none;
}

.v4aae-card--media:hover {
	background: var(--v4aae-surface);
}

.v4aae-card__shot {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--v4aae-radius) var(--v4aae-radius) 0 0;
	background: var(--v4aae-inset);
	line-height: 0;
}

.v4aae-card__shot img {
	display: block;
	width: 100%;
	height: auto;
	transition: scale .5s var(--v4aae-ease);
}

.v4aae-card--media:hover .v4aae-card__shot img {
	scale: 1.04;
}

.v4aae-card__pro {
	position: absolute;
	inset-block-start: .75rem;
	inset-inline-end: .75rem;
	z-index: 2;
}

.v4aae-card--media .v4aae-card__badge {
	position: absolute;
	inset-block-start: .75rem;
	inset-inline-end: .75rem;
	z-index: 2;
}

/* The actions sit over a scrim that only appears on hover. */
.v4aae-card__actions {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: .625rem;
	background: rgb(24 24 27 / 45%);
	opacity: 0;
	transition: opacity var(--v4aae-dur) var(--v4aae-ease);
}

.v4aae-card--media:hover .v4aae-card__actions,
.v4aae-card__actions:focus-within {
	opacity: 1;
}

.v4aae-card__buttons {
	display: flex;
	align-items: center;
	gap: .625rem;
}

.v4aae-card__action {
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: rgb(255 255 255 / 22%);
	color: #fff;
	text-decoration: none;
	backdrop-filter: blur(4px);
	transition: background-color var(--v4aae-dur) var(--v4aae-ease), color var(--v4aae-dur) var(--v4aae-ease);
}

.v4aae-card__action:hover,
.v4aae-card__action:focus-visible {
	background: #fff;
	color: var(--v4aae-accent);
}

.v4aae-card__action--main {
	background: var(--v4aae-accent);
	color: var(--v4aae-on-accent);
}

.v4aae-card__hint {
	padding: .3rem .85rem;
	border-radius: 999px;
	background: var(--v4aae-accent);
	color: var(--v4aae-on-accent);
	font-size: .8125rem;
	font-weight: 600;
	line-height: 1.5;
}

.v4aae-card__foot {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: .75rem;
	padding: .75rem 1rem 1rem;
}

.v4aae-card__titles {
	display: flex;
	flex-direction: column;
	gap: .15rem;
	min-width: 0;
}

.v4aae-card--media .v4aae-card__label {
	color: var(--v4aae-text);
	font-size: .9375rem;
	font-weight: 600;
	line-height: 1.4;
}

.v4aae-card__cat {
	color: var(--v4aae-muted);
	font-size: .8125rem;
	line-height: 1.4;
}

/* The download count. Green, as in the design, and its own token so it can be
   recoloured without touching the accent. */
.v4aae-card__downloads {
	display: inline-flex;
	align-items: center;
	gap: .25rem;
	flex: none;
	padding: .2rem .5rem;
	border-radius: 6px;
	background: var(--v4aae-count-bg, #e7f7ec);
	color: var(--v4aae-count, #17893e);
	font-size: .75rem;
	font-weight: 600;
	line-height: 1.5;
}

/* The icon-font fallback, for the few widgets with no bespoke SVG yet. Sized
   and coloured to match .v4aae-card__icon so the grid stays even. */
.v4aae-card__eicon {
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	font-size: 30px;
	line-height: 1;
	color: var(--v4aae-muted);
	transition: color var(--v4aae-dur) var(--v4aae-ease);
}

@media (hover: hover) {
	.v4aae-card:hover .v4aae-card__eicon {
		color: var(--v4aae-accent);
	}
}
