/*
 * Spacehopper App — phone fixes for the website, plus installed-app chrome.
 * Uses the marketplace design tokens; brand navy #0B2A5B, orange #FF6A00.
 */

/* ------------------------------------------------------------------ *
 * Phone fixes for everyone on the website (browser or installed)
 * ------------------------------------------------------------------ */
@media (max-width: 768px) {
	/* iOS zooms the whole page when a field under 16px is focused —
	   the search filters (14.4px) and file pickers (14.7px) did this. */
	input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="range"]),
	select,
	textarea { font-size: 16px !important; }

	/* File pickers (listing photos, proof, message artwork): a full-width, thumb-sized target. */
	input[type="file"] { min-height: 48px; padding: 12px; }
	input[type="file"]::file-selector-button { min-height: 36px; padding: 6px 14px; margin-right: 12px; border-radius: 6px; border: 1px solid var(--plm-border-strong, #c9ced8); background: #fff; color: #0B2A5B; font: inherit; font-weight: 650; }

	/* Conversations: one page scroll instead of a cramped scroll box inside the page. */
	.plm-messages { max-height: none; overflow: visible; padding-right: 0; }
	.plm-message { max-width: 92%; overflow-wrap: anywhere; }
	.plm-message-composer .plm-btn[type="submit"] { width: 100%; }
	.plm-message-composer textarea { min-height: 120px; }

	/* Keep focused fields clear of the sticky header and the app bar. */
	input, select, textarea { scroll-margin-top: 96px; scroll-margin-bottom: 96px; }

	/* Long words, URLs and references in cards never force sideways scrolling. */
	.plm-card, .plm-notification__text, .plm-thread-item { overflow-wrap: anywhere; }
}

/* ------------------------------------------------------------------ *
 * Installed app (display-mode standalone / iOS Home Screen)
 * ------------------------------------------------------------------ */
.sh-appnav { display: none; }

@media (display-mode: standalone) {
	html { --sh-appnav-h: 60px; }
}
html.sh-standalone { --sh-appnav-h: 60px; }

@media (display-mode: standalone) {
	.plt-header { padding-top: env(safe-area-inset-top); }
	.plt-header__inner, .plt-footer .plm-wrap, #plt-main { padding-left: max(env(safe-area-inset-left), 0px); padding-right: max(env(safe-area-inset-right), 0px); }
}
html.sh-standalone .plt-header { padding-top: env(safe-area-inset-top); }

@media (display-mode: standalone) and (max-width: 1024px) {
	.sh-appnav { display: flex; }
	body { padding-bottom: calc(var(--sh-appnav-h) + env(safe-area-inset-bottom)); }
	html { scroll-padding-bottom: calc(var(--sh-appnav-h) + env(safe-area-inset-bottom) + 12px); }
}
@media (max-width: 1024px) {
	html.sh-standalone .sh-appnav { display: flex; }
	html.sh-standalone body { padding-bottom: calc(var(--sh-appnav-h) + env(safe-area-inset-bottom)); }
	html.sh-standalone { scroll-padding-bottom: calc(var(--sh-appnav-h) + env(safe-area-inset-bottom) + 12px); }
}

.sh-appnav {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	z-index: 90; /* Below the theme's mobile menu panel (header z-index 100). */
	justify-content: space-around;
	align-items: stretch;
	background: #fff;
	border-top: 1px solid var(--plm-border, #e2e5eb);
	box-shadow: 0 -2px 12px rgba(11, 42, 91, .06);
	padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
	font-family: var(--plm-font-body, inherit);
}
.sh-appnav__item {
	flex: 1 1 0;
	min-width: 0;
	min-height: var(--sh-appnav-h, 60px);
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
	color: #526071;
	text-decoration: none;
	font-size: 0.72rem; font-weight: 650; line-height: 1.1;
	-webkit-tap-highlight-color: transparent;
}
.sh-appnav__item[aria-current="page"] { color: #0B2A5B; }
.sh-appnav__item[aria-current="page"] .sh-appnav__icon::after {
	content: ""; position: absolute; left: 50%; bottom: -5px; width: 18px; height: 3px; margin-left: -9px; border-radius: 3px; background: #FF6A00;
}
.sh-appnav__item:focus-visible { outline: 3px solid #0B2A5B; outline-offset: -3px; border-radius: 8px; }
.sh-appnav__icon { position: relative; display: inline-flex; }
.sh-appnav__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.sh-appnav__badge {
	position: absolute; top: -6px; left: 15px;
	min-width: 18px; height: 18px; padding: 0 5px;
	border-radius: 9px; background: #FF6A00; color: #0B2A5B;
	font-size: 0.68rem; font-weight: 800; line-height: 18px; text-align: center;
}
/* While typing, the keyboard owns the bottom of the screen. */
html.sh-typing .sh-appnav, html.sh-keyboard .sh-appnav { display: none !important; }
/* The theme's open mobile menu covers the page; keep the app bar out of its way. */
body:has(.plt-nav-toggle[aria-expanded="true"]) .sh-appnav { display: none !important; }

/* ------------------------------------------------------------------ *
 * Install invitation, toast, push card
 * ------------------------------------------------------------------ */
.sh-install {
	position: fixed;
	left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
	bottom: calc(12px + env(safe-area-inset-bottom));
	z-index: 95;
	display: flex; gap: 12px; align-items: flex-start;
	max-width: 520px; margin: 0 auto;
	padding: 16px 44px 16px 16px;
	background: #fff; color: #0B2A5B;
	border: 1px solid var(--plm-border, #e2e5eb); border-top: 3px solid #FF6A00; border-radius: 12px;
	box-shadow: 0 8px 28px rgba(11, 42, 91, .18);
	font-family: var(--plm-font-body, inherit);
}
.sh-install__icon { flex: 0 0 44px; border-radius: 10px; }
.sh-install__body { min-width: 0; }
.sh-install__title { font-size: 1rem; margin: 0 0 4px; line-height: 1.3; color: #0B2A5B; }
.sh-install__text, .sh-install__steps { margin: 0 0 10px; font-size: 0.9rem; line-height: 1.5; color: #334155; }
.sh-install__steps { padding-left: 1.2em; }
.sh-install__steps li { margin-bottom: 4px; }
.sh-install__share { display: inline-flex; vertical-align: -3px; color: #0B2A5B; }
.sh-install__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sh-install__actions .plm-btn { min-height: 44px; }
.sh-install__close {
	position: absolute; top: 4px; right: 4px;
	width: 44px; height: 44px; border: 0; background: none; color: #526071;
	font-size: 1.6rem; line-height: 1; cursor: pointer; border-radius: 8px;
}
.sh-install__close:focus-visible { outline: 3px solid #0B2A5B; }

.sh-toast {
	position: fixed;
	left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
	bottom: calc(12px + env(safe-area-inset-bottom));
	z-index: 120;
	max-width: 520px; margin: 0 auto;
	padding: 14px 16px;
	background: #0B2A5B; color: #fff; border-radius: 10px;
	font-size: 0.95rem; line-height: 1.45; font-weight: 600;
	box-shadow: 0 8px 28px rgba(11, 42, 91, .25);
	transform: translateY(150%); opacity: 0;
	transition: transform .2s ease, opacity .2s ease;
	pointer-events: none;
}
.sh-toast.is-visible { transform: none; opacity: 1; }
html.sh-standalone .sh-toast, html.sh-standalone .sh-install { bottom: calc(var(--sh-appnav-h, 60px) + 12px + env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) { .sh-toast { transition: none; } }

.sh-push { margin-top: 24px; }
.sh-push__text { margin: 8px 0 14px; line-height: 1.55; }
.sh-push__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sh-push__actions .plm-btn { min-height: 44px; }
.sh-push__status { margin: 12px 0 0; font-weight: 600; color: #0B2A5B; }
.sh-push__status:empty { display: none; }
@media (max-width: 560px) { .sh-push__actions .plm-btn { flex: 1 1 100%; } }
