/* ============================================================
   Friend Badges — chips, gift module, bottom sheet, spotlight.
   Built on the inner-app token system (mobile-redesign.css):
     --bg-surface, --bg-elevated, --bg-soft, --border-soft,
     --text-primary, --text-secondary, --text-muted,
     --accent (#6d7cff), --accent-2 (#00c3ff)
   Works in dark (default) and light (body.fq-theme-light) themes.
   Loaded ONLY on score-reveal / Friendboard / leaderboard pages.
   ============================================================ */

/* ---------- Chips (24px on scoreboard rows) ---------- */

.fq-badge-chips {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	margin-left: 6px;
	vertical-align: middle;
	white-space: nowrap;
}

/* Badge art is authored inline SVG (Rosette Burst set) — the chip is just a
   transparent anchor; the silhouette/material lives in the art itself. */
.fq-badge-chip {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	line-height: 1;
	animation: fqBadgePop 0.35s ease-out backwards;
	cursor: default;
	filter: drop-shadow(0 1px 2px rgba(3, 8, 18, 0.3));
}

.fq-badge-chip svg,
.fq-badge-chip img {
	display: block;
	width: 24px;
	height: 24px;
}

.fq-badge-chip[data-fq-badge-grant] {
	cursor: pointer;
}

.fq-badge-chip {
	position: relative;
}

/* W2: permanent ribbon on the first badge ever gifted on a board. */
.fq-badge-first {
	position: absolute;
	bottom: -5px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 7px;
	font-weight: 800;
	letter-spacing: .04em;
	text-transform: uppercase;
	color: #fff;
	background: linear-gradient(135deg, #ff4f7b, #ffc93d);
	border-radius: 999px;
	padding: 1px 4px;
	line-height: 1.3;
	pointer-events: none;
	white-space: nowrap;
}

/* W2: tier-band reveal + suggestion styling */
.fq-badge-tier-line {
	font-size: 13px;
	font-weight: 800;
	color: #ffc93d;
	margin-bottom: 6px;
	letter-spacing: .02em;
}

.fq-badge-module__first {
	font-size: 12.5px;
	color: var(--text-secondary, #b6c4dc);
	margin: -4px 0 10px;
}

.fq-badge-thumb {
	position: relative;
}

.fq-badge-thumb--suggested {
	border-color: var(--accent, #6d7cff);
	box-shadow: 0 0 0 2px rgba(109, 124, 255, 0.3);
}

.fq-badge-thumb__tag {
	position: absolute;
	top: -7px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 9px;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: .05em;
	color: #fff;
	background: linear-gradient(135deg, var(--accent, #6d7cff), var(--accent-2, #00c3ff));
	border-radius: 999px;
	padding: 1px 7px;
	white-space: nowrap;
}

/* W2: revisit competitive moment */
.fq-badge-outscored {
	margin: 10px auto 0;
	max-width: 480px;
	padding: 10px 14px;
	border-radius: 14px;
	border: 1px dashed rgba(255, 79, 123, 0.5);
	background: rgba(255, 79, 123, 0.07);
	color: var(--text-primary, #eef4ff);
	font-size: 13.5px;
	text-align: center;
}

.fq-badge-chip--more {
	font-size: 11px;
	font-weight: 700;
	color: var(--text-secondary, #b6c4dc);
	background: rgba(141, 154, 179, 0.14);
	border: 1px solid var(--border-soft, #2b3b56);
	border-radius: 999px;
	filter: none;
}

@keyframes fqBadgePop {
	from { transform: scale(0.4); opacity: 0; }
	to { transform: scale(1); opacity: 1; }
}

/* ---------- Tier-3 row glow (7 days) — holo palette, not brand purple ---------- */

tr.fq-badge-glow td,
.fq-badge-glow-row {
	background: linear-gradient(90deg, rgba(79, 216, 210, 0.10), rgba(122, 108, 255, 0.12), rgba(232, 121, 201, 0.10)) !important;
	box-shadow: inset 0 0 0 1px rgba(122, 108, 255, 0.4);
}

/* ---------- Creator badge shelf line ---------- */

.fq-badge-creator-line {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin: 4px 0 10px;
	font-size: 13px;
	color: var(--text-secondary, #b6c4dc);
}

.fq-badge-creator-line .fq-badge-chips {
	margin-left: 0;
}

/* ---------- W4: free reactions (badges = a reaction that ascended) ---------- */

.fq-react-bar,
.fq-react-bar * { box-sizing: border-box; }

.fq-react-bar {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	margin-left: 6px;
	vertical-align: middle;
}

.fq-react {
	display: inline-flex;
	align-items: center;
	gap: 1px;
	min-width: 22px;
	min-height: 22px;
	padding: 1px 4px;
	border-radius: 999px;
	border: 1px solid transparent;
	background: transparent;
	cursor: pointer;
	opacity: .8;
}

.fq-react svg {
	width: 15px;
	height: 15px;
	display: block;
}

.fq-react__n {
	font-size: 10.5px;
	font-weight: 700;
	color: var(--text-secondary, #b6c4dc);
}

.fq-react--on {
	background: rgba(109, 124, 255, 0.12);
	border-color: rgba(109, 124, 255, 0.35);
	opacity: 1;
}

.fq-react--zero {
	opacity: .45;
}

.fq-react[disabled] {
	cursor: default;
	pointer-events: none;
}

/* W1's preview strip shows non-interactive bars; existing reactions only. */
.fq-badge-teaser .fq-react-bar { margin-left: 4px; }

/* ---------- W1: Friendboard preview strip on the challenge landing ---------- */

.fq-badge-teaser {
	margin: 12px auto;
	padding: 12px 14px;
	max-width: 480px;
	border-radius: 18px;
	border: 1px solid var(--border-soft, #2b3b56);
	background: linear-gradient(180deg, rgba(109, 124, 255, 0.06), rgba(255, 255, 255, 0.01)), var(--bg-surface, #0f1624);
}

.fq-badge-teaser__head {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #c3ceff;
	margin-bottom: 8px;
	text-align: center;
}

body.fq-theme-light .fq-badge-teaser__head {
	color: #2f57d8;
}

.fq-badge-teaser__row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 8px;
	border-radius: 10px;
	font-size: 13.5px;
	color: var(--text-primary, #eef4ff);
}

.fq-badge-teaser__name {
	font-weight: 700;
	flex: 0 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.fq-badge-teaser__score {
	color: var(--text-secondary, #b6c4dc);
	flex: 0 0 auto;
}

.fq-badge-teaser__cta {
	margin-top: 8px;
	text-align: center;
	font-size: 13px;
	font-weight: 700;
	color: var(--text-secondary, #b6c4dc);
}

/* ---------- Gift module (below score card, dismissible) ---------- */

.fq-badge-module {
	margin: 14px auto;
	padding: 16px 14px;
	max-width: 480px;
	border-radius: 22px;
	border: 1px solid var(--border-soft, #2b3b56);
	background: linear-gradient(180deg, rgba(109, 124, 255, 0.07), rgba(255, 255, 255, 0.01)), var(--bg-surface, #0f1624);
	box-shadow: 0 14px 32px rgba(3, 8, 18, 0.4);
	position: relative;
	text-align: center;
}

.fq-badge-module__dismiss {
	position: absolute;
	top: 6px;
	right: 6px;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: transparent;
	color: var(--text-muted, #8d9ab3);
	font-size: 18px;
	cursor: pointer;
	border-radius: 999px;
}

.fq-badge-module__eyebrow {
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #c3ceff;
	font-size: 11px;
	margin-bottom: 4px;
	display: inline-block;
	padding: 4px 10px;
	border-radius: 999px;
	background: rgba(109, 124, 255, 0.12);
}

body.fq-theme-light .fq-badge-module__eyebrow {
	color: #2f57d8;
	background: rgba(47, 87, 216, 0.08);
}

.fq-badge-module__title {
	font-size: 16.5px;
	font-weight: 700;
	color: var(--text-primary, #eef4ff);
	margin: 4px 0 12px;
	line-height: 1.4;
}

.fq-badge-module__row {
	display: flex;
	align-items: stretch;
	justify-content: center;
	gap: 8px;
	flex-wrap: wrap;
}

.fq-badge-thumb {
	flex: 0 0 auto;
	width: 92px;
	min-height: 96px;
	padding: 10px 6px 8px;
	border-radius: 16px;
	border: 1px solid var(--border-soft, #2b3b56);
	background: var(--bg-elevated, #151f32);
	cursor: pointer;
	text-align: center;
	transition: transform 0.15s ease, border-color 0.15s ease;
}

.fq-badge-thumb:active {
	transform: scale(0.95);
}

.fq-badge-thumb__art {
	display: block;
	line-height: 0;
	margin: 0 auto;
	width: 48px;
}

.fq-badge-thumb__art svg {
	display: block;
}

.fq-badge-thumb__name {
	display: block;
	font-size: 11px;
	font-weight: 700;
	color: var(--text-primary, #eef4ff);
	margin-top: 4px;
	line-height: 1.25;
}

.fq-badge-thumb__price {
	display: block;
	font-size: 11px;
	color: var(--text-muted, #8d9ab3);
	margin-top: 2px;
}

.fq-badge-module__all {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin-top: 10px;
	padding: 8px 18px;
	border-radius: 14px;
	border: 1px solid var(--border-soft, #2b3b56);
	background: transparent;
	color: var(--text-secondary, #b6c4dc);
	font-size: 13.5px;
	font-weight: 600;
	cursor: pointer;
}

/* ---------- Whisper prompt (Friendboard inline nudge) ---------- */

.fq-badge-whisper {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	flex-wrap: wrap;
	margin: 10px auto;
	padding: 10px 14px;
	max-width: 460px;
	border-radius: 16px;
	border: 1px dashed rgba(109, 124, 255, 0.45);
	background: rgba(109, 124, 255, 0.06);
	color: var(--text-secondary, #b6c4dc);
	font-size: 13.5px;
	position: relative;
}

.fq-badge-whisper__cta {
	display: inline-flex;
	align-items: center;
	min-height: 36px;
	padding: 6px 14px;
	border-radius: 999px;
	border: none;
	background: linear-gradient(135deg, var(--accent, #6d7cff), var(--accent-2, #00c3ff));
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 6px 16px rgba(72, 112, 255, 0.35);
}

.fq-badge-whisper__dismiss {
	background: transparent;
	border: none;
	color: var(--text-muted, #8d9ab3);
	font-size: 16px;
	min-width: 36px;
	min-height: 36px;
	cursor: pointer;
}

/* ---------- Bottom sheet ---------- */

.fq-sheet-backdrop {
	position: fixed;
	inset: 0;
	z-index: 10060;
	background: rgba(3, 8, 18, 0.6);
	backdrop-filter: blur(2px);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.fq-sheet {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 10061;
	max-height: 86vh;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	border-radius: 22px 22px 0 0;
	border: 1px solid var(--border-soft, #2b3b56);
	border-bottom: none;
	background: var(--bg-surface, #0f1624);
	box-shadow: 0 -18px 48px rgba(3, 8, 18, 0.6);
	padding: 10px 16px calc(18px + env(safe-area-inset-bottom, 0px));
	transform: translateY(100%);
	transition: transform 0.25s cubic-bezier(0.22, 0.9, 0.36, 1);
	max-width: 560px;
	margin: 0 auto;
}

.fq-sheet--open {
	transform: translateY(0);
}

.fq-sheet-backdrop--open {
	opacity: 1;
}

.fq-sheet__grab {
	width: 44px;
	height: 4px;
	border-radius: 999px;
	background: var(--border-soft, #2b3b56);
	margin: 4px auto 12px;
}

.fq-sheet__title {
	font-size: 17px;
	font-weight: 800;
	color: var(--text-primary, #eef4ff);
	text-align: center;
	margin: 0 0 2px;
}

.fq-sheet__sub {
	font-size: 13px;
	color: var(--text-muted, #8d9ab3);
	text-align: center;
	margin: 0 0 14px;
}

.fq-sheet__close {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: transparent;
	color: var(--text-muted, #8d9ab3);
	font-size: 20px;
	cursor: pointer;
}

/* Catalog grid inside sheet */
.fq-sheet__grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
}

@media (max-width: 360px) {
	.fq-sheet__grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

.fq-sheet__tier-label {
	grid-column: 1 / -1;
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #c3ceff;
	margin: 8px 0 0;
}

body.fq-theme-light .fq-sheet__tier-label {
	color: #2f57d8;
}

.fq-badge-card {
	position: relative;
	padding: 12px 6px 10px;
	border-radius: 16px;
	border: 1px solid var(--border-soft, #2b3b56);
	background: var(--bg-elevated, #151f32);
	text-align: center;
	cursor: pointer;
	min-height: 104px;
	transition: border-color 0.15s ease, transform 0.15s ease;
}

.fq-badge-card:active {
	transform: scale(0.96);
}

.fq-badge-card--selected {
	border-color: var(--accent, #6d7cff);
	box-shadow: 0 0 0 2px rgba(109, 124, 255, 0.35);
}

.fq-badge-card__art {
	display: block;
	line-height: 0;
	margin: 0 auto;
	width: 44px;
}

.fq-badge-card__art img {
	display: block;
}

.fq-badge-card__name {
	display: block;
	font-size: 11.5px;
	font-weight: 700;
	color: var(--text-primary, #eef4ff);
	margin-top: 4px;
	line-height: 1.25;
}

.fq-badge-card__price {
	display: block;
	font-size: 11px;
	color: var(--text-muted, #8d9ab3);
	margin-top: 2px;
}

.fq-badge-card__limited {
	position: absolute;
	top: 6px;
	right: 6px;
	font-size: 9px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #ffc93d;
	background: rgba(255, 201, 61, 0.14);
	border: 1px solid rgba(255, 201, 61, 0.4);
	padding: 2px 6px;
	border-radius: 999px;
}

/* Sheet detail / confirm state */
.fq-sheet__detail {
	text-align: center;
	padding: 6px 0 0;
}

.fq-sheet__detail-art {
	display: block;
	line-height: 0;
	margin: 0 auto 4px;
	width: 120px;
	animation: fqBadgePop 0.4s ease-out backwards;
}

.fq-sheet__detail-art img {
	display: block;
}

.fq-sheet__detail-name {
	font-size: 19px;
	font-weight: 800;
	color: var(--text-primary, #eef4ff);
	margin: 6px 0 2px;
}

.fq-sheet__detail-tagline {
	font-size: 13.5px;
	color: var(--text-secondary, #b6c4dc);
	margin: 0 0 14px;
}

.fq-sheet__detail-meta {
	font-size: 12.5px;
	color: var(--text-muted, #8d9ab3);
	margin: 0 0 12px;
}

.fq-sheet__cta {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 50px;
	border: none;
	border-radius: 14px;
	background: linear-gradient(135deg, var(--accent, #6d7cff), var(--accent-2, #00c3ff));
	color: #fff;
	font-size: 15.5px;
	font-weight: 800;
	cursor: pointer;
	box-shadow: 0 8px 22px rgba(72, 112, 255, 0.42);
}

.fq-sheet__cta:disabled {
	opacity: 0.6;
	cursor: wait;
}

.fq-sheet__cta--ghost {
	background: transparent;
	border: 1px solid var(--border-soft, #2b3b56);
	color: var(--text-secondary, #b6c4dc);
	box-shadow: none;
	margin-top: 8px;
	min-height: 44px;
	font-weight: 600;
}

.fq-sheet__fineprint {
	font-size: 11px;
	color: var(--text-muted, #8d9ab3);
	text-align: center;
	margin: 10px 0 0;
	line-height: 1.5;
}

/* Success state */
.fq-sheet__success {
	text-align: center;
	padding: 12px 0;
}

.fq-sheet__success-emoji {
	font-size: 72px;
	display: block;
	animation: fqBadgeCelebrate 0.6s ease-out backwards;
}

.fq-sheet__success-art {
	display: block;
	line-height: 0;
	margin: 0 auto 8px;
	width: 110px;
	animation: fqBadgeCelebrate 0.6s ease-out backwards;
}

.fq-sheet__success-art img {
	display: block;
}

@keyframes fqBadgeCelebrate {
	0% { transform: scale(0.3) rotate(-12deg); opacity: 0; }
	60% { transform: scale(1.15) rotate(4deg); }
	100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ---------- Spotlight (receive loop) ---------- */

.fq-badge-spotlight {
	margin: 12px auto;
	padding: 18px 14px;
	max-width: 480px;
	border-radius: 22px;
	border: 1px solid rgba(255, 201, 61, 0.4);
	background: linear-gradient(180deg, rgba(255, 201, 61, 0.08), rgba(109, 124, 255, 0.06)), var(--bg-surface, #0f1624);
	text-align: center;
	position: relative;
	overflow: hidden;
}

.fq-badge-spotlight__emoji {
	font-size: 56px;
	display: block;
	animation: fqBadgeCelebrate 0.6s ease-out backwards;
}

.fq-badge-spotlight__art {
	display: block;
	line-height: 0;
	margin: 0 auto 6px;
	width: 72px;
	animation: fqBadgeCelebrate 0.6s ease-out backwards;
}

.fq-badge-spotlight__art svg {
	display: block;
}

.fq-badge-spotlight__text {
	font-size: 15px;
	font-weight: 700;
	color: var(--text-primary, #eef4ff);
	margin: 6px 0 2px;
}

.fq-badge-spotlight__sub {
	font-size: 13px;
	color: var(--text-secondary, #b6c4dc);
	margin: 0 0 12px;
}

.fq-badge-spotlight__actions {
	display: flex;
	gap: 8px;
	justify-content: center;
	flex-wrap: wrap;
}

/* CSS-only confetti bits inside spotlight */
.fq-badge-confetti {
	position: absolute;
	top: -8px;
	width: 7px;
	height: 11px;
	border-radius: 2px;
	opacity: 0.85;
	animation: fqConfettiFall 1.8s ease-in forwards;
}

.fq-badge-confetti:nth-child(odd) { background: #ffc93d; }
.fq-badge-confetti:nth-child(even) { background: var(--accent, #6d7cff); }
.fq-badge-confetti:nth-child(3n) { background: #ff4f7b; }
.fq-badge-confetti:nth-child(5n) { background: var(--accent-2, #00c3ff); }

@keyframes fqConfettiFall {
	0% { transform: translateY(-12px) rotate(0deg); opacity: 1; }
	100% { transform: translateY(220px) rotate(540deg); opacity: 0; }
}

/* ---------- Global leaderboard counter chip ---------- */

.fq-badge-count-chip {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	font-size: 11.5px;
	font-weight: 700;
	color: var(--text-secondary, #b6c4dc);
	background: rgba(109, 124, 255, 0.12);
	border: 1px solid rgba(109, 124, 255, 0.3);
	border-radius: 999px;
	padding: 2px 8px;
	margin-left: 6px;
	vertical-align: middle;
	white-space: nowrap;
}

/* Light theme: leaderboard pages use their own light tokens */
body.fq-theme-light .fq-badge-count-chip,
.fq-lb-page .fq-badge-count-chip {
	color: #4b5563;
	background: rgba(47, 87, 216, 0.07);
	border-color: rgba(47, 87, 216, 0.22);
}

.fq-lb-page .fq-badge-chip {
	box-shadow: 0 1px 3px rgba(23, 33, 74, 0.12);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
	.fq-badge-chip,
	.fq-sheet,
	.fq-sheet-backdrop,
	.fq-sheet__detail-art,
	.fq-sheet__success-emoji,
	.fq-sheet__success-art,
	.fq-badge-spotlight__emoji,
	.fq-badge-spotlight__art {
		animation: none !important;
		transition: none !important;
	}
	.fq-badge-confetti {
		display: none;
	}
}
