/* Modern Sticky Bar - responsive preview switcher */

/*
 * The switcher lives inside the bar, so everything here inherits the bar's own
 * colour. Using currentColor keeps the icons readable on light and dark presets
 * alike, without a second set of colour settings.
 */

#msb-bar #msb-preview {
	display: flex;
	align-items: center;
	gap: 2px;
	flex: 0 0 auto;
	color: var(--msb-color, #111);
}

#msb-bar #msb-preview[hidden] {
	display: none;
}

#msb-bar #msb-preview a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 8px;
	color: inherit;
	opacity: 0.45;
	text-decoration: none;
	box-shadow: none;
	cursor: pointer;
	transition: opacity 0.15s ease, background-color 0.15s ease;
}

/* A neutral grey wash reads as a highlight on both light and dark bars. */

#msb-bar #msb-preview a:hover,
#msb-bar #msb-preview a:focus-visible {
	opacity: 1;
	background: rgba(128, 128, 128, 0.18);
	outline: none;
}

#msb-bar #msb-preview a.active {
	opacity: 1;
	background: rgba(128, 128, 128, 0.28);
}

#msb-bar #msb-preview a:focus-visible {
	box-shadow: 0 0 0 2px currentColor;
}

#msb-bar #msb-preview svg {
	display: block;
}

/* Readout, reload and exit only mean anything while a device is active. */

#msb-bar #msb-preview .msb-preview-live {
	display: none;
	align-items: center;
	gap: 4px;
	margin-left: 6px;
	padding-left: 8px;
	border-left: 1px solid rgba(128, 128, 128, 0.3);
}

#msb-bar #msb-preview.is-previewing .msb-preview-live {
	display: inline-flex;
}

#msb-bar #msb-preview .msb-preview-dims {
	font-size: 11px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.3px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	opacity: 0.6;
}

#msb-bar #msb-preview .msb-preview-reload,
#msb-bar #msb-preview .msb-preview-exit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: inherit;
	opacity: 0.55;
	cursor: pointer;
}

#msb-bar #msb-preview .msb-preview-reload:hover,
#msb-bar #msb-preview .msb-preview-exit:hover,
#msb-bar #msb-preview .msb-preview-reload:focus-visible,
#msb-bar #msb-preview .msb-preview-exit:focus-visible {
	opacity: 1;
	background: rgba(128, 128, 128, 0.2);
	outline: none;
}

#msb-bar #msb-preview .msb-preview-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Stage — z-index comes from an inline rule so it sits just under the bar. */

#msb-preview-stage {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	padding: 16px;
	background: #16191d;
	overflow: hidden;
}

#msb-preview-stage[hidden] {
	display: none;
}

/* Start below the admin bar rather than painting over it. */

body.admin-bar #msb-preview-stage {
	top: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar #msb-preview-stage {
		top: 46px;
	}
}

#msb-preview-stage .msb-preview-sizer {
	position: relative;
	flex: 0 0 auto;
	transition: width 0.25s ease, height 0.25s ease;
}

#msb-preview-stage .msb-preview-frame {
	position: absolute;
	top: 0;
	left: 0;
	transform-origin: top left;
	background: #fff;
	border-radius: 4px;
	overflow: hidden;
	box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

#msb-preview-stage .msb-preview-iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: #fff;
}

/* Lock the underlying page while a device is being previewed. */

html.msb-preview-on,
html.msb-preview-on body {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	#msb-preview-stage .msb-preview-sizer,
	#msb-bar #msb-preview a {
		transition: none;
	}
}

/* Narrow screens: the readout would push the icons out of the bar. */

@media screen and (max-width: 600px) {
	#msb-bar #msb-preview .msb-preview-dims {
		display: none;
	}

	#msb-bar #msb-preview a {
		width: 30px;
		height: 30px;
	}
}
