/**
 * NexGen COA catalog and COA preview modal.
 *
 * Figma: COA Page 6150:14961 (catalog), 6150:15576 (preview pop-up).
 * The catalog uses Pepti's page-coa template; layout width and the sorting
 * field come from shop.css (.l-main--woocommerce / .pepti-catalog-toolbar).
 */

/* ---------------------------------------------------------- catalog -- */

.pepti-template-coa-catalog .pepti-coa-catalog {
	max-width: none;
	max-inline-size: none;
}

.pepti-template-coa-catalog .pepti-coa-catalog-controls__sorting {
	inline-size: 313px;
	max-inline-size: 100%;
	margin: 0;
}

.pepti-template-coa-catalog .wc-block-product-template {
	gap: var(--pepti-size-spacing-primitive-xs, 20px);
}

/* Figma COA page ends with the footer, no Subscribe block. */
body.page-template-page-coa .nx-cta {
	display: none;
}

/* ----------------------------------------------------------- COA card -- */

.c-product-card--coa {
	overflow: hidden;
	border: 1px solid var(--pepti-color-component-product-card-border-default, #041e42);
	border-radius: var(--pepti-size-spacing-primitive-xs, 20px);
	background: var(--pepti-color-component-product-card-surface-default, #00080f);
}

.c-product-card--coa > .c-product-card__media {
	border-radius: 0;
}

/*
 * Card media (Figma 6735:7863 + document layer): spotlight background with the
 * first page of the current certificate standing in the light (75% of the
 * 300px frame, 34px from the top). Markup: nexgen/coa-card-media.
 */
.c-product-card--coa > .c-product-card__media {
	position: relative;
	block-size: 300px;
	background: #000 url("../images/coa/coa-card-bg.jpg") center / cover no-repeat;
}

.nx-coa-card__media-wrap,
.nx-coa-card__media {
	display: block;
	block-size: 100%;
}

.nx-coa-card__media {
	position: relative;
	cursor: zoom-in;
}

.nx-coa-card__media:focus-visible {
	outline: 2px solid var(--pepti-color-global-content-accent, #05f4f9);
	outline-offset: -4px;
}

.nx-coa-card__document {
	position: absolute;
	inset-block-start: 11.4%;
	inset-inline-start: 50%;
	block-size: 75%;
	inline-size: auto;
	max-inline-size: 80%;
	object-fit: contain;
	border-radius: 2px;
	background: #fff;
	box-shadow: 0 10px 30px rgb(0 0 0 / 0.45), 0 0 40px rgb(5 244 249 / 0.12);
	transform: translateX(-50%);
	transition: transform 0.25s ease;
}

.nx-coa-card__media:is(:hover, :focus-visible) .nx-coa-card__document {
	transform: translateX(-50%) translateY(-4px);
}

.nx-coa-card__document--placeholder {
	display: grid;
	place-items: center;
	aspect-ratio: 834 / 1080;
	font: 600 20px/1 var(--pepti-type-product-card-desktop-title-font-family, "Poppins", sans-serif);
	color: #00080f;
}

/* ---------------------------------------------- previous certificates -- */
/* nexgen/coa-history: chip on the media, panel overlays the media area. */

.nx-coa-history {
	position: static;
}

.nx-coa-history__toggle {
	position: absolute;
	z-index: 3;
	inset-block-start: 12px;
	inset-inline-end: 12px;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-block-size: 36px;
	padding: 0 12px;
	border: 1px solid var(--pepti-color-global-border-accent-low, #00adbc);
	border-radius: var(--pepti-size-radius-primitive-pill, 100px);
	background: rgb(0 8 15 / 0.72);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	font-family: var(--pepti-type-product-card-desktop-meta-font-family, "Space Grotesk", sans-serif);
	font-size: 13px;
	line-height: 1;
	color: #fff;
	cursor: pointer;
	list-style: none;
	user-select: none;
	transition: background-color 0.2s ease, border-color 0.2s ease;
}

.nx-coa-history__toggle::-webkit-details-marker {
	display: none;
}

.nx-coa-history__toggle::marker {
	content: "";
}

.nx-coa-history__toggle:is(:hover, :focus-visible),
.nx-coa-history[open] > .nx-coa-history__toggle {
	border-color: var(--pepti-color-global-content-accent, #05f4f9);
	background: rgb(0 8 15 / 0.92);
}

.nx-coa-history__toggle:focus-visible {
	outline: 2px solid var(--pepti-color-global-content-accent, #05f4f9);
	outline-offset: 2px;
}

.nx-coa-history__icon {
	flex: none;
	color: var(--pepti-color-global-content-accent, #05f4f9);
}

.nx-coa-history__count {
	display: inline-grid;
	place-items: center;
	min-inline-size: 20px;
	block-size: 20px;
	padding: 0 5px;
	box-sizing: border-box;
	border-radius: 10px;
	background: var(--pepti-color-global-content-accent, #05f4f9);
	font-size: 12px;
	font-weight: 600;
	color: #00080f;
}

.nx-coa-history__panel {
	position: absolute;
	z-index: 2;
	inset: 0;
	display: flex;
	flex-direction: column;
	padding: 60px 12px 0 20px;
	background: rgb(0 8 15 / 0.94);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	animation: nx-coa-history-in 0.18s ease-out;
}

@keyframes nx-coa-history-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

.nx-coa-history__list {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 6px;
	min-block-size: 0;
	margin: 0;
	padding: 0 8px 20px 0;
	overflow-y: auto;
	list-style: none;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: rgb(5 244 249 / 0.5) transparent;
	/* Fade the last rows so a longer list reads as scrollable. */
	-webkit-mask-image: linear-gradient(#000 calc(100% - 28px), transparent);
	mask-image: linear-gradient(#000 calc(100% - 28px), transparent);
}

.nx-coa-history__list > li {
	margin: 0;
	padding: 0;
}

.nx-coa-history__item {
	display: flex;
	align-items: center;
	gap: 10px;
	min-block-size: 40px;
	padding: 8px 14px;
	box-sizing: border-box;
	border: 1px solid var(--pepti-color-component-product-card-border-default, #041e42);
	border-radius: var(--pepti-size-radius-primitive-xs, 10px);
	background: var(--pepti-color-global-surface-subtle, #081017);
	font-size: 14px;
	line-height: 1.3;
	color: #fff;
	text-decoration: none;
	transition: border-color 0.2s ease, color 0.2s ease;
}

.nx-coa-history__item::after {
	content: "";
	flex: none;
	inline-size: 16px;
	block-size: 16px;
	margin-inline-start: auto;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3h7v7M21 3l-9 9M19 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3h7v7M21 3l-9 9M19 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h5'/%3E%3C/svg%3E") center / contain no-repeat;
	opacity: 0.7;
}

.nx-coa-history__item:is(:hover, :focus-visible) {
	border-color: var(--pepti-color-global-content-accent, #05f4f9);
	color: var(--pepti-color-global-content-accent, #05f4f9);
}

.nx-coa-history__item:focus-visible {
	outline: none;
}

.nx-coa-history__label {
	font-weight: 500;
}

.nx-coa-history__date {
	font-size: 13px;
	color: var(--pepti-color-global-content-secondary, #b4bcc4);
	white-space: nowrap;
}

.nx-coa-history__item:is(:hover, :focus-visible) .nx-coa-history__date {
	color: inherit;
}

@media (prefers-reduced-motion: reduce) {
	.nx-coa-card__document,
	.nx-coa-history__panel {
		transition: none;
		animation: none;
	}
}

/* Editor placeholders. */
.nx-coa-card__media-wrap--editor,
.nx-coa-history--editor {
	display: grid;
	place-items: center;
	color: #fff;
}

.nx-coa-history--editor {
	position: absolute;
	inset-block-start: 12px;
	inset-inline-end: 12px;
	font-size: 13px;
}

.c-product-card--coa .c-product-card__body {
	gap: var(--pepti-size-spacing-primitive-xs, 20px);
	padding: var(--pepti-size-spacing-primitive-xs, 20px);
	border-block-start: 1px solid var(--pepti-color-component-product-card-border-default, #041e42);
	border-radius: 0;
}

.c-product-card--coa .c-product-card__summary {
	gap: 10px;
}

.c-product-card--coa .c-product-card__category {
	margin: 0;
	font-family: var(--pepti-type-product-card-desktop-meta-font-family, "Space Grotesk", sans-serif);
	font-size: var(--pepti-type-product-card-desktop-meta-font-size, 14px);
	font-weight: var(--pepti-type-product-card-desktop-meta-font-weight, 400);
	line-height: 1.4;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--pepti-color-global-content-accent, #05f4f9);
}

.c-product-card--coa .wp-block-post-title {
	margin: 0;
	font-family: var(--pepti-type-product-card-desktop-title-font-family, "Poppins", sans-serif);
	font-size: var(--pepti-type-product-card-desktop-title-font-size, 24px);
	font-weight: var(--pepti-type-product-card-desktop-title-font-weight, 600);
	line-height: 1.2;
	color: var(--pepti-color-component-product-info-content-title, #fff);
}

/* Figma: full-width primary "View Full PDF" (label set in nexgen_coa_card_action()).
 * Client asked for a smaller button than Figma's 56px / 16px. */
.c-product-card--coa .pepti-coa-action--card {
	--pepti-button-border-width: 0px;
	--pepti-button-render-surface: var(--pepti-color-component-button-primary-surface-default, #05f4f9);
	--pepti-button-render-border: transparent;
	--pepti-button-render-content: var(--pepti-color-component-button-primary-content-default, #00080f);
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	inline-size: 100%;
	block-size: 44px;
	min-block-size: 0;
	padding: 10px 24px;
	border-radius: var(--pepti-size-radius-primitive-pill, 100px);
	font-family: var(--pepti-type-button-default-desktop-medium-font-family, "Poppins", sans-serif);
	font-size: 14px;
	font-weight: var(--pepti-type-button-default-desktop-medium-font-weight, 500);
	line-height: 1.2;
	text-decoration: none;
}

.c-product-card--coa .pepti-coa-action--card:is(:hover, :focus-visible) {
	--pepti-button-render-surface: var(--pepti-color-component-button-primary-surface-hover, #a0fffe);
}

.c-product-card--coa .pepti-coa-action--card > span {
	font: inherit;
	color: inherit;
}

.c-product-card--coa .pepti-coa-action--card::before,
.c-product-card--coa .pepti-coa-action--card::after {
	content: none;
	display: none;
}

/* ------------------------------------------------- COA preview pop-up -- */
/* Shared by the COA catalog and the single product COA link. */

.c-modal.pepti-media-preview {
	--pepti-modal-inline-size: min(calc(100vw - (var(--pepti-size-spacing-primitive-xs, 20px) * 2)), 650px);
	--pepti-modal-padding: var(--pepti-size-spacing-primitive-lg, 60px);
	gap: var(--pepti-size-spacing-primitive-md, 40px);
	padding: var(--pepti-modal-padding);
	border: 1px solid var(--pepti-color-global-border-accent-low, #00adbc);
	border-radius: var(--pepti-size-radius-primitive-md, 20px);
	background: var(--pepti-color-global-surface-subtle, #081017);
	box-shadow: 0 4px 12px 0 rgb(255 255 255 / 0.2);
}

.c-modal.pepti-media-preview::backdrop {
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	background: var(--pepti-color-component-overlay-scrim, rgb(8 16 23 / 0.5));
}

.c-modal.pepti-media-preview .pepti-media-preview__close {
	position: absolute;
	inset-block-start: 19px;
	inset-inline-end: 19px;
	inline-size: 24px;
	block-size: 24px;
	padding: 0;
}

.c-modal.pepti-media-preview .pepti-media-preview__media {
	display: flex;
	justify-content: center;
	margin: 0;
	padding: 0;
	background: none;
}

.c-modal.pepti-media-preview .pepti-media-preview__image {
	display: block;
	inline-size: 100%;
	max-inline-size: 530px;
	block-size: auto;
	max-block-size: min(700px, calc(100dvh - 300px));
	object-fit: contain;
	border-radius: var(--pepti-size-spacing-primitive-xxs, 10px);
	background: #fff;
}

.c-modal.pepti-media-preview .pepti-media-preview__footer {
	display: flex;
	justify-content: center;
	margin: 0;
}

.c-modal.pepti-media-preview .pepti-media-preview__full {
	block-size: 56px;
	min-block-size: 0;
	padding: 16px var(--pepti-size-spacing-primitive-sm, 30px);
	font-size: var(--pepti-type-button-default-desktop-medium-font-size, 16px);
}

@media (max-width: 767px) {
	.c-modal.pepti-media-preview {
		--pepti-modal-padding: var(--pepti-size-spacing-primitive-sm, 20px);
		gap: var(--pepti-size-spacing-primitive-xs, 20px);
		padding-block-start: 52px;
	}

	.c-product-card--coa > .c-product-card__media {
		block-size: auto;
		aspect-ratio: 353 / 300;
	}
}

/* The title opens the product page (patterns/product-coa-card-template.php). */
.c-product-card--coa .wp-block-post-title a {
	color: inherit;
	text-decoration: none;
}

.c-product-card--coa .wp-block-post-title a:is(:hover, :focus-visible) {
	color: var(--pepti-color-global-content-accent, #05f4f9);
}

/* Figma COA section: 60px above and below the catalog on every width (QA Nov 2026: was 120px on desktop). */
.pepti-template-coa-catalog > .l-page-content--commerce.l-container {
	/* Fixed 60px: the lg token drops to 30px on phones. */
	padding-block: 60px;
}
