/**
 * The BzzCoin button in the Bzz Post header.
 *
 * Written to look like it came with the theme: the same lime, the same greys, the
 * same two typefaces, and the theme's own square corners. Every property the
 * newspaper's stylesheet might otherwise reach into — margins on paragraphs, link
 * colours, button chrome — is set here rather than inherited, because this markup
 * lands inside somebody else's header and must not depend on what it finds.
 */

.bzzcoin {
	position: relative;
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
	margin-left: 16px;
	font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
	line-height: 1.4;
}

/* No header to sit in. Pinned to the corner so there is still a way in. */
.bzzcoin--loose {
	position: fixed;
	top: 12px;
	right: 12px;
	z-index: 9999;
	margin-left: 0;
}

/*
 * After sign-in the B sits in .footer-social, same size as Facebook / TikTok /
 * Instagram, immediately to the left of Facebook.
 */
.bzzcoin--foot {
	margin-left: 0;
	z-index: 30;
}

.bzzcoin--foot .bzzcoin__button {
	width: 18px;
	height: 18px;
	padding: 0;
	border: none;
	background: transparent;
	gap: 0;
}

.bzzcoin--foot .bzzcoin__button:hover,
.bzzcoin--foot .bzzcoin__button:focus-visible,
.bzzcoin--foot[data-state="reader"] .bzzcoin__button {
	background: transparent;
	border: none;
}

.bzzcoin--foot .bzzcoin__label {
	display: none;
}

.bzzcoin--foot .bzzcoin__mark {
	width: 18px;
	height: 18px;
	font-size: 10px;
}

.bzzcoin--foot .bzzcoin__panel {
	top: auto;
	right: auto;
	bottom: calc(100% + 12px);
	left: 50%;
	transform: translateX(-50%);
}

.bzzcoin--foot .bzzcoin__flash {
	top: auto;
	right: auto;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translate(-50%, 6px);
}

.bzzcoin--foot[data-flash="true"] .bzzcoin__flash {
	transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------- the button */

.bzzcoin__button {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	margin: 0;
	padding: 6px 12px;
	border: 1px solid #1f2937;
	border-radius: 999px;
	background: #ffffff;
	box-shadow: none;
	color: #1f2937;
	font-family: inherit;
	font-size: 13px;
	font-weight: 700;
	line-height: 1.3;
	text-transform: none;
	cursor: pointer;
	transition: background 150ms ease, color 150ms ease;
}

.bzzcoin__button:hover,
.bzzcoin__button:focus-visible {
	background: #ddfa6c;
	border-color: #1f2937;
	color: #1f2937;
}

/* Nothing to say until the server has answered who this is. */
.bzzcoin[data-state="asking"] .bzzcoin__button {
	opacity: 0;
	pointer-events: none;
}

.bzzcoin[data-state="reader"] .bzzcoin__button {
	background: #ddfa6c;
	border-color: #ddfa6c;
}

.bzzcoin__mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 17px;
	height: 17px;
	flex-shrink: 0;
	border-radius: 50%;
	background: #1f2937;
	color: #ddfa6c;
	font-family: "Poppins", "Manrope", sans-serif;
	font-size: 11px;
	font-weight: 600;
	line-height: 1;
}

.bzzcoin[data-state="reader"] .bzzcoin__mark {
	background: #1f2937;
	color: #ddfa6c;
}

.bzzcoin__label {
	white-space: nowrap;
}

.bzzcoin[data-state="reader"] .bzzcoin__label::after {
	content: " Bzz";
	font-weight: 600;
	opacity: 0.75;
}

/* ----------------------------------------------------------------- the panel */

.bzzcoin__panel {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	z-index: 20;
	width: 268px;
	max-width: calc(100vw - 24px);
	padding: 20px;
	background: #ffffff;
	border: 2px solid #1f2937;
	border-radius: 16px;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
	color: #1f2937;
	font-size: 14px;
	text-align: left;
}

.bzzcoin__title {
	margin: 0 0 10px;
	font-family: "Poppins", "Manrope", sans-serif;
	font-size: 13px;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #1f2937;
}

.bzzcoin__row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding: 5px 0;
}

.bzzcoin__rowLabel {
	color: #6b7280;
	font-size: 13px;
}

.bzzcoin__value {
	font-weight: 700;
	white-space: nowrap;
}

.bzzcoin__note,
.bzzcoin__fine,
.bzzcoin__drop {
	margin: 8px 0 0;
	color: #4b5563;
	font-size: 14px;
}

.bzzcoin__fine {
	margin-top: 10px;
}

.bzzcoin__drop {
	color: #1f2937;
	font-weight: 600;
}

.bzzcoin__cta {
	display: block;
	margin-top: 12px;
	padding: 9px 12px;
	border-radius: 999px;
	background: #ddfa6c;
	color: #1f2937;
	font-size: 14px;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
	box-shadow: none;
}

.bzzcoin__cta:hover,
.bzzcoin__cta:focus-visible {
	background: #111827;
	color: #ddfa6c;
	text-decoration: none;
}

.bzzcoin__links {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-top: 12px;
	padding-top: 10px;
	border-top: 1px solid #f2f2f2;
}

.bzzcoin__link {
	padding: 5px 0;
	color: #1f2937;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
}

.bzzcoin__link:hover,
.bzzcoin__link:focus-visible {
	color: #1f2937;
	text-decoration: underline;
}

.bzzcoin__quiet {
	display: inline-block;
	margin-top: 12px;
	color: #6b7280;
	font-size: 12px;
	text-decoration: underline;
}

.bzzcoin__quiet:hover {
	color: #1f2937;
}

/* ----------------------------------------------------------------- the flash */

.bzzcoin__flash {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	z-index: 19;
	padding: 7px 12px;
	border-radius: 999px;
	background: #ddfa6c;
	color: #1f2937;
	font-family: "Poppins", "Manrope", sans-serif;
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
	opacity: 0;
	transform: translateY(-6px);
	transition: opacity 260ms ease, transform 260ms ease;
	pointer-events: none;
}

.bzzcoin[data-flash="true"] .bzzcoin__flash {
	opacity: 1;
	transform: translateY(0);
}

/* The panel is the fuller answer; two things pointing at once is noise. */
.bzzcoin[data-open="true"] .bzzcoin__flash {
	display: none;
}

/* ---------------------------------------------------------------- narrow screens */

@media (max-width: 768px) {
	.bzzcoin {
		flex-shrink: 0;
		min-width: fit-content;
		overflow: visible;
		margin-left: 10px;
	}

	.bzzcoin__button {
		flex-shrink: 0;
		min-width: 90px;
		overflow: visible;
		padding: 6px 11px;	
		font-size: clamp(11px, 3.2vw, 13px);
		white-space: nowrap;
	}

	/* A phone header holds a logo, a search, this, and a hamburger. The unit is
	   the first thing to go: the coin already says what the number is. */
	.bzzcoin[data-state="reader"] .bzzcoin__label::after {
		content: none;
	}

	/* Truncation is only for the numeric balance once signed in — the "Sign in"
	   label itself must never be clipped. */
	.bzzcoin[data-state="reader"] .bzzcoin__label {
		max-width: 96px;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.bzzcoin__label {
		white-space: nowrap;
	}

	/* Right of centre, so the panel cannot hang off the edge of the screen. */
	.bzzcoin__panel {
		right: -8px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bzzcoin__button,
	.bzzcoin__flash {
		transition: none;
	}
}
