/**
 * WP Custom Reviews — Frontend Styles
 *
 * Styles for the [wpcr_reviews] shortcode output.
 * Uses BEM naming convention with the 'wpcr-' prefix.
 *
 * @package WPCR
 */

/* ==========================================================================
   Layout
   ========================================================================== */

.wpcr-reviews {
	width: 100%;
	margin: 0 auto 2rem;
	font-family: inherit;
	color: #1a1a1a;
	line-height: 1.6;
}

.wpcr-reviews__heading {
	margin: 0 0 1.5rem;
}

.wpcr-reviews__empty {
	text-align: center;
	padding: 2rem;
	color: #666;
	font-style: italic;
}

/* ==========================================================================
   Rating Summary
   ========================================================================== */

.wpcr-summary {
	display: flex;
	gap: 2rem;
	align-items: flex-start;
	padding: 1.5rem;
	margin-bottom: 2rem;
	background: #fafafa;
	border: 1px solid #e5e5e5;
	border-radius: 8px;
}

.wpcr-summary-rating {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-width: 120px;
}

.wpcr-summary-rating__number {
	font-size: 2.5rem;
	font-weight: 700;
	line-height: 1;
	color: #1a1a1a;
}

.wpcr-summary-rating__count {
	margin-top: 0.25rem;
	font-size: 0.875rem;
	color: #666;
}

/* ==========================================================================
   Distribution Chart
   ========================================================================== */

.wpcr-distribution {
	flex: 1;
}

.wpcr-distribution__row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 0.25rem;
}

.wpcr-distribution__label {
	min-width: 36px;
	font-size: 0.8125rem;
	text-align: right;
	color: #555;
	white-space: nowrap;
}

.wpcr-distribution__bar {
	flex: 1;
	height: 10px;
	background: #e5e5e5;
	border-radius: 5px;
	overflow: hidden;
}

.wpcr-distribution__fill {
	display: block;
	height: 100%;
	background: #f5a623;
	border-radius: 5px;
	transition: width 0.3s ease;
}

.wpcr-distribution__count {
	min-width: 24px;
	font-size: 0.8125rem;
	color: #888;
}

/* ==========================================================================
   Stars
   ========================================================================== */

.wpcr-stars {
	display: inline-flex;
	gap: 1px;
}

.wpcr-star {
	color: #e5e5e5;
	line-height: 1;
}

.wpcr-star--full {
	color: #f5a623;
}

.wpcr-star--half {
	color: #f5a623;
	opacity: 0.6;
}

.wpcr-stars--sm .wpcr-star {
	font-size: 0.875rem;
}

.wpcr-stars--md .wpcr-star {
	font-size: 1.125rem;
}

.wpcr-stars--lg .wpcr-star {
	font-size: 1.5rem;
}

/* ==========================================================================
   Review Cards — Two Column Grid
   ========================================================================== */

.wpcr-reviews__list {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
}

.wpcr-review-card {
	padding: 1.25rem 1.5rem;
	background: #fff;
	border: 1px solid #e5e5e5;
	border-radius: 8px;
	transition: box-shadow 0.2s ease;
}

.wpcr-review-card:hover {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.wpcr-review-card__header {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	margin-bottom: 0.75rem;
}

.wpcr-review-card__author {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: wrap;
}

.wpcr-review-card__name {
	font-weight: 600;
	font-size: 0.9375rem;
}

.wpcr-review-card__badge {
	display: inline-flex;
	align-items: center;
	gap: 0.2rem;
	padding: 0.15rem 0.5rem;
	font-size: 0.75rem;
	font-weight: 500;
	color: #0d7e3f;
	background: #e6f7ed;
	border-radius: 20px;
	white-space: nowrap;
}

.wpcr-review-card__badge-icon {
	font-weight: 700;
}

.wpcr-review-card__date {
	display: block;
	font-size: 0.8125rem;
	color: #888;
}

.wpcr-review-card__title {
	margin: 0 0 0.5rem;
	font-size: 1rem;
	font-weight: 600;
}

.wpcr-review-card__content {
	margin: 0;
	font-size: 0.9375rem;
	color: #333;
}

.wpcr-review-card__footer {
	margin-top: 0.75rem;
	padding-top: 0.75rem;
	border-top: 1px solid #f0f0f0;
}

.wpcr-review-card__product {
	font-size: 0.8125rem;
	color: #888;
	margin: 0;
}

/* ==========================================================================
   Photo Gallery with Lightbox Thumbnails
   ========================================================================== */

.wpcr-review-card__photos {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 0.75rem;
	padding-top: 0.75rem;
	border-top: 1px solid #f0f0f0;
}

.wpcr-photo-thumb {
	display: inline-block;
	width: 72px;
	height: 72px;
	padding: 0;
	border: 1px solid #e5e5e5;
	border-radius: 4px;
	background: none;
	cursor: pointer;
	overflow: hidden;
	transition: all 0.2s ease;
}

.wpcr-photo-thumb:hover {
	border-color: #999;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
	transform: scale(1.05);
}

.wpcr-photo-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ==========================================================================
   Lightbox Overlay and Modal
   ========================================================================== */

.wpcr-lightbox {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wpcr-lightbox--hidden {
	display: none;
}

.wpcr-lightbox__overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.9);
	z-index: 1;
}

.wpcr-lightbox__container {
	position: relative;
	width: 90%;
	max-width: 900px;
	height: auto;
	max-height: 90vh;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2;
}

.wpcr-lightbox__image {
	max-width: 100%;
	max-height: 85vh;
	object-fit: contain;
	border-radius: 4px;
}

.wpcr-lightbox__close,
.wpcr-lightbox__prev,
.wpcr-lightbox__next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	background-color: rgba(255, 255, 255, 0.2);
	color: #fff;
	border: none;
	padding: 0.75rem 1rem;
	font-size: 1.5rem;
	cursor: pointer;
	border-radius: 4px;
	transition: background-color 0.2s ease;
	z-index: 3;
}

.wpcr-lightbox__close:hover,
.wpcr-lightbox__prev:hover,
.wpcr-lightbox__next:hover {
	background-color: rgba(255, 255, 255, 0.4);
}

.wpcr-lightbox__close {
	top: 1rem;
	right: 1rem;
	transform: none;
	font-size: 2rem;
	padding: 0.5rem 0.75rem;
}

.wpcr-lightbox__prev {
	left: 1rem;
}

.wpcr-lightbox__next {
	right: 1rem;
}

.wpcr-lightbox__prev:disabled,
.wpcr-lightbox__next:disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

/* ==========================================================================
   Random Reviews (product pages)
   ========================================================================== */

.wpcr-random-reviews .wpcr-reviews__list {
	grid-template-columns: 1fr;
}

.wpcr-random-reviews.wpcr-random-reviews--cols-2 .wpcr-reviews__list {
	grid-template-columns: 1fr 1fr;
}

.wpcr-random-reviews.wpcr-random-reviews--cols-3 .wpcr-reviews__list {
	grid-template-columns: 1fr 1fr 1fr;
}

/* ==========================================================================
   This flag's own reviews (product pages)
   ========================================================================== */

.wpcr-review-card__translated {
	margin-top: 0.5em;
	font-size: 0.9em;
}

.wpcr-review-card__translated-notice {
	cursor: pointer;
	opacity: 0.7;
}

.wpcr-review-card__translated[open] .wpcr-review-card__translated-notice {
	opacity: 1;
}

.wpcr-review-card__original-title,
.wpcr-review-card__original {
	padding-left: 0.75em;
	border-left: 2px solid currentColor;
	opacity: 0.8;
}

/* Title and text are one quotation — the words the customer wrote — so they
   sit inside one bar, with nothing between them. */
.wpcr-review-card__original-title {
	margin: 0.5em 0 0;
	font-weight: 600;
}

.wpcr-review-card__original {
	margin: 0.5em 0 0;
}

.wpcr-review-card__original-title + .wpcr-review-card__original {
	margin-top: 0;
}

.wpcr-product-rating {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5em;
}

.wpcr-product-rating__average {
	font-weight: 600;
}

.wpcr-product-rating__count a {
	color: inherit;
}

.wpcr-product-reviews__title {
	margin: 0 0 0.5em;
}

/* Reproduces the home page's rating pill (Matteo's approved mockup): a
   centred rounded pill holding the average, the stars, then the count. */
.wpcr-product-reviews__summary {
	display: flex;
	justify-content: center;
	margin: 0 0 1.75em;
	font-size: var(--text-l, 1.25rem);
}

.wpcr-product-reviews__pill {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.4em 1.3em;
	padding: 0.6em 1.8em;
	background: #fff;
	border: 1px solid #e5e5e5;
	border-radius: 999px;
}

.wpcr-product-reviews__average {
	font-size: 1.9em;
	line-height: 1;
	font-weight: 700;
	color: #1a1a1a;
}

.wpcr-product-reviews__summary .wpcr-stars--lg .wpcr-star {
	font-size: 1.35em;
}

.wpcr-product-reviews__count {
	font-size: 1em;
	color: #353030;
	white-space: nowrap;
}

.wpcr-product-reviews .wpcr-reviews__list {
	grid-template-columns: 1fr;
}

.wpcr-product-reviews.wpcr-random-reviews--cols-2 .wpcr-reviews__list {
	grid-template-columns: 1fr 1fr;
}

.wpcr-product-reviews.wpcr-random-reviews--cols-3 .wpcr-reviews__list {
	grid-template-columns: 1fr 1fr 1fr;
}

.wpcr-product-reviews__more {
	display: block;
	margin: 1.25em auto 0;
	padding: 0.6em 1.4em;
	background: none;
	/* A button that states no colour of its own is painted by Safari on a
	   phone in the system blue, border included — on a desktop the same
	   button is the colour of the text around it. Both are stated here so
	   the control looks the same everywhere. */
	color: #1a1a1a;
	border: 1px solid #d0d0d0;
	border-radius: 3px;
	cursor: pointer;
	font: inherit;
}

.wpcr-product-reviews__more:hover {
	border-color: #999;
}

.wpcr-product-reviews__more:disabled {
	opacity: 0.5;
	cursor: wait;
}

@media (max-width: 700px) {

	.wpcr-product-reviews.wpcr-random-reviews--cols-2 .wpcr-reviews__list,
	.wpcr-product-reviews.wpcr-random-reviews--cols-3 .wpcr-reviews__list {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 767px) {

	.wpcr-product-reviews__summary {
		font-size: var(--text-m, 1rem);
	}

	.wpcr-product-reviews__pill {
		padding: 0.5em 1.1em;
		gap: 0.35em 0.9em;
	}
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.wpcr-pagination {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 0.25rem;
	margin-top: 2rem;
	padding-top: 1.5rem;
	border-top: 1px solid #e5e5e5;
}

.wpcr-pagination__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 0.5rem;
	font-size: 0.875rem;
	text-decoration: none;
	color: #555;
	border: 1px solid #e5e5e5;
	border-radius: 4px;
	transition: all 0.15s ease;
}

.wpcr-pagination__link:hover {
	color: #1a1a1a;
	border-color: #ccc;
	background: #f9f9f9;
}

.wpcr-pagination__current {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	padding: 0 0.5rem;
	font-size: 0.875rem;
	color: #fff;
	background: #333;
	border: 1px solid #333;
	border-radius: 4px;
	font-weight: 600;
}

.wpcr-pagination__prev,
.wpcr-pagination__next {
	padding: 0 0.75rem;
}

.wpcr-pagination__ellipsis {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 36px;
	height: 36px;
	font-size: 0.875rem;
	color: #888;
	cursor: default;
}

/* ==========================================================================
   Skeleton Loading Placeholders (AJAX random reviews)
   ========================================================================== */

.wpcr-random-reviews__loading {
	display: grid;
	gap: 1rem;
}

.wpcr-random-reviews--cols-2 .wpcr-random-reviews__loading {
	grid-template-columns: 1fr 1fr;
}

.wpcr-random-reviews--cols-3 .wpcr-random-reviews__loading {
	grid-template-columns: 1fr 1fr 1fr;
}

/* The real card holds the same floor as the skeleton it replaces. On the five
   translated domains TranslatePress rewrites the cards after they are inserted,
   and for about a quarter of a second they are nearly empty: measured on the
   live Italian page, the block fell from 1190px to 597px and climbed back to
   1156px — a 0,123 layout shift, worse than the one the skeletons had just
   fixed. With a floor the block never collapses while that pass runs, and short
   reviews simply get a little more white space. */
.wpcr-review-card {
	min-height: 185px;
	box-sizing: border-box;
}

.wpcr-review-card--skeleton {
	pointer-events: none;

	/* Hold the space the real card will take, so the page does not move when the
	   cards arrive. Measured on the live shop (product page, phone, throttled):
	   six skeletons made the container 776px tall, the six real cards made it
	   1174px — the page pushed everything below it down by nearly 400px, seconds
	   after it had been drawn. Real cards measured 145-238px on a phone and
	   145-181px on a desktop, so the reservation is set just under the typical
	   card: too tall would leave a gap under the last row, which is the same
	   defect upside down. */
	min-height: 185px;
	box-sizing: border-box;
}

@keyframes wpcr-skeleton-pulse {
	0% {
		opacity: 1;
	}
	50% {
		opacity: 0.4;
	}
	100% {
		opacity: 1;
	}
}

.wpcr-skeleton {
	background: #e5e5e5;
	border-radius: 4px;
	animation: wpcr-skeleton-pulse 1.5s ease-in-out infinite;
}

.wpcr-skeleton--stars {
	width: 100px;
	height: 18px;
	margin-bottom: 0.75rem;
}

.wpcr-skeleton--text {
	width: 100%;
	height: 14px;
	margin-bottom: 0.5rem;
}

.wpcr-skeleton--short {
	width: 60%;
}

/* ==========================================================================
   Oxygen Builder Compatibility
   ========================================================================== */

.ct-shortcode:has(.wpcr-reviews),
.ct-shortcode:has(.wpcr-random-reviews),
.ct-shortcode:has(.wpcr-product-reviews) {
	align-self: stretch;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
	.wpcr-reviews__list,
	.wpcr-random-reviews.wpcr-random-reviews--cols-2 .wpcr-reviews__list,
	.wpcr-random-reviews.wpcr-random-reviews--cols-3 .wpcr-reviews__list {
		grid-template-columns: 1fr;
	}

	.wpcr-random-reviews--cols-2 .wpcr-random-reviews__loading,
	.wpcr-random-reviews--cols-3 .wpcr-random-reviews__loading {
		grid-template-columns: 1fr;
	}

	.wpcr-lightbox__close,
	.wpcr-lightbox__prev,
	.wpcr-lightbox__next {
		padding: 0.5rem 0.75rem;
		font-size: 1.25rem;
	}

	.wpcr-lightbox__prev {
		left: 0.5rem;
	}

	.wpcr-lightbox__next {
		right: 0.5rem;
	}
}

@media (max-width: 600px) {
	.wpcr-summary {
		flex-direction: column;
		align-items: center;
	}

	.wpcr-distribution {
		width: 100%;
	}

	.wpcr-review-card__header {
		flex-direction: column;
	}

	.wpcr-pagination {
		flex-wrap: wrap;
	}

	.wpcr-review-card__photos {
		gap: 0.4rem;
	}

	.wpcr-photo-thumb {
		width: 56px;
		height: 56px;
	}
}
