/*
 * The one form component: every form on the site, ours and WooCommerce's. Labels sit above, fields are 48px with
 * 16px text (so phones don't zoom in), errors sit below in red with an icon, and a valid field gets a tick.
 */

:root {
	--field: 48px;
	--icon-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5L20 7'/%3E%3C/svg%3E");
	--icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.500v5.500M12 16.500h.01'/%3E%3C/svg%3E");
}

.af-field,
.form-row {
	margin: 0 0 var(--s-4);
}

.af-field[hidden],
.form-row[hidden] {
	display: none;
}

.af-field > label,
.form-row > label,
.list-note > label {
	display: block;
	margin-bottom: var(--s-1);
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.3;
}

.af-req,
.form-row .required {
	color: var(--danger);
	font-weight: 700;
	text-decoration: none;
}

.af-opt,
.form-row .optional {
	color: var(--muted);
	font-weight: 400;
}

/* A field that is only sometimes required says so itself. */
.af-no-optional .optional {
	display: none;
}

input:not([type="checkbox"], [type="radio"], [type="submit"], [type="hidden"], [type="search"]),
select,
textarea {
	min-height: var(--field);
	border: 1px solid var(--border-strong);
	background: var(--bg);
	font-size: 16px;
}

textarea {
	display: block;
	min-height: 96px;
}

.af-control,
.woocommerce-input-wrapper {
	position: relative;
	display: block;
}

/* Fixed +91 in the mobile field. */
.af-mobile::before,
.af-mobile-row .woocommerce-input-wrapper::before {
	content: "+91";
	position: absolute;
	top: 0;
	left: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	height: var(--field);
	padding-inline: var(--s-3);
	color: var(--muted);
	font-weight: 600;
	pointer-events: none;
}

.af-mobile input,
.af-mobile-row input {
	padding-left: 3.25rem !important;
}

/* A valid field gets a tick. */
.is-valid .af-control::after,
.is-valid .woocommerce-input-wrapper::after {
	content: "";
	position: absolute;
	top: 14px;
	right: var(--s-3);
	width: 20px;
	height: 20px;
	background: var(--success);
	-webkit-mask: var(--icon-tick) center / contain no-repeat;
	mask: var(--icon-tick) center / contain no-repeat;
	pointer-events: none;
}

.is-valid.af-field--select .af-control::after,
.is-valid .af-has-toggle::after {
	right: 3.5rem;
}

.is-valid.af-field--notes .af-control::after,
.is-valid .woocommerce-input-wrapper:has(textarea)::after {
	content: none;
}

.is-invalid input:not([type="checkbox"]),
.is-invalid select,
.is-invalid textarea {
	border-color: var(--danger);
	box-shadow: inset 0 0 0 1px var(--danger);
}

.af-help,
.af-hint,
.af-note,
.form-row .description {
	margin: var(--s-1) 0 0;
	color: var(--muted);
	font-size: 0.875rem;
	line-height: 1.4;
}

.af-hint[hidden],
.af-error[hidden],
.af-form-error[hidden] {
	display: none;
}

.af-hint[data-level="weak"] {
	color: var(--danger);
}

.af-hint[data-level="okay"] {
	color: var(--warning);
}

.af-hint[data-level="strong"] {
	color: var(--success);
}

.af-hint--count {
	text-align: right;
}

.af-error {
	display: flex;
	gap: var(--s-1);
	margin: var(--s-1) 0 0;
	color: var(--danger);
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.35;
}

.af-error::before {
	content: "";
	flex: none;
	width: 16px;
	height: 16px;
	margin-top: 2px;
	background: currentcolor;
	-webkit-mask: var(--icon-alert) center / contain no-repeat;
	mask: var(--icon-alert) center / contain no-repeat;
}

/* WooCommerce's own inline messages are replaced by the ones above. */
.checkout-inline-error-message {
	display: none;
}

.af-form-error {
	margin: 0 0 var(--s-4);
	padding: var(--s-3);
	border-radius: var(--radius);
	background: var(--brand-soft);
	color: var(--danger);
	font-weight: 600;
}

.af-link {
	min-height: var(--tap);
	padding: 0;
	border: 0;
	background: none;
	color: var(--brand-text);
	font-weight: 600;
	text-align: left;
	text-decoration: underline;
	cursor: pointer;
}

/* Checkboxes: the whole label is the target. */
.af-check,
.woocommerce-form__label-for-checkbox {
	display: flex;
	align-items: flex-start;
	gap: var(--s-2);
	min-height: var(--tap);
	padding-block: var(--s-2);
	font-weight: 500;
	cursor: pointer;
}

.af-check input,
.woocommerce-form__label-for-checkbox input {
	margin-top: 1px;
}

/* Show or hide a password. */
.af-has-toggle {
	position: relative;
	display: block;
}

.af-has-toggle input {
	padding-right: 4rem;
}

.af-toggle {
	position: absolute;
	top: 0;
	right: 0;
	width: 3.5rem;
	height: var(--field);
	border: 0;
	background: none;
	color: var(--text);
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
}

/* WooCommerce adds its own toggle where its script runs; ours is the one that stays. */
.show-password-input {
	display: none !important;
}

.af-hp {
	position: absolute !important;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.af-note {
	margin: 0 0 var(--s-4);
}

/* Sending: the button keeps its size and the brand's A pulses in it. */
.af-submit,
#place_order {
	position: relative;
	min-height: var(--field);
}

.is-busy,
.processing #place_order {
	color: transparent !important;
	pointer-events: none;
}

.is-busy::after,
.processing #place_order::after {
	content: "";
	position: absolute;
	inset: 0;
	width: 22px;
	height: 22px;
	margin: auto;
	background: var(--on-brand);
	-webkit-mask: url("../brand/logo-mark.svg") center / contain no-repeat;
	mask: url("../brand/logo-mark.svg") center / contain no-repeat;
	animation: af-pulse 0.8s ease-in-out infinite alternate;
}

.btn--outline.is-busy::after,
.btn--neutral.is-busy::after {
	background: var(--text);
}

@keyframes af-pulse {
	from {
		opacity: 0.35;
		transform: scale(0.92);
	}

	to {
		opacity: 1;
		transform: scale(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.is-busy::after,
	.processing #place_order::after {
		animation-duration: 2.4s;
	}
}

/* Success, in place of the form. */
.af-success {
	padding: var(--s-4);
	border: 1px solid var(--border);
	border-left: 4px solid var(--success);
	border-radius: var(--radius);
	background: var(--surface);
}

.af-success__title {
	margin: 0;
	font-weight: 700;
}

.af-success ol {
	margin: var(--s-3) 0 0;
	padding-left: var(--s-5);
}

.af-success:focus {
	outline: none;
}

/* Bottom sheet on phones, centred on larger screens. */
dialog.af-sheet {
	width: 100%;
	max-width: 100%;
	max-height: 90dvh;
	margin: auto 0 0;
	padding: 0;
	overflow-y: auto;
	border: 0;
	border-radius: var(--radius) var(--radius) 0 0;
	background: var(--bg);
	color: var(--text);
	overscroll-behavior: contain;
}

dialog.af-sheet::backdrop {
	background: var(--backdrop);
}

html:has(dialog.af-sheet[open]) {
	overflow: hidden;
}

.af-sheet__head {
	position: sticky;
	top: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--s-3);
	padding: var(--s-2) var(--s-2) var(--s-2) var(--gutter);
	border-bottom: 1px solid var(--border);
	background: var(--bg);
}

.af-sheet__head h2 {
	margin: 0;
	font-size: 1.125rem;
}

.af-sheet__body {
	padding: var(--gutter);
	padding-bottom: calc(var(--gutter) + var(--safe-bottom));
}

@media (min-width: 600px) {
	dialog.af-sheet {
		width: 30rem;
		margin: auto;
		border-radius: var(--radius);
	}
}

/* Login */
.auth__who {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--s-3);
	margin: 0 0 var(--s-3);
	font-weight: 600;
}

.auth__page {
	max-width: 28rem;
	margin-inline: auto;
}

.auth__page h2 {
	margin-bottom: var(--s-4);
}

.auth__alt {
	margin-top: var(--s-3);
	text-align: center;
}

/* Price request */
.price-request-btn {
	margin-block: var(--s-2);
}

/* Consent banner: above the bottom nav on phones, never a wall. */
.consent-banner {
	position: fixed;
	right: var(--s-2);
	bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--s-2));
	left: var(--s-2);
	z-index: 45;
	padding: var(--s-3);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--bg);
	color: var(--text);
	box-shadow: var(--shadow-float);
	font-size: 0.875rem;
	line-height: 1.4;
}

.consent-banner[hidden] {
	display: none;
}

.consent-banner h2 {
	margin: 0 0 var(--s-1);
	font-size: 0.9375rem;
}

.consent-banner p {
	margin: 0 0 var(--s-2);
}

.consent-actions {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--s-2);
}

.consent-actions .btn {
	min-height: var(--tap);
	padding-inline: var(--s-1);
	font-size: 0.8125rem;
}

/* The WhatsApp button sits above the banner's place only while the banner is gone. */
.has-consent-banner .wa-fab {
	display: none;
}

@media (min-width: 1024px) {
	.consent-banner {
		right: auto;
		bottom: var(--s-4);
		left: var(--s-4);
		width: 26rem;
	}

	.has-consent-banner .wa-fab {
		display: inline-flex;
	}
}

.consent-row {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: var(--s-3);
	padding-block: var(--s-3);
	border-bottom: 1px solid var(--border);
}

.consent-row strong {
	display: block;
}

.consent-row span {
	color: var(--muted);
	font-size: 0.875rem;
}

.consent-row input {
	width: 1.5rem;
	height: 1.5rem;
	margin-top: 2px;
	flex: none;
}

.consent-row em {
	flex: none;
	color: var(--muted);
	font-size: 0.875rem;
	font-style: normal;
}

.consent-sheet-actions {
	display: grid;
	gap: var(--s-2);
	margin-top: var(--s-4);
}

/* Cookie table in the policy */
.cookie-table-wrap {
	overflow-x: auto;
}

.cookie-table {
	width: 100%;
	min-width: 40rem;
	border-collapse: collapse;
	font-size: 0.875rem;
}

.cookie-table th,
.cookie-table td {
	padding: var(--s-2);
	border-bottom: 1px solid var(--border);
	text-align: left;
	vertical-align: top;
}

.cookie-table code {
	overflow-wrap: anywhere;
}

.offers-manage {
	display: grid;
	gap: var(--s-6);
	max-width: 56rem;
}

@media (min-width: 769px) {
	.offers-manage {
		grid-template-columns: 1fr 1fr;
	}
}

.checkout-login {
	margin: 0 0 var(--s-4);
}

/* The quantity box is a row of buttons, so its message drops below it. */
.quantity {
	flex-wrap: wrap;
}

.quantity .af-error {
	flex-basis: 100%;
}
