/**
 * WB Gamification — Frontend Styles
 *
 * Minimal, utility-first styles for all gamification blocks.
 * Uses CSS custom properties for easy theming; block-specific overrides
 * in child theme or via the Global Styles panel.
 */

/*
 * Design tokens (canonical + shorthand aliases) live in
 * `src/shared/design-tokens.css`, registered as the `wb-gam-tokens`
 * style handle which this file (`wb-gamification`) depends on.
 * All blocks consume tokens via that handle alone — frontend.css is
 * legacy global polish (toasts, hub-only utilities) and must NOT
 * redeclare tokens.
 */

/* Toasts, the Moment card, banners, dialogs, the drawer and menus live in popups.css. */

/* ── Empty states (shared) ──────────────────────────────────────────────────── */
.wb-gam-leaderboard__empty,
.wb-gam-badge-showcase__empty,
.wb-gam-kudos-feed__empty {
	color: var(--wb-gam-silver);
	font-size: 0.9375rem;
	text-align: center;
	padding: 2rem;
	margin: 0;
}


@media (max-width: 640px) {
	.wb-gam-earning-guide__grid {
		grid-template-columns: 1fr !important;
	}
}

/* ─── Phase D.1 responsive baseline ─────────────────────────────────────────
 * Mobile-first breakpoints for the four migrated static-display blocks.
 * Phase E will fold these into per-block style.css files; for now they
 * keep the legacy markup behaving correctly at narrow viewports.
 */

@media (max-width: 1024px) {
	.wb-gam-earning-guide__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}
}

@media (max-width: 640px) {
	.wb-gam-member-points {
		gap: 0.5rem;
	}

	.wb-gam-member-points__number {
		font-size: 2.25rem;
	}

	.wb-gam-streak__stats {
		gap: 1rem;
		flex-wrap: wrap;
	}

	.wb-gam-streak__number {
		font-size: 1.875rem;
	}

	.wb-gam-streak__heatmap {
		overflow-x: auto;
		flex-wrap: nowrap;
		padding-block-end: 4px;
	}

	.wb-gam-level-progress__header {
		flex-wrap: wrap;
	}

	.wb-gam-level-progress__name {
		font-size: 1rem;
	}

	.wb-gam-earning-guide__grid {
		grid-template-columns: 1fr !important;
	}

	.wb-gam-earning-guide__card {
		padding: 12px 14px;
	}
}

@media (max-width: 640px) {
	.wb-gam-member-points__total {
		flex-direction: row;
		align-items: baseline;
		gap: 0.5rem;
	}

	.wb-gam-streak__number {
		font-size: 1.625rem;
	}

	.wb-gam-level-progress__icon {
		width: 36px;
		height: 36px;
	}

	.wb-gam-earning-guide__category {
		font-size: 1rem;
	}
}

/* ── BP activity-stream card ────────────────────────────────────────────────
 * One compact card for every gamification post (badge, level, kudos, challenge) on BuddyPress
 * and BuddyBoss: icon on the start side, a small uppercase label, the name, a one-line reason.
 * Theme tokens only, so it follows the theme's light/dark mode; logical properties for RTL.
 * Markup: src/BuddyPress/Stream/ActivityCard.php. The badge, level, kudos and challenge icons
 * carry their own tinted plate, so the image sits on no background of its own.
 *
 * The card is a paragraph (.wb-gam-activity-card-wrap) so the theme insets and spaces it like
 * the text of any post: BuddyX pads activity paragraphs 0 15px with a 15px bottom margin, Reign
 * and Nouveau give them margins. The plugin adds only a small top gap, never a side inset of its
 * own, so no theme gets double padding. */
.wb-gam-activity-card-wrap {
	margin-block-start: var(--wb-gam-space-sm);
}

/* The card is the last thing in the post: the entry's own bottom spacing is enough. On Reign the
 * paragraph margin stacked on the entry's and left ~60px of empty space under the card. BuddyX
 * sets its paragraph margin with !important, so its 15px stays. */
.wb-gam-activity-card-wrap:last-child {
	margin-block-end: 0;
}

.wb-gam-activity-card {
	display: flex;
	align-items: center;
	gap: 12px;
	box-sizing: border-box;
	max-inline-size: 100%;
	margin: 0;
	padding-block: 10px;
	padding-inline: 12px var(--wb-gam-space-md);
	border: 1px solid var(--wb-gam-color-border);
	border-inline-start: 3px solid var(--wb-gam-color-accent);
	border-radius: var(--wb-gam-radius-md);
	background: var(--wb-gam-color-surface);
	color: var(--wb-gam-color-text);
	line-height: var(--wb-gam-leading-tight);
}

/* Reign makes every span that is a direct child of an activity paragraph a block
 * (.bp-nouveau .activity-list .activity-item .activity-content p > span:not(...), specificity
 * 0,5,2), which stacked the icon above the text. :not(#wb-gam-card) adds one id's weight, the
 * least that outranks it, so the card keeps its row on every theme without !important. */
.wb-gam-activity-card:not(#wb-gam-card) {
	display: flex;
}

/* Activity themes size, float and space every image in a post; the icon opts out. */
.wb-gam-activity-card .wb-gam-activity-card__icon {
	flex: 0 0 auto;
	float: none;
	inline-size: 40px;
	block-size: 40px;
	max-inline-size: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--wb-gam-radius-md);
	object-fit: contain;
}

/* Badge art is often dark line-art on a transparent ground, which vanished on a dark card. It
 * always sits on a light tile, in every theme and scheme (the level art carries its own tile,
 * a kudos card shows an avatar). */
.wb-gam-activity-card--badge .wb-gam-activity-card__icon {
	box-sizing: border-box;
	padding: 4px;
	background: var(--wb-gam-color-art-tile);
}

.wb-gam-activity-card--kudos .wb-gam-activity-card__icon {
	border-radius: var(--wb-gam-radius-full);
	object-fit: cover;
}

.wb-gam-activity-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 2px;
	min-inline-size: 0;
}

.wb-gam-activity-card__eyebrow {
	color: var(--wb-gam-color-accent-text);
	font-size: var(--wb-gam-font-xs);
	font-weight: var(--wb-gam-weight-bold);
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

/* Name and reason each stay on one line; a grouped post lists several names. */
.wb-gam-activity-card__title,
.wb-gam-activity-card__desc {
	display: block;
	overflow: hidden;
	margin: 0;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wb-gam-activity-card__title {
	color: var(--wb-gam-color-text);
	font-size: var(--wb-gam-font-md);
	font-weight: var(--wb-gam-weight-bold);
}

.wb-gam-activity-card__desc {
	color: var(--wb-gam-color-text-muted);
	font-size: var(--wb-gam-font-sm);
}

@media (max-width: 480px) {
	.wb-gam-activity-card {
		gap: 10px;
		padding-inline: 10px 12px;
	}

	.wb-gam-activity-card__title {
		font-size: var(--wb-gam-font-sm);
	}
}

/* ── Public profile page (Engine\ProfilePage) ───────────────────────────── */
.wb-gam-profile-page {
	max-width: 800px;
	margin: 32px auto;
	padding: 0 16px;
}
.wb-gam-profile-page__hero {
	display: flex;
	align-items: center;
	gap: 20px;
	background: var(--wb-gam-color-white, #fff);
	border: 1px solid var(--wb-gam-color-border, #e5e7eb);
	border-radius: 12px;
	padding: 24px;
	margin-bottom: 24px;
}
.wb-gam-profile-page__avatar img {
	border-radius: 50%;
	width: 96px;
	height: 96px;
	object-fit: cover;
}
.wb-gam-profile-page__name {
	margin: 0;
	font-size: 22px;
	font-weight: 700;
	color: var(--wb-gam-color-text, #1f2937);
}
.wb-gam-profile-page__stats {
	margin: 6px 0 0;
	color: var(--wb-gam-color-text-muted, #6b7280);
	font-size: 14px;
}
.wb-gam-profile-page__section { margin-bottom: 28px; }
/* The neutral page for a private (or unknown) profile: one centred line. */
.wb-gam-profile-page--private {
	padding-block: var(--wb-gam-space-2xl);
	text-align: center;
}
@media (max-width: 640px) {
	.wb-gam-profile-page__hero { flex-direction: column; text-align: center; padding: 18px; }
	.wb-gam-profile-page__avatar img { width: 80px; height: 80px; }
}

/* BuddyPress member directory rank line (DirectoryIntegration.php).
 * Inline-SVG icons render as currentColor; muted text keeps rank meta
 * subordinate to the member name above it. */
.wb-gam-directory-rank {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	color: var(--wb-gam-color-text-muted, #65676b);
	font-size: 13px;
	line-height: 1.4;
	margin-top: 2px;
}
.wb-gam-directory-rank > span {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	white-space: nowrap;
}
.wb-gam-directory-icon {
	flex-shrink: 0;
	width: 14px;
	height: 14px;
}
.wb-gam-directory-level {
	color: var(--wb-gam-color-text, #1f2937);
	font-weight: 600;
}
.wb-gam-directory-points .wb-gam-directory-icon { color: var(--wb-gam-primary, #1d4ed8); }
.wb-gam-directory-badges .wb-gam-directory-icon { color: var(--wb-gam-accent, #f59e0b); }
/* Grid cards centre the name and meta; BuddyBoss makes the rank line a block-level flex box that would sit at the start edge. */
.bp-list.grid .wb-gam-directory-rank {
	justify-content: center;
}
@media (max-width: 640px) {
	.wb-gam-directory-rank { gap: 6px; font-size: 12px; }
	.wb-gam-directory-icon { width: 12px; height: 12px; }
}

/* ─────────────────────────────────────────────────────────────────────
 * [wb_gam_my_rewards] — member-facing redemption history list
 * Closes Basecamp #9927388714 / #9925383280 issue 3.
 * Plain semantic list; cards use the shared --wb-gam tokens so the
 * widget inherits site styling without per-theme overrides.
 * ───────────────────────────────────────────────────────────────────── */
.wb-gam-my-rewards { display: block; }
.wb-gam-my-rewards--guest,
.wb-gam-my-rewards--empty {
	padding: 24px 16px;
	border: 1px dashed var(--wb-gam-border, #e5e7eb);
	border-radius: var(--wb-gam-radius, 8px);
	text-align: center;
	color: var(--wb-gam-text-muted, #6b7280);
	font-size: 14px;
}
.wb-gam-my-rewards__list {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.wb-gam-my-rewards__item {
	background: var(--wb-gam-color-white, #fff);
	border: 1px solid var(--wb-gam-border, #e5e7eb);
	border-radius: var(--wb-gam-radius, 8px);
	padding: 12px 14px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.wb-gam-my-rewards__title {
	display: flex;
	align-items: center;
	gap: 10px;
	justify-content: space-between;
	font-size: 14px;
	color: var(--wb-gam-text, #1d2939);
}
.wb-gam-my-rewards__status {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--wb-gam-color-info-bg, #eff6ff);
	color: var(--wb-gam-primary, #1d4ed8);
	white-space: nowrap;
}
.wb-gam-my-rewards__status--fulfilled { background: var(--wb-gam-color-success-bg); color: var(--wb-gam-color-success); }
.wb-gam-my-rewards__status--failed    { background: var(--wb-gam-color-danger-bg); color: var(--wb-gam-color-danger); }
.wb-gam-my-rewards__status--refunded  { background: var(--wb-gam-color-warning-bg); color: var(--wb-gam-color-warning); }
.wb-gam-my-rewards__meta {
	display: flex;
	gap: 10px;
	font-size: 12px;
	color: var(--wb-gam-text-muted, #6b7280);
}
.wb-gam-my-rewards__cost { font-weight: 600; }
.wb-gam-my-rewards__coupon {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 4px;
	font-size: 13px;
}
.wb-gam-my-rewards__coupon-label { color: var(--wb-gam-text-muted, #6b7280); }
.wb-gam-my-rewards__coupon-code {
	font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
	font-weight: 700;
	letter-spacing: .04em;
	padding: 2px 8px;
	border-radius: 4px;
	background: var(--wb-gam-color-success-bg, #ecfdf5);
	color: var(--wb-gam-color-success, #065f46);
	border: 1px dashed var(--wb-gam-color-success-soft, #34d399);
}
@media (max-width: 480px) {
	.wb-gam-my-rewards__title { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* BuddyPress "Achievements" profile tab — wraps the reused blocks rendered
 * per sub-tab (Overview / Badges / Points / Streak). */
.wb-gam-bp-achievements {
	display: flex;
	flex-direction: column;
	gap: var(--wb-gam-space-lg, 24px);
}

.wb-gam-bp-achievements__more {
	margin: 0;
	text-align: center;
}

.wb-gam-bp-achievements__more a {
	font-weight: 600;
	color: var(--wb-gam-color-accent);
}

/* LMS profile — single "My Achievements" hub link, aligned right so it reads
 * as a profile action rather than a floating banner. Shared by the LearnDash
 * (.wb-gam-ld-link) and Learnomy (.wb-gam-lrn-link) profile integrations. */
.wb-gam-ld-link,
.wb-gam-lrn-link {
	margin: 0 0 16px;
	text-align: right;
}

.wb-gam-ld-link__btn,
.wb-gam-lrn-link__btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 16px;
	border-radius: var(--wb-gam-radius, 8px);
	background: var(--wb-gam-color-accent-light);
	color: var(--wb-gam-color-accent-text);
	font-weight: 600;
	font-size: 0.875rem;
	text-decoration: none;
}

.wb-gam-ld-link__btn:hover,
.wb-gam-lrn-link__btn:hover {
	background: var(--wb-gam-color-accent);
	color: var(--wb-gam-pop-accent-fg);
}

/* ── Profile visibility owner control ──────────────────────────────────────
   Member-facing privacy toggle on /u/{login}. Owner-only; lets a member make
   their own profile public/private (writes wb_gam_profile_public). */
.wb-gam-profile-privacy {
	border: 1px solid var(--wb-gam-color-border, #e2e4e7);
	border-radius: var(--wb-gam-radius, 8px);
	background: var(--wb-gam-color-surface, #fff);
	padding: 16px 20px;
}

.wb-gam-profile-privacy__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
}

.wb-gam-profile-privacy__copy {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.wb-gam-profile-privacy__label {
	font-weight: 600;
	color: var(--wb-gam-color-text, #1e1e1e);
}

.wb-gam-profile-privacy__state {
	font-size: 0.875rem;
	color: var(--wb-gam-color-text-muted, #646970);
}

.wb-gam-profile-privacy__toggle {
	flex-shrink: 0;
	min-height: 40px;
	padding: 8px 16px;
	border: 1px solid var(--wb-gam-color-accent, #2271b1);
	border-radius: var(--wb-gam-radius, 8px);
	background: var(--wb-gam-color-accent, #2271b1);
	color: var(--wb-gam-pop-accent-fg);
	font-weight: 600;
	font-size: 0.875rem;
	cursor: pointer;
}

.wb-gam-profile-privacy__toggle:hover {
	filter: brightness(0.94);
}

.wb-gam-profile-privacy__toggle:focus-visible {
	outline: 2px solid var(--wb-gam-color-accent, #2271b1);
	outline-offset: 2px;
}

.wb-gam-profile-privacy__toggle:disabled {
	opacity: 0.6;
	cursor: default;
}

.wb-gam-profile-privacy__note,
.wb-gam-profile-privacy__status {
	margin: 10px 0 0;
	font-size: 0.8125rem;
	color: var(--wb-gam-color-text-muted, #646970);
}

.wb-gam-profile-privacy__status:empty {
	display: none;
}

.wb-gam-member-prefs__set {
	display: grid;
	gap: var(--wb-gam-space-sm, 8px);
	margin: 0;
	padding: 0;
	border: 0;
}

.wb-gam-member-prefs__choice {
	display: flex;
	align-items: center;
	gap: var(--wb-gam-space-sm, 8px);
	min-height: 40px;
	color: var(--wb-gam-color-text, #1e1e1e);
	cursor: pointer;
}

.wb-gam-member-prefs__choice input {
	width: 18px;
	height: 18px;
	margin: 0;
	accent-color: var(--wb-gam-color-accent, #2271b1);
}

@media (max-width: 640px) {
	.wb-gam-profile-privacy__row {
		flex-direction: column;
		align-items: stretch;
	}

	.wb-gam-profile-privacy__toggle {
		width: 100%;
	}
}


/* ── BuddyPress profile header rank (ProfileIntegration::render_rank) ───────
 * The bar's look is overridable from the theme: --wb-gam-bar-color, --wb-gam-bar-bg and
 * --wb-gam-bar-height are read where they are used, with the defaults as fallbacks. Declaring
 * them on this element (as before) shadowed any override set on :root or body. */
.wb-gam-profile-rank {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--wb-gam-space-xs) var(--wb-gam-space-sm);
	margin-block: var(--wb-gam-space-sm);
	max-width: 360px;
	font-size: 0.875rem;
	line-height: 1.4;
}

.wb-gam-profile-rank .wb-gam-rank-badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 10px;
	border-radius: var(--wb-gam-radius-full);
	background: var(--wb-gam-color-accent-light);
	color: var(--wb-gam-color-accent-text);
	font-weight: 600;
}

.wb-gam-profile-rank .wb-gam-points-count {
	color: var(--wb-gam-color-text-muted);
	font-variant-numeric: tabular-nums;
}

.wb-gam-profile-rank .wb-gam-progress-bar {
	flex: 1 0 100%;
	height: var(--wb-gam-bar-height, 6px);
	overflow: hidden;
	border-radius: var(--wb-gam-radius-full);
	background: var(--wb-gam-bar-bg, var(--wb-gam-color-surface-alt));
}

.wb-gam-profile-rank .wb-gam-progress-fill {
	width: var(--wb-gam-fill, 0%);
	height: 100%;
	border-radius: inherit;
	background: var(--wb-gam-bar-color, var(--wb-gam-color-accent));
}

@media (max-width: 480px) {
	.wb-gam-profile-rank {
		max-width: 100%;
	}
}
