/**
 * Google Reviews Widget
 *
 * Deliberately plain. Every colour and dimension is a custom property, so a
 * client site restyles this from its own stylesheet without touching the
 * plugin. Override on `.grw`, or on a wrapper, or in `:root`.
 */

.grw {
	--grw-font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	--grw-text-color: #18181b;
	--grw-muted-color: #6b7280;
	--grw-accent-color: #1a73e8;
	--grw-star-color: #fbbc05;
	--grw-star-empty-color: #dcdce0;

	--grw-card-bg: #fff;
	--grw-card-border: 1px solid #e4e4e7;
	--grw-card-radius: 10px;
	--grw-card-padding: 20px;
	--grw-card-shadow: none;

	--grw-gap: 16px;
	--grw-grid-min: 260px;
	--grw-avatar-size: 40px;

	font-family: var( --grw-font );
	color: var( --grw-text-color );
	box-sizing: border-box;
}

.grw *,
.grw *::before,
.grw *::after {
	box-sizing: inherit;
}

/* Buttons and form controls do not inherit font-family from an ancestor, so
   the widget's own controls have to be named explicitly or they fall back to
   the browser's UI font. */
.grw button,
.grw input,
.grw select,
.grw textarea {
	font-family: var( --grw-font );
}

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

.grw-summary {
	display: flex;
	align-items: center;
	gap: var( --grw-gap );
	flex-wrap: wrap;
	margin-bottom: var( --grw-gap );
	padding: var( --grw-card-padding );
	background: var( --grw-card-bg );
	border: var( --grw-card-border );
	border-radius: var( --grw-card-radius );
	box-shadow: var( --grw-card-shadow );
}

.grw-summary__body {
	flex: 1 1 auto;
	min-width: 0;
}

.grw-summary__name {
	margin: 0 0 2px;
	font-weight: 700;
	line-height: 1.3;
}

.grw-summary__rating {
	display: flex;
	align-items: center;
	gap: 8px;
}

.grw-summary__score {
	font-size: 1.35em;
	font-weight: 700;
	line-height: 1;
}

.grw-summary__count {
	margin: 4px 0 0;
	font-size: 0.85em;
	color: var( --grw-muted-color );
}

.grw-summary__link {
	color: var( --grw-accent-color );
	font-size: 0.9em;
	font-weight: 700;
	text-decoration: none;
	white-space: nowrap;
}

.grw-summary__link:hover,
.grw-summary__link:focus-visible {
	text-decoration: underline;
}

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

/* The partial-fill overlay is a percentage of this box, so it must hug the
   stars. Without max-content it stretches as a flex item and a 4.0 rating
   paints five full stars. */
.grw-stars {
	position: relative;
	display: inline-block;
	width: max-content;
	max-width: 100%;
	align-self: start;
	line-height: 0;
	white-space: nowrap;
}

.grw-stars svg {
	width: 1em;
	height: 1em;
	display: inline-block;
	vertical-align: middle;
}

.grw-stars__empty svg {
	fill: var( --grw-star-empty-color );
}

.grw-stars__full {
	position: absolute;
	inset: 0 auto 0 0;
	overflow: hidden;
	white-space: nowrap;
}

.grw-stars__full svg {
	fill: var( --grw-star-color );
}

/* ------------------------------------------------------------------ Cards */

.grw__viewport {
	overflow: hidden;
}

.grw__track {
	display: grid;
	gap: var( --grw-gap );
}

.grw-card {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: var( --grw-card-padding );
	background: var( --grw-card-bg );
	border: var( --grw-card-border );
	border-radius: var( --grw-card-radius );
	box-shadow: var( --grw-card-shadow );
	/* Reserve height so cards do not shift the page as avatars load. */
	min-height: 180px;
}

.grw-card__head {
	display: flex;
	align-items: center;
	gap: 12px;
}

.grw-card__avatar {
	width: var( --grw-avatar-size );
	height: var( --grw-avatar-size );
	flex: 0 0 var( --grw-avatar-size );
	border-radius: 50%;
	object-fit: cover;
	background: #f1f1f3;
}

.grw-card__avatar--fallback {
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	color: var( --grw-muted-color );
	line-height: 1;
}

.grw-card__meta {
	min-width: 0;
	display: flex;
	flex-direction: column;
}

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

a.grw-card__author:hover,
a.grw-card__author:focus-visible {
	text-decoration: underline;
}

.grw-card__time {
	font-size: 0.82em;
	color: var( --grw-muted-color );
}

.grw-card__text {
	flex: 1 1 auto;
	font-size: 0.95em;
	line-height: 1.55;
}

.grw-card__text p {
	margin: 0;
	white-space: pre-line;
}

.grw-card__more {
	margin-top: 6px;
	padding: 0;
	background: none;
	border: 0;
	font: inherit;
	font-size: 0.85em;
	font-weight: 700;
	color: var( --grw-accent-color );
	cursor: pointer;
}

.grw-card__more:hover,
.grw-card__more:focus-visible {
	text-decoration: underline;
}

.grw-card__source {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: auto;
	font-size: 0.78em;
	color: var( --grw-muted-color );
	text-decoration: none;
}

.grw-card__source:hover,
.grw-card__source:focus-visible {
	color: var( --grw-text-color );
	text-decoration: underline;
}

.grw-google {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
}

/* --------------------------------------------------------------- Layouts */

.grw--grid .grw__track {
	grid-template-columns: repeat( auto-fit, minmax( var( --grw-grid-min ), 1fr ) );
}

.grw--list .grw__track {
	grid-template-columns: 1fr;
}

/* Carousel: a scroll-snap rail. Without JS it is still a usable swipe rail,
   which is why the arrows are only inserted once the script initialises. */
.grw--carousel .grw__viewport {
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.grw--carousel .grw__viewport::-webkit-scrollbar {
	display: none;
}

.grw--carousel .grw__track {
	grid-auto-flow: column;
	grid-auto-columns: 100%;
	grid-template-columns: none;
}

.grw--carousel .grw-card {
	scroll-snap-align: start;
}

@media ( min-width: 600px ) {
	.grw--carousel .grw__track {
		grid-auto-columns: calc( ( 100% - var( --grw-gap ) ) / 2 );
	}
}

@media ( min-width: 900px ) {
	.grw--carousel .grw__track {
		grid-auto-columns: calc( ( 100% - 2 * var( --grw-gap ) ) / 3 );
	}
}

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

.grw__controls {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-top: var( --grw-gap );
}

.grw--ready .grw__controls {
	display: flex;
}

.grw__nav {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	color: var( --grw-text-color );
	background: var( --grw-card-bg );
	border: var( --grw-card-border );
	border-radius: 50%;
	cursor: pointer;
}

.grw__nav svg {
	width: 18px;
	height: 18px;
}

.grw__nav:disabled {
	opacity: 0.35;
	cursor: default;
}

.grw__dots {
	display: flex;
	align-items: center;
	gap: 8px;
}

.grw__dot {
	width: 8px;
	height: 8px;
	padding: 0;
	background: var( --grw-star-empty-color );
	border: 0;
	border-radius: 50%;
	cursor: pointer;
}

.grw__dot[aria-selected="true"] {
	background: var( --grw-accent-color );
}

/* ------------------------------------------------------- Misc / a11y */

.grw__disclosure {
	margin: var( --grw-gap ) 0 0;
	font-size: 0.75em;
	line-height: 1.5;
	color: var( --grw-muted-color );
}

.grw__disclosure a {
	color: inherit;
}

.grw__empty {
	margin: 0;
	color: var( --grw-muted-color );
}

.grw--notice {
	padding: 12px 16px;
	border: 1px solid #f0c36d;
	border-radius: var( --grw-card-radius );
	background: #fdf6e3;
	color: #6b5310;
	font-size: 0.9em;
}

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

@media ( prefers-reduced-motion: reduce ) {
	.grw--carousel .grw__viewport {
		scroll-behavior: auto;
	}
}

/* -------------------------------------------------------- Admin page bits */

.grw-admin__test {
	display: flex;
	align-items: center;
	gap: 10px;
}

.grw-admin__test .grw-ok {
	color: #14722f;
}

.grw-admin__test .grw-fail {
	color: #b32d2e;
}

.grw-admin__status {
	max-width: 640px;
}

.grw-admin__pre {
	max-width: 640px;
	padding: 12px 16px;
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	overflow-x: auto;
}

.grw-admin__codes code {
	font-size: 13px;
}

.grw-admin__notes {
	max-width: 800px;
	list-style: disc;
	padding-left: 20px;
}
