@use '../../00-abstract/index' as *;
@use "../../tokens/variables";

/* Patterns - Navigation - Bottom Bar Item */
////
/// @group Patterns-Bottom_Bar_Item
/// Patterns - Navigation - Bottom Bar Item

///
.bottom-bar-wrapper {
	// ─── Component CSS API ─────────────────────────────────────────────
	--osui-bottom-bar-background:              var(--color-background-surface);
	--osui-bottom-bar-border-color:            var(--color-border);
	--osui-bottom-bar-item-color:              var(--color-text-subtlest);
	--osui-bottom-bar-item-active-color:       var(--color-primary);
	--osui-bottom-bar-item-icon-color:         #{variables.$token-icon-subtlest};
	--osui-bottom-bar-item-icon-active-color:  var(--osui-bottom-bar-item-active-color);
	// ───────────────────────────────────────────────────────────────────

	background-color: var(--osui-bottom-bar-background);
	border-block-start: variables.$token-border-size-025 solid var(--osui-bottom-bar-border-color);
	height: 100%;
}

///
.bottom-bar {
	display: flex;
	
	&:empty:after {
		color: var(--color-text-subtlest);
		content: 'Add Bottom Bar Items to this Container';
		display: block;
		font-size: variables.$token-font-size-300;
		padding: variables.$token-scale-500;
		text-align: center;
	}
	// The BottomBarItem block renders a plain container, not a link, so colour and the
	// active state must land on whichever element it emits. Scoping them to `> a` alone
	// meant a `div` item silently inherited ambient text colour and `.active` never
	// matched — leaving the selected item visually identical to the rest.
	& > a,
	& > div {
		color: var(--osui-bottom-bar-item-color);
		flex: 1;
		max-width: 150px; // design-spec
		overflow: hidden;

		&.active {
			color: var(--osui-bottom-bar-item-active-color);

			.bottom-bar-item-icon {
				color: var(--osui-bottom-bar-item-icon-active-color);
			}
		}
	}
	&-item {
		@include apply-typography(variables.$token-body-action-xs);

		display: flex;
		flex-direction: column;
		height: 100%;
		justify-content: center;
		overflow: hidden;
		padding-block: 0;
		padding-inline: variables.$token-scale-200;
		position: relative;
		text-align: center;

		&-icon {
			color: var(--osui-bottom-bar-item-icon-color);
			display: inline-flex;
			font-size: variables.$token-font-size-600;
			height: auto;
			justify-content: center;
		}

		&-text {
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			word-wrap: break-word;
		}
	}
}

.android {
	.layout-native {
		.bottom-bar-wrapper {
			padding-block-end: var(--safe-area-inset-bottom, 0px);
		}
	}
}

///
.layout-native {
	.bottom-bar-wrapper {
		padding-bottom: var(--os-safe-area-bottom);
	}
	.bottom-bar {
		height: 100%;
		justify-content: center;
	}
	.footer {
		height: var(--bottom-bar-size);
	}
}

// Accessibility ---------------------------------------------------------------------------
///
.has-accessible-features {
	.bottom-bar {
		& > a:focus {
			background-color: transparent;
			box-shadow: 0 0 0 variables.$token-border-size-075 var(--color-focus-outer);
		}
	}
}
