/*
 * Tacuna Google Reviews — card + slider + list styles.
 *
 * Scoped to .tacuna-rc-* (review card) and .tacuna-reviews-slider /
 * .tacuna-reviews-list (layout wrappers) so nothing bleeds outside the
 * review block patterns.
 *
 * Only loaded on pages that actually render the [tacuna_review_card]
 * shortcode — enqueue is gated via a do_shortcode_tag filter in
 * includes/modules/google-reviews.php.
 *
 * Replaces ~15 KB of CSS shipped by the widget-google-reviews plugin
 * (TacunaWPCLI#40). Total size here: ~2 KB.
 */

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

.tacuna-rc-card {
	box-sizing: border-box;
	padding: 1.25rem 1.5rem;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.04 );
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.tacuna-rc-header {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.tacuna-rc-avatar {
	display: inline-block;
	width: 56px;
	height: 56px;
	flex-shrink: 0;
	border-radius: 50%;
	overflow: hidden;
	/* Identicon SVG fills its own viewBox — the rounded background
	 * and pattern colors are set inline via hsl(). The border-radius
	 * here clips the SVG's square background into a circle. */
}

.tacuna-rc-who {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.tacuna-rc-author {
	font-weight: 600;
	color: #111827;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tacuna-rc-date {
	font-size: 0.875rem;
	color: #6b7280;
}

.tacuna-rc-stars {
	display: inline-flex;
	gap: 2px;
	color: #f59e0b; /* amber-500 */
}

.tacuna-rc-star {
	display: inline-block;
	width: 16px;
	height: 16px;
}

.tacuna-rc-text {
	font-size: 0.9375rem;
	line-height: 1.55;
	color: #374151;
	/* Clamp to ~5 lines so long reviews don't blow out card heights. */
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.tacuna-rc-text p {
	margin: 0;
}

/* -- Slider layout (homepage) --------------------------------------- */
/*
 * The [tacuna_reviews variant="slider"] shortcode emits cards directly
 * inside a single .tacuna-reviews-slider wrapper (no intermediate
 * core/query / core/post-template <ul> like 0.2.0's broken block-pattern
 * approach used). So the layout selectors target direct children.
 */

.tacuna-reviews-slider {
	display: flex;
	gap: 1rem;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-padding: 1rem;
	padding-bottom: 1rem; /* room for scrollbar */
	-webkit-overflow-scrolling: touch;
}

.tacuna-reviews-slider > .tacuna-rc-card {
	flex: 0 0 min( 360px, 80vw );
	scroll-snap-align: start;
}

/* -- List layout (cart / checkout) ---------------------------------- */

.tacuna-reviews-list {
	display: grid;
	grid-template-columns: repeat( auto-fit, minmax( 280px, 1fr ) );
	gap: 1rem;
}

/* -- Credibility badge ([tacuna_reviews_badge]) --------------------- */
/*
 * Compact inline-block badge for cart / checkout / footer / homepage
 * trust header. Layout: Google G logo | numeric rating + star row |
 * review count label. Whole thing is a clickable link to Google's
 * reviews-centric URL (search.google.com/local/reviews?placeid=...)
 * which opens the reviews modal directly — no map.
 */

.tacuna-reviews-badge {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.625rem 1rem;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	box-shadow: 0 1px 3px rgba( 0, 0, 0, 0.04 );
	text-decoration: none;
	color: inherit;
	transition: box-shadow 120ms ease, transform 120ms ease;
	max-width: 100%;
}

.tacuna-reviews-badge:hover {
	box-shadow: 0 4px 10px rgba( 0, 0, 0, 0.08 );
	transform: translateY( -1px );
	text-decoration: none;
}

.tacuna-reviews-badge:focus-visible {
	outline: 2px solid #4285f4; /* Google blue */
	outline-offset: 2px;
}

.tacuna-reviews-badge-g {
	flex-shrink: 0;
	width: 22px;
	height: 22px;
}

.tacuna-reviews-badge-content {
	display: flex;
	flex-direction: column;
	gap: 0.125rem;
	min-width: 0;
}

.tacuna-reviews-badge-rating {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
}

.tacuna-reviews-badge-score {
	font-weight: 700;
	font-size: 0.9375rem;
	color: #111827;
	font-variant-numeric: tabular-nums;
}

.tacuna-reviews-badge-stars {
	position: relative;
	display: inline-block;
	font-size: 0.9375rem;
	line-height: 1;
	letter-spacing: 1px;
}

.tacuna-reviews-badge-stars-empty {
	color: #e5e7eb;
}

.tacuna-reviews-badge-stars-filled {
	position: absolute;
	inset: 0;
	overflow: hidden;
	color: #f59e0b; /* amber-500 */
	white-space: nowrap;
}

.tacuna-reviews-badge-label {
	font-size: 0.75rem;
	color: #6b7280;
	line-height: 1.2;
}

/* -- Cart / checkout: 2x badge -------------------------------------- */
/*
 * The cart and checkout pages are where the badge is the page's
 * primary trust signal, not a supporting element. Scale it 2x so
 * it reads at a glance.
 *
 * Layout split:
 *   - 2x sizing (padding, gap, font sizes, G logo) applies to both.
 *   - The "match the Place Order button width" layout (full-width,
 *     centered content, margins) is checkout-only — cart keeps its
 *     natural inline-flex placement so the GP Element flow on cart
 *     is preserved.
 */

.woocommerce-cart .woocommerce .tacuna-reviews-badge,
.woocommerce-checkout .woocommerce .tacuna-reviews-badge {
	gap: 1.5rem;
	padding: 1.25rem 2rem;
	border-radius: 16px;
	/* Safety net: on a genuinely too-narrow viewport, allow
	 * the G logo to drop above the content rather than
	 * horizontally overflowing. */
	flex-wrap: wrap;
	row-gap: 0.75rem;
}

.woocommerce-cart .woocommerce .tacuna-reviews-badge-g,
.woocommerce-checkout .woocommerce .tacuna-reviews-badge-g {
	width: 44px;
	height: 44px;
}

.woocommerce-cart .woocommerce .tacuna-reviews-badge-content,
.woocommerce-checkout .woocommerce .tacuna-reviews-badge-content {
	gap: 0.375rem;
	/* Flatten the content column so the G logo, the rating
	 * row, and the label become direct flex children of the
	 * badge — placing the G immediately next to "5.0" instead
	 * of vertically centered against the whole content block. */
	display: contents;
}

.woocommerce-cart .woocommerce .tacuna-reviews-badge-rating,
.woocommerce-checkout .woocommerce .tacuna-reviews-badge-rating {
	gap: 0.75rem;
	flex-wrap: wrap;
	row-gap: 0.25rem;
}

.woocommerce-cart .woocommerce .tacuna-reviews-badge-score,
.woocommerce-checkout .woocommerce .tacuna-reviews-badge-score,
.woocommerce-cart .woocommerce .tacuna-reviews-badge-stars,
.woocommerce-checkout .woocommerce .tacuna-reviews-badge-stars {
	font-size: 1.75rem;
}

.woocommerce-cart .woocommerce .tacuna-reviews-badge-stars,
.woocommerce-checkout .woocommerce .tacuna-reviews-badge-stars {
	letter-spacing: 2px;
}

.woocommerce-cart .woocommerce .tacuna-reviews-badge-label,
.woocommerce-checkout .woocommerce .tacuna-reviews-badge-label {
	font-size: 1rem;
}

/* Cart only: constrain the badge to ~half the cart-collaterals
 * container width on desktop so it sits in its own column to
 * the left of cart_totals (which floats right at ~50%). The
 * badge fills its column at width:100% with content centered.
 * Drops to full width on narrow viewports where cart_totals
 * stacks below. */
.woocommerce-cart .woocommerce .tacuna-reviews-badge {
	display: flex;
	width: 100%;
	max-width: calc( 50% - 1rem );
	box-sizing: border-box;
	justify-content: center;
	align-items: center;
	border-radius: 12px;
	margin-block: 1.5rem;
}

@media ( max-width: 768px ) {
	.woocommerce-cart .woocommerce .tacuna-reviews-badge {
		max-width: 100%;
	}
}

/* Checkout only: stretch the badge to match the Place Order
 * button width and center its content inside the box. Tight
 * bottom margin so the badge sits close to the action button
 * below it. */
.woocommerce-checkout .woocommerce .tacuna-reviews-badge {
	display: flex;
	width: 100%;
	box-sizing: border-box;
	justify-content: center;
	align-items: center;
	margin-top: 1.5rem;
	margin-bottom: 0.5rem;
}

/* -- Footer override: transparent + light text ---------------------- */
/*
 * The badge lives on a dark teal/blue (#0b3c49) footer container
 * ("after-footer" class from the Custom Footer GP Element). Drop
 * the white card background, the light border, and the shadow so
 * it blends into the footer, and flip text colors to light for
 * legibility on the dark background.
 */

.after-footer .tacuna-reviews-badge,
.site-footer .tacuna-reviews-badge {
	background: transparent;
	border-color: transparent;
	box-shadow: none;
}

.after-footer .tacuna-reviews-badge:hover,
.site-footer .tacuna-reviews-badge:hover {
	box-shadow: none;
}

.after-footer .tacuna-reviews-badge-score,
.site-footer .tacuna-reviews-badge-score {
	color: #ffffff;
}

.after-footer .tacuna-reviews-badge-label,
.site-footer .tacuna-reviews-badge-label {
	color: #e5e7eb;
}

.after-footer .tacuna-reviews-badge-stars-empty,
.site-footer .tacuna-reviews-badge-stars-empty {
	color: #4b5563;
}

/* -- Dark theme override (if site ever toggles) --------------------- */

@media ( prefers-color-scheme: dark ) {
	.tacuna-rc-card {
		background: #1f2937;
		border-color: #374151;
	}
	.tacuna-rc-author {
		color: #f9fafb;
	}
	.tacuna-rc-date {
		color: #9ca3af;
	}
	.tacuna-rc-text {
		color: #d1d5db;
	}
	.tacuna-reviews-badge {
		background: #1f2937;
		border-color: #374151;
	}
	.tacuna-reviews-badge-score {
		color: #f9fafb;
	}
	.tacuna-reviews-badge-label {
		color: #9ca3af;
	}
	.tacuna-reviews-badge-stars-empty {
		color: #374151;
	}
}
