/*
 * Elevate Google Reviews — front end.
 *
 * Everything is a custom property with a default, so the widget can be restyled three ways
 * and they compose: a theme class sets a batch of them, the shortcode writes single ones
 * inline (which wins, being inline), and a site's own stylesheet can set any of them too:
 *
 *   .egr { --egr-card-bg: #f7f7f7; --egr-star: #f5a623; --egr-accent: #1d4ed8; }
 *
 * Spacing is in `em` rather than `rem` so that the size setting moves the padding and the
 * gaps with the text. With no size set the widget inherits the page's font size, which on
 * an ordinary 16px page is exactly what the rem values used to be.
 */
.egr {
	--egr-gap: 1.25em;
	--egr-card-bg: #fff;
	--egr-card-border: rgba(0, 0, 0, .08);
	--egr-card-radius: 14px;
	--egr-card-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px -8px rgba(0, 0, 0, .12);
	--egr-text: inherit;
	--egr-muted: rgba(0, 0, 0, .55);
	--egr-star: #FBBC05;
	--egr-star-empty: rgba(0, 0, 0, .12);
	--egr-accent: #1a73e8;
	--egr-on-accent: #fff;
	/*
	 * A link's colour, separate from the accent, because the two are read against different
	 * grounds: a button brings its own background and can be any colour, while a link sits
	 * on whatever is behind the widget. They are the same by default and part company on
	 * the blend-in theme, where what is behind the widget is unknown.
	 */
	--egr-link: var(--egr-accent);
	--egr-arrow-bg: #fff;
	--egr-arrow-fg: #1f1f1f;
	--egr-cols-base: 3;   /* set inline by the shortcode's columns attribute */
	--egr-cols: var(--egr-cols-base);
	--egr-lines: 5;
	--egr-pad: 1.25em;

	box-sizing: border-box;
	color: var(--egr-text);
	font-family: var(--egr-font, inherit);
	font-size: var(--egr-size, inherit);
	position: relative;
	max-width: 100%;
}

/* ------------------------------------------------------------------ Themes */
/* Two classes, so a theme always beats the block above it whatever the file order. */
.egr.egr--theme-light {
	--egr-card-bg: #fff;
	--egr-card-border: rgba(0, 0, 0, .08);
	--egr-text: #1f1f1f;
	--egr-muted: rgba(0, 0, 0, .55);
	--egr-star-empty: rgba(0, 0, 0, .12);
	--egr-arrow-bg: #fff;
	--egr-arrow-fg: #1f1f1f;
}
.egr.egr--theme-dark {
	--egr-card-bg: #1d1f23;
	--egr-card-border: rgba(255, 255, 255, .14);
	--egr-card-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px -8px rgba(0, 0, 0, .6);
	--egr-text: #f2f3f5;
	--egr-muted: rgba(255, 255, 255, .62);
	--egr-star-empty: rgba(255, 255, 255, .18);
	--egr-accent: #5b9dff;
	--egr-on-accent: #10131a;
	--egr-arrow-bg: #2a2d33;
	--egr-arrow-fg: #f2f3f5;
}
@media (prefers-color-scheme: dark) {
	.egr.egr--theme-auto {
		--egr-card-bg: #1d1f23;
		--egr-card-border: rgba(255, 255, 255, .14);
		--egr-card-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px -8px rgba(0, 0, 0, .6);
		--egr-text: #f2f3f5;
		--egr-muted: rgba(255, 255, 255, .62);
		--egr-star-empty: rgba(255, 255, 255, .18);
		--egr-accent: #5b9dff;
		--egr-on-accent: #10131a;
		--egr-arrow-bg: #2a2d33;
		--egr-arrow-fg: #f2f3f5;
	}
}
/*
 * Blend in: no colour of its own, so the widget takes the section it is dropped into.
 * The border and the empty star are neutral grey rather than an alpha of the text colour,
 * because that colour is inherited and unknown here — grey is the one value that reads
 * correctly on a light section and a dark one.
 */
.egr.egr--theme-inherit {
	--egr-card-bg: transparent;
	--egr-card-border: rgba(128, 128, 128, .32);
	--egr-card-shadow: none;
	--egr-text: inherit;
	--egr-muted: rgba(128, 128, 128, 1);
	--egr-star-empty: rgba(128, 128, 128, .3);
	--egr-arrow-bg: transparent;
	--egr-arrow-fg: inherit;
	/*
	 * Google blue on an unknown section is the one thing this theme cannot get away with —
	 * on a teal row it was barely readable. The text colour is the only colour known to work
	 * against that ground, so the link takes it and earns an underline to stay a link.
	 */
	--egr-link: currentColor;
}
.egr--theme-inherit .egr-card__more { text-decoration: underline; }

/* --------------------------------------------------------------- Card style */
.egr.egr--card-flat { --egr-card-shadow: none; }
.egr.egr--card-plain {
	--egr-card-shadow: none;
	--egr-card-border: transparent;
	--egr-card-bg: transparent;
}
/* A plain card keeps its padding on a badge, which would otherwise have nothing to sit in. */
.egr--card-plain .egr-card { padding-left: 0; padding-right: 0; }
.egr *, .egr *::before, .egr *::after { box-sizing: inherit; }
.egr ul { list-style: none; margin: 0; padding: 0; }

/* ------------------------------------------------------------------ Header */
.egr-head {
	display: flex;
	align-items: center;
	gap: 1rem;
	flex-wrap: wrap;
	margin: 0 0 1.5rem;
}
.egr-head__logo { display: inline-flex; flex: 0 0 auto; }
.egr-head__body { display: flex; flex-direction: column; gap: .2rem; min-width: 0; flex: 1 1 14rem; }
.egr-head__word { font-size: 1.25em; line-height: 1.2; }
.egr-head__line { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.egr-head__meta { color: var(--egr-muted); font-size: .9em; }
.egr-head__meta strong { color: var(--egr-text); }

.egr-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0 1.25rem;
	border-radius: 999px;
	background: var(--egr-accent);
	color: var(--egr-on-accent) !important;
	text-decoration: none !important;
	font-weight: 600;
	font-size: .95em;
	white-space: nowrap;
	transition: filter .15s ease;
}
.egr-btn:hover, .egr-btn:focus-visible { filter: brightness(1.08); }

/* ------------------------------------------------------------------- Stars */
.egr-stars {
	position: relative;
	display: inline-block;
	line-height: 0;
	white-space: nowrap;
	vertical-align: middle;
}
.egr-stars svg { display: inline-block; width: 18px; height: 18px; }
.egr-stars__bg svg { fill: var(--egr-star-empty); }
.egr-stars__fg { position: absolute; left: 0; top: 0; overflow: hidden; }
.egr-stars__fg svg { fill: var(--egr-star); }

/* -------------------------------------------------------------------- Card */
.egr-card {
	display: flex;
	flex-direction: column;
	gap: .75rem;
	height: 100%;
	padding: var(--egr-pad);
	background: var(--egr-card-bg);
	border: 1px solid var(--egr-card-border);
	border-radius: var(--egr-card-radius);
	box-shadow: var(--egr-card-shadow);
}
.egr-card__head { display: flex; align-items: center; gap: .75rem; }
.egr-card__avatar {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	object-fit: cover;
	margin: 0;
}
.egr-card__avatar--initial {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: hsl(var(--egr-hue, 210) 55% 45%);
	color: #fff;
	font-weight: 700;
	font-size: 1.1rem;
}
.egr-card__who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.3; }
.egr-card__name {
	font-weight: 600;
	color: inherit !important;
	text-decoration: none !important;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	/*
	 * A 36px tap target that takes no room in the layout: padding pulled back by margin.
	 * min-height as well as padding, because padding plus a line box is arithmetic that
	 * depends on the font size — at the small size setting it came out at 35.5px, which is
	 * a failure no screenshot shows and only a measurement finds.
	 */
	min-height: 36px;
	padding: .5rem 0;
	margin: -.5rem 0;
}
.egr-card__name:hover { text-decoration: underline !important; }
.egr-card__date { color: var(--egr-muted); font-size: .85em; }
.egr-card__g { display: inline-flex; flex: 0 0 auto; padding: .7rem; margin: -.7rem; border-radius: 50%; }
.egr-card__text {
	font-size: .97em;
	line-height: 1.55;
}
.egr-card__text p { margin: 0 0 .6em; }
.egr-card__text p:last-child { margin-bottom: 0; }
/* Clamped only once the script is running, so with JavaScript off the whole review is readable. */
.egr.is-js .egr-card__text:not(.is-open) {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--egr-lines);
	overflow: hidden;
}
.egr-card__more {
	align-self: flex-start;
	margin-top: -.25rem;
	padding: .5rem 0;
	min-height: 36px;
	border: 0;
	background: none;
	color: var(--egr-link);
	font: inherit;
	font-size: .9em;
	font-weight: 600;
	cursor: pointer;
}
.egr-card__more:hover { text-decoration: underline; }

/* -------------------------------------------------------------- Grid, list */
.egr-list { display: grid; gap: var(--egr-gap); grid-template-columns: repeat(var(--egr-cols), minmax(0, 1fr)); }
.egr--list .egr-list { grid-template-columns: minmax(0, 1fr); }
.egr-item { display: flex; min-width: 0; }

/* ---------------------------------------------------------------- Carousel */
/* The arrows live in a gutter of their own, so they never sit on top of a card. */
.egr-carousel { position: relative; padding: 0 3.25rem; }
.egr-track {
	display: flex;
	gap: var(--egr-gap);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;
	padding: 4px; /* room for the card shadow and focus rings */
	margin: -4px;
	-webkit-overflow-scrolling: touch;
}
.egr-track::-webkit-scrollbar { display: none; }
.egr-slide {
	display: flex;
	flex: 0 0 calc((100% - var(--egr-gap) * (var(--egr-cols) - 1)) / var(--egr-cols));
	min-width: 0;
	scroll-snap-align: start;
}
.egr-arrow {
	position: absolute;
	top: 50%;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--egr-card-border);
	border-radius: 50%;
	background: var(--egr-arrow-bg);
	color: var(--egr-arrow-fg);
	box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
	cursor: pointer;
	transform: translateY(-50%);
	transition: transform .15s ease, opacity .15s ease;
}
.egr-arrow:hover { transform: translateY(-50%) scale(1.06); }
.egr-arrow svg { pointer-events: none; }
.egr-arrow--prev { left: 0; }
.egr-arrow--next { right: 0; }
.egr-arrow[hidden] { display: none; }

/* ------------------------------------------------------------------ Badges */
.egr--badge { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .75rem; vertical-align: middle; }
.egr--button { display: inline-block; vertical-align: middle; }
.egr-badge {
	display: inline-flex;
	align-items: center;
	gap: .9rem;
	background: var(--egr-card-bg);
	border: 1px solid var(--egr-card-border);
	border-radius: var(--egr-card-radius);
	box-shadow: var(--egr-card-shadow);
	color: inherit !important;
	text-decoration: none !important;
	line-height: 1.25;
	transition: box-shadow .15s ease, transform .15s ease;
}
.egr-badge:hover, .egr-badge:focus-visible { box-shadow: 0 2px 4px rgba(0, 0, 0, .06), 0 10px 28px -10px rgba(0, 0, 0, .22); }
.egr-badge__logo { display: inline-flex; flex: 0 0 auto; }
.egr-badge__chevron { flex: 0 0 auto; color: var(--egr-muted); transition: transform .2s ease; }
.egr-badge[aria-expanded="true"] .egr-badge__chevron { transform: rotate(180deg); }

/* card: a small block */
.egr-badge--card { padding: .85em 1.1em; }
.egr-badge__body { display: flex; flex-direction: column; gap: .2rem; }
.egr-badge__top { display: flex; align-items: baseline; gap: .5rem; }
.egr-badge__label { font-weight: 600; font-size: .95em; }
.egr-badge__rating { font-size: 1.2em; }
.egr-badge__count { color: var(--egr-muted); font-size: .8em; }

/* bar: one line */
.egr-badge--bar { padding: .6em 1em; gap: .6em; border-radius: 999px; min-height: 44px; }
.egr-badge--bar .egr-stars svg { width: 16px; height: 16px; }
.egr-badge__word { font-weight: 600; letter-spacing: -.01em; }
.egr-badge__meta { font-size: .9em; color: var(--egr-muted); white-space: nowrap; }
.egr-badge__meta strong { color: var(--egr-text); }

/* float: the bar pinned to a corner of the window */
.egr--float {
	position: fixed;
	bottom: 1.25rem;
	right: 1.25rem;
	z-index: 9990;
	display: block;
}
.egr--float-bottom-left { right: auto; left: 1.25rem; }
.egr--float .egr-badge--bar { box-shadow: 0 4px 24px rgba(0, 0, 0, .18); }

/* the Write a review button */
.egr-btn--write { gap: .55rem; }
.egr-btn__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	margin-left: -.35rem;
	border-radius: 50%;
	background: #fff;
}

/* ------------------------------------------------------------------ Dialog */
.egr-modal {
	width: min(40rem, calc(100vw - 2rem));
	max-height: min(85dvh, 60rem);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: 16px;
	background: var(--egr-card-bg);
	color: var(--egr-text);
	box-shadow: 0 24px 80px -20px rgba(0, 0, 0, .45);
	overflow: hidden;
	display: none;
}
.egr-modal[open] { display: flex; flex-direction: column; }
.egr-modal::backdrop { background: rgba(0, 0, 0, .55); }
.egr-modal__head {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 1.25rem 3.5rem 1.25rem 1.25rem;
	border-bottom: 1px solid var(--egr-card-border);
	position: relative;
	flex: 0 0 auto;
	flex-wrap: wrap;
}
.egr-modal__logo { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; flex: 0 0 auto; margin: 0; }
.egr-modal__logo--g { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--egr-card-border); }
.egr-modal__who { display: flex; flex-direction: column; gap: .3rem; min-width: 0; flex: 1 1 12rem; }
.egr-modal__name { font-size: 1.15em; line-height: 1.2; }
.egr-modal__meta { font-size: .9em; color: var(--egr-muted); }
.egr-modal__meta strong { color: var(--egr-text); }
.egr-modal__sep { margin: 0 .35rem; }
.egr-modal__close {
	position: absolute;
	top: .75rem;
	right: .75rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--egr-muted);
	cursor: pointer;
}
.egr-modal__close:hover, .egr-modal__close:focus-visible { background: rgba(0, 0, 0, .06); color: var(--egr-text); }
.egr-modal__body { overflow-y: auto; flex: 1 1 auto; padding: 0 1.25rem; -webkit-overflow-scrolling: touch; }
.egr-modal__list { display: block; }
.egr-modal__item { padding: 1.25rem 0; border-bottom: 1px solid var(--egr-card-border); }
.egr-modal__item:last-child { border-bottom: 0; }
.egr-modal .egr-card { padding: 0; border: 0; box-shadow: none; border-radius: 0; height: auto; }
.egr-modal__none { padding: 2rem 0; color: var(--egr-muted); text-align: center; }
html.egr-modal-open { overflow: hidden; }

/* ------------------------------------------------------------------- Empty */
.egr-empty {
	padding: .75rem 1rem;
	border: 1px dashed rgba(0, 0, 0, .25);
	border-radius: 8px;
	font-size: .9em;
}

/* -------------------------------------------------------------- Responsive */
@media (max-width: 960px) {
	.egr { --egr-cols: min(var(--egr-cols-base), 2); }
}
@media (max-width: 640px) {
	.egr { --egr-cols: 1; }
	.egr-head { gap: .75rem; }
	.egr-btn { flex: 1 1 100%; }
	/* A thumb does this better than a button: no gutter, no arrows, and the next card
	   shows at the edge so it is obviously a row that moves. */
	.egr-carousel { padding: 0; }
	.egr-arrow { display: none; }
	.egr--carousel .egr-slide { flex-basis: 86%; }
	.egr-track { scroll-padding-left: 4px; }
	.egr--float { bottom: .75rem; right: .75rem; }
	.egr--float-bottom-left { left: .75rem; }
	.egr--float .egr-badge__meta { display: none; }
	.egr-modal { width: calc(100vw - 1rem); max-height: 92dvh; border-radius: 12px; }
	.egr-modal__head { padding: 1rem 3.25rem 1rem 1rem; }
	.egr-modal__head .egr-btn--write { flex: 1 1 100%; }
	.egr-modal__logo { width: 52px; height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
	.egr-track { scroll-behavior: auto; }
	.egr-arrow, .egr-btn { transition: none; }
}
