@use "@wordpress/base-styles/variables";
@use "@wordpress/base-styles/colors";
@use "@wordpress/base-styles/mixins";
@use "./font-library/style.scss" as *;
@use "./screen-revisions/style.scss" as *;
@use "./size-control/style.scss" as *;
@use "./variations/style.scss" as *;

.global-styles-ui-preview__wrapper {
	max-width: 100%;
	display: block;
	width: 100%;

	&.is-hoverable {
		cursor: var(--wpds-cursor-control);
	}
}

.global-styles-ui-typography-preview {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100px;
	margin-bottom: 20px;
	background: #f0f0f0;
	border-radius: 2px;
	overflow: hidden;
}

.global-styles-ui-element-preview {
	// The screen is a scrolling flex column, and this box hides its overflow,
	// so without this it collapses when the panels below are taller than the
	// screen.
	flex-shrink: 0;
	height: 120px;
	margin: 0 variables.$grid-unit-20 20px;
	border-radius: 2px;
	overflow: hidden;
	background: #f0f0f0;

	iframe {
		display: block;
		width: 100%;
		height: 100%;
		border: 0;
	}
}

.global-styles-ui-font-size__item {
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
	line-break: anywhere;
}

.global-styles-ui-font-size__item-value {
	color: #757575;
}

.global-styles-ui-screen-typography__indicator {
	height: 24px;
	width: 24px;
	font-size: 14px;
	display: flex !important;
	align-items: center;
	justify-content: center;
	border-radius: 2px;
}

.global-styles-ui-block-types-filter {
	margin-bottom: variables.$grid-unit-20;
	padding: 0 variables.$grid-unit-20;
}

.global-styles-ui-block-types-search {
	flex-grow: 1;
}

.global-styles-ui-block-types-item-list {
	// Inset the rows, and their focus rings, from the edges of the sidebar,
	// like List View. Icons have about 4px of space inside their 24px box, so
	// with the small item padding the icon itself lines up with the 16px inset
	// of the header, search field and headings.
	margin-inline: variables.$grid-unit-05;

	.global-styles-ui-block-types-item__icon {
		min-width: variables.$grid-unit-30;
	}

	// Bordered and already inside the screen padding, so it lines up with its
	// heading without the inset.
	&.global-styles-ui-element-block-overrides__list {
		margin-inline: 0;
	}
}

.global-styles-ui-block-types-item-list__no-results {
	padding-top: variables.$grid-unit-20;
}

// The rows above and below a group title already have about 5px of padding,
// so these margins are smaller than the space they appear to leave.
.global-styles-ui-block-types-group + .global-styles-ui-block-types-group {
	margin-top: variables.$grid-unit-15;
}

// Keep the last row clear of the bottom of the scroll container. Padding
// rather than margin, so it is kept at the end of the scrollable area.
.global-styles-ui-block-types-group:last-child {
	padding-bottom: variables.$grid-unit-15;
}

.global-styles-ui-block-types-group__title {
	margin-bottom: variables.$grid-unit-15;
	padding: 0 variables.$grid-unit-20;
}

.global-styles-ui-screen-typography__font-variants-count {
	color: colors.$gray-700;
}

.global-styles-ui-font-families__manage-fonts {
	justify-content: center;
}

.global-styles-ui-screen .color-block-support-panel {
	padding-left: 0;
	padding-right: 0;
	padding-top: 0;
	border-top: none;
	row-gap: calc(4px * 3);
}

.global-styles-ui-header {
	// Need to override the too specific bottom margin for complementary areas.
	margin-bottom: 0 !important;
	// Ensure header text is centred with the back button.
	line-height: 1.9 !important;
}

.global-styles-ui-subtitle {
	// Need to override the too specific styles for complementary areas.
	margin-bottom: 0 !important;
	text-transform: uppercase;
	font-weight: var(--wpds-typography-font-weight-emphasis) !important;
	font-size: 11px !important;
}

.global-styles-ui-section-title {
	color: colors.$gray-800;
	font-weight: var(--wpds-typography-font-weight-emphasis);
	line-height: 1.2;
	padding: 16px 16px 0;
	margin: 0;
}

.global-styles-ui-icon-with-current-color {
	fill: currentColor;
}

.global-styles-ui__color-indicator-wrapper {
	// Match the height of the rest of the icons (24px).
	height: variables.$grid-unit * 3;
	flex-shrink: 0;
	display: flex;
	align-items: center;
}

.global-styles-ui__palette-preview {
	display: inline-flex;

	> * + * {
		margin-inline-start: calc(-1 * variables.$grid-unit);
	}
}

.global-styles-ui__shadows-panel__options-container,
.global-styles-ui__typography-panel__options-container {
	height: variables.$grid-unit * 3;
}

.global-styles-ui__block-preview-panel {
	position: relative;
	width: 100%;
	border: #ddd 1px solid;
	border-radius: 2px;
	overflow: hidden;
}

.global-styles-ui__shadow-preview-panel,
.global-styles-ui__text-shadow-preview-panel {
	height: 144px;
	border: #ddd 1px solid;
	border-radius: 2px;
	overflow: auto;
	@include mixins.checkerboard-background( 8px );
}

.global-styles-ui__shadow-preview-block {
	border: #ddd 1px solid;
	border-radius: 2px;
	background-color: #fff;
	width: 60%;
	height: 60px;
}

.global-styles-ui__text-shadow-preview-panel {
	// Pull up against the screen header and separate from the editor below.
	margin-block: variables.$grid-unit-10 * -1 variables.$grid-unit-20;
}

.global-styles-ui__text-shadow-preview-text {
	font-size: 24px;
}

.global-styles-ui__text-shadow-editor__header {
	margin-block-end: variables.$grid-unit-10;
}

.global-styles-ui__text-shadow-editor__inputs {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: variables.$grid-unit-20;
}

.global-styles-ui__shadow-editor__dropdown-content,
.global-styles-ui__text-shadow-editor__dropdown-content {
	width: 280px;
}

.global-styles-ui__shadow-editor-panel,
.global-styles-ui__text-shadow-editor-panel {
	// because tooltip of the range control is too close to the edge and creates overflow
	margin-bottom: 4px;
}

.global-styles-ui__shadow-editor__dropdown,
.global-styles-ui__text-shadow-editor__dropdown {
	width: 100%;
	position: relative;
}

.global-styles-ui__shadow-editor__dropdown-toggle,
.global-styles-ui__text-shadow-editor__dropdown-toggle {
	width: 100%;
	height: auto;
	padding-top: 8px;
	padding-bottom: 8px;
	text-align: left;
	border-radius: inherit;

	&.is-open {
		background: colors.$gray-100;
		color: var(--wp-admin-theme-color);
	}
}

.global-styles-ui__shadow-editor__remove-button,
.global-styles-ui__text-shadow-editor__remove-button {
	position: absolute;
	right: 8px;
	top: 8px;
	opacity: 0;

	.global-styles-ui__shadow-editor__dropdown-toggle:hover + &,
	.global-styles-ui__text-shadow-editor__dropdown-toggle:hover + &,
	&:focus,
	&:hover {
		opacity: 1;
	}

	@media ( hover: none ) {
		// Show reset button on devices that do not support hover.
		opacity: 1;
	}
}

.global-styles-ui-screen-css {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	margin: 16px;

	.block-editor-global-styles-advanced-panel {
		flex: 1 1 auto;
	}

	.block-editor-global-styles-advanced-panel__custom-css-input {
		flex: 1 1 auto;
		display: flex;
		flex-direction: column;

		.components-base-control__field {
			flex: 1 1 auto;
			display: flex;
			flex-direction: column;
		}

		textarea {
			flex: 1 1 auto;
		}
	}
}

.global-styles-ui-screen-css-help-link {
	display: inline-block;
	margin-top: 8px;
}

.global-styles-ui-screen-variations {
	margin-top: 16px;
	border-top: 1px solid #ddd;

	> * {
		margin: 24px 16px;
	}
}

.global-styles-ui-sidebar__navigator-provider {
	height: 100%;
}

.global-styles-ui-sidebar__navigator-screen {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.global-styles-ui-color-palette__tablist-container {
	border-bottom: variables.$border-width solid colors.$gray-300;
}

.global-styles-ui-color-palette__tablist {
	margin-bottom: calc(-1 * variables.$border-width);
}

.global-styles-ui-sidebar__navigator-screen .single-column {
	grid-column: span 1;
}

.global-styles-ui-screen-root.global-styles-ui-screen-root,
.global-styles-ui-screen-style-variations.global-styles-ui-screen-style-variations {
	background: unset;
	color: inherit;
}

.global-styles-ui-sidebar__panel .block-editor-block-icon svg {
	fill: currentColor;
}

.global-styles-ui-screen-root__active-style-tile {
	// Todo: revisit use of Card component and/or remove override
	// The &#{&} is a workaround for the specificity of the Card component.
	&#{&},
	&#{&} .global-styles-ui-screen-root__active-style-tile-preview {
		border-radius: 2px;
	}
}

.global-styles-ui-screen-root__active-style-tile-preview {
	clip-path: border-box;
}

.global-styles-ui-color-palette-panel,
.global-styles-ui-gradient-palette-panel,
.global-styles-ui-duotone-palette-panel {
	padding: variables.$grid-unit-20;
}
