/**
 * E-Potion Google Reviews Widget
 *
 * Structure:
 *   .ep-gr                — outer section
 *     .ep-gr-header       — centered aggregate display (label, score, stars, count, logo, CTA)
 *     .ep-gr-carousel     — track wrapper (with arrows positioned on the sides)
 *       .ep-gr-track      — horizontal scroll-snap container
 *         .ep-gr-list     — flex row of cards
 *           .ep-gr-card   — single review card
 *
 * Card grid: desktop 4 / tablet 2 / mobile 1
 * Lightweight: ~5 KB, zero deps, native scroll-snap for touch swipe.
 *
 * @package Shoptimizer_Child
 */

/* ==========================================================================
   1. Container
   ========================================================================== */

.ep-gr {
	position: relative;
	width: 100%;
	margin: 0;
	padding: 32px 0;
	font-family: inherit;
	color: var(--ep-text-primary, #0e1116);
	box-sizing: border-box;
}

.ep-gr *,
.ep-gr *::before,
.ep-gr *::after {
	box-sizing: border-box;
}

/* ==========================================================================
   2. Header — centered aggregate display
   ========================================================================== */

.ep-gr-header {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	text-align: center;
	margin-bottom: 32px;
	padding: 0 16px;
}

.ep-gr-label {
	font-size: 14px;
	font-weight: 800;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--ep-text-primary, #0e1116);
	margin: 0;
}

.ep-gr-score-row {
	display: flex;
	align-items: center;
	gap: 12px;
}

.ep-gr-score {
	font-size: 32px;
	font-weight: 700;
	line-height: 1;
	color: var(--ep-text-primary, #0e1116);
	letter-spacing: -0.02em;
}

.ep-gr-stars-row {
	display: inline-flex;
	align-items: center;
	gap: 2px;
}

.ep-gr-star {
	display: block;
}

.ep-gr-count {
	font-size: 14px;
	color: var(--ep-text-secondary, #525a64);
	margin-top: -2px;
}

.ep-gr-count strong {
	color: var(--ep-text-primary, #0e1116);
	font-weight: 700;
}

.ep-gr-brand {
	margin-top: 4px;
}

.ep-gr-google-logo {
	display: block;
}

/* ==========================================================================
   3. CTA button
   ========================================================================== */

.ep-gr-cta {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin-top: 12px;
	padding: 12px 22px;
	background: #0e1116;
	color: #ffffff;
	border: 1px solid #0e1116;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	letter-spacing: 0.01em;
	transition: background-color 200ms ease, border-color 200ms ease, transform 200ms ease, box-shadow 250ms ease;
	-webkit-appearance: none;
}

.ep-gr-cta:hover,
.ep-gr-cta:focus-visible {
	background: var(--ep-accent, #ff6b1a);
	border-color: var(--ep-accent, #ff6b1a);
	color: #ffffff;
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(255, 107, 26, 0.28);
}

.ep-gr-cta:focus-visible {
	outline: 2px solid var(--ep-accent, #ff6b1a);
	outline-offset: 3px;
}

.ep-gr-cta .ep-gr-g {
	background: #fff;
	border-radius: 50%;
	padding: 3px;
}

/* ==========================================================================
   4. Carousel chrome
   ========================================================================== */

.ep-gr-carousel {
	position: relative;
}

.ep-gr-track {
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	-ms-overflow-style: none;
	padding: 6px 4px 12px;
	margin: 0 -4px;
}

.ep-gr-track::-webkit-scrollbar {
	display: none;
}

.ep-gr-list {
	display: flex;
	gap: 20px;
	list-style: none;
	padding: 0 4px;
	margin: 0;
}

/* Arrows — positioned outside the track on desktop */
.ep-gr-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	width: 44px;
	height: 44px;
	padding: 0;
	border-radius: 50%;
	border: 1px solid var(--ep-border-default, #e1e3e6);
	background: #ffffff;
	color: var(--ep-text-primary, #0e1116);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(14, 17, 22, 0.08);
	transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease, opacity 200ms ease;
}

.ep-gr-arrow--prev { left: -22px; }
.ep-gr-arrow--next { right: -22px; }

.ep-gr-arrow:hover:not(:disabled),
.ep-gr-arrow:focus-visible {
	background: #0e1116;
	color: #ffffff;
	border-color: #0e1116;
}

.ep-gr-arrow:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

/* ==========================================================================
   5. Card
   ========================================================================== */

.ep-gr-card {
	flex: 0 0 calc((100% - 3 * 20px) / 4); /* desktop: 4 cards × 3 gaps */
	min-width: 0;
	scroll-snap-align: start;
	position: relative;
	background: #ffffff;
	border: 1px solid var(--ep-border-default, #e1e3e6);
	border-radius: 12px;
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	transition: transform 250ms ease, box-shadow 250ms ease, border-color 250ms ease;
}

.ep-gr-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 8px 24px rgba(14, 17, 22, 0.07);
	border-color: rgba(14, 17, 22, 0.12);
}

/* Google G in top-right corner of card */
.ep-gr-card > .ep-gr-g {
	position: absolute;
	top: 16px;
	right: 16px;
	opacity: 0.95;
}

/* Card header — avatar + author block */
.ep-gr-card-head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding-right: 28px; /* don't overlap the G icon */
}

.ep-gr-avatar {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	overflow: hidden;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.02em;
	font-family: inherit;
	line-height: 1;
}

.ep-gr-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.ep-gr-author {
	min-width: 0;
	flex: 1;
}

.ep-gr-name {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	color: var(--ep-text-primary, #0e1116);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ep-gr-stats {
	margin-top: 3px;
	font-size: 11.5px;
	color: var(--ep-text-muted, #8a9098);
	line-height: 1.2;
	display: flex;
	align-items: center;
	gap: 4px;
	flex-wrap: wrap;
}

.ep-gr-local-guide {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	color: #1a73e8;
	font-weight: 600;
}

.ep-gr-local-guide svg {
	display: block;
}

/* Meta row — stars + when + NEW badge */
.ep-gr-meta-row {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.ep-gr-when {
	font-size: 12px;
	color: var(--ep-text-muted, #8a9098);
}

.ep-gr-new {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.06em;
	padding: 2px 6px;
	border-radius: 4px;
	background: #e8f0fe;
	/* WCAG-FIX: #1a73e8 on #e8f0fe = 3.93:1 — fails AA.
	   #1557b0 gives 5.31:1 on #e8f0fe — passes AA. */
	color: #1557b0;
}

/* Review text — 4-line clamp with ellipsis */
.ep-gr-text {
	font-size: 14px;
	line-height: 1.55;
	color: var(--ep-text-primary, #0e1116);
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 4;
	-webkit-box-orient: vertical;
	line-clamp: 4;
	overflow: hidden;
	text-overflow: ellipsis;
	min-height: calc(4 * 1.55em);
	overflow-wrap: anywhere;
	word-break: normal;
}

/* ==========================================================================
   6. Responsive
   ========================================================================== */

/* Tablet: 2 cards per row */
@media (min-width: 641px) and (max-width: 1024px) {
	.ep-gr-card {
		flex: 0 0 calc((100% - 1 * 20px) / 2);
	}

	.ep-gr-arrow--prev { left: 8px; }
	.ep-gr-arrow--next { right: 8px; }
}

/* Mobile: 1 card per row */
@media (max-width: 640px) {
	.ep-gr {
		padding: 24px 0;
	}

	.ep-gr-header {
		margin-bottom: 24px;
		gap: 10px;
	}

	.ep-gr-score {
		font-size: 28px;
	}

	.ep-gr-cta {
		padding: 11px 18px;
		font-size: 13px;
		width: 100%;
		max-width: 320px;
		justify-content: center;
	}

	.ep-gr-card {
		flex: 0 0 calc(100% - 8px);
	}

	.ep-gr-list {
		gap: 12px;
	}

	.ep-gr-arrow {
		display: none; /* swipe only on mobile */
	}

	.ep-gr-card {
		padding: 18px;
	}

	.ep-gr-text {
		font-size: 13.5px;
		-webkit-line-clamp: 5;
		line-clamp: 5;
		min-height: calc(5 * 1.55em);
	}
}

/* ==========================================================================
   7. Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.ep-gr-track {
		scroll-behavior: auto;
	}
	.ep-gr-card,
	.ep-gr-cta,
	.ep-gr-arrow {
		transition: none;
	}
	.ep-gr-card:hover {
		transform: none;
	}
	.ep-gr-cta:hover {
		transform: none;
	}
}