/**
 * Google Reviews: the base styles.
 *
 * Kept minimal on purpose: colours, type and spacing come from the Breakdance design panel (the
 * element's design controls). The CSS variables are the hooks for overrides.
 */

.dsgr-reviews {
	max-width: 100%;
	box-sizing: border-box;
	--dsgr-star-color: #fbbc04;
	--dsgr-star-size: 1em;
	--dsgr-card-bg: transparent;
	--dsgr-card-radius: 8px;
	--dsgr-card-padding: 1rem;
	--dsgr-gap: 1rem;
	--dsgr-avatar-size: 40px;
	--dsgr-name-color: inherit;
	--dsgr-name-size: 1em;
	--dsgr-name-weight: 600;
	--dsgr-text-color: inherit;
	--dsgr-text-size: 1em;
	--dsgr-meta-color: inherit;
	--dsgr-logo-size: 64px;
	--dsgr-badge-border-color: rgba(0, 0, 0, 0.12);
}

/* The Breakdance wrapper: as a flex item in a centred container it grew as wide as the carousel
 * and ran off the screen. */
.dsgr-element {
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

/* Header with the overall score */
.dsgr-header {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	justify-content: var(--dsgr-header-justify, flex-start);
	gap: 0.5em;
	margin-bottom: var(--dsgr-gap);
}

.dsgr-average {
	font-size: 1.6em;
	font-weight: 700;
	line-height: 1;
}

.dsgr-total {
	color: var(--dsgr-meta-color);
	opacity: 0.75;
}

/* Stars (partly filled through the width of an overlay) */
.dsgr-stars {
	position: relative;
	display: inline-block;
	line-height: 1;
	font-size: var(--dsgr-star-size);
	letter-spacing: 0.05em;
}

.dsgr-stars-bg {
	color: currentColor;
	opacity: 0.25;
}

.dsgr-stars-fill {
	position: absolute;
	top: 0;
	left: 0;
	overflow: hidden;
	white-space: nowrap;
	color: var(--dsgr-star-color);
}

/* Cards */
.dsgr-card {
	background: var(--dsgr-card-bg);
	border-radius: var(--dsgr-card-radius);
	padding: var(--dsgr-card-padding);
	/* A section that centres its text would centre the review text too. */
	text-align: start;
}

.dsgr-card-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75em;
	margin-bottom: 0.5em;
}

.dsgr-avatar {
	width: var(--dsgr-avatar-size, 40px);
	height: var(--dsgr-avatar-size, 40px);
	border-radius: 50%;
	object-fit: cover;
	flex-shrink: 0;
}

.dsgr-avatar-fallback {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: #e0e0e0;
	color: #555;
	font-weight: 700;
}

.dsgr-card-meta {
	display: flex;
	flex-direction: column;
	gap: 0.15em;
	min-width: 0;
}

.dsgr-name {
	color: var(--dsgr-name-color);
	font-size: var(--dsgr-name-size);
	font-weight: var(--dsgr-name-weight);
}

.dsgr-card-sub {
	display: flex;
	align-items: center;
	gap: 0.5em;
	font-size: 0.875em;
}

.dsgr-date {
	color: var(--dsgr-date-color, var(--dsgr-meta-color));
	opacity: var(--dsgr-date-opacity, 0.7);
}

/* The Google logo in the corner of a card, at the top, past the name. */
.dsgr-google-logo {
	display: inline-flex;
	flex-shrink: 0;
	align-self: flex-start;
	width: 1.5em;
	height: 1.5em;
	margin-left: auto;
}

/* With the logo the head stays one row: a long name wraps under itself instead of pushing the
 * logo onto a line of its own on a phone. */
.dsgr-card-head:has(.dsgr-google-logo) {
	flex-wrap: nowrap;
}

.dsgr-card-head:has(.dsgr-google-logo) .dsgr-card-meta {
	flex: 1 1 auto;
}

.dsgr-name {
	overflow-wrap: anywhere;
}

.dsgr-google-logo svg,
.dsgr-verified svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* The stars on a line of their own, under the name. */
.dsgr-card-stars {
	display: flex;
	align-items: center;
	gap: 0.5em;
	margin-bottom: 0.6em;
}

.dsgr-verified {
	display: inline-flex;
	flex-shrink: 0;
	width: calc(var(--dsgr-star-size) * 0.95);
	height: calc(var(--dsgr-star-size) * 0.95);
	color: var(--dsgr-verified-color, #4285f4);
}

/* The location a review was left at, when all of several locations show */
.dsgr-location {
	font-size: 0.875em;
	color: var(--dsgr-meta-color);
	opacity: 0.7;
}

/* Review text and read more */
.dsgr-text {
	color: var(--dsgr-text-color);
	font-size: var(--dsgr-text-size);
	overflow-wrap: anywhere;
}

.dsgr-clamp {
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.dsgr-clamp.dsgr-expanded {
	-webkit-line-clamp: unset;
	display: block;
	overflow: visible;
}

.dsgr-readmore {
	background: none;
	border: none;
	padding: 0;
	margin-top: 0.35em;
	cursor: pointer;
	font: inherit;
	font-size: 0.875em;
	font-weight: 600;
	text-decoration: underline;
	/* Its own colour, else the card's text colour (not the section's: white on a light card disappeared). */
	color: var(--dsgr-readmore-color, var(--dsgr-text-color));
}

/* Reply from the business */
.dsgr-reply {
	margin-top: 0.75em;
	padding: 0.75em;
	border-left: 3px solid rgba(0, 0, 0, 0.15);
	background: rgba(0, 0, 0, 0.03);
	border-radius: 4px;
	font-size: 0.9375em;
}

.dsgr-reply-label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.25em;
	font-size: 0.875em;
}

/* Layout: list */
.dsgr-layout-list .dsgr-track {
	display: flex;
	flex-direction: column;
	gap: var(--dsgr-gap);
}

.dsgr-layout-list .dsgr-card + .dsgr-card {
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* Layout: grid */
.dsgr-layout-grid .dsgr-track {
	display: grid;
	/* min(280px, 100%) keeps narrow phone screens from scrolling sideways. */
	grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
	gap: var(--dsgr-gap);
}

/* Layout: carousel */
.dsgr-carousel-wrap {
	position: relative;
}

.dsgr-layout-carousel .dsgr-track {
	display: flex;
	gap: var(--dsgr-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 0.5rem;
	/* The arrows and swiping move the track, so its scrollbar only adds a grey bar. */
	scrollbar-width: none;
}

.dsgr-layout-carousel .dsgr-track::-webkit-scrollbar {
	display: none;
}

.dsgr-layout-carousel .dsgr-card {
	flex: 0 0 min(320px, 85%);
	scroll-snap-align: start;
	background: var(--dsgr-card-bg, rgba(0, 0, 0, 0.03));
}

.dsgr-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.15);
	background: #fff;
	color: #1f1f1f;
	cursor: pointer;
	font-size: 1.25rem;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
}

.dsgr-nav-prev {
	left: -12px;
}

.dsgr-nav-next {
	right: -12px;
}

@media (max-width: 480px) {
	/* On narrow screens the arrows go under the cards: inside the viewport and off the text. */
	.dsgr-carousel-wrap {
		padding-bottom: 52px;
	}

	.dsgr-nav {
		top: auto;
		bottom: 0;
		transform: none;
		width: 44px;
		height: 44px;
	}

	.dsgr-nav-prev {
		left: calc(50% - 52px);
	}

	.dsgr-nav-next {
		right: calc(50% - 52px);
	}
}

/* Empty state */
.dsgr-empty,
.dsgr-no-match {
	opacity: 0.75;
	font-style: italic;
}

/* Clickable badge: a link without the usual link styling, with hover feedback */
.dsgr-badge-link {
	display: inline-block;
	max-width: 100%;
	color: inherit;
	text-decoration: none;
	cursor: pointer;
}

.dsgr-badge-link:hover .dsgr-badge,
.dsgr-badge-link:focus-visible .dsgr-badge {
	border-color: var(--dsgr-star-color);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Layout: badge (compact) */
.dsgr-badge {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem;
	max-width: 100%;
	padding: var(--dsgr-card-padding);
	border: 1px solid var(--dsgr-badge-border-color);
	border-radius: var(--dsgr-card-radius);
	background: var(--dsgr-card-bg, #fff);
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	box-sizing: border-box;
}

/* Badge stacked (logo above the text) */
.dsgr-badge.dsgr-badge-vertical {
	flex-direction: column;
	text-align: center;
}

.dsgr-badge.dsgr-badge-vertical .dsgr-badge-info {
	align-items: center;
}

/* Badge across the full width, content centred */
.dsgr-badge.dsgr-badge-full {
	display: flex;
	width: 100%;
	max-width: none;
	justify-content: center;
}

.dsgr-badge-logo,
.dsgr-badge-logo-wrap img {
	max-width: var(--dsgr-logo-size);
	max-height: var(--dsgr-logo-size);
	width: auto;
	height: auto;
	object-fit: contain;
	flex-shrink: 0;
}

.dsgr-badge-info {
	display: flex;
	flex-direction: column;
	gap: 0.2em;
}

.dsgr-badge-name {
	color: var(--dsgr-name-color);
	font-size: calc(var(--dsgr-name-size) * 1.1);
	font-weight: var(--dsgr-name-weight, 700);
	line-height: 1.2;
}

.dsgr-badge-count {
	color: var(--dsgr-meta-color);
	font-size: 0.875em;
	opacity: 0.75;
}

/* Fine-tuning for phones */
@media (max-width: 480px) {
	.dsgr-header {
		gap: 0.4em;
	}

	.dsgr-average {
		font-size: 1.35em;
	}

	.dsgr-avatar,
	.dsgr-avatar-fallback {
		width: 32px;
		height: 32px;
	}

	.dsgr-card-sub {
		flex-wrap: wrap;
		row-gap: 0.25em;
	}

	.dsgr-badge {
		gap: 0.65rem;
		padding: calc(var(--dsgr-card-padding) * 0.75);
	}

	.dsgr-badge-logo,
	.dsgr-badge-logo-wrap img {
		max-width: min(var(--dsgr-logo-size), 44px);
		max-height: min(var(--dsgr-logo-size), 44px);
	}

	.dsgr-layout-carousel .dsgr-card {
		flex-basis: min(280px, 88%);
	}
}

/* ---------------------------------------------------------------------
 * Reviews popup: the clickable trigger and the shared modal (at most one per page).
 * ------------------------------------------------------------------- */

/*
 * The popup is shared (at most one per page) and printed in wp_footer, so outside the DOM of
 * the individual Breakdance elements. That is why these tokens are set on :root (not per
 * element) and every var() has a literal fallback.
 */
:root {
	--dsgr-popup-overlay-color: rgba(27, 58, 87, 0.55);
	--dsgr-popup-bg: #fff;
	--dsgr-popup-radius: 12px;
	--dsgr-popup-padding: 1.5rem;
	--dsgr-popup-max-width: 560px;
	--dsgr-popup-google-bg: #1e3a5f;
	--dsgr-popup-google-color: #fff;
	--dsgr-popup-hover-shadow: rgba(0, 0, 0, 0.12);
}

/* The clickable area shrinks to the width of its content (such as the badge), so the hint
 * hangs neatly below it and there is no empty clickable space next to the block. */
.dsgr-popup-trigger {
	cursor: pointer;
	display: block;
	width: fit-content;
	max-width: 100%;
}

/* Except for a full-width badge: then the trigger takes the full width too. */
.dsgr-popup-trigger:has(.dsgr-badge-full),
.dsgr-popup-trigger:has(.dsgr-layout-list),
.dsgr-popup-trigger:has(.dsgr-layout-grid),
.dsgr-popup-trigger:has(.dsgr-layout-carousel) {
	width: 100%;
}

/* Hover effect on the reviews block only, not on the hint below it. */
.dsgr-popup-trigger .dsgr-reviews {
	border-radius: var(--dsgr-card-radius);
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}

/* Hover on the block itself: the effect shows only with the mouse on the reviews block (not
 * on the hint below it). With keyboard focus on the trigger, the block lights up too. */
.dsgr-popup-trigger .dsgr-reviews:hover,
.dsgr-popup-trigger:focus-visible .dsgr-reviews {
	box-shadow: 0 4px 16px var(--dsgr-popup-hover-shadow, rgba(0, 0, 0, 0.12));
	transform: translateY(-1px);
}

/* Cancels any hover effect themes or builders put on role="button" elements or on the hint
 * line: only the badge block itself may have one. */
.dsgr-popup-trigger:hover,
.dsgr-popup-trigger:focus {
	background: transparent !important;
	box-shadow: none !important;
	transform: none !important;
	filter: none !important;
}

.dsgr-popup-hint,
.dsgr-popup-hint:hover,
.dsgr-popup-trigger:hover .dsgr-popup-hint {
	background: transparent !important;
	box-shadow: none !important;
	text-decoration: none !important;
	transform: none !important;
}

.dsgr-popup-trigger:focus-visible {
	outline: 2px solid var(--dsgr-star-color);
	outline-offset: 2px;
}

.dsgr-popup-hint {
	display: block;
	margin-top: 0.5em;
	font-size: 0.875em;
	font-weight: 600;
	text-align: center;
	color: var(--dsgr-meta-color);
	opacity: 0.85;
}

/* Hint hidden: gone altogether (takes no space); the block stays clickable. */
.dsgr-popup-hint.dsgr-hint-hidden {
	display: none;
}

/* Overlay */
.dsgr-popup-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	background: var(--dsgr-popup-overlay-color, rgba(27, 58, 87, 0.55));
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.18s ease, visibility 0s linear 0.18s;
}

.dsgr-popup-overlay.is-open {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.18s ease;
}

/* Modal box.
 * The cards in the modal sit outside a .dsgr-reviews wrapper, so the component variables are
 * defined again here (with popup overrides where they apply). */
.dsgr-popup-modal {
	--dsgr-star-color: var(--dsgr-popup-star-color, #fbbc04);
	--dsgr-star-size: 1em;
	--dsgr-card-bg: transparent;
	--dsgr-card-radius: 8px;
	--dsgr-card-padding: 0;
	--dsgr-gap: 1rem;
	--dsgr-name-color: inherit;
	--dsgr-name-size: 1em;
	--dsgr-name-weight: 600;
	--dsgr-text-color: inherit;
	--dsgr-text-size: 1em;
	--dsgr-meta-color: inherit;
	position: relative;
	width: 100%;
	max-width: var(--dsgr-popup-max-width, 560px);
	max-height: 80vh;
	display: flex;
	flex-direction: column;
	background: var(--dsgr-popup-bg, #fff);
	border-radius: var(--dsgr-popup-radius, 12px);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
	overflow: hidden;
	transform: scale(0.96);
	opacity: 0;
	transition: transform 0.18s ease, opacity 0.18s ease;
}

.dsgr-popup-overlay.is-open .dsgr-popup-modal {
	transform: scale(1);
	opacity: 1;
}

.dsgr-popup-drag {
	display: none;
}

.dsgr-popup-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	padding: var(--dsgr-popup-padding, 1.5rem);
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.dsgr-popup-header-score {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5em;
}

/* Score line ("4.9" and stars), styled on its own through the popup variables. */
.dsgr-popup-header-score .dsgr-average {
	font-size: var(--dsgr-popup-score-size, 1.6em);
	color: var(--dsgr-popup-score-color, inherit);
}

/* High specificity: themes often style h2 heavily (size, colour, margin); this title is a
 * modest sub line and has to break free from that. */
.dsgr-popup-modal h2.dsgr-popup-title {
	flex-basis: 100%;
	margin: 0.15em 0 0;
	padding: 0;
	font-size: var(--dsgr-popup-title-size, 0.9rem);
	font-weight: 600;
	font-family: inherit;
	line-height: 1.35;
	letter-spacing: normal;
	text-transform: none;
	color: inherit;
	opacity: 0.85;
}

.dsgr-popup-modal .dsgr-popup-title-name {
	color: var(--dsgr-popup-title-color, inherit);
}

.dsgr-popup-modal .dsgr-popup-title-sub {
	color: var(--dsgr-popup-subtext-color, inherit);
	font-weight: 400;
}

/* A note above the reviews, about how many of Google's reviews show (only when fewer show
 * than Google's total). */
.dsgr-popup-note {
	margin: 0;
	font-size: 0.85em;
	opacity: 0.7;
	font-style: italic;
}

.dsgr-popup-close {
	flex-shrink: 0;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	background: transparent;
	border-radius: 50%;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	color: inherit;
}

.dsgr-popup-close:hover,
.dsgr-popup-close:focus-visible {
	background: rgba(0, 0, 0, 0.06);
}

.dsgr-popup-body {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: var(--dsgr-popup-padding, 1.5rem);
	display: flex;
	flex-direction: column;
	gap: var(--dsgr-gap);
}

.dsgr-popup-footer {
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5em;
	padding: var(--dsgr-popup-padding, 1.5rem);
	border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* High specificity and every link state spelled out, so the theme's link styling (colour,
 * underline, hover colour) never shows through. */
.dsgr-popup-modal a.dsgr-popup-google-btn,
.dsgr-popup-modal a.dsgr-popup-google-btn:visited,
.dsgr-popup-modal a.dsgr-popup-google-btn:active {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding: 0.85em 1.5em;
	border-radius: var(--dsgr-card-radius);
	background: var(--dsgr-popup-google-bg, #1e3a5f);
	color: var(--dsgr-popup-google-color, #fff);
	font-weight: 600;
	text-align: center;
	text-decoration: none;
	border-bottom: none;
	box-shadow: none;
}

.dsgr-popup-modal a.dsgr-popup-google-btn:hover,
.dsgr-popup-modal a.dsgr-popup-google-btn:focus-visible {
	color: var(--dsgr-popup-google-color, #fff);
	text-decoration: none;
	border-bottom: none;
	filter: brightness(1.15);
}

/* "Write a review" button: the shape of the Google button, as an outline, so the two buttons
 * do not read as one block. */
.dsgr-popup-modal a.dsgr-popup-write-review-btn,
.dsgr-popup-modal a.dsgr-popup-write-review-btn:visited,
.dsgr-popup-modal a.dsgr-popup-write-review-btn:active {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding: 0.85em 1.5em;
	border-radius: var(--dsgr-card-radius);
	background: transparent;
	border: 2px solid var(--dsgr-popup-google-bg, #1e3a5f);
	color: var(--dsgr-popup-google-bg, #1e3a5f);
	font-weight: 600;
	text-align: center;
	text-decoration: none;
	box-shadow: none;
}

.dsgr-popup-modal a.dsgr-popup-write-review-btn:hover,
.dsgr-popup-modal a.dsgr-popup-write-review-btn:focus-visible {
	background: var(--dsgr-popup-google-bg, #1e3a5f);
	color: var(--dsgr-popup-google-color, #fff);
	text-decoration: none;
}

/* Icon-only version of the Google button (text hidden, still clickable). */
.dsgr-popup-modal a.dsgr-popup-google-btn.dsgr-btn-icon-only {
	width: auto;
	min-width: 44px;
	min-height: 44px;
	padding: 0.7em;
}

.dsgr-btn-icon svg {
	display: block;
}

/* Phones: a bottom sheet instead of a centred modal */
@media (max-width: 768px) {
	.dsgr-popup-overlay {
		align-items: flex-end;
		padding: 0;
	}

	.dsgr-popup-modal {
		max-width: 100%;
		max-height: 92vh;
		border-radius: var(--dsgr-popup-radius, 12px) var(--dsgr-popup-radius, 12px) 0 0;
		transform: translateY(100%);
	}

	.dsgr-popup-overlay.is-open .dsgr-popup-modal {
		transform: translateY(0);
	}

	.dsgr-popup-drag {
		display: block;
		width: 40px;
		height: 4px;
		margin: 0.6rem auto 0;
		border-radius: 2px;
		background: rgba(0, 0, 0, 0.15);
		flex-shrink: 0;
	}

	.dsgr-popup-google-btn {
		width: 100%;
	}
}

/* Respect the motion preference */
@media (prefers-reduced-motion: reduce) {
	.dsgr-popup-overlay,
	.dsgr-popup-modal,
	.dsgr-popup-trigger {
		transition: none !important;
		transform: none !important;
	}
}
