/**
 * VG Google Reviews.
 *
 * Every colour, radius, and gap is a custom property on .vggr, so a theme can
 * restyle the carousel by redefining tokens instead of fighting selectors.
 */

.vggr {
	/* The wrapper's inline style sets --vggr-columns-desktop. This derives the
	   value the layout actually uses, so the media queries below can override
	   it: a stylesheet rule cannot beat an inline one. */
	--vggr-columns: var(--vggr-columns-desktop, 3);
	--vggr-gap: 1.25rem;
	--vggr-radius: 12px;

	/* The card is its own light surface, so its text colour is set here and
	   never inherited. A dark theme would otherwise put white text on it. */
	--vggr-card-bg: #fff;
	--vggr-card-border: #dfe1e5;
	--vggr-card-text: #202124;
	--vggr-card-muted: #5f6368;
	--vggr-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);

	/* The header sits on the page background, so it inherits the theme's own
	   colour and only softens it. That works on light and dark themes alike. */
	--vggr-muted: currentColor;

	--vggr-star: #fbbc04;
	--vggr-star-off: #dadce0;
	--vggr-accent: #1a73e8;
	--vggr-link: currentColor;

	position: relative;
}

/* Header
   ------------------------------------------------------------------------ */

.vggr-header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
	margin-block-end: 1.25rem;
}

.vggr-header__score {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
}

.vggr-header__rating {
	font-size: 1.75rem;
	font-weight: 700;
	line-height: 1;
}

.vggr-header__stars {
	display: inline-flex;
	align-items: center;
}

.vggr-header__nav {
	display: flex;
	gap: 0.5rem;
	margin-inline-start: auto;
}

.vggr-header__score,
.vggr-header__meta {
	min-width: 0;
}

.vggr-header__meta {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.25rem 1rem;
}

.vggr-header__count {
	color: var(--vggr-muted);
	opacity: 0.72;
	font-size: 0.9375rem;
	text-decoration: none;
}

.vggr-header__count:hover,
.vggr-header__write:hover {
	text-decoration: underline;
}

.vggr-header__write {
	color: var(--vggr-link);
	font-size: 0.9375rem;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* Stars
   ------------------------------------------------------------------------ */

.vggr-stars {
	display: inline-flex;
	gap: 1px;
	line-height: 0;
}

.vggr-star {
	fill: var(--vggr-star-off);
	flex: none;
}

.vggr-star--on {
	fill: var(--vggr-star);
}

/* Track
   ------------------------------------------------------------------------ */

.vggr-viewport {
	position: relative;
}

.vggr-track {
	display: flex;
	gap: var(--vggr-gap);
	margin: 0;
	padding: 0.25rem 0 1rem;
	list-style: none;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	overscroll-behavior-x: contain;

	/* Looping moves a card from one end of the track to the other. Scroll
	   anchoring would try to compensate for that DOM change and fight the
	   scrollLeft correction that keeps the swap invisible. */
	overflow-anchor: none;
}

.vggr-track::-webkit-scrollbar {
	display: none;
}

.vggr-track:focus-visible {
	outline: 2px solid var(--vggr-accent);
	outline-offset: 4px;
}

.vggr-card {
	/* Containing block for the visually-hidden rating labels. Without this
	   they resolve against .vggr, which sits outside the scroll container, so
	   the ones in off-screen cards escape clipping and give the page a
	   horizontal scrollbar on mobile. */
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 0.625rem;
	flex: 0 0 calc((100% - (var(--vggr-columns) - 1) * var(--vggr-gap)) / var(--vggr-columns));
	box-sizing: border-box;
	padding: 1.25rem;
	background: var(--vggr-card-bg);
	color: var(--vggr-card-text);
	border: 1px solid var(--vggr-card-border);
	border-radius: var(--vggr-radius);
	box-shadow: var(--vggr-shadow);
	scroll-snap-align: start;
}

.vggr-card__head {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.vggr-card__avatar {
	width: 40px;
	height: 40px;
	flex: none;
	border-radius: 50%;
	object-fit: cover;
}

.vggr-card__avatar--initial {
	display: grid;
	place-items: center;
	background: var(--vggr-accent);
	color: #fff;
	font-weight: 700;
	text-transform: uppercase;
}

/* Sits in the top-right of the card. It identifies where this one review
   came from, so it travels with the review rather than the header. */
.vggr-card__source {
	flex: none;
	margin-inline-start: auto;
	align-self: flex-start;
	line-height: 0;
}

.vggr-card__source svg {
	display: block;
	width: 18px;
	height: 18px;
}

.vggr-card__who {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.vggr-card__author {
	color: inherit;
	font-weight: 600;
	text-decoration: none;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.vggr-card__author:hover {
	text-decoration: underline;
}

.vggr-card__date {
	color: var(--vggr-card-muted);
	font-size: 0.8125rem;
}

.vggr-card__text {
	display: -webkit-box;
	-webkit-line-clamp: 5;
	line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 0.9375rem;
	line-height: 1.6;
}

.vggr-card.is-expanded .vggr-card__text {
	-webkit-line-clamp: unset;
	line-clamp: unset;
	overflow: visible;
}

.vggr-more {
	align-self: flex-start;
	margin-block-start: auto;
	padding: 0;
	background: none;
	border: 0;
	color: var(--vggr-accent);
	font: inherit;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
}

/* Controls
   ------------------------------------------------------------------------ */

/* Themes style every <button>. Kadence pads them, which inflates a fixed
   40px box into an oval, and several themes also set min-width, min-height,
   and a hover transform. Each reset below defends against one of those. */
.vggr-nav {
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 40px;
	height: 40px;
	min-width: 0;
	min-height: 0;
	max-width: none;
	padding: 0;
	margin: 0;
	appearance: none;
	-webkit-appearance: none;
	font-size: 0;
	line-height: 1;
	letter-spacing: normal;
	text-transform: none;
	flex: none;
	background: var(--vggr-card-bg);
	color: var(--vggr-card-text);
	border: 1px solid var(--vggr-card-border);
	border-radius: 50%;
	box-shadow: 0 1px 3px rgba(60, 64, 67, 0.16), 0 4px 10px rgba(60, 64, 67, 0.12);
	cursor: pointer;
	transition: background-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

/* Re-assert the centring transform, or a theme's :hover lift knocks the
   button out of vertical alignment. */
/* Themes commonly lift buttons on hover. Left alone that knocks an
   absolutely positioned arrow out of vertical alignment. */
.vggr-nav:hover,
.vggr-nav:focus,
.vggr-nav:active {
	transform: none;
	background: var(--vggr-card-bg);
	color: var(--vggr-card-text);
}

.vggr-nav:hover:not([disabled]) {
	box-shadow: 0 1px 3px rgba(60, 64, 67, 0.2), 0 6px 14px rgba(60, 64, 67, 0.18);
}

.vggr-nav:focus-visible {
	outline: 2px solid var(--vggr-accent);
	outline-offset: 2px;
}

.vggr-nav::before {
	content: "";
	display: block;
	box-sizing: border-box;
	width: 9px;
	height: 9px;
	border-top: 2px solid currentColor;
	border-right: 2px solid currentColor;
}

/* Headerless fallback: the track is inset so the arrows have their own
   gutter and never sit on top of a card. */
.vggr-viewport--inset {
	padding-inline: 52px;
}

.vggr-viewport--inset .vggr-nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	transform: translateY(-50%);
}

.vggr-viewport--inset .vggr-nav:hover,
.vggr-viewport--inset .vggr-nav:focus,
.vggr-viewport--inset .vggr-nav:active {
	transform: translateY(-50%);
}

.vggr-nav--prev {
	inset-inline-start: 0;
}

.vggr-nav--prev::before {
	transform: rotate(-135deg) translate(-2px, -2px);
}

.vggr-nav--next {
	inset-inline-end: 0;
}

.vggr-nav--next::before {
	transform: rotate(45deg) translate(-2px, 2px);
}

.vggr-nav[disabled] {
	opacity: 0;
	pointer-events: none;
	cursor: default;
}

.vggr-notice {
	padding: 0.75rem 1rem;
	background: #fff8e1;
	border-inline-start: 4px solid #fbbc04;
	border-radius: 4px;
	font-size: 0.9375rem;
}

/* The theme usually supplies this, but the carousel must not depend on it. */
.vggr .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Responsive
   ------------------------------------------------------------------------ */

@media (max-width: 900px) {
	.vggr {
		--vggr-columns: 2;
	}

	/* Let the arrows take their own row rather than squeezing the summary. */
	.vggr-header__nav {
		margin-inline-start: 0;
		width: 100%;
	}

	.vggr-viewport--inset {
		padding-inline: 0;
	}

	.vggr-viewport--inset .vggr-nav {
		display: none;
	}
}

@media (max-width: 600px) {
	.vggr {
		--vggr-columns: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.vggr-track {
		scroll-behavior: auto;
	}

	.vggr-nav {
		transition: none;
	}
}

/* Deliberately no prefers-color-scheme override. The cards are a light
   surface on every theme, which is how Google's own review UI reads and what
   keeps the star colour legible. Redefine the tokens above to change it. */
