/**
 * Mervia Catalogue: product and category page additions.
 *
 * Kept in the plugin rather than the theme's components.css, which the theme
 * owns. Reads only the theme's design tokens (--co-*), so a palette or
 * spacing change in tokens.css carries through. The 1024px breakpoint is the
 * one at which the theme's sidebar grids collapse; keep the two in step (the
 * inline script in inc/filters.php uses it too).
 */

/* --------------------------------------------------------------------------
   Category filters: a collapsed <details> on phones, the sidebar as before
   on wide screens.
   -------------------------------------------------------------------------- */

.mv-filters__summary {
	display: flex;
	align-items: center;
	gap: var(--co-space-3);
	min-height: var(--co-control-height);
	padding: 0 var(--co-control-padding-x);
	background: var(--co-color-surface);
	border: var(--co-border-width) solid var(--co-color-border-strong);
	border-radius: var(--co-radius-md);
	font-size: var(--co-text-sm);
	font-weight: var(--co-weight-semibold);
	color: var(--co-color-text);
	cursor: pointer;
	list-style: none;
}

.mv-filters__summary::-webkit-details-marker {
	display: none;
}

/* A chevron drawn in CSS, turned when open, so the state is visible. */
.mv-filters__summary::after {
	content: "";
	width: 0.5rem;
	height: 0.5rem;
	margin-inline-start: auto;
	border-inline-end: 2px solid currentColor;
	border-block-end: 2px solid currentColor;
	transform: rotate(45deg) translateY(-2px);
	transition: transform var(--co-transition-base);
}

.mv-filters[open] > .mv-filters__summary::after {
	transform: rotate(-135deg) translateY(-2px);
}

.mv-filters__summary:focus-visible {
	outline: none;
	box-shadow: var(--co-focus-ring);
}

.mv-filters__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.5rem;
	height: 1.5rem;
	padding: 0 var(--co-space-2);
	border-radius: var(--co-radius-pill);
	background: var(--co-color-action);
	color: var(--co-color-action-text);
	font-size: var(--co-text-xs);
}

@media (max-width: 1023.98px) {
	.mv-filters[open] > .c-filters {
		margin-block-start: var(--co-space-4);
		padding: var(--co-space-5);
		border: var(--co-border-width) solid var(--co-color-rule);
		border-radius: var(--co-radius-md);
		background: var(--co-color-surface);
	}
}

@media (min-width: 1024px) {
	/* Always open on wide screens (the inline script re-opens it when a
	   window is widened); the summary line has no job there. */
	.mv-filters__summary {
		display: none;
	}
}

/* Quote prompt under the category grid. */
.mv-cat-quote {
	margin-block-start: var(--co-space-8);
}

/* --------------------------------------------------------------------------
   Product page
   -------------------------------------------------------------------------- */

/* Long labels (Finnish, German) must wrap rather than overflow a 360px
   screen; the theme's .c-btn is nowrap. */
.mv-product-actions .c-btn {
	max-width: 100%;
	white-space: normal;
	text-align: center;
}

/* Certification badges that lead to the standard or quality page. */
a.mv-cert-link {
	text-decoration: none;
	transition: border-color var(--co-transition-base), color var(--co-transition-base);
}

a.mv-cert-link:hover {
	border-color: var(--co-color-text-link);
	color: var(--co-color-text-link);
}

a.mv-cert-link:focus-visible {
	outline: none;
	box-shadow: var(--co-focus-ring);
}

/* MOQ / lead time labels and the note under the table. */
.mv-spec-link {
	color: var(--co-color-text-link);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.15em;
}

.mv-spec-link:hover {
	color: var(--co-color-text-link-hover);
}

/* The jump target of "Request a quote for this product". */
#product-quote {
	scroll-margin-top: calc(var(--co-header-height, 4.5rem) + var(--co-space-5));
}

/* "Also useful": the same quiet list style as the resources' related list,
   laid out across the page. */
.mv-useful__title {
	margin: 0 0 var(--co-space-4);
	font-size: var(--co-text-sm);
	font-weight: var(--co-weight-semibold);
	text-transform: uppercase;
	letter-spacing: var(--co-tracking-wide);
	color: var(--co-color-text-muted);
}

.mv-useful {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
	gap: var(--co-space-3) var(--co-space-6);
	margin: 0;
	padding: var(--co-space-5) 0 0;
	border-block-start: var(--co-border-width) solid var(--co-color-rule);
	list-style: none;
}

.mv-useful__item {
	display: flex;
	flex-direction: column;
	gap: var(--co-space-1);
}

.mv-useful__type {
	font-size: var(--co-text-xs);
	text-transform: uppercase;
	letter-spacing: var(--co-tracking-wide);
	color: var(--co-color-text-subtle);
}

.mv-useful__link {
	font-weight: var(--co-weight-semibold);
	color: var(--co-color-text-link);
}

.mv-useful__link:hover {
	color: var(--co-color-text-link-hover);
}

@media (prefers-reduced-motion: reduce) {
	.mv-filters__summary::after,
	a.mv-cert-link {
		transition: none;
	}
}

@media print {
	.mv-useful,
	.mv-useful__title,
	.mv-filters__summary {
		display: none;
	}
}
