/*!
 * VisualEditor Toolbar styles.
 *
 * @copyright See AUTHORS.txt
 */

@import '../../../lib/codex-design-tokens/theme-wikimedia-ui.less';

.ve-ui-toolbar {
	/* Used by mobile context position hack */
	position: relative;
	/* Make sure the toolbar is shown on top of surface contents even when not floating,
	   for correct rendering of dropdowns, popups etc. */
	z-index: 2;

	&.ve-ui-toolbar-empty > .oo-ui-toolbar-bar {
		border: 0;
		box-shadow: none;
	}
}

/* PositionedTargetToolbar */

.ve-ui-positionedTargetToolbar-floatable {
	position: -webkit-sticky;
	position: sticky;
	top: 0;

	&.ve-ui-toolbar-floating {
		// Support: Firefox
		// Using a top position of 0 sometimes renders the tooblar 1px away
		// from the viewport edge (presumably a rounding error). To avoid
		// this transparent gap, add a 1px white border to the top and
		// use a negative top position.
		top: -1px;
		border-top: 1px solid @background-color-base;
	}
}

.ve-ui-toolbar.oo-ui-toolbar-position-bottom > .oo-ui-toolbar-bar {
	/* For bottom toolbars though (e.g. Flow), we apparently want the toolbar to be below the surface
	   overlay, but its dropdowns, popups etc. to be above it - this seems to work… (T169076) */
	z-index: auto;
}

.ve-ui-toolbar > .oo-ui-toolbar-bar .oo-ui-toolbar-bar {
	/* Dumb broken nested toolbars ruin everything again (T169617) */
	z-index: auto;
}

/* Mobile toolbar */

.ve-ui-targetToolbar-mobile .oo-ui-toolbar-tools {
	display: flex;

	.oo-ui-barToolGroup .oo-ui-tool-link {
		min-height: 3em;
	}

	> .oo-ui-toolGroup {
		flex: 1;
	}

	> .ve-ui-toolbar-group-back {
		border-right: @border-subtle;
	}

	> .oo-ui-toolGroup-empty {
		display: none;
	}

	> .oo-ui-indicatorElement > .oo-ui-popupToolGroup-handle {
		/* stylelint-disable-next-line declaration-no-important */
		padding: 3em 0 0 0 !important;
	}

	> .oo-ui-popupToolGroup {
		> .oo-ui-popupToolGroup-handle {
			> .oo-ui-iconElement-icon,
			> .oo-ui-indicatorElement-indicator {
				left: 50%;
			}

			> .oo-ui-iconElement-icon {
				/* No indicator */
				margin-left: -0.714285em;
			}
		}

		&.oo-ui-indicatorElement {
			/* Indicator uses up whitespace, so increase width to make spacing look even */
			flex: 1.2;

			> .oo-ui-popupToolGroup-handle > .oo-ui-iconElement-icon {
				margin-left: -1em;
			}
		}

		> .oo-ui-popupToolGroup-handle > .oo-ui-indicatorElement-indicator {
			margin-left: 0.375em;
			width: 0.5625em;
			min-width: 0.5625em;
		}
	}

	> .oo-ui-barToolGroup {
		text-align: center;

		> .oo-ui-toolGroup-tools > .oo-ui-tool {
			width: 100%;

			> .oo-ui-tool-link {
				padding: 0.875em 0;

				> .oo-ui-iconElement-icon:not( .oo-ui-tool-checkIcon ) {
					position: static;
					display: inline-block;
					vertical-align: middle;
				}

				> .oo-ui-tool-title {
					vertical-align: middle;
					margin-left: 0.3em;
					/* T260368 */
					line-height: 1em;

					@media screen and ( max-width: 767px ) {
						/* stylelint-disable-next-line declaration-no-important */
						display: none !important;
					}
				}
			}
		}
	}
}

.ve-ui-targetToolbar-mobile,
.ve-ui-overlay-global-mobile .oo-ui-toolbar-popups {
	/* Hide keyboard shortcut hints on mobile. Screen space is limited, and it's unlikely that the user
	   has a keyboard with modifier keys. */
	.oo-ui-tool-link .oo-ui-tool-accel {
		display: none;
	}
}
