/*
 * Google review badge and its "how is this worked out" tooltip
 * (includes/demas-review-stats.php, GreenLight 173 to-do #13).
 *
 *   .demas-rb            block row; aligns the badge (is-align-*, -t- tablet, -m- mobile)
 *   .demas-rb__inner     the badge: Google G, rating + stars (a <button>), the review
 *                        count (a link to the Google profile)
 *   .demas-tip           positioned container of a trigger and its bubble; also wraps the
 *                        homepage counter (.demas-tip--counter)
 *   .demas-tip__bubble   role="tooltip", in the HTML for crawlers and aria-describedby,
 *                        display: none until opened, so it never widens the page
 *
 * Opens on hover (devices that hover), keyboard focus (:focus-visible) and .is-open (a tap,
 * assets/demas-review-stats.js). .is-dismissed (Escape) keeps it shut until the pointer or
 * focus leaves. --demas-tip-shift keeps it inside the viewport (set by the script).
 *
 * Brand: navy #071025 and the site's gold gradient (.gold-txt / .free-btn), Gilroy for the
 * rating, DIN Pro for text. The badge replaces PNG badges that sat on dark bands, so the
 * dark theme is the default; theme="light" is for light backgrounds.
 */

.demas-rb {
	--demas-gold: linear-gradient(270deg, #88541b -46.55%, #dcb458 2.16%, #f3dd9f 50.86%, #dcb458 99.56%, #88541b 148.26%);
	--demas-rb-text: #fff;
	--demas-rb-star-empty: rgb(255 255 255 / 0.28);
	display: flex;
	justify-content: center;
	width: 100%;
}

.demas-rb--light {
	--demas-gold: linear-gradient(270deg, #88541b -46.55%, #dcb458 26.51%, #88541b 77.18%, #dcb458 138.52%);
	--demas-rb-text: #071025;
	--demas-rb-star-empty: rgb(7 16 37 / 0.2);
}

.demas-rb.is-align-left { justify-content: flex-start; }
.demas-rb.is-align-center { justify-content: center; }
.demas-rb.is-align-right { justify-content: flex-end; }

@media (max-width: 1024px) {
	.demas-rb.is-align-t-left { justify-content: flex-start; }
	.demas-rb.is-align-t-center { justify-content: center; }
	.demas-rb.is-align-t-right { justify-content: flex-end; }
}

@media (max-width: 767px) {
	.demas-rb.is-align-m-left { justify-content: flex-start; }
	.demas-rb.is-align-m-center { justify-content: center; }
	.demas-rb.is-align-m-right { justify-content: flex-end; }
}

.demas-rb__inner {
	align-items: center;
	color: var(--demas-rb-text);
	display: inline-flex;
	font-size: clamp(13px, 1.05vw, 17px);
	gap: 0.6em;
	max-width: 100%;
	text-align: left;
}

.demas-rb--lg .demas-rb__inner {
	font-size: clamp(14px, 1.5vw, 24px);
}

@media (max-width: 767px) {
	.demas-rb__inner { font-size: 12px; gap: 0.5em; }
	.demas-rb--lg .demas-rb__inner { font-size: 15px; gap: 0.6em; }
}

.demas-rb__g {
	flex: none;
	height: 2.7em;
	width: 2.7em;
}

.demas-rb__body {
	align-items: flex-start;
	display: flex;
	flex-direction: column;
	gap: 0.2em;
	min-width: 0;
}

button.demas-rb__score {
	align-items: center;
	display: inline-flex;
	gap: 0.4em;
	line-height: 1;
}

.demas-rb__rating {
	-webkit-background-clip: text;
	background-clip: text;
	background-image: var(--demas-gold);
	color: transparent;
	font-family: Gilroy, "DIN Pro", sans-serif;
	font-size: 1.75em;
	font-weight: 800;
	letter-spacing: 0.01em;
	line-height: 1;
}

/* Five stars: the row is masked by a star shape; the gold fill is as wide as the rating. */
.demas-rb__stars {
	--demas-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.8l3.09 6.26 6.91 1-5 4.87 1.18 6.88L12 17.56l-6.18 3.25L7 13.93 2 9.06l6.91-1z'/%3E%3C/svg%3E");
	-webkit-mask: var(--demas-star) left center / 1.2em 1.2em repeat-x;
	mask: var(--demas-star) left center / 1.2em 1.2em repeat-x;
	background: var(--demas-rb-star-empty);
	display: inline-block;
	flex: none;
	height: 1.2em;
	position: relative;
	width: 6em;
}

.demas-rb__stars-fill {
	background: var(--demas-gold);
	inset: 0 auto 0 0;
	position: absolute;
}

/* Doubled class: beats the theme's and Elementor's `.elementor a { text-decoration: none }`. */
.demas-rb .demas-rb__count,
.demas-rb a.demas-rb__count:visited {
	color: var(--demas-rb-text);
	font-family: "DIN Pro", Gilroy, sans-serif;
	font-size: 1.05em;
	font-weight: 500;
	line-height: 1.25;
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.22em;
}

.demas-rb a.demas-rb__count:hover,
.demas-rb a.demas-rb__count:focus-visible {
	color: var(--demas-rb-text);
	text-decoration-thickness: 2px;
}

.demas-sr {
	border: 0;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

/* ------------------------------------------------------------------ tooltip */

.demas-tip {
	position: relative;
}

.demas-tip--counter {
	display: block;
}

/* A trigger that is a <button> keeps the look of what it replaced. */
button.demas-tip__trigger {
	-webkit-appearance: none;
	appearance: none;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	color: inherit;
	cursor: help;
	font: inherit;
	letter-spacing: inherit;
	margin: 0;
	padding: 0;
	text-align: inherit;
	text-transform: inherit;
}

.demas-tip--counter > button.elementor-counter {
	width: 100%;
}

.demas-tip__trigger:focus {
	outline: none;
}

.demas-tip__trigger:focus-visible {
	border-radius: 4px;
	outline: 2px solid #dcb458;
	outline-offset: 3px;
}

.demas-tip__bubble {
	background: #071025;
	border: 1px solid rgb(220 180 88 / 0.65);
	border-radius: 10px;
	bottom: calc(100% + 12px);
	box-shadow: 0 18px 36px -16px rgb(7 16 37 / 0.6);
	color: #fff;
	cursor: auto;
	display: none;
	font-family: "DIN Pro", Gilroy, sans-serif;
	font-size: 14px;
	font-style: normal;
	font-weight: 400;
	left: 50%;
	letter-spacing: normal;
	line-height: 1.5;
	padding: 12px 14px;
	position: absolute;
	text-align: left;
	text-transform: none;
	transform: translateX(calc(-50% + var(--demas-tip-shift, 0px)));
	white-space: normal;
	width: min(340px, calc(100vw - 32px));
	z-index: 60;
}

/* The arrow keeps pointing at the trigger when the bubble is shifted. */
.demas-tip__bubble::after {
	background: #071025;
	border-bottom: 1px solid rgb(220 180 88 / 0.65);
	border-right: 1px solid rgb(220 180 88 / 0.65);
	bottom: -6px;
	content: '';
	height: 10px;
	left: calc(50% - 5px - var(--demas-tip-shift, 0px));
	position: absolute;
	transform: rotate(45deg);
	width: 10px;
}

/* The gap between the trigger and the bubble stays hoverable. */
.demas-tip__bubble::before {
	content: '';
	height: 14px;
	inset-inline: 0;
	position: absolute;
	top: 100%;
}

.demas-tip[data-place='below'] .demas-tip__bubble {
	bottom: auto;
	top: calc(100% + 12px);
}

.demas-tip[data-place='below'] .demas-tip__bubble::after {
	border: 0;
	border-left: 1px solid rgb(220 180 88 / 0.65);
	border-top: 1px solid rgb(220 180 88 / 0.65);
	bottom: auto;
	top: -6px;
}

.demas-tip[data-place='below'] .demas-tip__bubble::before {
	bottom: 100%;
	top: auto;
}

@media (hover: hover) {
	.demas-tip:hover .demas-tip__bubble {
		display: block;
	}
}

.demas-tip:has(.demas-tip__trigger:focus-visible) .demas-tip__bubble,
.demas-tip.is-open .demas-tip__bubble {
	display: block;
}

.demas-tip.is-dismissed .demas-tip__bubble {
	display: none !important;
}

.demas-tip.is-measuring .demas-tip__bubble {
	animation: none;
	display: block;
	visibility: hidden;
}

@keyframes demas-tip-in {
	from {
		opacity: 0;
		translate: 0 4px;
	}

	to {
		opacity: 1;
		translate: 0 0;
	}
}

.demas-tip__bubble {
	animation: demas-tip-in 140ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
	.demas-tip__bubble {
		animation: none;
	}
}
