/**
 * Frontend styles for Zhaket Ads.
 *
 * Visual language matches new-theme-html (.topbar / .float-ad).
 * #topbar.zads-ads / #floatAd beat theme base.css hardcoded rules.
 *
 * @package ZhaketAds
 */

/* --------------------------------------------------------------------------
   Topbar
   Source defaults: bg #22232A, text #EDEDF0, CTA #fff / #1F2025
   -------------------------------------------------------------------------- */

#topbar.zads-ads.topbar {
	position: relative;
	z-index: 60;
	background-color: var(--zads-tb-bg, #22232A);
	background-image: none;
	background-size: auto;
	background-position: center;
	background-repeat: no-repeat;
	color: var(--zads-tb-content, #EDEDF0);
	overflow: hidden;
}

/* A full gradient between the two admin colors, from the reading start (right, in
   RTL) to the end. It used to run from the chosen color into fixed dark greys, so a
   new color only tinted one end. Same color twice gives a solid bar. */
#topbar.zads-ads.topbar.topbar--solid {
	background-image: linear-gradient(to left, var(--zads-tb-bg, #22232A), var(--zads-tb-bg-end, #3A3A3A));
}

html:not([dir="rtl"]) #topbar.zads-ads.topbar.topbar--solid {
	background-image: linear-gradient(to right, var(--zads-tb-bg, #22232A), var(--zads-tb-bg-end, #3A3A3A));
}

/* Background image at its own pixel size, centered, never scaled (GIF-safe). */
#topbar.zads-ads.topbar.topbar--has-bg {
	background-size: auto;
	background-position: center;
}

#topbar.zads-ads.topbar[hidden] {
	display: none !important;
}

#topbar.zads-ads.topbar::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	background-image: repeating-linear-gradient(115deg, rgba(255, 150, 6, 0.10) 0 1px, transparent 1px 26px);
}

#topbar.zads-ads.topbar.topbar--has-bg::after {
	background-image: linear-gradient(90deg, rgba(34, 35, 42, 0.35), rgba(34, 35, 42, 0.15));
}

#topbar.zads-ads.topbar.topbar--solid::after {
	opacity: 0.55;
}

#topbar.zads-ads .wrap {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	gap: 14px;
	min-height: 46px;
	padding-block: 8px;
}

#topbar.zads-ads .tb-tag {
	flex: none;
	background: var(--orange, #FF9606);
	color: #fff;
	font-size: 11.5px;
	font-weight: 800;
	padding: 4px 10px;
	border-radius: var(--r-xs, 6px);
	box-shadow: 0 4px 12px rgba(255, 150, 6, 0.35);
}

#topbar.zads-ads .tb-txt {
	font-size: 13px;
	line-height: 1.85;
	color: var(--zads-tb-content, #EDEDF0);
	min-width: 0;
}

#topbar.zads-ads .tb-txt b,
#topbar.zads-ads .tb-txt strong {
	color: inherit;
	font-weight: 800;
}

#topbar.zads-ads .tb-timer {
	display: flex;
	align-items: center;
	gap: 5px;
	flex: none;
	direction: ltr;
}

#topbar.zads-ads .tb-timer__days {
	display: contents;
}

#topbar.zads-ads .tb-timer__days[hidden] {
	display: none !important;
}

#topbar.zads-ads .tb-timer i {
	background: var(--zads-tb-counter, #3A3A3A);
	color: var(--zads-tb-counter-num, #ffffff);
	border-radius: var(--r-xs, 6px);
	font-style: normal;
	font-size: 12.5px;
	font-weight: 800;
	padding: 4px 7px;
	min-width: 28px;
	text-align: center;
}

#topbar.zads-ads .tb-timer s {
	text-decoration: none;
	opacity: 0.55;
	font-weight: 800;
	color: var(--zads-tb-counter-title, #EDEDF0);
}

#topbar.zads-ads .tb-cta {
	flex: none;
	margin-inline-start: auto;
	background-color: var(--zads-tb-btn, #ffffff);
	color: var(--zads-tb-btn-text, #1F2025);
	font-size: 12.5px;
	font-weight: 700;
	padding: 7px 15px;
	border-radius: var(--r-btn, 8px);
	transition: background-color 0.16s, color 0.16s, filter 0.16s;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 0;
	height: auto;
}

/* Documented Large size (admin override of source compact). */
#topbar.zads-ads .tb-cta--lg {
	min-width: 200px;
	height: 40px;
	padding: 0 18px;
	font-size: 14px;
}

/* Documented Small size (admin override of source compact). */
#topbar.zads-ads .tb-cta--sm {
	min-width: 140px;
	height: 36px;
	padding: 0 14px;
	font-size: 12.5px;
}

/* Source hover: orange fill when CTA is still the default white. */
#topbar.zads-ads .tb-cta:hover,
#topbar.zads-ads .tb-cta:focus {
	background-color: var(--orange, #FF9606);
	color: #fff;
	filter: none;
}

#topbar.zads-ads .tb-x {
	flex: none;
	width: 28px;
	height: 28px;
	border: 0;
	border-radius: var(--r-xs, 6px);
	background: transparent;
	color: #9A9BA3;
	display: grid;
	place-items: center;
	cursor: pointer;
	transition: 0.16s;
}

#topbar.zads-ads .tb-x:hover,
#topbar.zads-ads .tb-x:focus {
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
}

/* Image banner: the admin's banner background fills whatever the image does not --
   the sides, once the window is wider than the image. */
#topbar.zads-ads.topbar.topbar--banner {
	padding: 0;
	min-height: 0;
	height: auto;
	background: var(--zads-tb-banner-bg, transparent);
	background-image: none;
}

#topbar.zads-ads.topbar--banner::after {
	display: none;
}

.topbar-banner {
	position: relative;
	width: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	line-height: 0;
}

.topbar-banner__link {
	display: flex;
	justify-content: center;
	align-items: center;
	width: 100%;
	/* A wrongly sized upload is cropped to this, not shrunk (and the page is spared a
	   1000px-tall bar). */
	max-height: 160px;
	overflow: hidden;
	line-height: 0;
}

/* Always the image's own pixel size -- never scaled, since these are often GIFs.
   Centered: on a wider screen the sides show the banner background; on a narrower
   one the sides are cropped (flex centering overflows both ways equally), so the
   content that matters belongs in the middle of the image. */
.topbar-banner__img {
	display: none;
	flex: none;
	width: auto;
	height: auto;
	max-width: none;
	max-height: none;
	margin: 0;
	vertical-align: top;
}

.topbar-banner__img--desktop {
	display: block;
}

.topbar-banner__img--mobile {
	display: none;
}

#topbar.zads-ads.topbar--banner .tb-x {
	position: absolute;
	top: 50%;
	inset-inline-end: 16px;
	transform: translateY(-50%);
	z-index: 2;
	color: #fff;
	background: rgba(31, 32, 37, 0.42);
}

#topbar.zads-ads.topbar--elementor {
	background: transparent;
	background-image: none;
	overflow: visible;
	height: auto;
	min-height: 0;
}

#topbar.zads-ads.topbar--elementor::after {
	display: none;
}

@media (max-width: 980px) {
	#topbar.zads-ads .tb-timer {
		display: none;
	}
}

@media (max-width: 720px) {
	#topbar.zads-ads .wrap {
		gap: 9px;
	}

	#topbar.zads-ads .tb-txt {
		font-size: 11.5px;
		line-height: 1.7;
	}

	#topbar.zads-ads .tb-txt .hide-m {
		display: none;
	}

	#topbar.zads-ads .tb-cta {
		padding: 6px 11px;
		font-size: 11.5px;
	}

	#topbar.zads-ads .tb-cta--lg {
		min-width: 120px;
		height: 36px;
	}

	#topbar.zads-ads .tb-cta--sm {
		min-width: 100px;
		height: 32px;
	}

	#topbar.zads-ads .tb-tag {
		font-size: 10.5px;
		padding: 3px 8px;
	}

	.topbar-banner__img--desktop {
		display: none;
	}

	.topbar-banner__img--mobile {
		display: block;
	}

	#topbar.zads-ads.topbar--banner .tb-x {
		inset-inline-end: 12px;
	}
}

/* --------------------------------------------------------------------------
   Floating ad (source: new-theme-html)
   -------------------------------------------------------------------------- */

#floatAd.float-ad {
	position: fixed;
	right: 22px;
	bottom: 22px;
	z-index: 95;
	/* As wide as the cover image (plus the 1px borders), capped at 420px; a wider
	   image is cropped at the sides, never shrunk. */
	width: calc(min(var(--zads-fb-cover-w, 324px), 420px) + 2px);
	max-width: calc(100vw - 32px);
	background: #fff;
	border: 1px solid var(--g3, #F4F5F6);
	border-radius: var(--r-lg, 14px);
	box-shadow: var(--sh-xl, 0 20px 60px -15px rgba(0, 0, 0, 0.15));
	overflow: hidden;
	transform: translateX(calc(100% + 40px));
	opacity: 0;
	transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s;
	pointer-events: none;
}

#floatAd.float-ad[hidden] {
	display: none !important;
}

#floatAd.float-ad.on {
	transform: none;
	opacity: 1;
	pointer-events: auto;
}

#floatAd .fa-cover {
	position: relative;
	display: grid;
	place-items: center;
	/* The image's own height and its own pixel size (background-size: auto). */
	/* Capped so a wrongly sized upload is cropped, not shrunk, and never towers. */
	height: min(var(--zads-fb-cover-h, 118px), 300px);
	color: #fff;
	text-align: center;
	padding: 14px;
	text-decoration: none;
	background-image: var(--zads-fb-cover, none);
	background-size: auto;
	background-repeat: no-repeat;
	background-position: center;
}

/* Nothing is drawn over the image: the theme's own stripe overlay is switched off
   too. Only the badge and the close button sit on it. */
#floatAd .fa-cover::after {
	content: none;
	display: none;
}



#floatAd .fa-off {
	position: absolute;
	top: 11px;
	right: 11px;
	z-index: 2;
	background: linear-gradient(180deg, var(--off-a, #FCA803), var(--off-b, #FBB002));
	color: #fff;
	font-size: 12.5px;
	font-weight: 800;
	padding: 5px 10px;
	border-radius: var(--r-btn, 8px);
	direction: ltr;
	box-shadow: 0 4px 10px rgba(251, 175, 2, 0.4);
	max-width: 60%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

#floatAd .fa-x {
	position: absolute;
	top: 9px;
	left: 9px;
	z-index: 3;
	width: 28px;
	height: 28px;
	border: 0;
	border-radius: 50%;
	background: var(--zads-fb-close-bg, rgba(31, 32, 37, 0.42));
	color: var(--zads-fb-close-fg, #fff);
	display: grid;
	place-items: center;
	cursor: pointer;
	transition: 0.16s;
	backdrop-filter: blur(3px);
}

#floatAd .fa-x:hover,
#floatAd .fa-x:focus {
	background: rgba(31, 32, 37, 0.72);
}

#floatAd .fa-body {
	padding: 14px 15px 16px;
}

#floatAd .fa-body h3 {
	font-size: 14.5px;
	line-height: 1.85;
	margin: 0 0 7px;
}

#floatAd .fa-body p {
	font-size: 12.5px;
	color: var(--g7, #6B6E76);
	line-height: 1.95;
	margin: 0 0 12px;
}

#floatAd .fa-price {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 9px;
	margin-bottom: 12px;
}

#floatAd .fa-price .old {
	font-size: 11.5px;
	color: var(--price-old, #9CA3AF);
	text-decoration: line-through;
}

#floatAd .fa-price .now {
	font-size: 16px;
	font-weight: 800;
	color: var(--g9, #1F2025);
}

#floatAd .fa-price .now small {
	font-size: 11px;
	font-weight: 600;
	color: var(--g7, #6B6E76);
}

/* Countdown to the campaign end, pinned to the far (left, in RTL) end of the row:
   four small tiles, number on top, unit underneath. */
/* Read left to right like a clock: days on the left, then hours, minutes, seconds. */
#floatAd .fa-countdown {
	margin-inline-start: auto;
	display: flex;
	direction: ltr;
	gap: 4px;
	flex: none;
}

#floatAd .fa-cd {
	display: grid;
	justify-items: center;
	min-width: 34px;
	padding: 4px 3px 3px;
	border-radius: var(--r-xs, 6px);
	background: var(--redL, #FFF1ED);
	line-height: 1.2;
}

#floatAd .fa-cd b {
	font-size: 13px;
	font-weight: 800;
	color: var(--red, #E5484D);
	font-variant-numeric: tabular-nums;
}

#floatAd .fa-cd small {
	margin-top: 1px;
	font-size: 9.5px;
	font-weight: 600;
	color: var(--g6, #8A8F98);
}

/* Title and slogan are links now, but read as text. */
#floatAd .fa-body .fa-link {
	color: inherit;
	text-decoration: none;
}

#floatAd .fa-body h3 .fa-link:hover,
#floatAd .fa-body h3 .fa-link:focus {
	color: var(--orange, #FF9606);
}

#floatAd .fa-cta {
	background: var(--zads-fb-btn, var(--orange, #FF9606));
}

/* Code and copy button share one height (they drifted apart on mobile, where the
   theme's .btn-sm sizing differs). */
#floatAd .fa-discount {
	display: flex;
	align-items: stretch;
	gap: 8px;
}

#floatAd .fa-code {
	flex: 1 1 auto;
	font-size: 13px;
	font-weight: 800;
	direction: ltr;
	text-align: center;
	padding: 0 10px;
	height: 40px;
	line-height: 40px;
	box-sizing: border-box;
	border-radius: var(--r-xs, 6px);
	background: rgba(96, 151, 243, 0.12);
}

#floatAd .fa-discount .fa-copy {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 40px;
	min-height: 40px;
	margin: 0;
	padding: 0 16px;
	box-sizing: border-box;
	border: 0;
	border-radius: var(--r-btn, 8px);
	background: var(--zads-fb-copy, #FF9606);
	color: var(--zads-fb-copy-text, #ffffff);
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	transition: filter 0.15s;
}

#floatAd .fa-discount .fa-copy:hover,
#floatAd .fa-discount .fa-copy:focus {
	filter: brightness(0.92);
}

#floatAd .fa-mobile-img {
	display: none;
	justify-content: center;
	overflow: hidden;
	line-height: 0;
}

/* Own size, never scaled (see the cover). */
#floatAd .fa-mobile-img img {
	display: block;
	flex: none;
	width: auto;
	height: auto;
	max-width: none;
}


#floatAd.float-ad--elementor {
	background: transparent;
	border: 0;
	box-shadow: none;
	overflow: visible;
	width: auto;
	max-width: calc(100vw - 32px);
	padding: 0;
}

@media (max-width: 720px) {
	#floatAd.float-ad {
		left: 16px;
		right: 16px;
		bottom: 16px;
		width: auto;
		max-width: none;
	}

	#floatAd.float-ad--context-product {
		bottom: 100px;
	}

	#floatAd.float-ad--context-cart {
		bottom: 150px;
	}

	/* Text cards on a phone show the mobile image, at its own size and height. */
	#floatAd.float-ad--mobile-cover .fa-cover {
		height: min(var(--zads-fb-mobile-h, 145px), 300px);
		background-image: var(--zads-fb-cover-mobile, var(--zads-fb-cover, none));
	}

	body.has-buybar #floatAd.float-ad {
		bottom: 88px;
	}

	/* Exactly as wide as the mobile image; cropped only on a screen narrower still. */
	#floatAd.float-ad--image {
		width: var(--zads-fb-mobile-w, var(--zads-fb-width, 300px));
		max-width: calc(100vw - 24px);
		left: auto;
		right: 12px;
		background: transparent;
		border: 0;
		box-shadow: none;
		border-radius: 0;
	}

	#floatAd.float-ad--image .fa-cover {
		display: none;
	}

	#floatAd.float-ad--image .fa-mobile-img {
		display: flex;
	}

	#floatAd.float-ad--image .fa-mobile-img img {
		border-radius: var(--r-lg, 14px);
		box-shadow: var(--sh-xl, 0 20px 60px -15px rgba(0, 0, 0, 0.15));
	}
}

@media (prefers-reduced-motion: reduce) {
	#floatAd.float-ad {
		transition: opacity 0.2s ease;
		transform: none;
	}
}
