/*
 * ZAIS Product Certificates - frontend styles.
 * All classes use the zhd_ prefix (per user spec).
 * Visual tokens are CSS custom properties set inline by the renderer
 * so values respect Appearance > Customize > ZAIS Certificates.
 */

.zhd_wrap {
	/* Palette */
	--zhd-accent-bg: #f3d24b;
	--zhd-accent-text: #222;
	--zhd-card-bg: #ffffff;
	--zhd-card-text: #1a1a1a;
	--zhd-card-border: transparent;
	--zhd-card-shadow: none;
	--zhd-btn-bg: #0e1f45;
	--zhd-btn-text: #ffffff;
	--zhd-lightbox-bg: rgba(0,0,0,0.9);

	/* Shape & scale */
	--zhd-radius: 12px;
	--zhd-font-scale: 1;
	--zhd-card-width: 340px;
	--zhd-card-min-height: auto;
	--zhd-gap: 20px;

	/* Thumbnail (image on the card) */
	--zhd-thumb-width: 100px;
	--zhd-thumb-height: 100px;
	--zhd-thumb-radius: 10px;

	/* Buttons */
	--zhd-btn-radius: 999px;
	--zhd-btn-pad-y: 10px;
	--zhd-btn-pad-x: 20px;
	--zhd-btn-border: transparent;
	--zhd-btn-hover-bg: var(--zhd-btn-bg);
	--zhd-btn-hover-text: var(--zhd-btn-text);

	/* Links (verify / product) */
	--zhd-link-color: var(--zhd-btn-bg);
	--zhd-link-hover-color: var(--zhd-link-color);
	--zhd-link-underline: 1;

	position: relative;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	/* Inherit the theme font. font-scale stays at 1 by default so nothing
	 * changes unless the user opts into a different scale in the Customizer. */
	font-family: inherit;
	font-size: calc(1em * var(--zhd-font-scale));
	color: var(--zhd-card-text);
}
.zhd_wrap *,
.zhd_wrap *::before,
.zhd_wrap *::after { box-sizing: border-box; }
/* Every interactive element inside a card must use the theme's font
 * stack; browsers default <button>/<input> to a system font. */
.zhd_wrap button,
.zhd_wrap input,
.zhd_wrap select,
.zhd_wrap textarea,
.zhd_wrap a { font-family: inherit; }

/* ------- Wrap / Grid mode (default) -------
 * Fixed-width cards that wrap onto the next line automatically. */
.zhd_wrap.zhd_mode_wrap .zhd_track {
	display: flex;
	flex-wrap: wrap;
	gap: var(--zhd-gap);
	align-items: stretch;
}
.zhd_wrap.zhd_mode_wrap .zhd_card {
	flex: 0 0 var(--zhd-card-width);
	max-width: 100%;
}

/* ------- Carousel mode (opt-in) ------- */
.zhd_wrap.zhd_mode_carousel .zhd_track {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	gap: var(--zhd-gap);
	scrollbar-width: thin;
	padding-bottom: 4px;
}
.zhd_wrap.zhd_mode_carousel .zhd_card {
	flex: 0 0 var(--zhd-card-width);
	scroll-snap-align: start;
}

/* ------- Single card ------- */
.zhd_wrap.zhd_single .zhd_track {
	display: flex;
	overflow: visible;
	scroll-snap-type: none;
}
.zhd_wrap.zhd_single .zhd_card {
	flex: 0 0 var(--zhd-card-width);
	max-width: 100%;
}

.zhd_wrap .zhd_card { min-height: var(--zhd-card-min-height, auto); }

/* ------- Nav arrows (carousel only) ------- */
.zhd_nav {
	position: absolute;
	top: 50%;
	width: 36px;
	height: 36px;
	border-radius: 999px;
	background: #fff;
	border: 1px solid #e5e5e5;
	cursor: pointer;
	transform: translateY(-50%);
	z-index: 2;
	line-height: 1;
	font-size: 18px;
	box-shadow: 0 2px 6px rgba(0,0,0,0.08);
	color: var(--zhd-card-text);
}
.zhd_nav:hover { background: var(--zhd-btn-bg); color: var(--zhd-btn-text); }
.zhd_prev { left: -6px; }
.zhd_next { right: -6px; }
.zhd_wrap:not(.zhd_mode_carousel) .zhd_nav,
.zhd_wrap.zhd_single .zhd_nav { display: none !important; }

/* Empty wrappers should never draw a visible box. This guards against
 * Elementor / theme styles that add padding, borders, or backgrounds
 * to generic block wrappers and makes sure the COA output never shows
 * phantom empty rectangles above or below the cards. The !important
 * flags are intentional: themes and Elementor ship aggressive rules
 * targeting `.elementor-widget-container`, `.entry-content > div`, etc. */
.zhd_archive:empty,
.zhd_wrap:empty,
.zhd_track:empty,
.zhd_archive_filter:empty,
.zhd_pager:empty { display: none !important; }

.zhd_archive,
.zhd_archive_filter,
.zhd_wrap,
.zhd_track,
.zhd_product_block {
	background: transparent !important;
	border: 0 !important;
	box-shadow: none !important;
	outline: 0 !important;
	padding: 0;
	margin: 0;
}
/* The archive column itself (parent of the cards) must never paint a
 * border or shadow of its own regardless of theme resets. */
.zhd_archive {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* ------- Card ------- */
.zhd_card {
	position: relative;
	background: var(--zhd-card-bg);
	border: 1px solid var(--zhd-card-border);
	border-radius: var(--zhd-radius);
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	color: var(--zhd-card-text);
	/* Shadow defaults to "none"; authors can switch the preset in
	 * Appearance > Customize > ZAIS Certificates > Card layout. */
	box-shadow: var(--zhd-card-shadow, none);
}
.zhd_card.zhd_stale { opacity: 0.75; }

.zhd_whole_link { position: absolute; inset: 0; border-radius: inherit; z-index: 1; }
.zhd_whole_link + * { position: relative; z-index: 2; }
.zhd_card .zhd_whole_link ~ * { position: relative; z-index: 2; }

/* ------- Badge (title) ------- */
.zhd_badge {
	display: inline-block;
	background: var(--zhd-accent-bg);
	color: var(--zhd-accent-text);
	border-radius: calc(var(--zhd-radius) * 0.7);
	padding: 6px 14px;
	font-weight: 600;
	text-decoration: none;
	align-self: flex-start;
	transition: filter 0.15s;
	line-height: 1.3;
}
a.zhd_badge:hover { filter: brightness(0.95); }

.zhd_body_head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zhd_stale_badge {
	font-size: 0.8em;
	background: #eee;
	color: #555;
	padding: 2px 8px;
	border-radius: 4px;
}

/* ------- Detail list ------- */
.zhd_details {
	list-style: none;
	margin: 6px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 3px;
	line-height: 1.45;
}
.zhd_details li { display: block; }
.zhd_key { font-weight: 600; }

.zhd_desc { margin-top: 4px; line-height: 1.5; color: #444; }

/* ------- Actions & buttons ------- */
.zhd_actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	margin-top: auto;
	padding-top: 10px;
}

/* Primary CTA (VIEW) */
.zhd_view_btn,
button.zhd_view_btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--zhd-btn-border);
	cursor: pointer;
	background: var(--zhd-btn-bg);
	color: var(--zhd-btn-text);
	padding: var(--zhd-btn-pad-y) var(--zhd-btn-pad-x);
	border-radius: var(--zhd-btn-radius);
	font-family: inherit;
	font-weight: 600;
	text-decoration: none;
	line-height: 1.2;
	transition: background 0.15s, color 0.15s, filter 0.15s, transform 0.15s;
}
.zhd_view_btn:hover,
button.zhd_view_btn:hover {
	background: var(--zhd-btn-hover-bg);
	color: var(--zhd-btn-hover-text);
	filter: brightness(1.05);
}
.zhd_view_btn:focus-visible { outline: 2px solid var(--zhd-btn-bg); outline-offset: 2px; }

/* Secondary text link (Verify / View product) */
a.zhd_verify,
a.zhd_product_link {
	background: transparent;
	color: var(--zhd-link-color);
	padding: 0;
	border: 0;
	border-radius: 0;
	font-weight: 500;
	text-decoration: none;
	line-height: 1.2;
	position: relative;
}
a.zhd_verify { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a.zhd_product_link { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.zhd_wrap[data-link-underline="0"] a.zhd_verify,
.zhd_wrap[data-link-underline="0"] a.zhd_product_link { text-decoration: none; }
.zhd_wrap[data-link-underline="0"] a.zhd_verify:hover,
.zhd_wrap[data-link-underline="0"] a.zhd_product_link:hover { text-decoration: underline; }
a.zhd_verify:hover,
a.zhd_product_link:hover { color: var(--zhd-link-hover-color); }
a.zhd_verify:focus-visible,
a.zhd_product_link:focus-visible { outline: 2px solid var(--zhd-link-color); outline-offset: 2px; }

/* ------- Unified card inner layout (image left, body right) ------- */
.zhd_card_inner {
	display: flex;
	gap: 16px;
	align-items: flex-start;
	flex: 1 1 auto;
}
.zhd_card.zhd_no_image .zhd_card_inner { gap: 0; }

.zhd_thumb_btn {
	flex: 0 0 var(--zhd-thumb-width);
	width: var(--zhd-thumb-width);
	height: var(--zhd-thumb-height);
	padding: 0;
	margin: 0;
	border: 1px solid #e5e5e5;
	border-radius: var(--zhd-thumb-radius);
	background: #fff;
	cursor: pointer;
	overflow: hidden;
	display: block;
	position: relative;
	text-decoration: none;
	text-transform: none;
	letter-spacing: normal;
	font-weight: normal;
	color: inherit;
	box-shadow: none;
	transition: border-color 0.15s;
}
.zhd_thumb_btn:hover { border-color: var(--zhd-btn-bg); }
.zhd_thumb_btn:focus-visible { outline: 2px solid var(--zhd-btn-bg); outline-offset: 2px; }
.zhd_thumb_btn img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.25s ease;
}
.zhd_thumb_btn:hover img { transform: scale(1.04); }

/* Circle thumbnails (data attribute emitted by the renderer). */
.zhd_wrap[data-thumb-shape="circle"] .zhd_thumb_btn { border-radius: 999px; }

.zhd_body {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.zhd_image_count {
	position: absolute;
	top: 6px;
	right: 6px;
	background: rgba(0,0,0,0.7);
	color: #fff;
	font-size: 0.7em;
	padding: 2px 7px;
	border-radius: 999px;
	pointer-events: none;
}

/* Empty state */
.zhd_empty {
	padding: 20px;
	border: 1px dashed #ddd;
	border-radius: var(--zhd-radius);
	text-align: center;
	color: #666;
}

/* Archive filter (layout only - appearance reset lives in the
 * "Empty wrappers" block above). */
.zhd_archive_filter { display: flex; gap: 8px; align-items: stretch; }
.zhd_archive_filter input[type="search"] {
	flex: 1;
	padding: 10px 14px;
	border: 1px solid #ddd;
	border-radius: var(--zhd-radius);
	font-size: 1em;
}
.zhd_btn {
	background: var(--zhd-btn-bg);
	color: var(--zhd-btn-text);
	border: 0;
	border-radius: var(--zhd-btn-radius);
	padding: 10px 22px;
	cursor: pointer;
	font-weight: 600;
}
.zhd_pager { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.zhd_pager a, .zhd_pager span {
	padding: 6px 12px;
	border: 1px solid #e5e5e5;
	border-radius: 6px;
	text-decoration: none;
}
.zhd_pager .zhd_current { background: var(--zhd-btn-bg); color: var(--zhd-btn-text); }

/* On very narrow viewports, let cards flex to full width so they don't overflow. */
@media (max-width: 520px) {
	.zhd_wrap.zhd_mode_wrap .zhd_card,
	.zhd_wrap.zhd_single .zhd_card,
	.zhd_wrap.zhd_mode_carousel .zhd_card {
		flex-basis: 100%;
		max-width: 100%;
	}
}

/* -------------- Lightbox --------------
 * z-index uses the 2147483xxx range (int32 max) and !important so no
 * sticky header, floating cart, chat widget, or Elementor popup layer
 * can paint over the modal. The JS also reparents this element to
 * <body> on init so it escapes any ancestor stacking context. */
.zhd_lightbox[hidden] { display: none !important; }
.zhd_lightbox {
	position: fixed !important;
	inset: 0;
	z-index: 2147483600 !important;
	display: flex;
	align-items: center;
	justify-content: center;
}
.zhd_lightbox_backdrop { z-index: 1; }
.zhd_lightbox_panel    { z-index: 2; }
.zhd_lightbox_backdrop {
	position: absolute;
	inset: 0;
	background: var(--zhd-lightbox-bg, rgba(0,0,0,0.9));
}
.zhd_lightbox_panel {
	position: relative;
	max-width: min(96vw, 1100px);
	max-height: 96vh;
	background: #fff;
	border-radius: 14px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.zhd_lightbox_head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 18px;
	border-bottom: 1px solid #eee;
}
.zhd_lightbox_title { margin: 0; font-size: 1.05em; flex: 1; }
.zhd_lightbox_counter { color: #666; font-size: 0.9em; }
.zhd_lightbox_close {
	background: transparent;
	border: 0;
	font-size: 1.8em;
	line-height: 1;
	cursor: pointer;
	color: #333;
}
.zhd_lightbox_stage {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #111;
	min-height: 40vh;
	max-height: 80vh;
	overflow: auto;
}
.zhd_lightbox_img {
	max-width: 100%;
	max-height: 80vh;
	display: block;
	user-select: none;
	touch-action: pinch-zoom;
}
.zhd_lightbox_prev, .zhd_lightbox_next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	background: rgba(255,255,255,0.9);
	border: 0;
	width: 44px;
	height: 44px;
	border-radius: 999px;
	cursor: pointer;
	font-size: 1.2em;
	z-index: 2;
}
.zhd_lightbox_prev { left: 12px; }
.zhd_lightbox_next { right: 12px; }
.zhd_lightbox_foot {
	padding: 12px 18px;
	border-top: 1px solid #eee;
	background: #fafafa;
}
.zhd_lightbox_desc { margin-bottom: 10px; line-height: 1.5; font-size: 0.95em; }
.zhd_lightbox_desc:empty { display: none; }
.zhd_lightbox_thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.zhd_lightbox_thumbs button {
	width: 56px;
	height: 40px;
	border: 2px solid transparent;
	border-radius: 4px;
	background-size: cover;
	background-position: center;
	cursor: pointer;
	padding: 0;
}
.zhd_lightbox_thumbs button[aria-selected="true"] { border-color: var(--zhd-btn-bg, #0e1f45); }
