/**
 * QR panel on wp-login.php.
 *
 * Sized to sit inside the 320px #login column alongside the standard form.
 */

/*
 * Side-by-side layout.
 *
 * The panel and the login box are wrapped in this row by the script. It wraps
 * on narrow screens so the panel drops underneath rather than squeezing the
 * form, and it leaves #login's width and padding alone so any site-side
 * customisation of the login box still applies.
 */
/*
 * Three columns: an empty one, the login box, an empty one. The two outer
 * tracks are equal, so the login box lands dead centre of the page and stays
 * there whether the QR panel is shown or not. The panel then sits inside an
 * outer track and hangs off the middle without shifting it.
 *
 * A flex row cannot do this: it centres the pair, which drags the login box off
 * to one side as soon as the panel appears.
 *
 * Bottom edges are aligned rather than centres, so the two boxes sit on a
 * shared baseline instead of both ends looking ragged.
 */
.imloginqr-layout {
	align-items: end;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
}

.imloginqr-layout > #login {
	grid-column: 2;
	grid-row: 1;
	/*
	 * WordPress centres #login with auto margins. Inside a grid those would
	 * soak up the free space in the track and fight the column layout, which is
	 * doing the centring now.
	 */
	margin: 0;
}

.imloginqr-layout--right .imloginqr {
	grid-column: 3;
	grid-row: 1;
	justify-self: start;
	margin-left: 40px;
}

.imloginqr-layout--left .imloginqr {
	grid-column: 1;
	grid-row: 1;
	justify-self: end;
	margin-right: 40px;
}

/*
 * Anything still sitting below the form pushes the column's bottom edge past
 * it, so the panel lines up with empty space rather than with the form. The
 * links WordPress puts there are the usual culprit when they have been emptied
 * rather than removed.
 */
.imloginqr-layout #nav:empty,
.imloginqr-layout #backtoblog:empty {
	display: none;
	margin: 0;
}

/* Too narrow for two columns: drop the panel underneath. */
@media ( max-width: 900px ) {
	.imloginqr-layout {
		display: block;
	}

	.imloginqr-layout .imloginqr {
		margin: 24px auto 0;
	}
}

.imloginqr {
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.04 );
	box-sizing: border-box;
	margin: 16px 0 0;
	padding: 20px 24px 24px;
	text-align: center;
	width: 100%;
}

/*
 * Alongside the form the panel sizes to its code rather than to the column.
 * Only the vertical margins are cleared - a shorthand here would wipe out the
 * horizontal spacing each placement sets.
 */
.imloginqr-layout .imloginqr {
	margin-bottom: 0;
	margin-top: 0;
	width: calc( var( --imloginqr-size, 320px ) + 48px );
}

.imloginqr-layout .imloginqr__title {
	font-size: 16px;
}

.imloginqr-layout .imloginqr__status {
	font-size: 14px;
}

.imloginqr[hidden] {
	display: none;
}

.imloginqr__title {
	color: #1d2327;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	margin: 0 0 14px;
	padding: 0;
}

.imloginqr__frame {
	background: #fff;
	border-radius: 4px;
	margin: 0 auto;
	/* Set from the Code size setting; the fallback matches its default. */
	max-width: var( --imloginqr-size, 320px );
	position: relative;
	width: 100%;
}

.imloginqr__code svg {
	display: block;
	height: auto;
	width: 100%;
}

/* Covers a dead code so nobody scans one that will not work. */
.imloginqr__veil {
	background: rgba( 255, 255, 255, 0.82 );
	border-radius: 4px;
	bottom: 0;
	left: 0;
	position: absolute;
	right: 0;
	top: 0;
}

.imloginqr__veil[hidden] {
	display: none;
}

.imloginqr__status {
	color: #50575e;
	font-size: 13px;
	line-height: 1.5;
	margin: 14px 0 0;
	min-height: 2.6em;
}

.imloginqr__timer {
	color: #787c82;
	font-size: 12px;
	font-variant-numeric: tabular-nums;
	margin: 2px 0 0;
	min-height: 1.4em;
}

.imloginqr__refresh {
	margin-top: 10px;
}

.imloginqr__refresh[hidden] {
	display: none;
}

@media screen and ( prefers-reduced-motion: no-preference ) {
	.imloginqr__code svg {
		transition: opacity 0.15s ease;
	}
}
