@use "@wordpress/base-styles/colors" as *;
@use "@wordpress/base-styles/variables" as *;
@use "../utils/composite-item";

.components-dropdown-menu__toggle {
	vertical-align: top;
}

.components-dropdown-menu__menu {
	width: 100%;
	font-family: $default-font;
	font-size: $default-font-size;
	line-height: $default-line-height;

	.components-dropdown-menu__menu-item,
	.components-menu-item {
		width: 100%;
		padding: 6px;
		outline: none;
		cursor: var(--wpds-cursor-control);
		white-space: nowrap;
		font-weight: var(--wpds-typography-font-weight-default);

		&.has-separator {
			margin-top: 6px;
			position: relative;
			overflow: visible;
		}

		&.has-separator::before {
			display: block;
			content: "";
			box-sizing: content-box;
			background-color: var(--wpds-color-stroke-surface-neutral);
			position: absolute;
			top: -3px;
			left: 0;
			right: 0;
			height: 1px;
		}

		&.is-active {
			svg,
			.dashicon {
				// Block UI appearance.
				color: $white;
				background: $gray-900;
				box-shadow: 0 0 0 $border-width $gray-900;
				border-radius: $border-width;
				// Dashicons fade their color in wp-admin, which would lag behind the background.
				transition: none;
			}

			@include composite-item.when-highlighted {
				svg,
				.dashicon {
					color: var(--wpds-color-background-interactive-brand-strong-active);
					background: var(--wpds-color-foreground-interactive-brand-strong-active);
					box-shadow: 0 0 0 $border-width var(--wpds-color-foreground-interactive-brand-strong-active);

					@media ( forced-colors: active ) {
						color: Highlight;
						background: HighlightText;
						box-shadow: 0 0 0 $border-width HighlightText;
					}
				}
			}
		}

		// If menu items are icon-only, make them stretch only to the icon size.
		&.is-icon-only {
			width: auto;
		}
	}

	.components-menu-item__button,
	.components-menu-item__button.components-button {
		min-height: $grid-unit-40;
		height: auto;
		text-align: left;
		padding-left: $grid-unit-10;
		padding-right: $grid-unit-10;

		// Offset the 1px border reserved by Button, since the height here
		// is determined by the content rather than fixed.
		padding-top: $grid-unit-05 - $border-width;
		padding-bottom: $grid-unit-05 - $border-width;

		&.has-icon {
			// Matches the `.has-icon` padding of Button.
			padding-top: 6px - $border-width;
			padding-bottom: 6px - $border-width;
		}
	}

}
