// Inputs

@import 'mediawiki.mixins.less';
@import 'mediawiki.ui/variables.less';

// Text inputs
//
// Apply the mw-ui-input class to input and textarea fields.

// mw-ui-input
//
// Style an input using MediaWiki UI.
// Currently in draft status and subject to change.
// When focused a progressive highlight appears to the left of the field.
//
// Markup:
// <input class="mw-ui-input" placeholder="Enter your name">
// <textarea class="mw-ui-input">Text here</textarea>
.mw-ui-input {
	background-color: @background-color-base;
	color: @color-base--emphasized;
	box-sizing: border-box;
	display: block;
	width: 100%;
	border: @border-base;
	border-radius: @border-radius-base;
	padding: 6px 8px;
	// necessary for smooth transition
	box-shadow: @box-shadow-base;
	font-family: inherit;
	font-size: inherit;
	line-height: 1.28571429em;
	vertical-align: middle;

	// Normalize & style placeholder text, see T139034
	.mixin-placeholder( {
		color: @color-placeholder;
		opacity: 1;
	} );

	// Firefox: Remove red outline when `required` attribute set and invalid content.
	// See https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid
	// This should come before `:focus` so latter rules take preference.
	&:invalid {
		box-shadow: none;
	}

	&:hover {
		border-color: @colorGray7;
	}

	&:focus {
		border-color: @border-color-base--focus;
		box-shadow: @box-shadow-base--focus;
		outline: 0;
	}

	// `:not()` is used exclusively for `transition`s as both are not supported by IE < 9.
	&:not( :disabled ) {
		transition: color 100ms, border-color 100ms, box-shadow 100ms;
	}

	&:disabled {
		border-color: @colorGray14;
		color: @colorGray12;
	}

	// Normalize styling for `<input type="search">`
	&[ type='search' ] {
		// Support: Safari/iOS `none` needed, Chrome would accept `textfield` as well.
		/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
		-webkit-appearance: none;
		// Support: Firefox.
		/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
		-moz-appearance: textfield;

		// Remove proprietary clear button in IE 10-11, Edge 12+
		&::-ms-clear {
			display: none;
		}

		// Remove the inner padding and cancel buttons in Chrome on OS X and Safari on OS X
		&::-webkit-search-cancel-button,
		&::-webkit-search-decoration {
			/* stylelint-disable-next-line plugin/no-unsupported-browser-features */
			-webkit-appearance: none;
		}
	}
}

textarea.mw-ui-input {
	min-height: 8em;
}

// mw-ui-input-inline
//
// Use mw-ui-input-inline with mw-ui-input in cases where you want a button to line up with the input.
//
// Markup:
// <input class="mw-ui-input mw-ui-input-inline">
// <button class="mw-ui-button mw-ui-progressive">Submit</button>
.mw-ui-input-inline {
	display: inline-block;
	width: auto;
	// Make sure we limit `width` to parent element because
	// in case of text `input` fields, `width: auto;` equals `size` attribute.
	max-width: 100%;
}

// mw-ui-input-large
//
// Use mw-ui-input-large with mw-ui-input in cases where there are multiple inputs on a screen and you
// want to draw attention to one instance. For example, replying with a subject line and more text.
// Currently in draft status and subject to change. When used on an input field, the text is styled
// in a large font. When used alongside another mw-ui-input large they are pushed together to form one
// contiguous block.
//
// Markup:
// <input value="input" class="mw-ui-input mw-ui-input-large" value="input" placeholder="Enter subject">
// <textarea class="mw-ui-input mw-ui-input-large" placeholder="Provide additional details"></textarea>
.mw-ui-input-large {
	margin-top: 0;
	margin-bottom: 0;

	// When two large inputs are together, we make them flush by hiding one of the borders
	& + .mw-ui-input-large {
		margin-top: -1px;
	}
	// When focusing, make the input relative to raise it above any attached inputs to unhide its borders
	&:focus {
		position: relative;
	}
}

input.mw-ui-input-large {
	padding: 8px;
	font-size: 1.75em;
	font-weight: bold;
	line-height: 1.25em;
}
