/**
 * Befello Profiles — navigation account control.
 *
 * This is the only stylesheet that may load on ordinary pages, so it is
 * kept deliberately small and every selector is namespaced to .befello-*.
 * Nothing here can reach the theme's own menu, header or logo.
 */

.befello-account {
	position: relative;
	display: inline-flex;
	align-items: center;
	line-height: 1;
}

/* Neutralise the theme's link/button styling inside our control only. */
.befello-account .befello-account__trigger {
	-webkit-appearance: none;
	appearance: none;
	background: none;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.befello-account .befello-account__trigger:hover {
	box-shadow: 0 0 0 3px var(--befello-ring);
}

.befello-account .befello-account__trigger:focus-visible {
	box-shadow: 0 0 0 3px var(--befello-ring-strong);
	outline: none;
}

.befello-account .befello-account__trigger[aria-expanded="true"] {
	box-shadow: 0 0 0 3px var(--befello-ring);
}

.befello-account__trigger--guest {
	background: color-mix(in srgb, var(--befello-primary) 8%, #fff) !important;
	border: 1px solid var(--befello-border) !important;
	color: var(--befello-primary-dark);
	height: var(--befello-avatar-size, 36px);
	width: var(--befello-avatar-size, 36px);
}

/*
 * flex: 0 0 auto and the matching min/max are load-bearing, not tidy-up.
 * The avatar sits inside inline-flex/flex parents, so without them a
 * cramped navigation bar shrinks it horizontally and the "circle" renders
 * as an ellipse. The explicit sizes also outrank a theme's global
 * `img { width: 100%; height: auto }` reset.
 */
.befello-account .befello-avatar {
	border-radius: 50%;
	display: block;
	flex: 0 0 auto;
	height: var(--befello-avatar-size, 36px);
	max-width: none;
	min-width: var(--befello-avatar-size, 36px);
	object-fit: cover;
	width: var(--befello-avatar-size, 36px);
}

.befello-account .befello-avatar--initials {
	align-items: center;
	background: var(--befello-avatar-bg, #2563EB);
	color: var(--befello-avatar-fg, #fff);
	display: flex;
	font-size: calc(var(--befello-avatar-size, 36px) * 0.4);
	font-weight: 600;
	justify-content: center;
	line-height: 1;
	user-select: none;
}

.befello-account .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Panel ------------------------------------------------------------------ */

.befello-account .befello-account__panel {
	background: var(--befello-surface, #fff);
	border: 1px solid var(--befello-border, #DCE4F2);
	border-radius: var(--befello-radius, 14px);
	box-shadow: var(--befello-shadow-lg, 0 12px 40px -12px rgba(18, 32, 59, .28));
	color: var(--befello-text, #12203B);
	font-size: 0.92rem;
	line-height: 1.4;
	min-width: 15rem;
	padding: 0.4rem;
	position: absolute;
	right: 0;
	text-align: left;
	top: calc(100% + 0.6rem);
	z-index: 999;
}

.befello-account .befello-account__panel[hidden] {
	display: none;
}

/* Flip to the left edge when the trigger sits near the viewport edge. */
.befello-account[data-align="left"] .befello-account__panel {
	left: 0;
	right: auto;
}

.befello-account__header {
	align-items: center;
	border-bottom: 1px solid var(--befello-border, #DCE4F2);
	display: flex;
	gap: 0.65rem;
	margin-bottom: 0.3rem;
	padding: 0.6rem 0.65rem 0.75rem;
}

.befello-account__header .befello-avatar {
	--befello-avatar-size: 40px;
	min-width: 40px;
}

.befello-account__identity {
	display: flex;
	flex-direction: column;
	gap: 0.1rem;
	min-width: 0;
}

.befello-account__name {
	color: var(--befello-text, #12203B);
	font-weight: 700;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.befello-account .befello-account__view {
	color: var(--befello-primary, #2563EB);
	font-size: 0.85rem;
	font-weight: 600;
	text-decoration: none;
}

.befello-account .befello-account__view:hover,
.befello-account .befello-account__view:focus-visible {
	text-decoration: underline;
}

.befello-account__group {
	padding: 0.15rem 0;
}

.befello-account__group--last {
	border-top: 1px solid var(--befello-border, #DCE4F2);
	margin-top: 0.3rem;
	padding-top: 0.3rem;
}

.befello-account .befello-account__item {
	align-items: center;
	border-radius: calc(var(--befello-radius, 14px) * 0.5);
	color: var(--befello-text, #12203B);
	display: flex;
	gap: 0.6rem;
	/* Comfortable tap target. */
	min-height: 44px;
	padding: 0.55rem 0.65rem;
	text-decoration: none;
	transition: background-color 0.12s ease, color 0.12s ease;
}

.befello-account .befello-account__item:hover {
	background: var(--befello-surface-alt, #F8FAFF);
	color: var(--befello-primary-dark, #173B73);
}

.befello-account .befello-account__item:focus-visible {
	background: var(--befello-surface-alt, #F8FAFF);
	box-shadow: inset 0 0 0 2px var(--befello-ring-strong);
	outline: none;
}

.befello-account .befello-account__item .befello-icon {
	color: var(--befello-muted, #5A6A85);
	flex: 0 0 auto;
}

/* Signed-out links ------------------------------------------------------- */

.befello-account--guest-links {
	align-items: center;
	display: inline-flex;
	gap: 0.5rem;
}

.befello-account .befello-account__signin {
	color: inherit;
	font-weight: 600;
	text-decoration: none;
}

.befello-account .befello-account__signin:hover {
	color: var(--befello-primary, #2563EB);
}

.befello-account .befello-account__join {
	background: var(--befello-primary, #2563EB);
	border-radius: 999px;
	color: #fff;
	display: inline-flex;
	align-items: center;
	font-size: 0.88rem;
	font-weight: 600;
	line-height: 1.2;
	min-height: 40px;
	padding: 0.5rem 1rem;
	text-decoration: none;
	transition: background-color 0.15s ease;
	white-space: nowrap;
}

.befello-account .befello-account__join:hover,
.befello-account .befello-account__join:focus-visible {
	background: var(--befello-primary-dark, #173B73);
	color: #fff;
}

/* Menu item wrapper ------------------------------------------------------ */

/*
 * Themes give menu links their height through padding on the <a>. Our item
 * has no link, so it needs its own padding and centring or the avatar sits
 * flush against the top of the bar.
 */
.befello-account-menu-item {
	align-items: center;
	display: flex;
	padding: 0 var(--befello-menu-gap, 12px);
}

.befello-account-menu-item > .befello-account {
	/* Beats a theme's `.menu li > *` line-height inheritance. */
	line-height: 0;
}

/* Mobile ----------------------------------------------------------------- */

@media (max-width: 47.99em) {
	.befello-account .befello-account__panel {
		left: auto;
		right: 0;
		/* Never wider than the screen, never off-canvas. */
		max-width: min(18rem, calc(100vw - 1.5rem));
		min-width: 13rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.befello-account,
	.befello-account * {
		transition-duration: 0.001ms !important;
		animation-duration: 0.001ms !important;
	}
}
