/**
 * GGF Community Core: the Follow Game control in a GGF Game Hubs header.
 *
 * The button itself uses Game Hubs' own button classes and colours
 * (.ggfh-btn, --ggfh-* tokens), so it matches the hub's Join button in both
 * schemes. This file only adds what Game Hubs does not have: the pressed
 * (Following) and busy states, the guest invitation and the short status
 * line. Every rule is scoped to .ggfh .ggfc-hub-follow; nothing here
 * touches the theme or other plugins.
 */

.ggfh .ggfc-hub-follow {
	position: relative;
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	max-width: 100%;
}

.ggfh.ggfh .ggfc-hub-follow__btn {
	white-space: nowrap;
}

.ggfh .ggfc-hub-follow__icon {
	flex: none;
	width: 16px;
	height: 16px;
}

/* Following: a check mark and a different label say it; the colour only supports them. */
.ggfh.ggfh .ggfc-hub-follow__btn[aria-pressed="true"] {
	border-color: var(--ggfh-primary);
	box-shadow: inset 0 0 0 1px var(--ggfh-primary);
}

.ggfh.ggfh .ggfc-hub-follow__btn[aria-busy="true"] {
	cursor: progress;
	opacity: .7;
}

@media (prefers-reduced-motion: no-preference) {
	.ggfh.ggfh .ggfc-hub-follow__btn[aria-busy="true"] .ggfc-hub-follow__icon {
		animation: ggfc-hub-follow-pulse 1s ease-in-out infinite alternate;
	}
}

@keyframes ggfc-hub-follow-pulse {
	from { opacity: 1; }
	to { opacity: .35; }
}

/*
 * The status line is always read out (role="status"). A confirmation is not
 * shown as well: the button's label and check mark already show it. A
 * problem is shown under the button, without moving anything around it.
 */
.ggfh .ggfc-hub-follow__said {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.ggfh .ggfc-hub-follow__said.is-error {
	top: calc(100% + 6px);
	left: 0;
	z-index: 19;
	width: max-content;
	max-width: min(280px, calc(100vw - 32px));
	height: auto;
	margin: 0;
	padding: 6px 10px;
	overflow: visible;
	clip: auto;
	clip-path: none;
	white-space: normal;
	border: 1px solid var(--ggfh-danger);
	border-radius: var(--ggfh-radius-sm);
	background: var(--ggfh-elevated);
	color: var(--ggfh-foreground);
	font-size: 13px;
	line-height: 1.4;
	text-shadow: none;
}

.ggfh .ggfc-hub-follow__said.is-error:empty {
	display: none;
}

/* Guest invitation: below the button, inside the hub's own surface colours. */
.ggfh .ggfc-hub-follow__prompt {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	z-index: 20;
	width: min(320px, calc(100vw - 32px));
	padding: 14px;
	border: 1px solid var(--ggfh-border);
	border-radius: var(--ggfh-radius-md);
	background: var(--ggfh-elevated);
	color: var(--ggfh-foreground);
	box-shadow: var(--ggfh-shadow-pop);
	text-align: left;
	text-shadow: none;
}

.ggfh.ggfh .ggfc-hub-follow__text {
	margin: 0 0 12px;
	font-size: 14px;
	line-height: 1.45;
	color: var(--ggfh-foreground);
}

.ggfh .ggfc-hub-follow__links {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

/* Inside the invitation the hub's photo overlay styles do not apply. */
.ggfh.ggfh .ggfh-hero .ggfc-hub-follow__prompt .ggfh-btn--ghost {
	color: var(--ggfh-foreground);
	border-color: var(--ggfh-border);
	background: transparent;
}

.ggfh.ggfh .ggfh-hero .ggfc-hub-follow__prompt .ggfh-btn--ghost:hover {
	background: var(--ggfh-muted);
}

/* Right-aligned hero actions on wider screens: open the invitation towards the left. */
@media (min-width: 768px) {
	.ggfh .ggfh-hero__actions .ggfc-hub-follow__prompt,
	.ggfh .ggfh-hero__actions .ggfc-hub-follow__said.is-error {
		left: auto;
		right: 0;
	}
}

/* Phones: the invitation takes its own line under the button instead of floating. */
@media (max-width: 479px) {
	.ggfh .ggfc-hub-follow {
		flex: 1 1 100%;
	}

	.ggfh .ggfc-hub-follow__prompt,
	.ggfh .ggfc-hub-follow__said.is-error {
		position: static;
		width: 100%;
		max-width: none;
		margin-top: 2px;
	}
}

/* A signed-in reader is not invited to join again: hide the hub's own Join button then. */
html.ggfc-in .ggfh .ggfh-hero__actions .ggfh-join {
	display: none;
}
