/*
 * Contact Form 7 styling for Skrall Media Theme.
 *
 * Två blockstilar för blocket contact-form-7/contact-form-selector:
 * - Ljus (standard): för ljusa bakgrunder.
 * - Mörk (.is-style-dark): för mörka bakgrunder, t.ex. brand-primary-900.
 *
 * Endast temats variabler används (färger, typsnitt, storlekar, radier, avstånd)
 * så att stylingen kan återanvändas på andra sajter med samma tema.
 * Typsnittet ärvs från temat (styles.typography i theme.json).
 */

/* Ljus (standard) */
.wpcf7 {
	--sm-cf7-field-bg: var(--wp--preset--color--white);
	--sm-cf7-field-bg-focus: var(--wp--preset--color--white);
	--sm-cf7-field-border: var(--wp--preset--color--gray-300);
	--sm-cf7-field-border-focus: var(--wp--preset--color--brand-primary-500);
	--sm-cf7-focus-ring: color-mix(in srgb, var(--wp--preset--color--brand-primary-500) 20%, transparent);
	--sm-cf7-text: var(--wp--preset--color--gray-900);
	--sm-cf7-text-muted: var(--wp--preset--color--gray-700);
	--sm-cf7-placeholder: var(--wp--preset--color--gray-500);
	--sm-cf7-link: var(--wp--preset--color--brand-primary-700);
	--sm-cf7-link-hover: var(--wp--preset--color--brand-primary-900);
	--sm-cf7-accent: var(--wp--preset--color--brand-primary-500);
	--sm-cf7-button-bg: var(--wp--preset--color--brand-primary-700);
	--sm-cf7-button-bg-hover: var(--wp--preset--color--brand-primary-900);
	--sm-cf7-button-text: var(--wp--preset--color--brand-primary-100);
	--sm-cf7-button-text-hover: var(--wp--preset--color--brand-primary-100);
	--sm-cf7-error: var(--wp--preset--color--red-500);
	--sm-cf7-error-tip: var(--wp--preset--color--red-700);
	--sm-cf7-error-bg: var(--wp--preset--color--red-100);
	--sm-cf7-error-text: var(--wp--preset--color--red-900);
	--sm-cf7-success-bg: var(--wp--preset--color--green-100);
	--sm-cf7-success-border: var(--wp--preset--color--green-500);
	--sm-cf7-success-text: var(--wp--preset--color--green-900);
	--sm-cf7-field-radius: var(--wp--preset--border-radius--full, 9999px);
	--sm-cf7-textarea-radius: var(--wp--preset--border-radius--lg, 1.25rem);
	--sm-cf7-message-radius: var(--wp--preset--border-radius--md, 1rem);
	--sm-cf7-row-gap: var(--wp--preset--spacing--50);
	--sm-cf7-submit-gap: var(--wp--preset--spacing--40);
	--sm-cf7-control-height: 48px;
	--sm-cf7-control-padding-x: var(--wp--preset--spacing--40);

	box-sizing: border-box;
	width: 100%;
	margin-block: var(--wp--preset--spacing--45);
	margin-inline: auto;
	color: var(--sm-cf7-text);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.45;
}

/* Mörk */
.is-style-dark .wpcf7 {
	--sm-cf7-field-bg: color-mix(in srgb, var(--wp--preset--color--brand-primary-100) 8%, transparent);
	--sm-cf7-field-bg-focus: color-mix(in srgb, var(--wp--preset--color--brand-primary-100) 14%, transparent);
	--sm-cf7-field-border: color-mix(in srgb, var(--wp--preset--color--brand-primary-100) 25%, transparent);
	--sm-cf7-field-border-focus: var(--wp--preset--color--brand-primary-300);
	--sm-cf7-focus-ring: color-mix(in srgb, var(--wp--preset--color--brand-primary-300) 25%, transparent);
	--sm-cf7-text: var(--wp--preset--color--brand-primary-100);
	--sm-cf7-text-muted: var(--wp--preset--color--brand-primary-300);
	--sm-cf7-placeholder: color-mix(in srgb, var(--wp--preset--color--brand-primary-100) 70%, transparent);
	--sm-cf7-link: var(--wp--preset--color--brand-primary-100);
	--sm-cf7-link-hover: var(--wp--preset--color--brand-primary-300);
	--sm-cf7-accent: var(--wp--preset--color--brand-primary-300);
	--sm-cf7-button-bg: var(--wp--preset--color--brand-primary-100);
	--sm-cf7-button-bg-hover: var(--wp--preset--color--brand-primary-300);
	--sm-cf7-button-text: var(--wp--preset--color--brand-primary-900);
	--sm-cf7-button-text-hover: var(--wp--preset--color--brand-primary-900);
	--sm-cf7-error: var(--wp--preset--color--red-300);
	--sm-cf7-error-tip: var(--wp--preset--color--red-300);
	--sm-cf7-success-bg: var(--wp--preset--color--green-900);
	--sm-cf7-success-border: var(--wp--preset--color--green-700);
	--sm-cf7-success-text: var(--wp--preset--color--green-100);
}

.wpcf7 *,
.wpcf7 *::before,
.wpcf7 *::after {
	box-sizing: border-box;
}

.wpcf7 form {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: var(--sm-cf7-row-gap);
	width: 100%;
	margin: 0;
	color: var(--sm-cf7-text);
}

.wpcf7 p {
	margin: 0;
}

.wpcf7 p:has(input[type="submit"]),
.wpcf7 .wpcf7-submit-wrap {
	margin-top: var(--sm-cf7-submit-gap);
}

.wpcf7 label {
	display: block;
	margin: 0;
	padding: 0;
	color: var(--sm-cf7-text);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	line-height: 1.35;
}

.wpcf7 label > .wpcf7-form-control-wrap,
.wpcf7 .wpcf7-form-control-wrap {
	display: block;
	margin-top: var(--wp--preset--spacing--20);
}

.wpcf7 input[type="text"],
.wpcf7 input[type="email"],
.wpcf7 input[type="url"],
.wpcf7 input[type="tel"],
.wpcf7 input[type="number"],
.wpcf7 input[type="password"],
.wpcf7 input[type="search"],
.wpcf7 input[type="date"],
.wpcf7 input[type="time"],
.wpcf7 select,
.wpcf7 textarea {
	display: block;
	width: 100%;
	min-height: var(--sm-cf7-control-height);
	margin: 0;
	padding: 10px var(--sm-cf7-control-padding-x);
	color: var(--sm-cf7-text);
	background-color: var(--sm-cf7-field-bg);
	border: 1px solid var(--sm-cf7-field-border);
	border-radius: var(--sm-cf7-field-radius);
	box-shadow: none;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--form); /* fast 16px: mindre zoomar iOS Safari vid fokus */
	font-weight: 400;
	line-height: 1.35;
	transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.wpcf7 textarea {
	min-height: 96px;
	padding-block: var(--wp--preset--spacing--40);
	border-radius: var(--sm-cf7-textarea-radius);
	resize: vertical;
}

/* Pil i select ritas med currentColor så den följer textfärgen i båda stilarna */
.wpcf7 select {
	padding-right: 44px;
	background-image:
		linear-gradient(45deg, transparent 50%, currentColor 50%),
		linear-gradient(135deg, currentColor 50%, transparent 50%);
	background-repeat: no-repeat;
	background-position: right 22px center, right 17px center;
	background-size: 5px 5px, 5px 5px;
	appearance: none;
}

.wpcf7 input::placeholder,
.wpcf7 textarea::placeholder {
	color: var(--sm-cf7-placeholder);
	opacity: 1;
}

.wpcf7 input:focus,
.wpcf7 select:focus,
.wpcf7 textarea:focus {
	outline: none;
	background-color: var(--sm-cf7-field-bg-focus);
	border-color: var(--sm-cf7-field-border-focus);
	box-shadow: 0 0 0 3px var(--sm-cf7-focus-ring);
}

.wpcf7 input:disabled,
.wpcf7 select:disabled,
.wpcf7 textarea:disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

.wpcf7 .wpcf7-form-control-wrap[data-name],
.wpcf7 .wpcf7-form-control-wrap .wpcf7-form-control {
	max-width: none;
}

.wpcf7 .wpcf7-checkbox,
.wpcf7 .wpcf7-radio,
.wpcf7 .wpcf7-acceptance {
	display: grid;
	gap: var(--wp--preset--spacing--20);
}

.wpcf7 .wpcf7-list-item {
	display: grid;
	grid-template-columns: 18px minmax(0, 1fr);
	align-items: flex-start;
	column-gap: var(--wp--preset--spacing--20);
	margin: 0;
}

.wpcf7 .wpcf7-list-item label {
	display: contents;
	font-weight: 400;
}

.wpcf7 input[type="checkbox"],
.wpcf7 input[type="radio"] {
	display: inline-block;
	width: 18px !important;
	min-width: 18px;
	max-width: 18px;
	height: 18px !important;
	min-height: 18px;
	margin: 2px 0 0 0 !important;
	padding: 0;
	accent-color: var(--sm-cf7-accent);
	cursor: pointer;
}

.wpcf7 input[type="checkbox"] {
	border-radius: var(--wp--preset--border-radius--xs, 0.25rem);
}

.wpcf7 .wpcf7-list-item-label {
	display: block;
	width: auto;
	max-width: 100%;
	margin: 0;
	padding: 0;
	color: var(--sm-cf7-text);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.45;
	cursor: pointer;
}

.wpcf7 .wpcf7-list-item-label a {
	color: var(--sm-cf7-link);
	text-decoration-color: currentColor;
	text-underline-offset: 0.18em;
}

.wpcf7 .wpcf7-list-item-label a:hover {
	color: var(--sm-cf7-link-hover);
}

.wpcf7 input[type="file"] {
	width: 100%;
	color: var(--sm-cf7-text);
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small);
}

.wpcf7 input[type="file"]::file-selector-button {
	margin-right: var(--wp--preset--spacing--40);
	padding: 9px var(--wp--preset--spacing--40);
	color: var(--sm-cf7-button-text);
	background: var(--sm-cf7-button-bg);
	border: none;
	border-radius: var(--sm-cf7-field-radius);
	font-family: inherit;
	cursor: pointer;
	transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.wpcf7 input[type="file"]::file-selector-button:hover {
	color: var(--sm-cf7-button-text-hover);
	background: var(--sm-cf7-button-bg-hover);
}

.wpcf7 input[type="submit"],
.wpcf7 button[type="submit"] {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.25em;
	min-height: var(--sm-cf7-control-height);
	width: auto;
	margin: 0;
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--45);
	color: var(--sm-cf7-button-text);
	background: var(--sm-cf7-button-bg);
	border: none;
	border-radius: var(--sm-cf7-field-radius);
	box-shadow: none;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 400;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.wpcf7 button[type="submit"]::after {
	content: "\f46a";
	font-family: var(--wp--preset--font-family--material-symbols-rounded, "Material Symbols Rounded");
	font-size: 1.15em;
	font-weight: normal;
	line-height: 1;
	transition: transform 0.2s ease-in-out;
}

.wpcf7 input[type="submit"]:hover,
.wpcf7 button[type="submit"]:hover {
	color: var(--sm-cf7-button-text-hover);
	background: var(--sm-cf7-button-bg-hover);
}

.wpcf7 button[type="submit"]:hover::after {
	transform: translateX(3px);
}

.wpcf7 input[type="submit"]:focus-visible,
.wpcf7 button[type="submit"]:focus-visible {
	outline: 2px solid var(--sm-cf7-accent);
	outline-offset: 3px;
}

.wpcf7 form.submitting input[type="submit"],
.wpcf7 form.submitting button[type="submit"] {
	cursor: wait;
	opacity: 0.65;
}

.wpcf7 input[type="submit"]:disabled,
.wpcf7 button[type="submit"]:disabled {
	cursor: not-allowed;
	opacity: 0.65;
}

.wpcf7 .wpcf7-spinner {
	margin: 0 0 0 var(--wp--preset--spacing--20);
	background-color: var(--sm-cf7-accent);
	vertical-align: middle;
}

.wpcf7 .wpcf7-not-valid {
	border-color: var(--sm-cf7-error) !important;
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--sm-cf7-error) 16%, transparent);
}

.wpcf7 .wpcf7-not-valid-tip {
	display: block;
	margin-top: var(--wp--preset--spacing--20);
	color: var(--sm-cf7-error-tip);
	font-size: var(--wp--preset--font-size--extra-small);
	font-style: normal;
	font-weight: 500;
	line-height: 1.4;
}

.wpcf7 form .wpcf7-response-output {
	margin: var(--wp--preset--spacing--40) 0 0;
	padding: var(--wp--preset--spacing--40) !important;
	border-radius: var(--sm-cf7-message-radius);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.45;
	text-align: center;
}

.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7 form.unaccepted .wpcf7-response-output,
.wpcf7 form.payment-required .wpcf7-response-output,
.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form.aborted .wpcf7-response-output,
.wpcf7 form.spam .wpcf7-response-output {
	color: var(--sm-cf7-error-text);
	background: var(--sm-cf7-error-bg);
	border: 1px solid var(--sm-cf7-error);
}

.wpcf7 form.sent .wpcf7-response-output {
	color: var(--sm-cf7-success-text);
	background: var(--sm-cf7-success-bg);
	border: 1px solid var(--sm-cf7-success-border);
}

.wpcf7 .screen-reader-response,
.wpcf7 .wpcf7-display-none {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
}

/* Nyhetsbrevsformulär: fält och knapp på samma rad */
.wpcf7 .sm-newsletter-form {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	grid-template-rows: auto auto;
	align-items: start;
	gap: var(--wp--preset--spacing--30);
	width: 100%;
}

.wpcf7 .sm-newsletter-form > label,
.wpcf7 .sm-newsletter-form > p:has(> label) {
	grid-column: 1;
	grid-row: 1;
	min-width: 0;
}

.wpcf7 .sm-newsletter-form > input[type="submit"],
.wpcf7 .sm-newsletter-form > button[type="submit"],
.wpcf7 .sm-newsletter-form > p:has(input[type="submit"]),
.wpcf7 .sm-newsletter-form > p:has(button[type="submit"]) {
	grid-column: 2;
	grid-row: 1;
	align-self: start;
	margin: 0;
}

.wpcf7 .sm-newsletter-form > .wpcf7-form-control-wrap:has(.wpcf7-acceptance),
.wpcf7 .sm-newsletter-form > p:has(.wpcf7-acceptance) {
	grid-column: 1 / -1;
	grid-row: 2;
	margin: 0;
}

.wpcf7 .sm-newsletter-form .wpcf7-form-control-wrap:has(.wpcf7-email) {
	margin-top: 0;
}

.wpcf7 .sm-newsletter-form label > .wpcf7-form-control-wrap,
.wpcf7 .sm-newsletter-form .wpcf7-form-control-wrap:has(.wpcf7-acceptance) {
	margin-top: var(--wp--preset--spacing--20);
}

.wpcf7 .sm-newsletter-form input[type="submit"],
.wpcf7 .sm-newsletter-form button[type="submit"] {
	padding-inline: var(--wp--preset--spacing--45);
	white-space: nowrap;
}

.wpcf7 .sm-newsletter-form .wpcf7-acceptance {
	gap: 0;
}

.wpcf7 .sm-newsletter-form .wpcf7-list-item-label {
	color: var(--sm-cf7-text-muted);
	font-size: var(--wp--preset--font-size--extra-small);
}

.wpcf7 .sm-newsletter-form .wpcf7-not-valid-tip {
	grid-column: 1 / -1;
}

@media (max-width: 700px) {
	.wpcf7 {
		--sm-cf7-row-gap: var(--wp--preset--spacing--45);
	}

	.wpcf7 .sm-newsletter-form {
		grid-template-columns: 1fr;
	}

	.wpcf7 .sm-newsletter-form > label,
	.wpcf7 .sm-newsletter-form > p:has(> label),
	.wpcf7 .sm-newsletter-form > input[type="submit"],
	.wpcf7 .sm-newsletter-form > button[type="submit"],
	.wpcf7 .sm-newsletter-form > p:has(input[type="submit"]),
	.wpcf7 .sm-newsletter-form > p:has(button[type="submit"]),
	.wpcf7 .sm-newsletter-form > .wpcf7-form-control-wrap:has(.wpcf7-acceptance),
	.wpcf7 .sm-newsletter-form > p:has(.wpcf7-acceptance) {
		grid-column: 1;
		grid-row: auto;
	}

	.wpcf7 .sm-newsletter-form input[type="submit"],
	.wpcf7 .sm-newsletter-form button[type="submit"] {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wpcf7 *,
	.wpcf7 *::before,
	.wpcf7 *::after {
		transition-duration: 0.01ms !important;
	}
}
