/* Info tooltip, used on the product page and next to the checkout order note. */
.wh-cert-tooltip {
	position: relative;
	display: inline-block;
	width: 18px;
	height: 18px;
	line-height: 18px;
	text-align: center;
	border-radius: 50%;
	background: #e5e7eb;
	color: #374151;
	font-size: 12px;
	font-weight: 700;
	cursor: help;
	margin-left: 6px;
	vertical-align: middle;
}

.wh-cert-tooltip__bubble {
	display: none;
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	background: #1f2937;
	color: #fff;
	padding: 8px 10px;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.4;
	width: 260px;
	text-align: left;
	z-index: 10;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
	white-space: normal;
}

.wh-cert-tooltip__bubble::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 6px solid transparent;
	border-top-color: #1f2937;
}

.wh-cert-tooltip:hover .wh-cert-tooltip__bubble,
.wh-cert-tooltip:focus .wh-cert-tooltip__bubble {
	display: block;
}

/* Product page: choose whether a certificate is issued. The cards are radio
   inputs, and the fields below are revealed with :has() so the block still works
   with JavaScript disabled. */
.wh-cert-options {
	margin: 0 0 16px;
	width: 100%;
	/* Themes float the elements around the add to cart button. */
	clear: both;
}

.wh-cert-choice {
	margin: 0;
	padding: 16px;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
}

/*
 * The browser cuts the fieldset's top border to the width of the legend's box, so
 * a legend that fills the line leaves that cut running on past the end of the text.
 * It only shows once the container is wide enough for the gap to open up, hence the
 * explicit shrink to fit rather than relying on the default width.
 */
.wh-cert-choice__legend {
	display: block;
	width: fit-content;
	max-width: 100%;
	float: none;
	padding: 0 6px;
	margin-left: -6px;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #374151;
}

.wh-cert-choice__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
	gap: 10px;
}

.wh-cert-card {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 12px;
	border: 2px solid #e5e7eb;
	border-radius: 8px;
	cursor: pointer;
	background: #fff;
	transition: border-color 120ms ease, background-color 120ms ease;
}

.wh-cert-card:hover {
	border-color: #c9c9c9;
}

/* The radio itself is only there for the form data and keyboard use. */
.wh-cert-card__input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	margin: 0;
	pointer-events: none;
}

.wh-cert-card:has(.wh-cert-card__input:checked) {
	border-color: #990000;
	background: #fdf7f7;
}

.wh-cert-card:has(.wh-cert-card__input:focus-visible) {
	outline: 2px solid #990000;
	outline-offset: 2px;
}

.wh-cert-card__icon {
	flex: 0 0 auto;
	width: 34px;
	height: 34px;
	color: #6b7280;
}

.wh-cert-card__icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

.wh-cert-card:has(.wh-cert-card__input:checked) .wh-cert-card__icon {
	color: #990000;
}

.wh-cert-card__text {
	display: block;
	line-height: 1.35;
}

.wh-cert-card__title {
	display: block;
	font-weight: 700;
	text-transform: uppercase;
	font-size: 0.95em;
	color: #1f2937;
}

.wh-cert-card:has(.wh-cert-card__input:checked) .wh-cert-card__title {
	color: #990000;
}

.wh-cert-card__desc {
	display: block;
	margin-top: 2px;
	font-size: 0.85em;
	color: #6b7280;
}

/* Only relevant once the certificate card is picked. */
.wh-cert-fields {
	display: none;
}

.wh-cert-options:has(.wh-cert-card__input[value="certificate"]:checked) .wh-cert-fields {
	display: block;
}

.wh-cert-fields {
	margin-top: 12px;
	padding: 14px;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	background: #f9fafb;
}

.wh-cert-field {
	margin: 0 0 12px;
}

.wh-cert-field:last-child {
	margin-bottom: 0;
}

.wh-cert-field input[type="text"],
.wh-cert-field textarea {
	display: block;
	width: 100%;
	margin-top: 6px;
	box-sizing: border-box;
	padding: 6px 8px;
	border: 1px solid #d1d5db;
	border-radius: 4px;
	background: #fff;
	/* Form controls carry their own small default font. */
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	font-weight: 400;
	color: inherit;
}

/* The browser focus ring is blue; use a thin shop red one instead. */
.wh-cert-field input[type="text"]:focus,
.wh-cert-field textarea:focus {
	outline: none;
	border-color: #990000;
	box-shadow: 0 0 0 1px #990000;
}

/* Remaining room in a limited field — the name and the Widmung both have one;
   the number itself is kept current by assets/js/product-certificate.js. */
.wh-cert-field__counter {
	display: block;
	margin-top: 3px;
	text-align: right;
	font-size: 0.8em;
	font-weight: 400;
	line-height: 1.3;
	color: #6b7280;
	font-variant-numeric: tabular-nums;
}

.wh-cert-field__counter--full {
	color: #990000;
}

/* Checkout: mark the mandatory fields.

   The checkout block labels optional fields with "(optional)" and leaves required
   ones unmarked, which reads as if nothing is mandatory. The inputs do carry the
   native required attribute, and the label is a sibling of the input inside the
   field wrapper, so :has() can reach it. */
.wc-block-components-text-input:has(input:required) label::after,
.wc-block-components-combobox:has(input:required) label::after,
.wc-block-components-select:has(select:required) label::after,
.wc-block-components-textarea:has(textarea:required) label::after {
	content: " *";
	color: #990000;
}

/* Dialog after an add to cart that still needs a decision. */
.wh-cert-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
}

.wh-cert-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	backdrop-filter: blur(2px);
}

.wh-cert-modal__dialog {
	position: relative;
	max-width: 460px;
	margin: 12vh auto 0;
	background: #fff;
	padding: 28px 28px 22px;
	border-radius: 10px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
	text-align: center;
	animation: wh-cert-modal-in 200ms ease-out;
}

@keyframes wh-cert-modal-in {
	from {
		transform: translateY(14px);
		opacity: 0;
	}

	to {
		transform: none;
		opacity: 1;
	}
}

.wh-cert-modal__icon {
	width: 56px;
	height: 56px;
	font-size: 30px;
	font-weight: 700;
	line-height: 56px;
	margin: 0 auto 14px;
}

.wh-cert-modal__dialog h2 {
	margin: 0 0 10px;
	font-size: 1.35rem;
}

.wh-cert-modal__dialog p {
	margin: 0 0 18px;
	color: #475569;
	line-height: 1.5;
}

.wh-cert-modal__actions {
	display: flex;
	justify-content: center;
	gap: 10px;
	flex-wrap: wrap;
}

/*
 * Shop CTA colour for the primary action. The site styles its buttons through
 * .single_add_to_cart_button / .add_to_cart_button, which these are not, so without
 * this they fall back to WooCommerce's default purple.
 */
.wh-cert-modal__actions .button.alt {
	background-color: #990000 !important;
	color: #fff !important;
}

.wh-cert-modal__actions .button.alt:hover,
.wh-cert-modal__actions .button.alt:focus {
	background-color: #7a0000 !important;
	color: #fff !important;
}

/* Cart: edit the certificate name and Widmung in place. */
.wh-cert-edit {
	margin: 6px 0 0;
	/* The exact size is set from the meta list in cart-certificate-editor.js. */
	font: inherit;
}

.wh-cert-edit__toggle {
	background: none;
	border: 0;
	padding: 0;
	color: #990000;
	text-decoration: underline;
	cursor: pointer;
	font: inherit;
}

.wh-cert-edit__toggle:hover,
.wh-cert-edit__toggle:focus-visible {
	color: #7a0000;
}

.wh-cert-edit__form {
	margin-top: 8px;
	padding: 10px;
	border: 1px solid #e5e7eb;
	border-radius: 6px;
	background: #f9fafb;
}

.wh-cert-edit__field {
	margin: 0 0 8px;
}

.wh-cert-edit__field label {
	display: block;
	font-weight: 600;
	margin-bottom: 3px;
}

.wh-cert-edit__field input,
.wh-cert-edit__field textarea {
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding: 6px 8px;
	border: 1px solid #d1d5db;
	border-radius: 4px;
	background: #fff;
	/* Form controls carry their own small default font, and they sit inside the
	   bold label, so the weight is reset rather than inherited. */
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	font-weight: 400;
	color: inherit;
}

/* The browser focus ring is blue; use a thin shop red one instead. */
.wh-cert-edit__field input:focus,
.wh-cert-edit__field textarea:focus {
	outline: none;
	border-color: #990000;
	box-shadow: 0 0 0 1px #990000;
}

/* Sits outside the bold label, so only the size and colour need resetting. */
.wh-cert-edit__counter {
	display: block;
	margin-top: 3px;
	text-align: right;
	font-size: 0.85em;
	line-height: 1.3;
	color: #6b7280;
	font-variant-numeric: tabular-nums;
}

.wh-cert-edit__counter--full {
	color: #990000;
}

.wh-cert-edit__actions {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
	margin: 10px 0 0;
}

/*
 * The theme and WooCommerce both style .button for the shop CTAs, which is out
 * of scale inside a cart line. The selector outruns WooCommerce's own
 * ".woocommerce button.button" so no !important is needed.
 */
.wh-cert-edit__actions button.wh-cert-edit__save.button {
	display: inline-block;
	padding: 6px 14px;
	border: 0;
	border-radius: 4px;
	background-color: #990000;
	color: #fff;
	font-family: inherit;
	font-size: inherit;
	line-height: 1.4;
	font-weight: 600;
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
	text-shadow: none;
	cursor: pointer;
}

.wh-cert-edit__actions button.wh-cert-edit__save.button:hover,
.wh-cert-edit__actions button.wh-cert-edit__save.button:focus {
	background-color: #7a0000;
	color: #fff;
}

.wh-cert-edit__actions button.wh-cert-edit__save.button:disabled {
	opacity: 0.6;
	cursor: default;
}

.wh-cert-edit__msg {
	margin: 6px 0 0;
	min-height: 1.2em;
}

.wh-cert-edit__msg--error {
	color: #b91c1c;
}

.wh-cert-edit__msg--ok {
	color: #15803d;
}
