/*
 * Product Codes widget (.meshut-pc).
 *
 * The card layout is the prototype's spec card (the "Teknik Bilgiler" card,
 * work/bathhere pages.css .pd-spec-card): a white card on the brand border,
 * a cream badge with a gold icon beside the title, label / value rows on
 * hairlines. The inline layout is the prototype's product meta rows
 * (.product-info__meta). The codes are the point of the widget, so they are
 * set in the heading face with tabular figures; a lock marks the codes only
 * authorized users see.
 *
 * A click on a code copies it: the code is a button drawn as text, with the
 * navy tipsy-style tooltip of the quote document's IBAN (mzr-quotes
 * quote-document.css .qd-copy) — "Copy", then a green "Copied" (is-copied,
 * assets/js/product-codes.js). A code the product form changes flashes gold
 * (is-changed). The button resets WoodMart's button base rule
 * (:is(.btn,.button,button,…): 42px min-height, padding, uppercase), so
 * every rule on it carries two classes.
 *
 * Colours and fonts come from the --mzr-* tokens (child theme, MZR
 * Settings CSS Options) with the brand values as fallbacks.
 */

.meshut-pc {
	--meshut-pc-gold: var(--mzr-primary-color, #B8952A);
	--meshut-pc-gold-dark: var(--mzr-color-gold-dark, #7A5F28);
	--meshut-pc-navy: var(--mzr-secondary-color, #0F1E2E);
	--meshut-pc-cream: var(--mzr-color-cream, #FAF5EC);
	--meshut-pc-border: var(--mzr-color-border, #E0D0A8);
	--meshut-pc-hairline: rgba(224, 208, 168, 0.4);
	--meshut-pc-ink: var(--mzr-color-espresso, #3D2E12);
	--meshut-pc-text: var(--mzr-text-color, #2A1F0E);
	--meshut-pc-green: #1f6f4a;
	position: relative;
	color: var(--meshut-pc-text);
	font-family: var(--mzr-font-body, 'Inter', sans-serif);
	font-size: 14px;
	line-height: 1.5;
}

/* ── Card ──
   The box of the package calculator on the same page (mzr-products
   frontend-calculator.css .meshut-pkg-calc): the same corner radius,
   padding and width on every screen, so the two line up (1.9.1). A change
   there needs the same change here (tools/tests/product-codes-assets-test.php
   compares them). */

.meshut-pc--card {
	max-width: 520px;
	padding: 20px 22px;
	border: 1px solid var(--meshut-pc-border);
	border-radius: 12px;
	background: var(--mzr-color-white, #FFFFFF);
}

.meshut-pc__head {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0 0 8px;
	padding-bottom: 16px;
	border-bottom: 1px solid var(--meshut-pc-border);
}

.meshut-pc__badge {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--meshut-pc-cream);
	color: var(--meshut-pc-gold);
}

.meshut-pc__badge svg {
	width: 20px;
	height: 20px;
}

.meshut-pc .meshut-pc__title {
	margin: 0;
	padding: 0;
	font-family: var(--mzr-font-heading, 'Space Grotesk', sans-serif);
	font-size: 18px;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: 0;
	text-transform: none;
	color: var(--meshut-pc-ink);
}

/* ── Rows ── */

.meshut-pc .meshut-pc__list {
	margin: 0;
	padding: 0;
}

.meshut-pc__row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 6px 16px;
	padding: 12px 0;
	border-bottom: 1px solid var(--meshut-pc-hairline);
}

.meshut-pc__row:last-child {
	padding-bottom: 0;
	border-bottom: 0;
}

.meshut-pc .meshut-pc__label {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	gap: 10px;
	margin: 0;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.4;
	color: var(--meshut-pc-text);
}

.meshut-pc__label-text {
	opacity: 0.7;
}

.meshut-pc__icon {
	display: inline-flex;
	color: var(--meshut-pc-gold);
}

.meshut-pc__icon svg {
	width: 18px;
	height: 18px;
}

.meshut-pc__lock {
	display: inline-flex;
	margin-left: -4px;
	color: var(--meshut-pc-gold-dark);
}

.meshut-pc__lock svg {
	width: 12px;
	height: 12px;
}

.meshut-pc .meshut-pc__value {
	min-width: 0;
	margin: 0 0 0 auto;
	padding: 0;
	font-family: var(--mzr-font-heading, 'Space Grotesk', sans-serif);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.02em;
	font-variant-numeric: tabular-nums;
	text-align: right;
	color: var(--meshut-pc-ink);
	overflow-wrap: anywhere;
}

.meshut-pc__code {
	display: inline-block;
}

.meshut-pc__empty {
	font-family: var(--mzr-font-body, 'Inter', sans-serif);
	font-size: 14px;
	font-weight: 400;
	letter-spacing: 0;
	color: var(--meshut-pc-text);
	opacity: 0.55;
}

/* ── Copy on a click ── */

/* The hover wash reaches 6px past the code (padding) without moving it
   (negative margin), so the box may be 12px wider than its cell. */
.meshut-pc .meshut-pc__copy,
.meshut-pc .meshut-pc__text {
	position: relative;
	display: inline-block;
	box-sizing: border-box;
	max-width: calc(100% + 12px);
	margin: -2px -6px;
	padding: 2px 6px;
	border-radius: 6px;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.meshut-pc .meshut-pc__copy {
	-webkit-appearance: none;
	appearance: none;
	min-width: 0;
	min-height: 0;
	gap: 0;
	font: inherit;
	font-feature-settings: inherit;
	font-variant-numeric: inherit;
	letter-spacing: inherit;
	line-height: inherit;
	text-align: inherit;
	text-transform: none;
	text-decoration: none;
	text-shadow: none;
	color: inherit;
	background: none;
	border: 0;
	box-shadow: none;
	outline: 0;
	cursor: copy;
}

.meshut-pc .meshut-pc__copy:hover,
.meshut-pc .meshut-pc__copy:focus {
	color: inherit;
	background-color: var(--meshut-pc-cream);
	border: 0;
	box-shadow: none;
}

.meshut-pc .meshut-pc__copy:focus-visible {
	outline: 2px solid var(--meshut-pc-gold);
	outline-offset: 2px;
}

.meshut-pc .meshut-pc__copy.is-copied {
	color: var(--meshut-pc-green);
}

.meshut-pc .meshut-pc__copy[hidden],
.meshut-pc .meshut-pc__text[hidden],
.meshut-pc .meshut-pc__empty[hidden] {
	display: none;
}

/* The tooltip and its arrow, centred over the code. */
.meshut-pc__tip {
	--meshut-pc-tip: var(--meshut-pc-navy);
	position: absolute;
	z-index: 30;
	left: 50%;
	bottom: calc(100% + 8px);
	padding: 5px 9px;
	border-radius: 4px;
	background: var(--meshut-pc-tip);
	color: var(--meshut-pc-cream);
	box-shadow: 0 4px 12px rgba(15, 30, 46, 0.18);
	font-family: var(--mzr-font-body, 'Inter', sans-serif);
	font-size: 11px;
	font-weight: 500;
	font-variant-numeric: normal;
	line-height: 1.3;
	letter-spacing: 0.01em;
	text-transform: none;
	white-space: nowrap;
	transform: translateX(-50%);
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
	-webkit-user-select: none;
	user-select: none;
	transition: opacity 0.15s ease, visibility 0.15s ease;
}

.meshut-pc__tip::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	margin-left: -5px;
	border: 5px solid transparent;
	border-top-color: var(--meshut-pc-tip);
	border-bottom-width: 0;
}

/* Right-aligned codes keep their tooltip inside the card. */
.meshut-pc--card .meshut-pc__tip {
	left: auto;
	right: 0;
	transform: none;
}

.meshut-pc--card .meshut-pc__tip::after {
	left: auto;
	right: 14px;
	margin-left: 0;
}

/* Touch screens show only "Copied": a tap would leave a hover tooltip standing. */
@media (hover: hover) {
	.meshut-pc__copy:hover .meshut-pc__tip {
		visibility: visible;
		opacity: 1;
	}
}

.meshut-pc__copy:focus-visible .meshut-pc__tip,
.meshut-pc__copy.is-copied .meshut-pc__tip {
	visibility: visible;
	opacity: 1;
}

.meshut-pc__tip-done,
.meshut-pc__copy.is-copied .meshut-pc__tip-idle {
	display: none;
}

.meshut-pc__copy.is-copied .meshut-pc__tip-done {
	display: inline;
}

.meshut-pc__copy.is-copied .meshut-pc__tip {
	--meshut-pc-tip: var(--meshut-pc-green);
}

/* ── A code the product form changed ── */

@keyframes meshut-pc-changed {
	from {
		background-color: rgba(184, 149, 42, 0.24);
	}

	to {
		background-color: transparent;
	}
}

.meshut-pc__value.is-changed .meshut-pc__copy,
.meshut-pc__value.is-changed .meshut-pc__text {
	animation: meshut-pc-changed 0.9s ease-out;
}

/* ── Lock note, editor note, placeholder ── */

.meshut-pc .meshut-pc__note {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 16px 0 0;
	padding: 14px 0 0;
	border-top: 1px solid var(--meshut-pc-hairline);
	font-size: 12px;
	line-height: 1.5;
	color: var(--meshut-pc-text);
	opacity: 0.8;
}

.meshut-pc__note-icon {
	display: inline-flex;
	flex-shrink: 0;
	color: var(--meshut-pc-gold-dark);
}

.meshut-pc__note-icon svg {
	width: 12px;
	height: 12px;
}

.meshut-pc .meshut-pc__editor-note {
	margin: 12px 0 0;
	font-size: 12px;
	line-height: 1.5;
	color: var(--mzr-text-muted-color, #3D2E12);
}

.meshut-pc--placeholder {
	padding: 16px;
	border: 1px dashed var(--mzr-color-border, #E0D0A8);
	border-radius: var(--mzr-radius-input, 8px);
	font-size: 13px;
	color: var(--mzr-text-muted-color, #3D2E12);
}

.meshut-pc--placeholder p {
	margin: 0;
}

/* Read out by screen readers only. */
.meshut-pc__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ── Inline: the product meta rows ──
   Labels in one column, the codes lined up in the next (the rows step
   aside with display: contents, their cells join the list's grid). A long
   label wraps before a code breaks: the label column takes at most 45%. */

.meshut-pc--inline .meshut-pc__list {
	display: grid;
	grid-template-columns: fit-content(45%) minmax(0, 1fr);
	gap: 8px 14px;
	align-items: center;
}

.meshut-pc--inline .meshut-pc__row {
	display: contents;
}

.meshut-pc--inline .meshut-pc__label {
	gap: 6px;
	font-weight: 500;
}

.meshut-pc--inline .meshut-pc__lock {
	margin-left: -2px;
}

.meshut-pc--inline .meshut-pc__icon svg {
	width: 15px;
	height: 15px;
}

.meshut-pc--inline .meshut-pc__value {
	justify-self: start;
	margin: 0;
	font-family: var(--mzr-font-body, 'Inter', sans-serif);
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0;
	text-align: left;
}

.meshut-pc--inline .meshut-pc__note {
	margin-top: 12px;
	padding-top: 0;
	border-top: 0;
}

@media (prefers-reduced-motion: reduce) {
	.meshut-pc .meshut-pc__copy,
	.meshut-pc .meshut-pc__text,
	.meshut-pc__tip {
		transition: none;
	}

	.meshut-pc__value.is-changed .meshut-pc__copy,
	.meshut-pc__value.is-changed .meshut-pc__text {
		animation: none;
	}
}

@media print {
	.meshut-pc__tip,
	.meshut-pc__note,
	.meshut-pc__editor-note {
		display: none;
	}
}
