/**
 * Zen Dev Tools Core: shared block styles.
 *
 * Design tokens use :where(:root) (zero specificity) so the Zen Dev Tools
 * theme and its Customizer colours always win, while the blocks still look
 * right with any other theme. Also holds styles used by more than one block
 * or by theme templates: buttons, product cards, the catalogue, the video
 * dialog and the scroll-reveal animations.
 *
 * Blocks use --zdtp-surface for cards and --zdtp-primary-text for red text.
 * The Zen Dev Tools theme switches both (and the base colours) in dark mode;
 * this plugin has no dark rules of its own, so the block editor stays light.
 */
:where(:root) {
	--zdtp-primary: #c30029;
	--zdtp-dark: #330000;
	--zdtp-accent: #fcc;
	--zdtp-text: #1d1b22;
	--zdtp-bg: #fff;
	--zdtp-primary-dark: color-mix(in srgb, var(--zdtp-primary) 78%, #000);
	--zdtp-primary-soft: color-mix(in srgb, var(--zdtp-primary) 8%, var(--zdtp-bg));
	--zdtp-muted: color-mix(in srgb, var(--zdtp-text) 64%, var(--zdtp-bg));
	--zdtp-bg-alt: color-mix(in srgb, var(--zdtp-text) 3.5%, var(--zdtp-bg));
	--zdtp-border: color-mix(in srgb, var(--zdtp-text) 11%, var(--zdtp-bg));
	--zdtp-surface-dark: color-mix(in srgb, var(--zdtp-dark) 55%, #0c0b10);
	--zdtp-gradient: linear-gradient(135deg, var(--zdtp-primary) 0%, color-mix(in srgb, var(--zdtp-primary) 55%, var(--zdtp-dark)) 55%, var(--zdtp-dark) 100%);
	--zdtp-gold: #f5a524;
	--zdtp-surface: var(--zdtp-bg);
	--zdtp-primary-text: var(--zdtp-primary);
	--zdtp-gradient-text: var(--zdtp-gradient);
	--zdtp-font-mono: ui-monospace, sfmono-regular, menlo, consolas, monospace;
	--zdtp-content: 760px;
	--zdtp-wide: 1200px;
	--zdtp-gutter: 24px;
	--zdtp-radius: 8px;
	--zdtp-radius-lg: 8px;
	--zdtp-shadow-sm: 0 1px 2px rgba(20, 16, 30, 0.06), 0 2px 8px rgba(20, 16, 30, 0.04);
	--zdtp-shadow: 0 10px 30px -12px rgba(20, 16, 30, 0.18);
	--zdtp-shadow-lg: 0 30px 60px -20px rgba(20, 16, 30, 0.3);
	--zdtp-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ------------------------------------------------------------------
 * Buttons
 * ---------------------------------------------------------------- */
.zdtp-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	min-height: 48px;
	padding: 0.7em 1.5em;
	border: 2px solid transparent;
	border-radius: 999px;
	background: var(--zdtp-primary);
	box-shadow: 0 10px 24px -12px var(--zdtp-primary);
	color: #fff;
	font: inherit;
	font-size: 0.98rem;
	font-weight: 700;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: transform 0.25s var(--zdtp-ease), box-shadow 0.25s var(--zdtp-ease), background-color 0.25s var(--zdtp-ease), color 0.25s var(--zdtp-ease), border-color 0.25s var(--zdtp-ease);
}

.zdtp-btn:hover,
.zdtp-btn:focus {
	background: var(--zdtp-primary-dark);
	color: #fff;
	transform: translateY(-2px);
}

.zdtp-btn svg {
	width: 1.1em;
	height: 1.1em;
	transition: transform 0.25s var(--zdtp-ease);
}

.zdtp-btn:hover svg {
	transform: translateX(3px);
}

.zdtp-btn--outline {
	border-color: currentColor;
	background: transparent;
	box-shadow: none;
	color: var(--zdtp-primary-text);
}

.zdtp-btn--outline:hover,
.zdtp-btn--outline:focus {
	border-color: var(--zdtp-primary-text);
	background: var(--zdtp-primary);
	color: #fff;
}

.zdtp-btn--light {
	background: #fff;
	box-shadow: 0 12px 28px -14px rgba(0, 0, 0, 0.5);
	color: var(--zdtp-primary-dark);
}

.zdtp-btn--light:hover,
.zdtp-btn--light:focus {
	background: var(--zdtp-accent);
	color: var(--zdtp-dark);
}

/* ------------------------------------------------------------------
 * Product grid and cards
 * ---------------------------------------------------------------- */
.zdtp-product-grid__grid {
	display: grid;
	grid-template-columns: repeat(var(--zdtp-cols, 3), minmax(0, 1fr));
	gap: clamp(20px, 2.5vw, 32px);
}

.zdtp-product-grid__grid.columns-2 { --zdtp-cols: 2; }
.zdtp-product-grid__grid.columns-3 { --zdtp-cols: 3; }
.zdtp-product-grid__grid.columns-4 { --zdtp-cols: 4; }

@media (max-width: 960px) {
	.zdtp-product-grid__grid.columns-3,
	.zdtp-product-grid__grid.columns-4 {
		--zdtp-cols: 2;
	}
}

@media (max-width: 600px) {
	.zdtp-product-grid__grid {
		--zdtp-cols: 1 !important;
	}
}

.zdtp-product-card {
	position: relative;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-radius: var(--zdtp-radius-lg);
	background: var(--zdtp-surface);
	box-shadow: 0 0 0 1px var(--zdtp-border), var(--zdtp-shadow-sm);
	transition: transform 0.4s var(--zdtp-ease), box-shadow 0.4s var(--zdtp-ease);
}

.zdtp-product-card:hover,
.zdtp-product-card:focus-within {
	box-shadow: 0 0 0 1px color-mix(in srgb, var(--zdtp-primary) 30%, var(--zdtp-border)), var(--zdtp-shadow-lg);
	transform: translateY(-8px);
}

.zdtp-product-card[hidden] {
	display: none;
}

.zdtp-product-card__media {
	position: relative;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	background: var(--zdtp-gradient);
}

.zdtp-product-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: top center;
	transition: transform 0.8s var(--zdtp-ease), object-position 3s ease;
}

.zdtp-product-card:hover .zdtp-product-card__media img {
	transform: scale(1.04);
}

.zdtp-product-card__placeholder {
	display: grid;
	place-items: center;
	height: 100%;
	color: rgba(255, 255, 255, 0.85);
	font-size: 4rem;
	font-weight: 800;
}

/* Diagonal corner ribbon ("Free", "Most popular", "New"). */
.zdtp-product-card__ribbon {
	position: absolute;
	top: 20px;
	left: -42px;
	z-index: 1;
	width: 160px;
	padding: 6px 0;
	background: var(--zdtp-primary);
	box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.5);
	color: #fff;
	font-family: var(--zdtp-font-mono);
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-align: center;
	text-transform: uppercase;
	transform: rotate(-45deg);
}

.zdtp-product-card__tag {
	position: absolute;
	right: 14px;
	bottom: 14px;
	z-index: 1;
	padding: 5px 12px;
	border-radius: 999px;
	background: var(--zdtp-primary);
	box-shadow: 0 6px 16px -6px var(--zdtp-primary);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 800;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	animation: zdtp-tag-pulse 2.6s ease-in-out infinite;
}

@keyframes zdtp-tag-pulse {
	50% {
		transform: scale(1.08);
	}
}

.zdtp-product-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 6px;
	padding: 20px 22px 22px;
}

.zdtp-product-card__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.zdtp-product-card__title {
	margin: 0;
	font-size: 1.1rem;
	font-weight: 750;
	line-height: 1.3;
	letter-spacing: -0.01em;
}

.zdtp-product-card__title a {
	color: inherit;
	text-decoration: none;
}

.zdtp-product-card__title a:hover,
.zdtp-product-card__title a:focus {
	color: var(--zdtp-primary-text);
}

/* The whole card is clickable through the title link. */
.zdtp-product-card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
}

.zdtp-product-card__price {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	margin: 0;
	line-height: 1.2;
	white-space: nowrap;
}

.zdtp-product-card__price strong {
	font-size: 1.05rem;
	font-weight: 800;
}

.zdtp-product-card__price del {
	color: var(--zdtp-muted);
	font-size: 0.82rem;
}

.zdtp-product-card__meta {
	margin: 0;
	overflow: hidden;
	color: var(--zdtp-muted);
	font-size: 0.85rem;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ------------------------------------------------------------------
 * Catalogue
 * ---------------------------------------------------------------- */
.zdtp-catalog__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px 24px;
	margin-bottom: 18px;
	padding: 14px;
	border-radius: var(--zdtp-radius-lg);
	background: var(--zdtp-surface);
	box-shadow: 0 0 0 1px var(--zdtp-border), var(--zdtp-shadow);
}

.zdtp-catalog__tabs {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.zdtp-catalog__tab {
	min-height: 42px;
	padding: 8px 16px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	box-shadow: none;
	color: var(--zdtp-text);
	font: inherit;
	font-size: 0.92rem;
	font-weight: 700;
	cursor: pointer;
	transition: background-color 0.25s var(--zdtp-ease), color 0.25s var(--zdtp-ease);
}

.zdtp-catalog__tab span {
	opacity: 0.6;
	font-weight: 600;
}

.zdtp-catalog__tab:hover,
.zdtp-catalog__tab:focus {
	background: var(--zdtp-primary-soft);
	color: var(--zdtp-primary-text);
	transform: none;
}

.zdtp-catalog__tab[aria-pressed="true"] {
	background: var(--zdtp-primary);
	color: #fff;
}

.zdtp-catalog__filters {
	display: flex;
	flex: 1 1 360px;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 10px;
}

.zdtp-catalog__select,
.zdtp-catalog__search {
	min-height: 44px;
	padding: 0.55em 1em;
	border: 1.5px solid var(--zdtp-border);
	border-radius: 999px;
	background: var(--zdtp-surface);
	color: var(--zdtp-text);
	font: inherit;
	font-size: 0.95rem;
}

.zdtp-catalog__select {
	flex: 0 1 200px;
}

.zdtp-catalog__search {
	flex: 1 1 220px;
}

.zdtp-catalog__count {
	margin: 0 0 22px;
	color: var(--zdtp-muted);
	font-size: 0.9rem;
}

.zdtp-catalog__empty {
	padding: 48px 24px;
	border: 1px dashed var(--zdtp-border);
	border-radius: var(--zdtp-radius-lg);
	color: var(--zdtp-muted);
	text-align: center;
}

.zdtp-catalog__more {
	margin-top: 40px;
	text-align: center;
}

.zdtp-catalog.is-ready .zdtp-product-card.is-entering {
	animation: zdtp-card-in 0.6s var(--zdtp-ease) both;
	animation-delay: var(--zdtp-delay, 0s);
}

@keyframes zdtp-card-in {
	from {
		opacity: 0;
		transform: translateY(18px) scale(0.98);
	}
}

/* ------------------------------------------------------------------
 * Video dialog (Video Card block)
 * ---------------------------------------------------------------- */
.zdtp-video-dialog {
	width: min(1100px, 92vw);
	max-width: none;
	padding: 0;
	border: 0;
	border-radius: var(--zdtp-radius-lg);
	background: #000;
	overflow: visible;
}

.zdtp-video-dialog::backdrop {
	background: rgba(10, 8, 14, 0.82);
	backdrop-filter: blur(4px);
}

.zdtp-video-dialog[open] {
	animation: zdtp-dialog-in 0.35s var(--zdtp-ease);
}

.zdtp-video-dialog__frame {
	aspect-ratio: 16 / 9;
}

.zdtp-video-dialog__frame iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	border-radius: var(--zdtp-radius-lg);
}

.zdtp-video-dialog__close {
	position: absolute;
	top: -18px;
	right: -18px;
	width: 42px;
	min-height: 42px;
	height: 42px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: #111;
	font-size: 1.6rem;
	line-height: 1;
	cursor: pointer;
}

@keyframes zdtp-dialog-in {
	from {
		opacity: 0;
		transform: scale(0.94);
	}
}

/* ------------------------------------------------------------------
 * Shared text helpers
 * ---------------------------------------------------------------- */
.zdtp-eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 14px;
	color: var(--zdtp-primary-text);
	font-family: var(--zdtp-font-mono);
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/* ------------------------------------------------------------------
 * Scroll reveal (same contract as the Zen Dev Tools theme)
 * ---------------------------------------------------------------- */
.zdtp-js [data-zdtp-animate] {
	opacity: 0;
	transition: opacity 0.8s var(--zdtp-ease), transform 0.8s var(--zdtp-ease);
	transition-delay: var(--zdtp-delay, 0s);
}

.zdtp-js [data-zdtp-animate="fade-up"] { transform: translateY(32px); }
.zdtp-js [data-zdtp-animate="fade-down"] { transform: translateY(-32px); }
.zdtp-js [data-zdtp-animate="fade-left"] { transform: translateX(40px); }
.zdtp-js [data-zdtp-animate="fade-right"] { transform: translateX(-40px); }
.zdtp-js [data-zdtp-animate="zoom-in"] { transform: scale(0.92); }

.zdtp-js [data-zdtp-animate].is-inview {
	opacity: 1;
	transform: none;
}

.zdtp-js:not(.zdtp-reveal-ready) [data-zdtp-animate] {
	animation: zdtp-reveal-fallback 0.6s 2.5s forwards;
}

@keyframes zdtp-reveal-fallback {
	to {
		opacity: 1;
		transform: none;
	}
}

/* Never hide anything inside the block editor. */
.editor-styles-wrapper [data-zdtp-animate],
.block-editor-block-list__layout [data-zdtp-animate] {
	opacity: 1 !important;
	transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.zdtp-js [data-zdtp-animate] {
		opacity: 1;
		transform: none;
		transition: none;
	}

	.zdtp-product-card__tag,
	.zdtp-catalog.is-ready .zdtp-product-card.is-entering {
		animation: none;
	}
}
