/*!
 * VisualEditor MediaWiki Initialization MobileArticleTarget styles.
 *
 * @copyright See AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
 */
@import 'mediawiki.skin.variables.less';

.ve-init-mw-target-surface {
	// margin-left and margin-right defined by the skin
	// (see .content styles in Minerva)
	margin-bottom: 1em;

	> .ve-ce-surface .ve-ce-attachedRootNode,
	> .ve-ui-surface-placeholder {
		padding: 0;
		margin-top: 1em;
	}

	> .ve-ce-surface {
		// Ensure surface is full height so top "Edit full page" button can
		// be scrolled out of view.
		min-height: ~'calc( 100vh + 2.5em )';

		.ve-ce-attachedRootNode {
			min-height: ~'calc( 100vh - 15em )';
		}

		.ve-ce-attachedRootNode.ve-ce-documentNode {
			// Ensure whole page is focusable (T109508)
			// Only apply in full page editing mode (.ve-ce-attachedRootNode === .ve-ce-documentNode),
			// as in section editing we may show an "Edit full page" button that we want close
			// to the text. As this issue only really applies when the document is empty, this
			// should not be an issue.

			// Subtract toolbar height, margin-bottom and a little more
			// to prevent scrolling.
			min-height: ~'calc( 100vh - 5em )';

			.ve-init-target-ios & {
				// More spacing required on iOS to prevent scrolling.
				min-height: ~'calc( 100vh - 10em )';
			}

			.ve-ui-targetWidget & {
				min-height: 0;
			}
		}
	}
}

.ve-ui-mwTargetWidget {
	/* stylelint-disable-next-line selector-class-pattern */
	.ve-ui-mwSurface.content {
		// When content is applied to surface in a TargetWidget, don't add margins
		margin: 0;
	}
}

/* stylelint-disable selector-class-pattern */
.ve-init-mw-mobileArticleTarget.overlay {
	// Override MobileFrontend `.overlay` styles.
	// `padding-top` is instead set on a different element in adjustContentPadding().
	padding-top: 0;
}
/* stylelint-enable selector-class-pattern */

.ve-init-mw-mobileArticleTarget {
	.ve-ui-overlay-local,
	.ve-ui-sidebarDialogWindowManager {
		// Reset line height set by .content
		line-height: 1.4;
	}
}

.oo-ui-windowManager-ios-modal-ready .ve-init-mw-mobileArticleTarget {
	height: 100%;
	overflow: hidden;
}

.ve-init-mw-mobileArticleTarget-toolbar-popups {
	// Avoid jittering while scrolling (T209192)
	position: fixed;
}

.ve-init-mw-mobileArticleTarget-toolbar.ve-ui-targetToolbar-mobile {
	// The toolbar is marked as 'floatable' for calculating
	// surface padding, but actual floating is handled by
	// the MobileFrontend overlay.
	position: static;
	border-top: 0;

	.oo-ui-toolbar-tools > {
		.ve-ui-toolbar-group-back,
		.ve-ui-toolbar-group-save {
			flex: 0;
			min-width: 2.75em;
		}
	}
}

@media screen and ( max-width: 767px ) {
	.ve-init-mw-target-surface > .ve-ui-surface-placeholder > * {
		/* Fix margin overlap */
		margin-top: 0;
		/* Placeholder doesn't need a border as well */
		border: 0;
	}
}

@media all and ( min-width: @min-width-breakpoint-desktop ) {
	.ve-init-mw-target-surface {
		// This should be in-sync with .overlay-header rule in MinervaNeue's overlay.less
		max-width: calc( 993.3px + ( 2 * 1em ) );
	}
}

.ve-ui-debugBar {
	margin: 0 -16px;
	padding: 0 16px;
	border-top: @border-subtle;
	box-shadow: 0 10px 10px -10px rgba( 0, 0, 0, 0.15 ) inset;

	@media screen and ( min-width: 720px ) {
		margin: 0 -3.35em;
		padding: 0 3.35em;
	}
	padding-top: 0.8em;
}

.ve-ui-targetWidget .ve-ui-debugBar {
	margin: 0;
}

.ve-ui-debugBar-selectionLabel {
	min-width: auto;
	width: 100%;
}

/* Restrict width of context to tablet width */
.ve-ui-mobileContext-menu {
	max-width: 995px;
	margin: 0 auto;
}

.ve-ce-surface-interface {
	font-size: 0.875rem;
	font-family: sans-serif;
}
