/**
 * Community app (ECC_App).
 *
 * The tab bar is in every page's markup but only shows when the site runs
 * as an installed app. In an ordinary browser nothing here applies.
 */

.ecc-app-tabs {
	display: none;
}

/* "unread" after the badge number, for screen readers only. Its own rule,
   because ecc-api.css (with .ecc-visually-hidden) is not on every page. */
.ecc-app-tabs__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Install suggestion, built by ECC_App::install_hint(): a small floating
   notice fixed just under the header, in phone browsers only. Under the
   header's layer (z-index 100) so the open hamburger panel covers it, and
   hidden while that panel is open. Top of the screen because the cookie
   banner and the Chaty WhatsApp button already sit at the bottom. */
.ecc-app-hint {
	position: fixed;
	top: calc(var(--header-height, 83px) + 6px);
	left: 12px;
	right: 12px;
	z-index: 99;
	display: flex;
	align-items: center;
	gap: 8px;
	max-width: 480px;
	margin: 0 auto;
	padding: 5px 4px 5px 8px;
	box-sizing: border-box;
	background: var(--color-surface, #fff);
	border: 1px solid var(--color-pill-border);
	border-radius: 12px;
	box-shadow: 0 6px 18px rgba(10, 19, 18, 0.14);
	font-size: 12px;
	line-height: 1.25;
	opacity: 0;
	transform: translateY(-12px);
	transition: opacity 0.25s ease, transform 0.25s ease;
	pointer-events: none;
}

.ecc-app-hint.is-visible {
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

html.menu-open .ecc-app-hint {
	display: none;
}

.ecc-app-hint__icon {
	flex: 0 0 auto;
	width: 24px;
	height: 24px;
	border-radius: 6px;
}

.ecc-app-hint__text {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	color: var(--color-text-muted);
}

.ecc-app-hint__text strong {
	color: #0A1312;
	font-size: 13px;
}

.ecc-app-hint__install {
	flex: 0 0 auto;
	padding: 5px 12px;
	border: 0;
	border-radius: 999px;
	background: var(--color-primary);
	color: #0A1312;
	font: inherit;
	font-size: 12px;
	font-weight: 700;
	cursor: pointer;
}

.ecc-app-hint__close {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--color-text-muted);
	cursor: pointer;
}

.ecc-app-hint__close:hover,
.ecc-app-hint__close:focus-visible {
	background: rgba(10, 19, 18, 0.06);
}

/* "Get the app" card in the hamburger panel, under the menu links (built by
   ECC_App::install_hint(), phones only). A tinted card rather than a menu
   item so it stands out, and not solid green so it does not read as the
   Join button below it. Selector beats the theme's ".main-navigation a". */
.main-navigation a.ecc-app-install {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 12px;
	padding: 12px 14px;
	background: rgba(124, 179, 66, 0.14);
	border: 1.5px solid rgba(124, 179, 66, 0.55);
	border-radius: 12px;
	color: #0A1312;
	font-size: 14px;
	font-weight: 400;
	line-height: 1.3;
	text-decoration: none;
}

.ecc-app-install__icon {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border-radius: 8px;
}

.ecc-app-install__text {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
	font-size: 12px;
	color: var(--color-text-muted);
}

.ecc-app-install__text strong {
	font-size: 15px;
	font-weight: 700;
	color: #0A1312;
}

.ecc-app-install__arrow {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--color-primary);
	color: #0A1312;
}

/* iPhone "how to install" panel (ECC_App::install_hint(), iosHelp()).
   Above everything, the cookie banner and the WhatsApp button included. */
.ecc-app-sheet {
	position: fixed;
	inset: 0;
	z-index: 1000000;
}

.ecc-app-sheet__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 19, 18, 0.45);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.ecc-app-sheet__panel {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	max-width: 520px;
	margin: 0 auto;
	padding: 22px 20px calc(18px + env(safe-area-inset-bottom, 0px));
	box-sizing: border-box;
	background: #ffffff;
	border-radius: 22px 22px 0 0;
	box-shadow: 0 -10px 30px rgba(10, 19, 18, 0.18);
	transform: translateY(100%);
	transition: transform 0.25s ease;
	color: #0A1312;
	font-size: 15px;
	line-height: 1.4;
}

.ecc-app-sheet.is-open .ecc-app-sheet__backdrop {
	opacity: 1;
}

.ecc-app-sheet.is-open .ecc-app-sheet__panel {
	transform: none;
}

.ecc-app-sheet__panel h2 {
	margin: 0 0 16px;
	font-size: 20px;
	font-weight: 800;
	line-height: 1.25;
	letter-spacing: -0.3px;
}

.ecc-app-sheet__panel ol {
	list-style: none;
	margin: 0 0 18px;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.ecc-app-sheet__panel li {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	margin: 0;
}

.ecc-app-sheet__icon {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 12px;
	background: rgba(124, 179, 66, 0.16);
	color: #4A7326;
}

.ecc-app-sheet__num {
	font-size: 17px;
	font-weight: 800;
}

.ecc-app-sheet__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding-top: 2px;
}

.ecc-app-sheet__text small {
	font-size: 13px;
	color: #5A5A54;
}

.ecc-app-sheet__done {
	display: block;
	width: 100%;
	min-height: 50px;
	border: 0;
	border-radius: 999px;
	background: #7CB342;
	color: #0A1312;
	font: inherit;
	font-size: 16px;
	font-weight: 700;
	cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
	.ecc-app-sheet__backdrop,
	.ecc-app-sheet__panel {
		transition: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ecc-app-hint {
		transition: none;
	}
}

@media (display-mode: standalone) {
	.ecc-app-hint {
		display: none;
	}

	/* Room under the page for the tab bar, so the last thing on every page
	   can scroll clear of it. "html body" and !important because an inline
	   "body { padding-bottom: 0 }" printed later in the page won on order
	   and the bottom of every page sat under the bar. */
	html body {
		padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
	}

	/* Anything else pinned to the bottom of the screen goes above the bar:
	   the cookie banner (footer.php, inline bottom: 30px) and the plugin's
	   toast messages (ecc-api.css, bottom: 24px). Full-screen overlays
	   (photo viewer, dialogs) already cover the bar and need nothing. */
	#gdpr-cookie-banner {
		bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
	}

	body .ecc-toast {
		bottom: calc(80px + env(safe-area-inset-bottom, 0px));
	}

	/* The tab bar replaces the footer. The header stays: it holds the
	   notifications bell and the only Log out link. */
	#colophon {
		display: none;
	}

	/* Compact chrome. The site's header and page heroes are sized for a
	   marketing site; in the app they ate half the screen before any
	   content. The theme's own rules are untouched outside the app. */

	/* Header: smaller logo, tighter bar. --header-height is what the theme
	   uses for sticky offsets: 8px x 2 layer + 6px x 2 bar + 34px logo +
	   2px border. */
	:root {
		--header-height: 64px;
	}

	/* No WordPress admin bar in the app, even for staff. Core pushes the page
	   down with "html { margin-top: 32px !important }" (46px on phones), and
	   the theme offsets the sticky header to match; both are undone here.
	   In an ordinary browser the bar is unchanged. */
	#wpadminbar {
		display: none !important;
	}

	html:root {
		margin-top: 0 !important;
	}

	html body.admin-bar .site-header {
		top: 0;
	}

	body .site-header .main-bar {
		padding-top: 6px;
		padding-bottom: 6px;
	}

	body .site-header .site-branding .custom-logo {
		height: 34px;
	}

	/* The open hamburger panel may be as tall as the screen minus the tab
	   bar, and scrolls inside itself past that (the theme allowed the full
	   100dvh, so the tab bar covered its last links). */
	body .site-header:has(.main-navigation.mobile-open) {
		max-height: calc(100vh - 64px - env(safe-area-inset-bottom, 0px));
		max-height: calc(100dvh - 64px - env(safe-area-inset-bottom, 0px));
		overflow-y: auto;
		overscroll-behavior: contain;
	}

	/* Page heroes (Your account, Leaderboard, posts): a title bar, not a
	   banner. */
	body .ecc-hero {
		padding: 20px 0 22px;
	}

	body .ecc-hero .ecc-hero__back {
		margin-bottom: 10px;
		font-size: 13px;
	}

	body .ecc-hero .ecc-hero__title {
		margin: 0;
		font-size: 26px;
		letter-spacing: -0.5px;
	}

	body .ecc-hero .ecc-hero__lead {
		margin: 8px 0 0;
		font-size: 15px;
		line-height: 1.5;
	}

	body .ecc-hero .ecc-hero__meta {
		margin-top: 10px;
		font-size: 13px;
	}

	body .ecc-section {
		padding-top: 24px;
		padding-bottom: 32px;
	}

	body .ecc-section--feed {
		padding-top: 12px;
	}

	/* Chaty's floating WhatsApp button would sit behind the tab bar. The
	   same chat is added to the header menu instead (ECC_App::tabs()).
	   !important and the body prefix because Chaty shows the widget with
	   ".chaty.active { display: block !important }". */
	body .chaty,
	body .chaty.active,
	body .chaty-outer-forms {
		display: none !important;
	}

	/* z-index just under the header's mobile menu panel (1001). */
	.ecc-app-tabs {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 1000;
		display: flex;
		background: var(--color-surface, #fff);
		border-top: 1px solid var(--color-pill-border);
		box-shadow: 0 -4px 16px rgba(10, 19, 18, 0.06);
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}

	.ecc-app-tabs__tab {
		flex: 1 1 0;
		min-width: 0;
		height: 64px;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 3px;
		color: var(--color-text-muted);
		font-size: 11px;
		line-height: 1.2;
		text-decoration: none;
		-webkit-tap-highlight-color: transparent;
	}

	.ecc-app-tabs__tab:hover,
	.ecc-app-tabs__tab:focus {
		text-decoration: none;
	}

	.ecc-app-tabs__tab[aria-current="page"] {
		color: var(--color-primary-on-light);
		font-weight: 700;
	}

	.ecc-app-tabs__icon {
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.ecc-app-tabs__label {
		max-width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	/* Post: icon in a filled green circle. */
	.ecc-app-tabs__tab--post .ecc-app-tabs__icon {
		width: 34px;
		height: 34px;
		border-radius: 50%;
		background: var(--color-primary);
		color: #0A1312;
	}

	.ecc-app-tabs__tab--post .ecc-app-tabs__icon svg {
		width: 20px;
		height: 20px;
	}

	.ecc-app-tabs__badge {
		position: absolute;
		top: -6px;
		right: -10px;
		min-width: 18px;
		height: 18px;
		padding: 0 5px;
		box-sizing: border-box;
		border-radius: 9px;
		background: #D93025;
		color: #fff;
		font-size: 11px;
		font-weight: 700;
		line-height: 18px;
		text-align: center;
	}
}

/* Login and join screens inside the app (wp-login.php gets this stylesheet
   through login_enqueue_scripts). The theme's login styles are inline and
   use !important throughout, hence "html body.login" and !important here.
   The theme stylesheet is not on wp-login.php, so colours are literal. */
@media (display-mode: standalone) {
	html body.login {
		align-items: flex-start !important;
		padding: calc(28px + env(safe-area-inset-top, 0px)) 16px 28px !important;
	}

	html body.login #login h1 a {
		height: 40px !important;
		padding-bottom: 0 !important;
		margin-bottom: 18px !important;
	}

	html body.login #login form {
		padding: 24px 20px !important;
		border-radius: 20px !important;
		box-shadow: 0 10px 30px rgba(10, 19, 18, 0.06) !important;
	}

	/* "Welcome back", added by ECC_App::login_to_feed(). */
	.ecc-app-login-head {
		margin: 0 0 20px;
	}

	.ecc-app-login-head h2 {
		margin: 0 0 4px;
		font-size: 24px;
		font-weight: 800;
		line-height: 1.2;
		letter-spacing: -0.4px;
		color: #0A1312;
	}

	.ecc-app-login-head p {
		margin: 0;
		font-size: 14px;
		line-height: 1.45;
		color: #5A5A54;
	}

	/* 16px stops iPhones zooming into the field on focus. */
	html body.login input[type=text],
	html body.login input[type=password],
	html body.login input[type=email] {
		min-height: 50px !important;
		font-size: 16px !important;
	}

	html body.login .button-primary {
		min-height: 52px !important;
		background: #7CB342 !important;
		border-color: #7CB342 !important;
		color: #0A1312 !important;
		box-shadow: none !important;
	}

	html body.login .button-primary:hover,
	html body.login .button-primary:focus {
		background: #6CA036 !important;
		border-color: #6CA036 !important;
	}

	/* WordPress draws the checkbox, the password eye and focus rings in its
	   own blue (--wp-admin-theme-color); in the app they take the green. */
	html body.login {
		--wp-admin-theme-color: #7CB342;
		--wp-admin-theme-color-darker-10: #6CA036;
		--wp-admin-theme-color-darker-20: #4A7326;
	}

	html body.login input[type=checkbox] {
		width: 24px !important;
		height: 24px !important;
		border: 1.5px solid #7CB342 !important;
		border-radius: 7px !important;
		background: #ffffff !important;
		box-shadow: none !important;
	}

	html body.login input[type=checkbox]:checked {
		background: #7CB342 !important;
		border-color: #7CB342 !important;
	}

	/* Core's tick, drawn dark on the green like the app's buttons. */
	html body.login input[type=checkbox]:checked::before {
		content: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2020%2020%27%3E%3Cpath%20d%3D%27M14.83%204.89l1.34.94-5.81%208.38H9.02L5.78%209.67l1.34-1.25%202.57%202.4z%27%20fill%3D%27%230A1312%27%2F%3E%3C%2Fsvg%3E") !important;
	}

	html body.login .wp-hide-pw,
	html body.login .wp-hide-pw .dashicons {
		color: #4A7326 !important;
	}

	html body.login .ecomcademy-login-register .button-secondary {
		border-color: #7CB342 !important;
		color: #4A7326 !important;
	}

	html body.login #nav,
	html body.login #backtoblog {
		margin-top: 14px !important;
		font-size: 15px !important;
	}

	/* Join: the form first. The marketing list and the meetup photo stay on
	   the page in a browser; in the app the title and one line lead in. */
	body .join-body--intro {
		padding-top: 16px;
	}

	body .join-page .join-grid {
		gap: 18px;
	}

	body .join-info > h2,
	body .join-info .join-list,
	body .join-info .join-photo {
		display: none;
	}

	body .join-intro h1 {
		margin-bottom: 6px;
		font-size: 26px;
		letter-spacing: -0.5px;
	}

	body .join-info .join-intro__lead {
		margin-bottom: 0;
		font-size: 15px;
		line-height: 1.5;
	}

	/* The form card sat 36px from the screen edge (section 20px + container
	   16px) with 18px inside it. In the app: 12px outside, 16px inside. */
	body .join-page .join-body {
		padding-left: 0;
		padding-right: 0;
	}

	body .join-page .join-body > .container {
		padding-left: 12px;
		padding-right: 12px;
	}

	body .join-page .join-intro {
		padding: 0 6px;
	}

	body .join-page .join-form-card {
		padding: 22px 16px;
		border-radius: 20px;
	}

	body .join-page input[type="checkbox"] {
		accent-color: #7CB342;
	}

	body .join-field input[type="text"],
	body .join-field input[type="email"],
	body .join-field input[type="password"] {
		min-height: 50px;
		font-size: 16px;
	}
}

/* Pull to refresh and the "New posts" pill (ECC_App::app_extras()), and
   page transitions. App only. */
@media (display-mode: standalone) {
	.ecc-app-ptr {
		position: fixed;
		top: calc(var(--header-height, 64px) + 4px);
		left: 50%;
		z-index: 99;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 38px;
		height: 38px;
		border-radius: 50%;
		background: #ffffff;
		color: #4A7326;
		box-shadow: 0 4px 14px rgba(10, 19, 18, 0.16);
		opacity: 0;
		transform: translate(-50%, 0);
		pointer-events: none;
	}

	.ecc-app-ptr.is-ready {
		background: #7CB342;
		color: #0A1312;
	}

	.ecc-app-ptr.is-loading svg {
		animation: ecc-app-spin 0.7s linear infinite;
	}

	@keyframes ecc-app-spin {
		to { transform: rotate(360deg); }
	}

	.ecc-app-newposts {
		position: fixed;
		top: calc(var(--header-height, 64px) + 10px);
		left: 50%;
		z-index: 99;
		transform: translateX(-50%);
		padding: 9px 16px;
		border: 0;
		border-radius: 999px;
		background: #0A1312;
		color: #ffffff;
		font: inherit;
		font-size: 13px;
		font-weight: 700;
		box-shadow: 0 6px 18px rgba(10, 19, 18, 0.25);
		cursor: pointer;
		white-space: nowrap;
	}

	html.menu-open .ecc-app-newposts,
	html.menu-open .ecc-app-ptr {
		display: none;
	}
}

/* Pages fade into each other instead of flashing white between taps. The
   header and the tab bar stay put. Browsers without cross-document view
   transitions ignore this; nobody who asked for reduced motion gets it. */
@media (display-mode: standalone) and (prefers-reduced-motion: no-preference) {
	@view-transition {
		navigation: auto;
	}

	.site-header {
		view-transition-name: ecc-app-header;
	}

	.ecc-app-tabs {
		view-transition-name: ecc-app-tabs;
	}

	::view-transition-old(root),
	::view-transition-new(root) {
		animation-duration: 0.18s;
	}
}
