/* Floating "Get the app" pill — the scroll-triggered entry point that
   replaces the old auto-popup-on-load card below. Small, quiet, sits just
   above the bottom tab bar; component.js reveals it once the visitor has
   scrolled a little (never immediately on load), auto-hides it again a
   few seconds later or as soon as they keep scrolling, and opens the full
   card (below) if they tap it instead. Mobile/tablet only — component.js
   bails out entirely on desktop viewports, and this media query is the
   CSS-side backstop for the same rule. */

@media (min-width: 1025px) {
	.qg-pwa-pill {
		display: none !important;
	}
}

.qg-pwa-pill {
	position: fixed;
	left: 50%;
	bottom: calc(64px + env(safe-area-inset-bottom, 0px) + var(--qg-space-3));
	z-index: 130;
	display: flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.55rem 1.1rem 0.55rem 0.55rem;
	background: var(--qg-color-ink);
	color: var(--qg-color-surface);
	border: 0;
	border-radius: 999px;
	box-shadow: 0 12px 30px -8px rgba(22, 19, 15, 0.45);
	cursor: pointer;
	transform: translate(-50%, 16px) scale(0.94);
	opacity: 0;
	pointer-events: none;
	transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s var(--qg-ease);
}

.qg-pwa-pill.is-visible {
	transform: translate(-50%, 0) scale(1);
	opacity: 1;
	pointer-events: auto;
}

.qg-pwa-pill img {
	width: 26px;
	height: 26px;
	border-radius: 8px;
	flex-shrink: 0;
}

.qg-pwa-pill span {
	font-family: var(--qg-font-body);
	font-size: 0.82rem;
	font-weight: 600;
	white-space: nowrap;
}

.qg-pwa-pill .qg-icon {
	width: 15px;
	height: 15px;
	flex-shrink: 0;
	color: var(--qg-color-accent);
}

@media (prefers-reduced-motion: reduce) {
	.qg-pwa-pill {
		transition: opacity 0.3s ease;
		transform: translate(-50%, 0) scale(1) !important;
	}
}

/* "Install the app" full card (see components/pwa-install/template.php +
   component.js) — opened by tapping the pill above, never shown on its
   own automatically. Starts off-screen/hidden; component.js only reveals
   it once it has confirmed the visit is actually installable (a real
   `beforeinstallprompt` capture, or Safari on iOS, which never fires that
   event and needs its own manual-steps copy instead). */

.qg-pwa-install {
	position: fixed;
	/* Longhand, not `inset: auto 0 0 0` — Safari only shipped the `inset`
	   shorthand in 14.1 (2021); on anything older the whole declaration is
	   invalid and silently dropped, leaving top/right/bottom/left all at
	   `auto`. With every offset auto, a fixed element is pinned to its
	   *static* position instead of the viewport — computed once from where
	   it'd fall in normal flow, which for markup injected at the very end
	   of a ~7000px-tall homepage lands partway down the document. That
	   matches exactly what was reported: the card sitting at one spot in
	   the middle of the page instead of stuck to the bottom of the screen. */
	top: auto;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 90;
	display: flex;
	justify-content: center;
	padding: 0 var(--qg-space-3) calc(var(--qg-space-3) + env(safe-area-inset-bottom, 0px));
	pointer-events: none;
	/* Forces its own compositor layer — works around a separate, longstanding
	   iOS Safari bug where `position: fixed` elements can detach and scroll
	   with the page (rather than stay pinned) on long documents. Harmless
	   elsewhere; not a fix for the `inset` issue above, but insurance
	   against a related class of iOS-only fixed-position bugs. */
	-webkit-transform: translateZ(0);
	transform: translateZ(0);
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	/* `visibility`, not `display: none` / the `hidden` attribute — see the
	   docblock in template.php for why toggling `display` on a
	   `position: fixed` element is specifically what breaks it on iOS
	   Safari. The card itself is already fully off-screen by default (its
	   own `translateY(120%)`, below), so this is purely to keep the
	   install/dismiss buttons out of tab order while parked off-screen. */
	visibility: hidden;
}

.qg-pwa-install.is-visible,
.qg-pwa-install.is-leaving {
	visibility: visible;
}

.qg-pwa-install__card {
	pointer-events: auto;
	position: relative;
	width: 100%;
	max-width: 420px;
	display: flex;
	gap: var(--qg-space-3);
	padding: var(--qg-space-4);
	background: var(--qg-color-ink);
	color: var(--qg-color-surface);
	border-radius: var(--qg-radius-lg);
	box-shadow: 0 20px 50px rgba(15, 14, 14, 0.35), 0 2px 8px rgba(15, 14, 14, 0.2);
	transform: translateY(120%);
	opacity: 0;
	transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

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

/* Exit is a distinct motion from the entrance, not just its reverse — a
   quick downward "drop and spin away" (scale down + rotate + fall), on a
   snappier ease-in curve, so dismissing feels like its own deliberate
   flourish rather than the slide-up simply playing backwards. */
.qg-pwa-install.is-leaving .qg-pwa-install__card {
	transform: translateY(140%) scale(0.82) rotate(-6deg);
	opacity: 0;
	transition: transform 0.4s cubic-bezier(0.55, 0, 1, 0.45), opacity 0.35s ease-in;
}

.qg-pwa-install__close {
	position: absolute;
	top: 0.6rem;
	right: 0.7rem;
	width: 26px;
	height: 26px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: rgba(255, 253, 250, 0.12);
	border-radius: 50%;
	color: var(--qg-color-surface);
	font-size: 1.1rem;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s var(--qg-ease);
}

.qg-pwa-install__close:hover {
	background: rgba(255, 253, 250, 0.22);
}

.qg-pwa-install__icon {
	flex-shrink: 0;
}

.qg-pwa-install__icon img {
	width: 52px;
	height: 52px;
	border-radius: 14px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.qg-pwa-install__body {
	flex: 1;
	min-width: 0;
	padding-right: var(--qg-space-4);
}

.qg-pwa-install__title {
	margin: 0 0 0.3rem;
	font-family: var(--qg-font-heading);
	font-size: 1.02rem;
	font-weight: 700;
	color: var(--qg-color-surface);
}

.qg-pwa-install__text {
	margin: 0 0 var(--qg-space-3);
	font-family: var(--qg-font-body);
	font-size: 0.82rem;
	line-height: 1.5;
	color: rgba(255, 253, 250, 0.72);
}

.qg-pwa-install__steps {
	list-style: none;
	margin: 0 0 var(--qg-space-3);
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.qg-pwa-install__steps[hidden] {
	display: none;
}

.qg-pwa-install__steps li {
	display: flex;
	align-items: center;
	gap: 0.55rem;
	font-size: 0.8rem;
	color: rgba(255, 253, 250, 0.85);
}

.qg-pwa-install__step-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	flex-shrink: 0;
	border-radius: 50%;
	background: rgba(255, 253, 250, 0.14);
}

.qg-pwa-install__step-icon .qg-icon {
	width: 13px;
	height: 13px;
}

.qg-pwa-install__actions {
	display: flex;
	align-items: center;
	gap: var(--qg-space-3);
}

.qg-pwa-install__install {
	padding: 0.65rem 1.4rem;
	font-size: 0.85rem;
}

/* .qg-btn sets its own `display` (an author-stylesheet rule of equal
   specificity to, and loaded after, the UA stylesheet's `[hidden]`), so the
   plain `hidden` attribute alone doesn't hide it — needed for the iOS path,
   which hides this button and shows the manual steps list instead. */
.qg-pwa-install__install[hidden] {
	display: none !important;
}

.qg-pwa-install__later {
	border: 0;
	background: none;
	color: rgba(255, 253, 250, 0.65);
	font-family: var(--qg-font-body);
	font-size: 0.82rem;
	font-weight: 600;
	cursor: pointer;
	padding: 0.5rem 0;
	transition: color 0.2s var(--qg-ease);
}

.qg-pwa-install__later:hover {
	color: var(--qg-color-surface);
}

@media (min-width: 640px) {
	.qg-pwa-install {
		justify-content: flex-start;
		padding-left: var(--qg-space-5);
		padding-bottom: var(--qg-space-5);
	}

	.qg-pwa-install__card {
		max-width: 380px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.qg-pwa-install__card {
		transition: opacity 0.3s ease;
		transform: none !important;
	}
}
