@import "@wordpress/base-styles/breakpoints";
@import "@wordpress/base-styles/mixins";

.web-preview {
	position: fixed;
	top: 0;
	right: 0;
	left: 0;
	margin: 0 auto;
	overflow: hidden;
	opacity: 0;
	z-index: 999999999 !important; /* To override the z-index added by admin-bar on simple sites - opengrok - fbhepr%2Skers%2Sjcpbz%2Sjc%2Qpbagrag%2Szh%2Qcyhtvaf%2Sn8p%2Qgbbyone%2Sfhcre%2Qnqzva%2Qone.pff%3Se%3Q4o71s805%2387-og */
	transition: opacity 0.3s ease-in-out;

	&.is-visible {
		opacity: 1;
		bottom: 0;
		visibility: visible;

		.web-preview__content {
			opacity: 1;
			transform: translateY(0);
		}
	}

	&.is-with-sidebar {
		@include breakpoint-deprecated( ">660px" ) {
			left: 273px;
		}
	}
}

.web-preview__backdrop {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: block;
	background: color-mix(in srgb, var(--color-neutral-0) 80%, transparent);
}

.web-preview__content {
	display: flex;
	flex-direction: column;
	box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-neutral-light) 50%, transparent);
	background: var(--color-neutral-0);
	border-radius: 2px 2px 0 0;
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0 auto;
	opacity: 0;
	transform: translateY(80vh);
	transition: transform 0.2s ease-out, opacity 0.1s ease-in-out;

	@include break-large {
		top: 24px;
		left: 24px;
		right: 24px;
		bottom: 24px;
		width: calc(100% - 46px); /* IE11 fix */
	}
}

.web-preview__toolbar {
	height: 46px;
	background: var(--color-surface);
	border-bottom: 1px solid var(--color-neutral-10);
	border-radius: 2px 2px 0 0;
	display: flex;
	gap: 24px;
	padding: 0 12px;
	align-items: center;
}

.web-preview__close.button {
	border-right: 1px solid var(--color-neutral-5);
	padding: 6px 16px;
	min-width: 80px;
	color: var(--color-primary);
	border-radius: 0;

	@include break-large {
		padding: 6px 32px;
	}

	&:hover {
		color: var(--color-accent);
	}
}

.web-preview__edit-header-link.button {
	padding: 6px 16px;
	line-height: 34px;
	color: var(--color-primary);
	border-radius: 0;

	@include break-large {
		padding: 6px 32px;
	}

	&:hover {
		color: var(--color-accent);
	}
}

.web-preview__loading-spinner.button {
	padding: 6px 16px;
	color: var(--color-primary);
	border-radius: 0;

	@include break-large {
		padding: 6px 32px;
	}

	&:hover {
		color: var(--color-accent);
	}
}

.web-preview__external {
	min-width: 120px;
	text-align: center;
}

.web-preview__edit.button {
	min-width: 100px;
	text-align: center;
}

.web-preview__toolbar-actions {
	margin-left: auto;
	display: flex;
	justify-content: flex-end;
	align-items: center;
	gap: 8px;
}

.web-preview__device-switcher {
	display: none;

	@include break-small {
		display: flex;
	}
}

.web-preview__url-clipboard-input {
	flex-grow: 1;
	width: auto;

	.form-text-input {
		color: var(--color-text-subtle);
		font-size: $font-body-small;
		height: 35px;
		border-color: transparent;
		text-overflow: ellipsis;
		text-align: center;
	}

	&:hover .form-text-input:not(:focus) {
		border-color: var(--color-neutral-10);
	}

	.clipboard-button {
		display: none;
	}

	&:hover .clipboard-button {
		display: block;
	}
}

.web-preview__device-button {
	border-right: none;
	padding-left: 8px;
	padding-right: 8px;

	&.is-active {
		color: var(--color-neutral-70);
	}

	@media (max-width: $break-small) {
		display: none;
	}
}

.web-preview__seo-button {
	border-right: none;
	padding: 0 14px;
	height: 100%;

	&.is-active {
		color: var(--color-neutral-70);
	}

	&.is-showing-device-switcher {
		border-left: 1px solid var(--color-neutral-10);
		margin-left: 8px;
	}
}

.web-preview__seo-label {
	margin-left: 6px;
	vertical-align: middle;
}

.web-preview__back-to-preview-button {
	display: block;

	@include break-small {
		display: none;
	}
}

.web-preview__frame {
	display: block;
	width: 100%;
	max-width: 100%;
	height: 100%;
	opacity: 0;
	transition: opacity 0.2s ease-in-out, max-width 0.2s ease-out;
	margin: 0 auto;
	pointer-events: none;

	.is-loaded & {
		opacity: 1;
		pointer-events: all;
	}

	.is-tablet & {
		max-width: 783px;
	}

	.is-phone & {
		max-width: 460px;
	}

	.is-seo & {
		max-width: 865px;
	}

	.is-fixed-viewport-width & {
		margin: 0;
		max-width: none;
		transform-origin: 0 0;
	}
}

.web-preview__frame-wrapper {
	position: absolute;
	top: 0;
	left: 0;
	height: 100%;
	width: 100%;

	&.is-resizable {
		background: var(--color-neutral-0);

		.web-preview__frame {
			.is-tablet & {
				max-width: 783px;
			}

			.is-phone & {
				max-width: 460px;
			}
		}
	}
}

.web-preview__placeholder {
	position: relative;
	width: 100%;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	flex: 1;
}

.web-preview__inner {
	height: 100%;
	display: flex;
	flex-direction: column;
	position: relative;
}

.web-preview__loading-message-wrapper {
	display: flex;
	justify-content: center;
	flex-direction: column;
	position: absolute;
	height: 100%;
	width: 100%;
	z-index: z-index("root", ".web-preview__loading-message-wrapper");
	text-align: center;
}

.web-preview__loading-message {
	color: var(--color-text-subtle);
	font-size: $font-body;
}

.web-preview__loading-message strong {
	color: var(--color-text-subtle);
	display: block;
	font-size: $font-title-medium;
	margin-bottom: 5px;
}

.web-preview__inner .spinner-line {
	position: absolute;
	top: 22px;
	width: 100%;
	z-index: z-index("root", ".web-preview__inner .spinner-line");
}
