/*
 * pwa.css — только то, что относится к приложению:
 * нижняя панель, приглашение установить, уведомление об обновлении,
 * страница «нет интернета».
 *
 * Существующую вёрстку не меняем: нижняя панель по умолчанию появляется
 * только в установленном приложении (display-mode: standalone), в обычном
 * браузере ни один селектор ниже не срабатывает. Штатная мобильная панель
 * .tab-bar в standalone прячется — её место занимает панель приложения.
 */

/* =============== Экран загрузки приложения =============== */

/*
 * Показывается один раз за запуск приложения. Виден только когда <html>
 * помечен как aqsham-standalone и заставка ещё не была показана в этой
 * сессии — классы ставит инлайн-скрипт в <head> до первой отрисовки.
 *
 * Логотип — жёлтая эмблема с белым текстом (logo-mobile), поэтому фон
 * именно чёрный: и заставка, и maskable-иконки на одной подложке.
 */

.pwa-splash {
	display: none;
}

html.aqsham-standalone:not(.aqsham-splash-off) .pwa-splash {
	position: fixed;
	inset: 0;
	/* Выше шапки и мобильного меню — заставка перекрывает всё. */
	z-index: 100010;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 44px;
	background: #000;
	opacity: 1;
	transition: opacity 0.45s ease;
	/*
	 * Страховка без участия JS: если скрипт почему-то не отработал, заставка
	 * всё равно уйдёт сама и не запрёт приложение на чёрном экране.
	 */
	animation: pwa-splash-failsafe 0.6s ease 8s forwards;
}

.pwa-splash.is-hidden {
	opacity: 0;
	pointer-events: none;
}

.pwa-splash__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Мягкое жёлтое свечение под логотипом — медленно «дышит». */
.pwa-splash__glow {
	position: absolute;
	width: 128%;
	aspect-ratio: 1;
	border-radius: 50%;
	background:
		radial-gradient(circle at 38% 50%, rgba(255, 228, 0, 0.45), transparent 62%),
		radial-gradient(circle at 62% 50%, rgba(249, 200, 70, 0.4), transparent 62%);
	filter: blur(38px);
	opacity: 0.45;
	animation: pwa-splash-breathe 2.8s ease-in-out infinite alternate;
}

.pwa-splash__logo {
	position: relative;
	display: block;
	width: min(70vw, 380px);
	aspect-ratio: 113 / 32;
	background: url("../img/pwa/splash-logo.png") center / contain no-repeat;
	opacity: 0;
	transform: translateY(10px) scale(0.96);
	animation: pwa-splash-in 0.75s cubic-bezier(0.22, 0.7, 0.3, 1) forwards;
}

/* Тонкая полоса: по ней бежит короткий жёлтый отрезок. */
.pwa-splash__bar {
	position: relative;
	width: 132px;
	height: 2px;
	overflow: hidden;
	background: rgba(255, 255, 255, 0.12);
	border-radius: 999px;
	opacity: 0;
	animation: pwa-splash-fade 0.5s ease 0.35s forwards;
}

.pwa-splash__bar i {
	position: absolute;
	top: 0;
	left: 0;
	width: 42%;
	height: 100%;
	border-radius: inherit;
	background: linear-gradient(90deg, var(--yellow-500), var(--gold));
	animation: pwa-splash-sweep 1.25s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes pwa-splash-failsafe {
	to {
		opacity: 0;
		visibility: hidden;
	}
}

@keyframes pwa-splash-in {
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@keyframes pwa-splash-fade {
	to {
		opacity: 1;
	}
}

@keyframes pwa-splash-breathe {
	from {
		opacity: 0.32;
		transform: scale(0.94);
	}
	to {
		opacity: 0.7;
		transform: scale(1.06);
	}
}

@keyframes pwa-splash-sweep {
	from {
		transform: translateX(-105%);
	}
	to {
		transform: translateX(348%);
	}
}

/* Пользователь просил меньше движения — оставляем статичный логотип. */
@media (prefers-reduced-motion: reduce) {
	/* Анимацию-страховку (.pwa-splash) намеренно не трогаем. */
	.pwa-splash__logo,
	.pwa-splash__glow,
	.pwa-splash__bar,
	.pwa-splash__bar i {
		animation: none;
	}
	.pwa-splash__logo,
	.pwa-splash__bar {
		opacity: 1;
		transform: none;
	}
}

/* =============== Нижняя панель навигации =============== */

.aqsham-bottombar {
	display: none;
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 150;
	align-items: stretch;
	background: var(--text-dark-900);
	border-top: 1px solid #404040;
	padding-bottom: env(safe-area-inset-bottom, 0px);
	box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.25);
}

/* Приложение установлено — панель нужна. */
@media (display-mode: standalone) {
	.aqsham-bottombar {
		display: flex;
	}
}
@media (display-mode: fullscreen) {
	.aqsham-bottombar {
		display: flex;
	}
}
/* iOS отдаёт standalone через navigator.standalone — класс ставит pwa.js. */
html.aqsham-standalone .aqsham-bottombar {
	display: flex;
}

/* Режим «и на телефонах в браузере» — включается в настройках темы. */
@media (max-width: 700px) {
	.aqsham-bottombar--mobile {
		display: flex;
	}
}

/*
 * Штатная мобильная панель темы (.tab-bar) уступает место панели приложения —
 * иначе внизу было бы две полосы навигации.
 */
html.aqsham-standalone .tab-bar {
	display: none !important;
}
@media (display-mode: standalone) {
	.tab-bar {
		display: none !important;
	}
}
@media (display-mode: fullscreen) {
	.tab-bar {
		display: none !important;
	}
}
@media (max-width: 700px) {
	body:has(.aqsham-bottombar--mobile) .tab-bar {
		display: none !important;
	}
}

.aqsham-bottombar__item {
	flex: 1 1 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	min-width: 0;
	height: 58px;
	padding: 6px 2px;
	color: var(--text-gray-200);
	text-decoration: none;
	-webkit-tap-highlight-color: transparent;
	transition: color 0.18s ease;
}

.aqsham-bottombar__item:hover,
.aqsham-bottombar__item:focus-visible {
	color: #ffffff;
}

.aqsham-bottombar__item.is-active {
	color: var(--yellow-500);
}

.aqsham-bottombar__ico {
	position: relative;
	display: block;
	width: 24px;
	height: 24px;
}

.aqsham-bottombar__icon {
	display: block;
	width: 24px;
	height: 24px;
}

.aqsham-bottombar__label {
	max-width: 100%;
	overflow: hidden;
	font-size: 11px;
	line-height: 1.1;
	letter-spacing: -0.01em;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.aqsham-bottombar__count {
	position: absolute;
	top: -5px;
	left: 13px;
	min-width: 17px;
	height: 17px;
	padding: 0 4px;
	background: var(--yellow-500);
	border-radius: 999px;
	color: var(--text-near-black);
	font-size: 10px;
	font-weight: var(--fw-medium);
	line-height: 17px;
	text-align: center;
}

.aqsham-bottombar__count[hidden] {
	display: none;
}

/*
 * Панель перекрывает низ страницы — добавляем отступ ровно там, где она
 * показана. Обычный сайт в браузере остаётся без изменений.
 */
@media (display-mode: standalone) {
	body {
		padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
	}
}
@media (display-mode: fullscreen) {
	body {
		padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
	}
}
html.aqsham-standalone body {
	padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 700px) {
	body:has(.aqsham-bottombar--mobile) {
		padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
	}
}

/* =============== Приглашение установить =============== */

.pwa-install {
	position: fixed;
	left: 24px;
	right: 24px;
	bottom: 24px;
	z-index: 260;
	display: flex;
	align-items: center;
	gap: 16px;
	max-width: 640px;
	margin-inline: auto;
	padding: 16px 20px;
	background: var(--text-dark-900);
	color: #ffffff;
	/* Тонкая рамка: на тёмном подвале баннер иначе сливается с фоном. */
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
	transform: translateY(160%);
	transition: transform 0.35s ease;
}

.pwa-install.is-visible {
	transform: translateY(0);
}

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

.pwa-install__icon {
	flex: none;
	width: 48px;
	height: 48px;
	border-radius: 10px;
}

.pwa-install__body {
	flex: 1 1 auto;
	min-width: 0;
}

.pwa-install__title {
	margin: 0 0 2px;
	font-size: 16px;
	font-weight: var(--fw-medium);
	letter-spacing: var(--ls-base);
}

.pwa-install__text {
	margin: 0;
	font-size: 13px;
	line-height: 1.4;
	color: rgba(255, 255, 255, 0.75);
}

.pwa-install__actions {
	flex: none;
	display: flex;
	align-items: center;
	gap: 8px;
}

.pwa-install__btn {
	height: 40px;
	padding: 0 20px;
	background: var(--yellow-500);
	border: 0;
	border-radius: 999px;
	color: var(--text-near-black);
	font-family: var(--font-main);
	font-weight: var(--fw-medium);
	font-size: 14px;
	letter-spacing: var(--ls-base);
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.pwa-install__btn:hover {
	background: #ffffff;
	color: var(--text-black);
}

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

.pwa-install__later {
	height: 40px;
	padding: 0 12px;
	background: none;
	border: 0;
	color: rgba(255, 255, 255, 0.7);
	font-family: var(--font-main);
	font-size: 14px;
	cursor: pointer;
	transition: color 0.2s ease;
}

.pwa-install__later:hover {
	color: #ffffff;
}

@media (max-width: 700px) {
	.pwa-install {
		left: 12px;
		right: 12px;
		bottom: 12px;
		flex-wrap: wrap;
		gap: 12px;
		padding: 16px;
	}
	.pwa-install__icon {
		width: 40px;
		height: 40px;
	}
	.pwa-install__actions {
		width: 100%;
	}
	.pwa-install__btn {
		flex: 1 1 auto;
	}
}

/* =============== Уведомление об обновлении =============== */

.pwa-toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	z-index: 270;
	display: flex;
	align-items: center;
	gap: 16px;
	/* По содержимому, но не шире экрана: иначе flex сжимает его в столбик. */
	width: max-content;
	max-width: calc(100% - 48px);
	padding: 12px 16px 12px 20px;
	background: var(--text-dark-900);
	color: #ffffff;
	border-radius: 999px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
	transform: translate(-50%, 160%);
	transition: transform 0.35s ease;
}

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

.pwa-toast__text {
	flex: 1 1 auto;
	font-size: 14px;
	line-height: 1.35;
	letter-spacing: var(--ls-base);
}

.pwa-toast__btn {
	flex: none;
	height: 34px;
	padding: 0 16px;
	background: var(--yellow-500);
	border: 0;
	border-radius: 999px;
	color: var(--text-near-black);
	font-family: var(--font-main);
	font-weight: var(--fw-medium);
	font-size: 13px;
	cursor: pointer;
}

.pwa-toast__btn:hover {
	background: #ffffff;
	color: var(--text-black);
}

html.aqsham-standalone .pwa-toast {
	bottom: calc(16px + 58px + env(safe-area-inset-bottom, 0px));
}
@media (display-mode: standalone) {
	.pwa-toast {
		bottom: calc(16px + 58px + env(safe-area-inset-bottom, 0px));
	}
}

/* =============== Страница «нет интернета» =============== */

.pwa-offline {
	max-width: 560px;
	margin: 0 auto;
	padding: 48px 24px 64px;
	text-align: center;
}

.pwa-offline__title {
	margin: 0 0 12px;
	font-size: 32px;
	font-weight: var(--fw-bold);
	color: var(--text-dark-900);
}

.pwa-offline__text {
	margin: 0 0 8px;
	font-size: 16px;
	line-height: 1.5;
	color: var(--text-gray-600);
}

.pwa-offline__hint {
	margin: 0 0 32px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--text-gray-500);
}

.pwa-offline__icon {
	display: block;
	width: 88px;
	height: 88px;
	margin: 0 auto 24px;
	color: var(--yellow-450);
}

.pwa-offline__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 12px;
}

.pwa-offline__btn {
	height: 48px;
	display: inline-flex;
	align-items: center;
	padding: 0 32px;
	background: var(--yellow-500);
	border: 0;
	border-radius: 999px;
	color: var(--text-near-black);
	font-family: var(--font-main);
	font-weight: var(--fw-medium);
	font-size: 16px;
	letter-spacing: var(--ls-base);
	text-decoration: none;
	cursor: pointer;
}

.pwa-offline__btn--ghost {
	background: var(--bg-gray-100);
	color: var(--text-dark-900);
}

@media (max-width: 700px) {
	.pwa-offline {
		padding: 32px 16px 48px;
	}
	.pwa-offline__title {
		font-size: 24px;
	}
}

/* =============== Кнопка установки (постоянная, справа снизу) =============== */

.pwa-fab {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 250;
	display: none;
}

/* Показываем, только когда установка возможна (класс ставит pwa.js). */
.pwa-fab.is-visible {
	display: block;
	animation: pwa-fab-in 0.35s ease both;
}

/* Уже установлено — кнопка не нужна ни в одном из режимов. */
html.aqsham-standalone .pwa-fab,
.pwa-fab[hidden] {
	display: none !important;
}

/*
 * Открыт оверлей темы (бургер-меню, мобильный поиск, каталог) — кнопка и
 * баннер установки не должны лежать поверх него.
 */
body:has(.burger.is-open) .pwa-fab,
body:has(.burger.is-open) .pwa-install,
body:has(.search-mobile.is-open) .pwa-fab,
body:has(.search-mobile.is-open) .pwa-install,
body:has(.header__catalog.is-open) .pwa-fab,
body:has(.header__catalog.is-open) .pwa-install,
body:has(.nav__catalog.is-open) .pwa-fab,
body:has(.nav__catalog.is-open) .pwa-install {
	display: none !important;
}
@media (display-mode: standalone) {
	.pwa-fab {
		display: none !important;
	}
}
@media (display-mode: fullscreen) {
	.pwa-fab {
		display: none !important;
	}
}

@keyframes pwa-fab-in {
	from {
		opacity: 0;
		transform: translateY(16px) scale(0.96);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.pwa-fab__btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 48px;
	padding: 0 20px;
	background: var(--yellow-500);
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 999px;
	color: var(--text-near-black);
	font-family: var(--font-main);
	font-weight: var(--fw-medium);
	font-size: 14px;
	letter-spacing: var(--ls-base);
	white-space: nowrap;
	cursor: pointer;
	box-shadow: 0 10px 28px rgba(232, 184, 0, 0.4);
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.pwa-fab__btn:hover {
	background: var(--text-dark-900);
	color: var(--yellow-500);
	transform: translateY(-2px);
}

.pwa-fab__btn:active {
	transform: translateY(0);
}

.pwa-fab__icon {
	flex: none;
	width: 20px;
	height: 20px;
}

/* Баннер установки и кнопка не должны налезать друг на друга. */
.pwa-fab.is-above-banner {
	bottom: calc(24px + 96px);
}

/* Нижняя панель приложения — поднимаем кнопку над ней. */
html.aqsham-standalone .pwa-fab.is-visible {
	bottom: calc(24px + 58px + env(safe-area-inset-bottom, 0px));
}

/* --- Адаптив: на телефоне широкая кнопка во всю ширину с текстом --- */
@media (max-width: 700px) {
	.pwa-fab {
		left: 12px;
		right: 12px;
		/* Над штатной мобильной панелью темы (.tab-bar, 60px). */
		bottom: calc(12px + 60px);
	}
	.pwa-fab.is-visible {
		display: flex;
	}
	.pwa-fab__btn {
		width: 100%;
		height: 52px;
		justify-content: center;
		padding: 0 16px;
		font-size: 16px;
	}
	.pwa-fab__btn:hover {
		transform: none;
	}
	.pwa-fab__icon {
		width: 22px;
		height: 22px;
	}
	.pwa-fab.is-above-banner {
		bottom: calc(12px + 60px + 132px);
	}
	/* Мобильная нижняя панель приложения в браузере, если включена в настройках. */
	body:has(.aqsham-bottombar--mobile) .pwa-fab {
		bottom: calc(12px + 58px + env(safe-area-inset-bottom, 0px));
	}
	body:has(.aqsham-bottombar--mobile) .pwa-fab.is-above-banner {
		bottom: calc(12px + 58px + 132px + env(safe-area-inset-bottom, 0px));
	}
}
