@import './variables';

.s-badge {
	display: inline-block;
	line-height: $badge-line-height;
	position: relative;

	.s-badge__badge {
		--_badge-offset-x: var(--s-badge-offset-x, 6px);
		--_badge-offset-y: var(--s-badge-offset-y, 6px);

		color: $badge-color;
		display: inline-block;
		font-size: $badge-font-size;
		height: $badge-height;
		letter-spacing: $badge-letter-spacing;
		line-height: 1;
		min-width: $badge-min-width;
		padding: $badge-padding;
		pointer-events: auto;
		position: absolute;
		text-align: center;
		text-indent: 0;
		top: $badge-top;
		transition: $primary-transition;
		white-space: nowrap;
		right: $badge-right;

		&::after {
			color: var(--theme-cards);
		}

		.s-icon {
			color: inherit;
			font-size: $badge-font-size;
			margin: $badge-icon-margin;
		}

		.s-img {
			height: $badge-font-size;
			width: $badge-font-size;
		}

		&:not(.block-end) {
			bottom: calc(100% - var(--_badge-offset-y));

			@supports (inset-block-end: 1px) {
				inset-block-end: calc(100% - var(--_badge-offset-y));
			}
		}

		&.block-end {
			inset-block-end: auto;
			inset-block-start: calc(100% - var(--_badge-offset-y));

			@supports not (inset-inline-start: 1px) {
				bottom: auto;
				top: calc(100% - var(--_badge-offset-y));

				[dir='rtl'] & {
					bottom: calc(100% - var(--_badge-offset-y));
					top: auto;
				}
			}
		}

		&:not(.inline-start) {
			left: calc(100% - var(--_badge-offset-x));

			@supports (inset-inline-start: 1px) {
				inset-inline-start: calc(100% - var(--_badge-offset-x));
			}
		}

		&.inline-start {
			inset-inline-start: auto;
			inset-inline-end: calc(100% - var(--_badge-offset-x));

			@supports not (inset-inline-start: 1px) {
				left: auto;
				right: calc(100% - var(--_badge-offset-x));

				[dir='rtl'] & {
					left: calc(100% - var(--_badge-offset-x));
					right: auto;
				}
			}
		}

		&:not(.tile) {
			border-radius: $badge-border-radius;
		}

		&.bordered {
			&::after {
				border-radius: inherit;
				border-width: $badge-bordered-width;
				border-style: solid;
				bottom: 0;
				content: '';
				left: 0;
				position: absolute;
				right: 0;
				top: 0;
				transform: scale(1.15);
			}
		}

		&.dot {
			border-radius: $badge-dot-border-radius;
			height: $badge-dot-height;
			min-width: 0;
			padding: 0;
			width: $badge-dot-width;

			&::after {
				border-width: $badge-dot-border-width;
			}
		}
	}

	.s-badge__wrapper {
		pointer-events: none;
		position: absolute;
		flex: 0 1;
		height: 100%;
		width: 100%;
		top: 0;
		left: 0;

		@supports (inset-inline-start: 1px) {
			inset-inline-start: 0;
			inset-block-start: 0;
		}
	}
}
