/*!
 * Copyright 2024 Adobe. All rights reserved.
 *
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at <http://www.apache.org/licenses/LICENSE-2.0>
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */

/* @todo align modifiers to use field-label or fieldlabel but not both */

.spectrum-FieldLabel,
.spectrum-FieldLabel--sizeM {
	--spectrum-field-label-min-height: var(--spectrum-component-height-75);
	--spectrum-field-label-top-to-text: var(--spectrum-component-top-to-text-75);
	--spectrum-field-label-bottom-to-text: var(--spectrum-component-bottom-to-text-75);
	--spectrum-field-label-font-size: var(--spectrum-font-size-75);

	--spectrum-field-label-side-margin-block-start: var(--spectrum-field-label-top-margin-medium);
	--spectrum-field-label-side-padding-right: var(--spectrum-spacing-200);

	--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-medium);
}

.spectrum-FieldLabel--sizeS {
	--spectrum-field-label-min-height: var(--spectrum-component-height-75);
	--spectrum-field-label-top-to-text: var(--spectrum-component-top-to-text-75);
	--spectrum-field-label-bottom-to-text: var(--spectrum-component-bottom-to-text-75);
	--spectrum-field-label-font-size: var(--spectrum-font-size-75);

	--spectrum-field-label-side-margin-block-start: var(--spectrum-field-label-top-margin-small);
	--spectrum-field-label-side-padding-right: var(--spectrum-spacing-100);

	--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-small);
}

.spectrum-FieldLabel--sizeL {
	--spectrum-field-label-min-height: var(--spectrum-component-height-100);
	--spectrum-field-label-top-to-text: var(--spectrum-component-top-to-text-100);
	--spectrum-field-label-bottom-to-text: var(--spectrum-component-bottom-to-text-100);
	--spectrum-field-label-font-size: var(--spectrum-font-size-100);

	--spectrum-field-label-side-margin-block-start: var(--spectrum-field-label-top-margin-large);
	--spectrum-field-label-side-padding-right: var(--spectrum-spacing-200);

	--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-large);
}

.spectrum-FieldLabel--sizeXL {
	--spectrum-field-label-min-height: var(--spectrum-component-height-200);
	--spectrum-field-label-top-to-text: var(--spectrum-component-top-to-text-200);
	--spectrum-field-label-bottom-to-text: var(--spectrum-component-bottom-to-text-200);
	--spectrum-field-label-font-size: var(--spectrum-font-size-200);

	--spectrum-field-label-side-margin-block-start: var(--spectrum-field-label-top-margin-extra-large);
	--spectrum-field-label-side-padding-right: var(--spectrum-spacing-200);

	--spectrum-field-label-text-to-asterisk: var(--spectrum-field-label-text-to-asterisk-extra-large);
}

.spectrum-FieldLabel {
	display: block;
	box-sizing: border-box;
	min-block-size: var(--mod-fieldlabel-min-height, var(--spectrum-field-label-min-height));

	padding-block: var(--mod-fieldlabel-padding-block, var(--mod-field-label-top-to-text, var(--spectrum-field-label-top-to-text)) var(--mod-field-label-bottom-to-text, var(--spectrum-field-label-bottom-to-text)));
	padding-inline: var(--mod-fieldlabel-padding-inline, 0);
	margin-block: var(--mod-fieldlabel-margin-block, var(--mod-fieldlabel-margin-block-start, 0) var(--mod-fieldlabel-margin-block-end, 0));
	margin-inline: var(--mod-fieldlabel-margin-inline, var(--mod-fieldlabel-margin-inline-start, 0) var(--mod-fieldlabel-margin-inline-end, 0));

	font-size: var(--mod-fieldlabel-font-size, var(--spectrum-field-label-font-size));
	font-weight: var(--mod-fieldlabel-font-weight, var(--spectrum-regular-font-weight));

	line-height: var(--mod-fieldlabel-line-height, var(--spectrum-line-height-100));

	-webkit-font-smoothing: subpixel-antialiased;
	-moz-osx-font-smoothing: auto;

	color: var(--highcontrast-field-label-content-color, var(--mod-fieldlabel-color, var(--spectrum-neutral-subdued-content-color-default)));

	/* CJK (Chinese, Japanese, and Korean) language support */
	&:lang(ja),
	&:lang(zh),
	&:lang(ko) {
		--mod-fieldlabel-line-height: var(--mod-fieldlabel-line-height-cjk, var(--spectrum-cjk-line-height-100));
	}

	/********* Disabled state *********/
	&.is-disabled {
		--mod-fieldlabel-color: var(--mod-disabled-content-color, var(--spectrum-disabled-content-color));
	}
}

.spectrum-FieldLabel-requiredIcon {
	color: inherit;
	margin-block: 0;
	margin-inline: var(--mod-field-label-text-to-asterisk, var(--spectrum-field-label-text-to-asterisk)) 0;
	vertical-align: var(--mod-field-label-asterisk-vertical-align, baseline);
}

.spectrum-FieldLabel--left,
.spectrum-FieldLabel--right {
	display: inline-block;

	margin-block-start: var(--mod-fieldlabel-side-margin-block-start, var(--spectrum-field-label-side-margin-block-start));
	margin-block-end: 0;
	margin-inline-end: var(--mod-fieldlabel-side-padding-right, var(--spectrum-field-label-side-padding-right));

	vertical-align: top;
}

.spectrum-FieldLabel--right {
	text-align: end;
}

/********* WHCM *********/
@media (forced-colors: active) {
	.spectrum-FieldLabel.is-disabled {
		--highcontrast-field-label-content-color: GrayText;
	}
}
