/* Smart Announcement Bar - Public Frontend Styles */

.sab-bar {
	position: relative;
	z-index: 99990;
	width: 100%;
	box-sizing: border-box;
	background-color: var(--sab-bg, #0f172a);
	color: var(--sab-color, #ffffff);
	font-family: var(--sab-font-family, inherit);
	font-size: var(--sab-font-size, 14px);
	line-height: 1.45;
	min-height: var(--sab-min-height, 42px);
	padding: var(--sab-pad-y, 8px) var(--sab-pad-x, 16px);
	display: flex;
	align-items: center;
	overflow: hidden;
	contain: layout style;
}

.sab-bar *,
.sab-bar *::before,
.sab-bar *::after {
	box-sizing: border-box;
}

.sab-bar.is-dismissed {
	display: none !important;
}

/* Positioning */
.sab-bar.sab-pos-top.sab-is-sticky {
	position: sticky;
	top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--sab-banner-offset, 0px));
}

.sab-bar.sab-pos-top {
	z-index: 420;
}

.sab-bar.sab-pos-bottom {
	position: relative;
}

.sab-bar.sab-pos-inline {
	position: relative;
	z-index: 10;
	border-radius: inherit;
}

.sab-bar.sab-pos-bottom.sab-is-sticky {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.12);
}

/* Prevent bottom sticky bar from covering Woodmart mobile bottom toolbar or WooCommerce sticky add-to-cart */
@media (max-width: 1024px) {
	body.sab-woodmart-compat .sab-bar.sab-pos-bottom.sab-is-sticky {
		bottom: var(--wd-toolbar-height, 0px);
	}
}

/* Coordinate top sticky bar cleanly with Woodmart sticky header without overlap */
body.sab-woodmart-compat .whb-header.whb-sticked {
	top: calc(var(--wp-admin--admin-bar--height, 0px) + var(--sab-top-sticky-height, 0px));
}

/* Coordinate overlapping Woodmart header when top announcement bar is active */
body.sab-woodmart-compat.sab-has-top-bar .whb-header.whb-overcontent:not(.whb-sticked) {
	top: var(--sab-above-header-height, 0px);
}

/* Stay safely beneath WordPress admin bar (99999) and Woodmart mobile drawer/popups (500+) */
.sab-bar {
	z-index: 380;
}

/* Device Visibility */
@media (max-width: 767px) {
	.sab-bar.sab-device-desktop {
		display: none !important;
	}
}

@media (min-width: 768px) {
	.sab-bar.sab-device-mobile {
		display: none !important;
	}
}

/* Inner layout */
.sab-bar__inner {
	width: 100%;
	max-width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	position: relative;
}

.sab-bar__viewport {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Message elements */
.sab-msg {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: inherit;
	text-decoration: none;
	white-space: nowrap;
	font-weight: 500;
}

.sab-msg--link {
	cursor: pointer;
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: opacity 0.2s ease, border-color 0.2s ease;
}

.sab-msg--link:hover,
.sab-msg--link:focus-visible {
	opacity: 0.88;
	border-bottom-color: currentColor;
	outline: none;
}

.sab-msg__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	line-height: 1;
}

.sab-msg__icon svg {
	display: block;
	width: 1.1em;
	height: 1.1em;
}

.sab-msg__emoji {
	display: inline-block;
	flex-shrink: 0;
	line-height: 1;
}

.sab-sep {
	opacity: 0.55;
	margin-inline: 18px;
	flex-shrink: 0;
}

/* Continuous Marquee Mode (Seamless Infinite Track) */
.sab-marquee {
	width: 100%;
	overflow: hidden;
	display: flex;
	align-items: center;
	/* Force LTR layout coordinates internally so translate3d math stays uniform across RTL/LTR pages */
	direction: ltr;
}

.sab-marquee__runner {
	display: flex;
	align-items: center;
	width: max-content;
	will-change: transform;
	animation-name: sab-marquee-rtl-move;
	animation-duration: var(--sab-loop-duration, 24s);
	animation-timing-function: linear;
	animation-iteration-count: infinite;
}

/* LTR setting = moves left-to-right; RTL setting = moves right-to-left */
.sab-bar.sab-dir-ltr .sab-marquee__runner {
	animation-name: sab-marquee-ltr-move;
}

.sab-bar:hover .sab-marquee__runner,
.sab-bar:focus-within .sab-marquee__runner {
	animation-play-state: paused;
}

.sab-marquee__track {
	display: flex;
	align-items: center;
	flex-shrink: 0;
}

.sab-item {
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
	direction: rtl;
}

.sab-bar.sab-dir-ltr .sab-item {
	direction: ltr;
}

/* Right-to-left motion (enters from right, exits left) */
@keyframes sab-marquee-rtl-move {
	0% {
		transform: translate3d(0, 0, 0);
	}
	100% {
		transform: translate3d(calc(-1 * var(--sab-loop-distance, 50%)), 0, 0);
	}
}

/* Left-to-right motion (enters from left, exits right) */
@keyframes sab-marquee-ltr-move {
	0% {
		transform: translate3d(calc(-1 * var(--sab-loop-distance, 50%)), 0, 0);
	}
	100% {
		transform: translate3d(0, 0, 0);
	}
}

/* Interval Switcher Mode */
.sab-slider {
	position: relative;
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 1.5em;
}

.sab-slide {
	display: none;
	align-items: center;
	justify-content: center;
	text-align: center;
	max-width: 100%;
	animation: sab-fade-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.sab-slide.is-active {
	display: flex;
}

.sab-slide .sab-msg {
	white-space: normal;
	justify-content: center;
	flex-wrap: wrap;
}

@keyframes sab-fade-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Close Button */
.sab-bar__close {
	appearance: none;
	-webkit-appearance: none;
	background: transparent;
	border: 1px solid transparent;
	color: inherit;
	opacity: 0.78;
	cursor: pointer;
	padding: 6px;
	margin: 0;
	border-radius: 6px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	min-width: 28px;
	min-height: 28px;
	transition: opacity 0.2s ease, background-color 0.2s ease;
}

.sab-bar__close:hover,
.sab-bar__close:focus-visible {
	opacity: 1;
	background-color: rgba(255, 255, 255, 0.14);
	outline: none;
}

/* Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
	.sab-marquee__runner {
		animation: none !important;
		transform: none !important;
		width: 100%;
		justify-content: center;
		flex-wrap: wrap;
		gap: 8px 16px;
	}

	.sab-marquee__track[data-sab-clone="1"] {
		display: none !important;
	}

	.sab-slide {
		animation: none !important;
	}
}

/* Mobile refinements */
@media (max-width: 767px) {
	.sab-bar {
		font-size: max(12px, calc(var(--sab-font-size, 14px) - 1px));
		padding-inline: max(10px, calc(var(--sab-pad-x, 16px) * 0.75));
	}
}
