/**
 * PWA for Fluent Community — estilos de front-end.
 *
 * Escopo estreito de propósito: todo seletor começa com .pwafc- e nada
 * seleciona elementos do tema. Um plugin que estiliza body, a ou button
 * quebra temas alheios de formas difíceis de diagnosticar.
 *
 * As cores herdam de variáveis CSS com fallback, então o tema pode
 * sobrescrever sem !important.
 */

.pwafc-prompt,
.pwafc-bulletin {
	--pwafc-bg: var( --pwafc-color-bg, #ffffff );
	--pwafc-fg: var( --pwafc-color-fg, #1a1a1a );
	--pwafc-muted: var( --pwafc-color-muted, #5c5c5c );
	--pwafc-accent: var( --pwafc-color-accent, #1e40af );
	--pwafc-accent-fg: var( --pwafc-color-accent-fg, #ffffff );
	--pwafc-border: var( --pwafc-color-border, rgba( 0, 0, 0, 0.12 ) );

	box-sizing: border-box;
	font-family: inherit;
	font-size: 15px;
	line-height: 1.45;
	color: var( --pwafc-fg );
}

.pwafc-prompt *,
.pwafc-bulletin * {
	box-sizing: border-box;
}

/* ------------------------------------------------------------------ */
/* Prompts flutuantes                                                  */
/* ------------------------------------------------------------------ */

.pwafc-prompt {
	position: fixed;
	z-index: 99999;
	left: 50%;
	bottom: 16px;
	width: calc( 100% - 32px );
	max-width: 420px;
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 16px;
	background: var( --pwafc-bg );
	border: 1px solid var( --pwafc-border );
	border-radius: 14px;
	box-shadow: 0 12px 32px rgba( 0, 0, 0, 0.16 );

	/* Começa fora da tela e sem interatividade, para animar a entrada
	   sem causar layout shift no carregamento. */
	transform: translate( -50%, 130% );
	opacity: 0;
	pointer-events: none;
	transition: transform 0.28s ease, opacity 0.28s ease;
}

.pwafc-prompt.is-visible {
	transform: translate( -50%, 0 );
	opacity: 1;
	pointer-events: auto;
}

.pwafc-prompt__icon {
	width: 44px;
	height: 44px;
	border-radius: 10px;
	flex: 0 0 auto;
	object-fit: cover;
}

.pwafc-prompt__content {
	flex: 1 1 auto;
	min-width: 0;
}

.pwafc-prompt__title {
	display: block;
	font-size: 15px;
	font-weight: 600;
	margin-bottom: 2px;
}

.pwafc-prompt__body {
	margin: 0;
	font-size: 13.5px;
	color: var( --pwafc-muted );
}

.pwafc-prompt__actions {
	display: flex;
	flex-direction: column;
	gap: 6px;
	flex: 0 0 auto;
}

/* ------------------------------------------------------------------ */
/* Botões                                                              */
/* ------------------------------------------------------------------ */

.pwafc-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 8px 14px;
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.2;
	border: 1px solid transparent;
	border-radius: 8px;
	cursor: pointer;
	text-decoration: none;
	white-space: nowrap;
	transition: opacity 0.15s ease;
}

.pwafc-btn:hover {
	opacity: 0.88;
}

/* Foco visível: remover o outline sem repor um indicador torna o
   componente inutilizável por teclado. */
.pwafc-btn:focus-visible,
.pwafc-bulletin__close:focus-visible {
	outline: 2px solid var( --pwafc-accent );
	outline-offset: 2px;
}

.pwafc-btn--primary {
	background: var( --pwafc-accent );
	color: var( --pwafc-accent-fg );
}

.pwafc-btn--ghost {
	background: transparent;
	color: var( --pwafc-muted );
	border-color: var( --pwafc-border );
}

/* ------------------------------------------------------------------ */
/* Mural                                                               */
/* ------------------------------------------------------------------ */

.pwafc-bulletin {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 14px 16px;
	background: var( --pwafc-bg );
	border: 1px solid var( --pwafc-border );
	border-radius: 12px;
	opacity: 0;
	transition: opacity 0.28s ease, transform 0.28s ease;
}

.pwafc-bulletin.is-visible {
	opacity: 1;
}

.pwafc-bulletin__image {
	width: 48px;
	height: 48px;
	border-radius: 8px;
	object-fit: cover;
	flex: 0 0 auto;
}

.pwafc-bulletin__content {
	flex: 1 1 auto;
	min-width: 0;
}

.pwafc-bulletin__title {
	display: block;
	font-weight: 600;
	margin-bottom: 3px;
}

.pwafc-bulletin__body p:first-child {
	margin-top: 0;
}

.pwafc-bulletin__body p:last-child {
	margin-bottom: 0;
}

.pwafc-bulletin__actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex: 0 0 auto;
}

/*
 * ALVO DE TOQUE, NÃO ÍCONE.
 *
 * Este botão tinha 22px de fonte e 2px de padding — algo em torno de 26×20
 * reais. As diretrizes de acessibilidade pedem no mínimo 44×44 para toque, e a
 * consequência de ficar abaixo disso não é estética: a pessoa erra, acerta o
 * conteúdo atrás, e o aviso não fecha. Num mural que reaparece, isso vira
 * irritação com o app inteiro.
 *
 * A área cresce; o desenho do "×" não. Por isso o tamanho vem de width/height
 * com centralização, e não de font-size.
 */
.pwafc-bulletin__close {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;

	width: 44px;
	height: 44px;
	padding: 0;

	background: none;
	border: 0;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	color: var( --pwafc-muted );
	border-radius: 50%;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.pwafc-bulletin__close:hover {
	background: rgba( 127, 127, 127, 0.14 );
	color: inherit;
}

/* Banner e toast flutuam; inline fica no fluxo da página. */
.pwafc-bulletin--banner,
.pwafc-bulletin--toast {
	position: fixed;
	z-index: 99998;
	left: 50%;
	width: calc( 100% - 32px );
	max-width: 640px;
	transform: translate( -50%, 20px );
	box-shadow: 0 8px 24px rgba( 0, 0, 0, 0.14 );
}

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

.pwafc-bulletin--banner {
	top: 16px;
}

.pwafc-bulletin--toast {
	bottom: 16px;
	max-width: 420px;
}

.pwafc-bulletin--bottom {
	top: auto;
	bottom: 16px;
}

.pwafc-bulletin--inline {
	margin: 0 0 12px;
}

.pwafc-bulletin--modal {
	position: fixed;
	z-index: 100000;
	top: 50%;
	left: 50%;
	width: calc( 100% - 32px );
	max-width: 480px;
	transform: translate( -50%, -46% );
	flex-direction: column;
	box-shadow: 0 24px 64px rgba( 0, 0, 0, 0.28 );
}

.pwafc-bulletin--modal.is-visible {
	transform: translate( -50%, -50% );
}

.pwafc-mural {
	margin: 0 0 16px;
}

.pwafc-mural--empty {
	display: none;
}

/* ------------------------------------------------------------------ */
/* Tema escuro e acessibilidade                                        */
/* ------------------------------------------------------------------ */

@media ( prefers-color-scheme: dark ) {
	.pwafc-prompt,
	.pwafc-bulletin {
		--pwafc-color-bg: #1c1c1e;
		--pwafc-color-fg: #f2f2f7;
		--pwafc-color-muted: #a1a1aa;
		--pwafc-color-border: rgba( 255, 255, 255, 0.14 );
		--pwafc-color-accent: #60a5fa;
		--pwafc-color-accent-fg: #0b1220;
	}
}

/* Respeita quem pediu menos animação no sistema — para parte das pessoas
   isso não é preferência estética, é o que evita enjoo. */
@media ( prefers-reduced-motion: reduce ) {
	.pwafc-prompt,
	.pwafc-bulletin {
		transition: opacity 0.01ms;
		transform: none;
	}

	.pwafc-prompt.is-visible,
	.pwafc-bulletin.is-visible {
		transform: none;
	}

	.pwafc-prompt {
		left: auto;
		right: 16px;
	}

	.pwafc-bulletin--banner,
	.pwafc-bulletin--toast,
	.pwafc-bulletin--modal {
		left: auto;
		right: 16px;
	}
}

@media ( max-width: 480px ) {
	.pwafc-prompt {
		flex-wrap: wrap;
	}

	.pwafc-prompt__actions {
		flex-direction: row;
		width: 100%;
	}

	.pwafc-prompt__actions .pwafc-btn {
		flex: 1 1 auto;
	}
}

/* ------------------------------------------------------------------
 * Botão flutuante (FAB)
 *
 * Uma bolinha fixa no canto inferior direito, com dois papéis conforme o
 * contexto: instalar o app (no navegador) ou ativar as notificações (dentro
 * do app). Ver renderFloatingAction() em pwafc-app.js.
 *
 * O z-index fica alto o bastante para vencer temas, mas ABAIXO do splash —
 * uma bolinha flutuando por cima da tela de abertura seria ruído.
 * ------------------------------------------------------------------ */

.pwafc-fab {
	position: fixed;
	right: 18px;
	/* Acima da barra inferior do sistema no iOS, quando instalado. */
	bottom: calc( 18px + env( safe-area-inset-bottom, 0px ) );
	z-index: 99990;

	display: flex;
	align-items: center;
	justify-content: center;

	width: 56px;
	height: 56px;
	padding: 0;

	border: 0;
	border-radius: 50%;
	background: var( --pwafc-accent, #111 );
	color: #fff;
	cursor: pointer;

	box-shadow: 0 6px 20px rgba( 0, 0, 0, 0.25 );

	/* Entra suave; começa deslocado para baixo e invisível. */
	opacity: 0;
	transform: translateY( 12px ) scale( 0.9 );
	transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.2s ease;
}

.pwafc-fab.is-visible {
	opacity: 1;
	transform: translateY( 0 ) scale( 1 );
}

.pwafc-fab:hover,
.pwafc-fab:focus-visible {
	background: var( --pwafc-accent-hover, #000 );
}

.pwafc-fab:focus-visible {
	outline: 3px solid var( --pwafc-accent, #111 );
	outline-offset: 3px;
}

/* Notificações ganham um toque de destaque: é a ação mais "opcional" das
   duas, e um cinza escuro passaria despercebido dentro do app. */
.pwafc-fab[data-pwafc-mode="notifications"] {
	background: var( --pwafc-accent-alt, #1c6ef2 );
}

.pwafc-fab svg {
	display: block;
	width: 24px;
	height: 24px;
}

@media ( prefers-reduced-motion: reduce ) {
	.pwafc-fab {
		transition: none;
		transform: none;
	}
}

/* ------------------------------------------------------------------
 * Splash do mural
 *
 * Camada cheia exibida na abertura do app instalado. Só roda em standalone:
 * no navegador, cobrir a tela de quem está apenas visitando seria intrusivo.
 * ------------------------------------------------------------------ */

.pwafc-splash {
	position: fixed;
	inset: 0;
	z-index: 99999;

	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;

	background: rgba( 0, 0, 0, 0.55 );
	backdrop-filter: blur( 3px );

	opacity: 0;
	transition: opacity 0.25s ease;
}

.pwafc-splash.is-visible {
	opacity: 1;
}

.pwafc-splash__card {
	position: relative;
	width: 100%;
	max-width: 420px;
	max-height: 85vh;
	overflow-y: auto;

	padding: 28px 24px 24px;
	border-radius: 18px;
	background: var( --pwafc-surface, #fff );
	color: var( --pwafc-text, #111 );
	box-shadow: 0 20px 60px rgba( 0, 0, 0, 0.35 );

	transform: translateY( 16px );
	transition: transform 0.25s ease;
}

.pwafc-splash.is-visible .pwafc-splash__card {
	transform: translateY( 0 );
}

/*
 * O SPLASH É O CASO MAIS CRÍTICO DO FECHAR.
 *
 * Ele ocupa a tela inteira na abertura do app e não tem nada atrás para clicar:
 * este botão é a ÚNICA saída. Com 36px e 55% de opacidade, ele era ao mesmo
 * tempo pequeno demais para o dedo e discreto demais para ser encontrado — numa
 * tela que a pessoa quer justamente atravessar depressa.
 *
 * Passa a 48px, com fundo próprio para se destacar de qualquer imagem que o
 * aviso traga, e opacidade cheia. Fechar não é uma ação secundária aqui.
 */
.pwafc-splash__close {
	position: absolute;
	top: 10px;
	right: 10px;

	display: inline-flex;
	align-items: center;
	justify-content: center;

	width: 48px;
	height: 48px;
	padding: 0;

	border: 0;
	border-radius: 50%;
	background: rgba( 127, 127, 127, 0.16 );
	color: inherit;
	font-size: 30px;
	line-height: 1;
	cursor: pointer;
	opacity: 0.9;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.pwafc-splash__close:hover,
.pwafc-splash__close:focus-visible {
	background: rgba( 127, 127, 127, 0.28 );
	opacity: 1;
}

.pwafc-splash__image img {
	display: block;
	width: 100%;
	height: auto;
	margin-bottom: 16px;
	border-radius: 12px;
}

.pwafc-splash__title {
	display: block;
	margin-bottom: 10px;
	font-size: 1.25rem;
	line-height: 1.3;
}

.pwafc-splash__body {
	font-size: 0.98rem;
	line-height: 1.55;
}

.pwafc-splash__body :last-child {
	margin-bottom: 0;
}

.pwafc-splash__actions {
	margin-top: 20px;
}

.pwafc-splash__actions:empty {
	display: none;
}

.pwafc-splash__actions .pwafc-btn {
	width: 100%;
	text-align: center;
}

@media ( prefers-color-scheme: dark ) {
	.pwafc-splash__card {
		background: var( --pwafc-surface, #1c1c1e );
		color: var( --pwafc-text, #f2f2f7 );
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.pwafc-splash,
	.pwafc-splash__card {
		transition: none;
		transform: none;
	}
}
