/**
 * LDT Google Reviews
 *
 * Sizing and colour hang off custom properties so a Kindling theme.json palette
 * can retint the badge without overriding rules. Only the Google brand colours
 * on the wordmark and the star gold are fixed, since those carry the
 * recognition the badge exists for.
 */

.ldtgr {
	--ldtgr-star: #fbbc05;
	--ldtgr-star-muted: currentColor;
	--ldtgr-gap: 0.5em;

	display: inline-flex;
	align-items: center;
	gap: var(--ldtgr-gap);
	flex-wrap: wrap;
	line-height: 1.2;
}

.ldtgr__link {
	display: inline-flex;
	align-items: center;
	gap: var(--ldtgr-gap);
	flex-wrap: wrap;
	color: inherit;
	text-decoration: none;
}

/* Keeps the mark, rating and stars together as one unit on both layouts. */
.ldtgr__main {
	display: inline-flex;
	align-items: center;
	gap: var(--ldtgr-gap);
}

/**
 * Stacked drops the count to a second row.
 *
 * The direction has to be set on .ldtgr__link as well as .ldtgr: when a reviews
 * URL is present every child lives inside the link, so styling only the outer
 * element leaves a single flex item and the layout silently stays inline.
 */
.ldtgr--stacked,
.ldtgr--stacked .ldtgr__link {
	flex-direction: column;
	align-items: flex-start;
	gap: 0.3em;
}

.ldtgr__link:hover .ldtgr__count,
.ldtgr__link:focus-visible .ldtgr__count {
	text-decoration: underline;
}

.ldtgr__link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

.ldtgr__wordmark {
	font-weight: 700;
	letter-spacing: -0.02em;
}

.ldtgr__rating {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* Two stacked rows; the coloured row is clipped to the rating percentage. */
.ldtgr__stars {
	position: relative;
	display: inline-block;
	flex: none;
	line-height: 0;
}

.ldtgr__stars-base {
	display: block;
	opacity: 0.25;
}

.ldtgr__stars-fill {
	position: absolute;
	inset: 0 auto 0 0;
	display: block;
	overflow: hidden;
	white-space: nowrap;
	color: var(--ldtgr-star);
}

.ldtgr__star {
	fill: currentColor;
	display: inline-block;
	vertical-align: top;
}

.ldtgr__stars-base .ldtgr__star {
	color: var(--ldtgr-star-muted);
}

.ldtgr__count {
	opacity: 0.8;
	font-size: 0.9em;
}

@media (prefers-reduced-motion: no-preference) {
	.ldtgr__link {
		transition: opacity 0.15s ease;
	}

	.ldtgr__link:hover {
		opacity: 0.85;
	}
}

/* ==========================================================================
   Review feed
   ========================================================================== */

/**
 * Measurements follow the commercial review widgets this feed replaces, so
 * the swap is not a visual change. All of them are custom properties, so a
 * theme can retint the accent or square off the corners without overriding
 * rules.
 */
.ldtgr-feed {
	--ldtgr-card-bg: #f5f5f5;
	--ldtgr-card-radius: 12px;
	--ldtgr-card-pad: 16px;
	--ldtgr-card-gap: 16px;
	--ldtgr-card-width: 306px;
	--ldtgr-card-text: #333;
	--ldtgr-card-muted: #555;
	--ldtgr-feed-gap: 1rem;
	--ldtgr-accent: #154fc1;
	--ldtgr-star: #fb8e28;
	--ldtgr-arrow-bg: #f5f5f5;
	--ldtgr-arrow-border: #ccc;
	--ldtgr-font: Arial, Helvetica, sans-serif;

	font-family: var( --ldtgr-font );
	color: var( --ldtgr-card-text );
	line-height: 1.5;
}

.ldtgr-feed__head {
	margin-bottom: var( --ldtgr-feed-gap );
}

.ldtgr-feed__track {
	position: relative;

	/*
	 * A grid or flex item has min-width:auto, which resolves to min-content —
	 * so a scroll container nested in one grows to fit every card instead of
	 * clipping and scrolling, and pushes the page into horizontal overflow.
	 * This is what actually lets overflow-x work on the slider.
	 */
	min-width: 0;
}

.ldtgr-feed__list {
	display: grid;
	gap: var( --ldtgr-card-gap );
	margin: 0;
	padding: 0;
	list-style: none;
	min-width: 0;
}

/* List: one column, full width. */
.ldtgr-feed--list .ldtgr-feed__list {
	grid-template-columns: 1fr;
}

/**
 * Grid: auto-fit rather than a fixed column count, so the feed reflows on its
 * own container width. A theme that drops it into a narrow sidebar gets one
 * column without needing a breakpoint written for that case.
 */
.ldtgr-feed--grid .ldtgr-feed__list {
	grid-template-columns: repeat( auto-fit, minmax( min( var( --ldtgr-card-width ), 100% ), 1fr ) );
}

/**
 * Slider: native scroll-snap. Swipes on touch, scrolls with shift+wheel, and
 * arrow-keys once focused. ldtgr-slider.js adds the arrow buttons and dots
 * on top; without it this is still a working, scrollable row.
 */
.ldtgr-feed--slider .ldtgr-feed__list {
	grid-auto-flow: column;
	grid-auto-columns: minmax( min( var( --ldtgr-card-width ), 85% ), 1fr );
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	scroll-behavior: smooth;

	/* Room for the card's focus ring and shadow, which overflow would clip;
	   scroll-padding keeps the snap points where they were. */
	padding: 8px;
	margin: -8px;
	scroll-padding-inline: 8px;
	scrollbar-width: none;

	/*
	 * Paint containment, without which the cards scrolled off to the right
	 * still count toward the page's scroll width and give the whole document a
	 * horizontal scrollbar — on a container that is itself scrolling correctly,
	 * which makes it a confusing one to track down. Clipping the overflow on an
	 * ancestor does not fix it; containment does.
	 */
	contain: paint;
}

.ldtgr-feed--slider .ldtgr-feed__list::-webkit-scrollbar {
	display: none;
}

.ldtgr-feed--slider .ldtgr-review {
	scroll-snap-align: start;
}

.ldtgr-feed--slider .ldtgr-feed__list:focus-visible {
	outline: 2px solid var( --ldtgr-accent );
	outline-offset: 2px;
}

@media ( prefers-reduced-motion: reduce ) {
	.ldtgr-feed--slider .ldtgr-feed__list {
		scroll-behavior: auto;
	}
}

/* --------------------------------------------------------------------------
   Slider controls (added by ldtgr-slider.js)
   -------------------------------------------------------------------------- */

/* Make room for the arrows either side and the dots below. */
.ldtgr-feed__track--enhanced {
	padding: 0 42px 26px;
}

.ldtgr-feed__arrow {
	position: absolute;
	top: calc( 50% - 13px - 17px );
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	margin: 0;
	border: 1px solid var( --ldtgr-arrow-border );
	border-radius: 50%;
	background: var( --ldtgr-arrow-bg );
	color: var( --ldtgr-card-muted );
	box-shadow: 0 2px 6px rgba( 0, 0, 0, 0.15 );
	cursor: pointer;
	line-height: 0;
}

.ldtgr-feed__arrow--prev {
	left: 0;
}

.ldtgr-feed__arrow--next {
	right: 0;
}

.ldtgr-feed__arrow:disabled {
	opacity: 0.35;
	cursor: default;
}

.ldtgr-feed__arrow:not( :disabled ):hover {
	color: var( --ldtgr-accent );
}

.ldtgr-feed__arrow:focus-visible,
.ldtgr-feed__dot:focus-visible {
	outline: 2px solid var( --ldtgr-accent );
	outline-offset: 2px;
}

.ldtgr-feed__dots {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	display: flex;
	justify-content: center;
	gap: 4px;
	line-height: 0;
}

.ldtgr-feed__dots[hidden] {
	display: none;
}

.ldtgr-feed__dot {
	width: 8px;
	height: 8px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: #cfcfcf;
	cursor: pointer;
}

.ldtgr-feed__dot[aria-current="true"] {
	background: var( --ldtgr-accent );
}

/* --------------------------------------------------------------------------
   Review card
   -------------------------------------------------------------------------- */

.ldtgr-review {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin: 0;
	padding: var( --ldtgr-card-pad );
	background: var( --ldtgr-card-bg );
	border-radius: var( --ldtgr-card-radius );
	font-size: 15px;
	line-height: 24px;
	color: var( --ldtgr-card-text );
	box-sizing: border-box;
}

/* A fixed card height keeps the slider row level; the body clamps. */
.ldtgr-feed--slider .ldtgr-review {
	min-height: 272px;
}

/* Google mark in the corner, as the reference widgets place it. */
.ldtgr-review__mark {
	position: absolute;
	top: 12px;
	right: 12px;
	line-height: 0;
}

.ldtgr-review__head {
	display: flex;
	align-items: center;
	gap: 12px;

	/* Keep the name clear of the corner mark. */
	padding-right: 20px;
}

.ldtgr-review__avatar {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	object-fit: cover;
}

.ldtgr-review__avatar--initial {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 18px;
	font-weight: 700;
	line-height: 1;
	color: #fff;

	/* Neutral slate rather than a brand colour: the initial is a placeholder
	   for a person, not a Google mark. */
	background: #5f6368;
}

.ldtgr-review__meta {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.ldtgr-review__author {
	font-size: 15px;
	font-weight: 700;
	line-height: 1.25;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ldtgr-review__date {
	font-size: 12px;
	line-height: 1.25;
	color: var( --ldtgr-card-muted );
}

.ldtgr-review__body {
	display: flex;
	flex-direction: column;
	gap: 8px;
	min-height: 0;
}

.ldtgr-review__rating {
	display: block;
	line-height: 0;
}

.ldtgr-review__rating .ldtgr__star {
	width: 20px;
	height: 20px;
}

.ldtgr-review__rating .ldtgr__stars-fill {
	color: var( --ldtgr-star );
}

/**
 * Six lines of body, then an inner scroll — the reference widget's approach,
 * and the one that lets the text be read in full without a "read more"
 * control or a jump to Google. The thin scrollbar is the affordance.
 */
.ldtgr-review__text {
	margin: 0;
	padding: 0 4px 0 0;
	border: 0;
	quotes: none;
	font-style: normal;
	font-size: 15px;
	line-height: 24px;
	max-height: 144px;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: #cfcfcf transparent;
}

.ldtgr-review__text::-webkit-scrollbar {
	width: 6px;
}

.ldtgr-review__text::-webkit-scrollbar-thumb {
	background: #cfcfcf;
	border-radius: 3px;
}

.ldtgr-review__reply {
	padding-left: 12px;
	border-left: 3px solid rgba( 0, 0, 0, 0.12 );
	font-size: 14px;
	line-height: 1.5;
	color: var( --ldtgr-card-muted );
}

.ldtgr-review__reply-label {
	display: block;
	margin-bottom: 2px;
	font-weight: 700;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

/**
 * Local copy of the core screen-reader class. Themes that do not print it
 * would otherwise render the rating text visibly next to the star row.
 */
.ldtgr-feed .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

/* ==========================================================================
   Showcase: summary panel beside the cards
   ========================================================================== */

.ldtgr-feed__title {
	margin: 0 0 1.25rem;
	text-align: center;
	font-family: inherit;
}

/* The block inherits the theme's body font; only the widget itself is Arial. */
.ldtgr-feed--showcase .ldtgr-feed__title {
	font-family: var( --ldtgr-heading-font, var( --wp--preset--font-family--heading, inherit ) );
}

/**
 * Two columns once there is room, stacked below it. The summary column is
 * fixed and the cards take the rest, so the cards keep their own scroll
 * behaviour rather than being squeezed.
 *
 * minmax(0, …) on the second track matters: without it a scroll container in a
 * grid takes its content width as a minimum and refuses to shrink, which breaks
 * the slider at narrow widths.
 */
.ldtgr-feed--showcase {
	display: grid;
	gap: 1.5rem;
	align-items: start;
	grid-template-columns: minmax( 0, 1fr );
}

@media ( min-width: 48em ) {
	.ldtgr-feed--showcase {
		grid-template-columns: 300px minmax( 0, 1fr );
		gap: 0 1.5rem;
	}

	.ldtgr-feed--showcase .ldtgr-feed__title {
		grid-column: 1 / -1;
	}

	/* A slider is a single row, so centring the summary against it reads better. */
	.ldtgr-feed--showcase.ldtgr-feed--slider {
		align-items: center;
	}

	.ldtgr-feed--showcase.ldtgr-feed--slider .ldtgr-summary {
		/* Line up with the cards, not the dots row beneath them. */
		margin-bottom: 26px;
	}
}

/* --------------------------------------------------------------------------
   Summary panel
   -------------------------------------------------------------------------- */

.ldtgr-summary {
	display: grid;
	grid-template-columns: 48px minmax( 0, 1fr );
	column-gap: 12px;
	row-gap: 12px;
	align-items: start;
	font-size: 16px;
	line-height: 1.25;
	color: var( --ldtgr-card-text );
}

.ldtgr-summary__icon {
	display: block;
	width: 48px;
	height: 48px;
	color: var( --ldtgr-accent );
}

.ldtgr-summary__info {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	min-width: 0;
}

.ldtgr-summary__word {
	font-size: 16px;
	font-weight: 700;
	color: var( --ldtgr-accent );
}

.ldtgr-summary__name {
	font-size: 16px;
	font-weight: 700;
	color: var( --ldtgr-accent );
	text-decoration: none;
}

a.ldtgr-summary__name:hover,
a.ldtgr-summary__name:focus-visible {
	text-decoration: underline;
}

.ldtgr-summary__rating {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	line-height: 0;
}

.ldtgr-summary__score {
	font-size: 16px;
	font-weight: 900;
	line-height: 20px;
	color: var( --ldtgr-star );
	font-variant-numeric: tabular-nums;
}

.ldtgr-summary__rating .ldtgr__star {
	width: 20px;
	height: 20px;
}

.ldtgr-summary__rating .ldtgr__stars-fill {
	color: var( --ldtgr-star );
}

.ldtgr-summary__count {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 13.6px;
	color: #777;
}

.ldtgr-summary__count .ldtgr__g {
	flex: none;
}

/* Buttons sit under both columns, indented past the icon. */
.ldtgr-summary__actions {
	grid-column: 2;
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

/**
 * Both buttons are filled; the reference makes no visual distinction between
 * "see all" and "write one". Colour comes from a custom property so a Kindling
 * palette can retint it without overriding rules.
 */
.ldtgr-summary__button {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 6px 8px;
	border-radius: 8px;
	color: var( --ldtgr-button-text, #fff );
	background: var( --ldtgr-button-bg, #0a6cff );
	box-shadow: 0 0 2px rgba( 0, 0, 0, 0.12 ), 0 2px 2px rgba( 0, 0, 0, 0.24 );
	font-size: 13.6px;
	font-weight: 400;
	line-height: 17px;
	text-decoration: none;
	white-space: nowrap;
}

/* The G on "review us on" sits in a white disc so the coloured mark reads on blue. */
.ldtgr-summary__button .ldtgr__g {
	flex: none;
	padding: 1px;
	border-radius: 50%;
	background: #fff;
	box-sizing: content-box;
}

.ldtgr-summary__button:hover,
.ldtgr-summary__button:focus-visible {
	color: var( --ldtgr-button-text, #fff );
	filter: brightness( 1.08 );
}

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

/**
 * No prefers-color-scheme override on purpose. Most sites do not switch on the
 * OS preference, so honouring it here painted invisible cards on light pages
 * for anyone with a dark desktop. A theme with a dark section retints the
 * custom properties on that section instead, e.g.
 *
 *   .is-style-dark .ldtgr-feed { --ldtgr-card-bg: rgba(255,255,255,.08); --ldtgr-card-text: currentColor; }
 */
