/**
 * Tanova PWA — standalone app bar (back + title).
 * Only visible in installed / display-mode: standalone.
 */

.tn-pwa-appbar {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 100050;
	box-sizing: border-box;
	align-items: center;
	gap: 0.35rem;
	min-height: 3rem;
	padding: env(safe-area-inset-top, 0px) 0.5rem 0;
	background: rgba(10, 10, 10, 0.94);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	color: #f5f0e6;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Standalone / installed PWA only */
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
	.tn-pwa-appbar:not(.tn-pwa-appbar--hidden) {
		display: flex;
	}

	body.tn-pwa-standalone {
		/* room for bar + safe area; JS may refine via CSS var */
		padding-top: calc(3rem + env(safe-area-inset-top, 0px)) !important;
	}

	body.tn-pwa-standalone.tn-pwa-home {
		padding-top: env(safe-area-inset-top, 0px) !important;
	}

	/* Slightly tuck the site promo under the app chrome */
	body.tn-pwa-standalone .tn-promo {
		margin-top: 0;
	}
}

/* iOS Safari “Add to Home Screen” (class set by JS) */
html.tn-pwa-ios-standalone .tn-pwa-appbar:not(.tn-pwa-appbar--hidden),
body.tn-pwa-standalone .tn-pwa-appbar:not(.tn-pwa-appbar--hidden) {
	display: flex;
}

html.tn-pwa-ios-standalone body,
body.tn-pwa-standalone {
	padding-top: calc(3rem + env(safe-area-inset-top, 0px)) !important;
}

html.tn-pwa-ios-standalone body.tn-pwa-home,
body.tn-pwa-standalone.tn-pwa-home {
	padding-top: env(safe-area-inset-top, 0px) !important;
}

.tn-pwa-appbar__back {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.15rem;
	min-width: 2.75rem;
	min-height: 2.75rem;
	padding: 0 0.55rem 0 0.35rem;
	margin: 0;
	border: 0;
	background: transparent;
	color: #f5f0e6;
	font: inherit;
	font-size: 0.95rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	cursor: pointer;
	border-radius: 0.5rem;
	-webkit-tap-highlight-color: transparent;
	flex-shrink: 0;
}

.tn-pwa-appbar__back:active {
	opacity: 0.55;
	background: rgba(245, 240, 230, 0.06);
}

.tn-pwa-appbar__chevron {
	display: block;
	width: 0.7rem;
	height: 0.7rem;
	border-left: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	margin-right: 0.15rem;
	flex-shrink: 0;
}

.tn-pwa-appbar__back-label {
	max-width: 6.5rem;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tn-pwa-appbar__titles {
	flex: 1;
	min-width: 0;
	padding-right: 0.75rem;
	text-align: center;
	/* Optical centre when back button is on the left */
	margin-left: -1.5rem;
}

.tn-pwa-appbar__title {
	display: block;
	font-size: 0.95rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	line-height: 1.25;
	color: #fff;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tn-pwa-appbar__parent {
	display: block;
	margin-top: 0.1rem;
	font-size: 0.68rem;
	font-weight: 500;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: rgba(245, 240, 230, 0.55);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.tn-pwa-appbar__parent:empty {
	display: none;
}

/* Hide bar when JS marks home / no need */
.tn-pwa-appbar--hidden {
	display: none !important;
}

/* -------------------------------------------------------------------------
   Bottom tab bar (PWA standalone only)
   ------------------------------------------------------------------------- */

.tn-pwa-tabbar {
	display: none;
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 100050;
	box-sizing: border-box;
	align-items: stretch;
	justify-content: space-around;
	gap: 0.15rem;
	/* Taller bar + extra space under icons for iPhone home-indicator / thumbs */
	min-height: 4.35rem;
	padding: 0.5rem 0.4rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
	background: rgba(10, 10, 10, 0.96);
	border-top: 1px solid rgba(255, 255, 255, 0.08);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
	.tn-pwa-tabbar {
		display: flex;
	}

	body.tn-pwa-standalone {
		padding-bottom: calc(5.15rem + env(safe-area-inset-bottom, 0px)) !important;
	}
}

html.tn-pwa-ios-standalone .tn-pwa-tabbar,
body.tn-pwa-standalone .tn-pwa-tabbar {
	display: flex;
}

html.tn-pwa-ios-standalone body,
body.tn-pwa-standalone {
	padding-bottom: calc(5.15rem + env(safe-area-inset-bottom, 0px)) !important;
}

.tn-pwa-tabbar__item {
	flex: 1 1 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.28rem;
	min-width: 0;
	min-height: 3.25rem;
	padding: 0.4rem 0.25rem 0.55rem;
	margin: 0;
	border: 0;
	border-radius: 0.65rem;
	background: transparent;
	color: rgba(245, 240, 230, 0.48);
	text-decoration: none;
	font: inherit;
	font-size: 0.62rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	-webkit-tap-highlight-color: transparent;
	cursor: pointer;
	transition: color 0.15s ease, background 0.15s ease;
}

.tn-pwa-tabbar__item:active {
	opacity: 0.75;
}

.tn-pwa-tabbar__item.is-active {
	color: #f5f0e6;
	background: rgba(245, 240, 230, 0.07);
}

.tn-pwa-tabbar__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 1.45rem;
	height: 1.45rem;
}

.tn-pwa-tabbar__icon svg {
	display: block;
	width: 1.35rem;
	height: 1.35rem;
	stroke: currentColor;
	fill: none;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* Custom media-library icons (PNG/SVG/WebP) */
.tn-pwa-tabbar__icon img.tn-pwa-tabbar__img,
.tn-pwa-tabbar__img {
	display: block;
	width: 1.35rem;
	height: 1.35rem;
	object-fit: contain;
	opacity: 0.52;
	transition: opacity 0.15s ease;
}

.tn-pwa-tabbar__item.is-active .tn-pwa-tabbar__img {
	opacity: 1;
}

.tn-pwa-tabbar__label {
	display: block;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	line-height: 1.1;
}

/* Book tab: subtle accent so primary action stands out without being loud */
.tn-pwa-tabbar__item[data-tab="book"].is-active,
.tn-pwa-tabbar__item[data-tab="book"] {
	color: #f5f0e6;
}

.tn-pwa-tabbar__item[data-tab="book"]:not(.is-active) {
	color: rgba(245, 240, 230, 0.72);
}
