/**
 * WP PWA Kit - front-end styles.
 * Everything is prefixed and self-contained so themes stay untouched.
 */

/*
 * The three overlays ship with the HTML `hidden` attribute and are revealed by
 * the runtime. A class rule that sets `display` outranks the browser's own
 * `[hidden] { display: none }`, so without these the sheet would sit over the
 * whole page at inset 0 - invisible at opacity 0, but swallowing every click on
 * the site. Keep this block above the rules that set `display`.
 */
.wppwa-install[hidden],
.wppwa-sheet[hidden],
.wppwa-toast[hidden] {
	display: none !important;
}

/*
 * Second line of defence: until the runtime adds `is-visible`, nothing here can
 * receive a pointer event. If a theme, a cache plugin or a stray script ever
 * strips the `hidden` attribute, the worst case is an invisible element that is
 * still click-through rather than an unusable site.
 */
.wppwa-sheet:not(.is-visible),
.wppwa-toast:not(.is-visible) {
	pointer-events: none;
}

.wppwa-sheet.is-visible,
.wppwa-toast.is-visible {
	pointer-events: auto;
}

.wppwa-install:not(.is-visible) {
	pointer-events: none;
}

.wppwa-install.is-visible {
	pointer-events: auto;
}

.wppwa-install {
	position: fixed;
	z-index: 99990;
	display: inline-flex;
	align-items: center;
	gap: 9px;
	padding: 12px 20px;
	border: 0;
	cursor: pointer;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.2;
	background: var(--wppwa-install-bg, #101828);
	color: var(--wppwa-install-fg, #fff);
	border-radius: var(--wppwa-install-radius, 999px);
	box-shadow: 0 6px 24px -8px rgba(16, 24, 40, .55);
	opacity: 0;
	transform: translateY(10px);
	transition: opacity .22s ease, transform .22s ease;
}

.wppwa-install.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.wppwa-install:hover {
	filter: brightness(1.08);
}

.wppwa-install:active {
	transform: scale(.97);
}

.wppwa-install:focus-visible {
	outline: 3px solid var(--wppwa-install-bg, #101828);
	outline-offset: 3px;
}

.wppwa-install__icon {
	width: 19px;
	height: 19px;
	flex: none;
}

.wppwa-pos-bottom-right {
	right: 20px;
	bottom: calc(20px + env(safe-area-inset-bottom));
}

.wppwa-pos-bottom-left {
	left: 20px;
	bottom: calc(20px + env(safe-area-inset-bottom));
}

.wppwa-pos-bottom-center {
	left: 50%;
	bottom: calc(20px + env(safe-area-inset-bottom));
	transform: translate(-50%, 10px);
}

.wppwa-pos-bottom-center.is-visible {
	transform: translate(-50%, 0);
}

.wppwa-pos-top-right {
	right: 20px;
	top: calc(20px + env(safe-area-inset-top));
}

.wppwa-pos-top-left {
	left: 20px;
	top: calc(20px + env(safe-area-inset-top));
}

@media screen and (max-width: 782px) {
	.wppwa-hide-mobile {
		display: none !important;
	}
}

@media screen and (min-width: 783px) {
	.wppwa-hide-desktop {
		display: none !important;
	}
}

/* iOS instructions sheet ------------------------------------------------- */

.wppwa-sheet {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

.wppwa-sheet__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(8, 12, 22, .6);
	opacity: 0;
	transition: opacity .25s ease;
}

.wppwa-sheet.is-visible .wppwa-sheet__backdrop {
	opacity: 1;
}

.wppwa-sheet__panel {
	position: relative;
	width: 100%;
	max-width: 420px;
	margin: 0 12px 12px;
	padding: 28px 24px calc(28px + env(safe-area-inset-bottom));
	border-radius: 20px;
	background: var(--wppwa-surface, #0b1220);
	color: var(--wppwa-on-surface, #fff);
	text-align: center;
	box-shadow: 0 24px 60px -20px rgba(8, 12, 22, .7);
	transform: translateY(24px);
	opacity: 0;
	transition: opacity .25s ease, transform .25s ease;
}

.wppwa-sheet.is-visible .wppwa-sheet__panel {
	transform: translateY(0);
	opacity: 1;
}

.wppwa-sheet__close {
	position: absolute;
	top: 12px;
	right: 14px;
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: inherit;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.wppwa-sheet__icon {
	width: 64px;
	height: 64px;
	border-radius: 16px;
	object-fit: contain;
	margin: 0 auto 16px;
	display: block;
	background: rgba(255, 255, 255, .08);
}

.wppwa-sheet__title {
	margin: 0 0 8px;
	font-size: 1.15rem;
	line-height: 1.3;
}

.wppwa-sheet__text {
	margin: 0 0 20px;
	font-size: .9375rem;
	opacity: .8;
	line-height: 1.55;
}

.wppwa-sheet__steps {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: 12px;
	text-align: left;
}

.wppwa-sheet__steps li {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 14px;
	border-radius: 12px;
	background: rgba(255, 255, 255, .07);
	font-size: .875rem;
	margin: 0;
}

.wppwa-sheet__steps svg {
	width: 20px;
	height: 20px;
	flex: none;
	opacity: .9;
}

/* Update notice ---------------------------------------------------------- */

.wppwa-toast {
	position: fixed;
	z-index: 99995;
	display: flex;
	align-items: center;
	gap: 14px;
	max-width: calc(100vw - 32px);
	padding: 12px 14px 12px 18px;
	border-radius: 14px;
	background: #101828;
	color: #fff;
	font-size: .875rem;
	box-shadow: 0 16px 40px -16px rgba(8, 12, 22, .8);
	opacity: 0;
	transform: translateY(14px);
	transition: opacity .25s ease, transform .25s ease;
}

.wppwa-toast.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.wppwa-toast--bottom-center {
	left: 50%;
	bottom: calc(20px + env(safe-area-inset-bottom));
	transform: translate(-50%, 14px);
}

.wppwa-toast--bottom-center.is-visible {
	transform: translate(-50%, 0);
}

.wppwa-toast--bottom-right {
	right: 20px;
	bottom: calc(90px + env(safe-area-inset-bottom));
}

.wppwa-toast--top-center {
	left: 50%;
	top: calc(20px + env(safe-area-inset-top));
	transform: translate(-50%, -14px);
}

.wppwa-toast--top-center.is-visible {
	transform: translate(-50%, 0);
}

.wppwa-toast__text {
	line-height: 1.4;
}

.wppwa-toast__action {
	appearance: none;
	border: 0;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	padding: 8px 16px;
	border-radius: 999px;
	background: var(--wppwa-theme, #3ddc97);
	color: #fff;
	white-space: nowrap;
}

.wppwa-toast__action:disabled {
	opacity: .6;
	cursor: default;
}

.wppwa-toast__dismiss {
	appearance: none;
	border: 0;
	background: transparent;
	color: inherit;
	opacity: .6;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	padding: 4px 6px;
}

.wppwa-toast__dismiss:hover {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.wppwa-install,
	.wppwa-toast,
	.wppwa-sheet__panel,
	.wppwa-sheet__backdrop {
		transition: none;
	}
}

/* Message shown when a non-Safari iOS browser cannot install the app. */
.wppwa-sheet__url {
	margin: 16px 0 0;
	text-align: center;
}

.wppwa-sheet__url code {
	display: inline-block;
	max-width: 100%;
	padding: 8px 12px;
	border-radius: 8px;
	background: rgba(16, 24, 40, 0.07);
	font-size: 13px;
	line-height: 1.5;
	word-break: break-all;
}
