/**
 * HubSpot Form block (Point 3.3): visual parity with assets/css/components/marketo.css.
 *
 * HubSpot's developer embed injects its own base styles (style[data-hsfc-id="BaseStyle"]).
 * Those rules only READ the --hsf-* variables, with HubSpot defaults as fallback, so the
 * variables set on the block wrapper below win. Rules that need more than a variable are
 * prefixed with the block class AND [data-hsfc-id="Renderer"], one level more specific
 * than HubSpot's own "[data-hsfc-id=Renderer] .hsfc-*", so stylesheet order never matters.
 *
 * Colours use the same theme tokens as the Marketo form, so they flip inside
 * is-mode-*-dark sections the same way.
 */

.wp-block-panopto-hubspot-form {
	--panopto-hsf-error: #e93636;

	/* Global */
	--hsf-global__font-family: var(--wp--custom--typography--body-sm--font-family);
	--hsf-global__font-size: 1rem;
	--hsf-global__color: var(--wp--custom--color--theme--text--body);
	--hsf-global__error-color: var(--panopto-hsf-error);

	/* Spacing: 16px between rows, 8px between label and input (Marketo) */
	--hsf-row__vertical-spacing: var(--wp--preset--spacing--16);
	--hsf-row__horizontal-spacing: var(--wp--preset--spacing--16);
	--hsf-module__vertical-spacing: var(--wp--preset--spacing--8);

	/* Labels: eyebrow-lg in the title colour */
	--hsf-field-label__font-family: var(--wp--custom--typography--eyebrow-lg--font-family);
	--hsf-field-label__font-size: var(--wp--custom--typography--eyebrow-lg--font-size);
	--hsf-field-label__color: var(--wp--custom--color--theme--text--title);
	--hsf-field-label-requiredindicator__color: var(--wp--custom--color--theme--text--title);
	--hsf-field-description__color: var(--wp--custom--color--theme--text--body);
	--hsf-field-description__font-family: var(--wp--custom--typography--body-sm--font-family);
	--hsf-field-footer__color: var(--wp--custom--color--theme--text--body);
	--hsf-field-footer__font-family: var(--wp--custom--typography--body-sm--font-family);

	/* Inputs: white box (Marketo reverts to the browser default), 2px border, 8px radius, 16px padding */
	--hsf-field-input__font-family: var(--wp--custom--typography--body-sm--font-family);
	--hsf-field-input__font-size: 1rem;
	--hsf-field-input__color: #000;
	--hsf-field-input__background-color: #fff;
	--hsf-field-input__placeholder-color: var(--wp--custom--color--neutrals--700);
	--hsf-field-input__border-color: var(--wp--custom--color--neutrals--300);
	--hsf-field-input__border-width: 2px;
	--hsf-field-input__border-style: solid;
	--hsf-field-input__border-radius: 0.5rem;
	--hsf-field-input__padding: var(--wp--preset--spacing--16);
	--hsf-field-dropdown-options__border-radius: 0.5rem;

	--hsf-field-textarea__font-family: var(--wp--custom--typography--body-sm--font-family);
	--hsf-field-textarea__font-size: 1rem;
	--hsf-field-textarea__color: #000;
	--hsf-field-textarea__background-color: #fff;
	--hsf-field-textarea__placeholder-color: var(--wp--custom--color--neutrals--700);
	--hsf-field-textarea__border-color: var(--wp--custom--color--neutrals--300);
	--hsf-field-textarea__border-width: 2px;
	--hsf-field-textarea__border-style: solid;
	--hsf-field-textarea__border-radius: 0.5rem;
	--hsf-field-textarea__padding: var(--wp--preset--spacing--16);

	/* Checkbox / radio: 2px border in the section's icon colour, checkmark in the surface colour */
	--hsf-field-checkbox__background-color: transparent;
	--hsf-field-checkbox__border-color: var(--wp--custom--color--theme--icon--primary);
	--hsf-field-checkbox__border-width: 2px;
	--hsf-field-checkbox__border-style: solid;
	--hsf-field-checkbox__color: var(--wp--custom--color--theme--surface--primary);
	--hsf-field-checkbox__padding: 0;
	--hsf-field-radio__background-color: transparent;
	--hsf-field-radio__border-color: var(--wp--custom--color--theme--icon--primary);
	--hsf-field-radio__border-width: 2px;
	--hsf-field-radio__border-style: solid;
	--hsf-field-radio__color: var(--wp--custom--color--theme--icon--primary);
	--hsf-field-radio__padding: 0;

	/* Button: primary pill, same tokens as Marketo's .mktoButton */
	--hsf-button__font-family: var(--wp--custom--typography--button--md--font-family);
	--hsf-button__font-size: var(--wp--custom--typography--button--md--font-size);
	--hsf-button__font-weight: var(--wp--custom--typography--button--md--font-weight);
	--hsf-button__color: var(--wp--custom--color--theme--button--primary--text--rest);
	--hsf-button__background-color: var(--wp--custom--color--theme--button--primary--background--rest);
	--hsf-button__background-image: none;
	--hsf-button__border-color: var(--wp--custom--color--theme--button--primary--border--rest);
	--hsf-button__border-width: 2px;
	--hsf-button__border-style: solid;
	--hsf-button__border-radius: var(--wp--custom--border--radius--full);
	--hsf-button__padding: var(--wp--custom--spacing--8) var(--wp--custom--spacing--16);
	--hsf-button__box-shadow: none;
	--hsf-button__width: auto;
	--hsf-button--hover__color: var(--wp--custom--color--theme--button--primary--text--hover);
	--hsf-button--hover__background-color: var(--wp--custom--color--theme--button--primary--background--hover);
	--hsf-button--hover__border-color: var(--wp--custom--color--theme--button--primary--border--hover);
	--hsf-button--focus__color: var(--wp--custom--color--theme--button--primary--text--hover);
	--hsf-button--focus__background-color: var(--wp--custom--color--theme--button--primary--background--hover);
	--hsf-button--focus__border-color: var(--wp--custom--color--theme--button--primary--border--hover);
	--hsf-navigationrow-buttons-single__justify-content: flex-start;

	/* Rich text (consent text, thank-you message), headings, alerts */
	--hsf-richtext__font-family: var(--wp--custom--typography--body-sm--font-family);
	--hsf-richtext__font-size: 1rem;
	--hsf-richtext__color: var(--wp--custom--color--theme--text--body);
	--hsf-heading__font-family: var(--wp--custom--typography--eyebrow-lg--font-family);
	--hsf-heading__color: var(--wp--custom--color--theme--text--title);
	--hsf-erroralert__color: var(--panopto-hsf-error);
	--hsf-erroralert__font-family: var(--wp--custom--typography--body-sm--font-family);
	--hsf-erroralert__font-size: var(--wp--custom--typography--body-sm--font-size);
	--hsf-infoalert__color: var(--wp--custom--color--theme--text--body);
	--hsf-infoalert__font-family: var(--wp--custom--typography--body-sm--font-family);
	--hsf-infoalert__font-size: var(--wp--custom--typography--body-sm--font-size);

	/* Form container: transparent, no padding, the section shows through */
	--hsf-background__background-color: transparent;
	--hsf-background__background-image: none;
	--hsf-background__border-width: 0;
	--hsf-background__padding: 0;

	width: 100%;
}

/* Rows HubSpot leaves behind for fields hidden by a rule (empty) or for hidden fields only
   (Marketo hides the same kind of rows), so they take no space. */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Row:empty,
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Row:not(:has(> :not(input[type="hidden"]))) {
	display: none;
}

/* Label: eyebrow-lg weight and line height (no variables for these) */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-FieldLabel {
	font-weight: var(--wp--custom--typography--eyebrow-lg--font-weight);
	line-height: var(--wp--custom--typography--eyebrow-lg--line-height);
}

/* Required asterisk hidden, like Marketo's .mktoAsterix */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-FieldLabel__RequiredIndicator {
	display: none;
}

/* Inputs: full width, same box sizing and height as Marketo (54px: 18px line + 2x16px padding + 2x2px border) */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-TextInput,
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-TextareaInput {
	box-sizing: border-box;
	line-height: 1.125rem;
	width: 100%;
}

/* Phone prefix (flag + country code): input text colour, also inside dark sections */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-PhoneInput__FlagAndCaret {
	color: var(--hsf-field-input__color);
}

/* Consent text: body size and line height like Marketo's rich text. HubSpot's rich-text
   editor writes inline sizes and colours (11px, black on white), which break dark sections,
   so they are reset to the theme here. Links keep the theme link colour. */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Form .hsfc-RichText {
	line-height: 1.6;
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Form .hsfc-RichText :is(p, span, strong, em)[style] {
	background-color: transparent !important;
	color: inherit !important;
	font-size: inherit !important;
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Form .hsfc-RichText a[style] {
	background-color: transparent !important;
	font-size: inherit !important;
}

/* Placeholder: body-sm, like Marketo */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-TextInput::placeholder,
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-TextareaInput::placeholder {
	font-family: var(--wp--custom--typography--body-sm--font-family);
	font-size: var(--wp--custom--typography--body-sm--font-size);
	font-weight: var(--wp--custom--typography--body-sm--font-weight);
	line-height: var(--wp--custom--typography--body-sm--line-height);
}

/* Invalid state: red border, like .mktoInvalid */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-TextInput[aria-invalid="true"],
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-TextareaInput[aria-invalid="true"],
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-PhoneInput:has(.hsfc-TextInput[aria-invalid="true"]) .hsfc-PhoneInput__FlagAndCaret {
	border-color: var(--panopto-hsf-error);
}

/* Dropdown: Marketo's caret instead of HubSpot's triangle */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-DropdownInput > .hsfc-TextInput {
	padding-inline-end: var(--wp--preset--spacing--48);
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-DropdownInput__Caret {
	/* stylelint-disable-next-line stylistic/max-line-length */
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6 8 10 12 6' stroke='%233b524c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / 1rem;
	padding: 0;
	right: var(--wp--preset--spacing--16);
	width: 1rem;
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-DropdownInput__Caret > span {
	display: none;
}

/* Checkbox: 24px box with the section accent, masked checkmark (Marketo's shapes) */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-CheckboxField label {
	align-items: flex-start;
	justify-content: flex-start;
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-CheckboxInput {
	appearance: none;
	block-size: 1.5rem;
	border-radius: var(--wp--custom--border--radius--small);
	box-shadow: none;
	box-sizing: border-box;
	cursor: pointer;
	inline-size: 1.5rem;
	margin: 0;
	position: relative;
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-CheckboxInput:checked {
	background-color: var(--wp--custom--color--theme--icon--primary);
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-CheckboxInput:checked::after {
	/* stylelint-disable-next-line stylistic/max-line-length */
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='12' viewBox='0 0 14 12' fill='none'%3E%3Cpath d='M1 6 5.16837 10.1684 13 1' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	mask-size: 0.875rem 0.75rem;
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-CheckboxInput[aria-invalid="true"] {
	border-color: var(--panopto-hsf-error);
}

/* Button: min height, line height and the theme transition (no variables for these) */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Button {
	align-items: center;
	display: inline-flex;
	justify-content: center;
	letter-spacing: var(--wp--custom--typography--button--md--letter-spacing);
	line-height: var(--wp--custom--typography--button--md--line-height);
	min-block-size: 3rem;
	text-transform: var(--wp--custom--typography--button--md--text-transform);
	transition: background-color 0.3s ease-in-out, border-color 0.3s ease-in-out, color 0.3s ease-in-out;
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Button:not([disabled]):hover,
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Button:not([disabled]):active {
	transform: none;
}

/* Button row: 16px above like every other row (HubSpot doubles it), never full width */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-NavigationRow {
	margin-top: 0;
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-NavigationRow__Buttons > * {
	width: auto;
}

@media (max-width: 430px) {

	.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-NavigationRow__Buttons {
		align-items: flex-start;
	}
}

/* Thank-you message after submit: theme colours instead of HubSpot's inline black */
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-PostSubmit,
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-PostSubmit span {
	color: var(--wp--custom--color--theme--text--body);
}

.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-PostSubmit strong,
.wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-PostSubmit strong span {
	color: var(--wp--custom--color--theme--text--title);
}

/* Two-column layout once the container is wider than 600px, like has-two-column-marketo-form.
   Works inside the existing pattern group (.has-two-column-marketo-form, container set by
   the theme) and inside .has-two-column-hubspot-form (container set here). */
.wp-block-group.has-two-column-hubspot-form {
	container-type: inline-size;
}

@container (width > 600px) {

	.has-two-column-marketo-form .wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Step__Content,
	.has-two-column-hubspot-form .wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Step__Content {
		column-gap: var(--wp--preset--spacing--16);
		display: grid;
		grid-template-columns: 1fr 1fr;
	}

	/* Full width: consent text, checkbox rows, rows HubSpot already splits in two, the button */
	.has-two-column-marketo-form .wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Step__Content > :is(.hsfc-Row:has(.hsfc-RichText), .hsfc-Row:has(.hsfc-CheckboxField), .hsfc-Row:has(> :not(input[type="hidden"]) ~ :not(input[type="hidden"])), .hsfc-NavigationRow),
	.has-two-column-hubspot-form .wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Step__Content > :is(.hsfc-Row:has(.hsfc-RichText), .hsfc-Row:has(.hsfc-CheckboxField), .hsfc-Row:has(> :not(input[type="hidden"]) ~ :not(input[type="hidden"])), .hsfc-NavigationRow),
	.has-two-column-marketo-form .wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Step__Content > :not(.hsfc-Row):not(.hsfc-NavigationRow),
	.has-two-column-hubspot-form .wp-block-panopto-hubspot-form [data-hsfc-id="Renderer"] .hsfc-Step__Content > :not(.hsfc-Row):not(.hsfc-NavigationRow) {
		grid-column: 1 / -1;
	}
}
