/* TM Reviews – frontend styles */

.tm-reviews-wrap {
	--tm-star: #fbbc04; /* Google yellow */
	--tm-star-empty: #dadce0;

	--swiper-pagination-bullet-inactive-color: #fff;
	--swiper-pagination-color: #fff;

	margin: 1.5rem 0;
	max-width: 100% !important;
}

/* Wraps the slider + arrows only (not the pagination below it), so the
   arrows can be positioned outside .tm-reviews-swiper's overflow:hidden
   while still vertically centering on just the card height. */
.tm-reviews-track {
	position: relative;
	/* side padding keeps the nav buttons off the slide content, see buttons below */
	padding: 0 3.25rem;
}

.tm-reviews-aggregate {
	display: flex;
	align-items: center;
	gap: 0.5rem 1rem;
	flex-wrap: wrap;
	margin-bottom: 1rem;
	font-size: 1.05rem;
}

.tm-reviews-aggregate .tm-aggregate-value {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
}

/* Slider base layout */
.tm-reviews-swiper {
	position: relative;
	padding: 0.25rem 0;
}

.swiper-slide {
	height: auto; /* let Swiper's flex layout equalize slide heights */
}

.tm-review {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0;
	height: 100%; /* fill the (equalized) slide height so every card matches */
	box-sizing: border-box;
	padding: 1.75rem 1.5rem 1.5rem;
	background: linear-gradient( 180deg, #fff, #fcfcfd );
	border: 1px solid #ececef;
	border-radius: 16px;
	box-shadow: 0 1px 2px rgba( 16, 24, 40, 0.04 ), 0 6px 20px rgba( 16, 24, 40, 0.06 );
	text-align: center;
	transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.tm-review:hover {
	box-shadow: 0 2px 4px rgba( 16, 24, 40, 0.06 ), 0 12px 28px rgba( 16, 24, 40, 0.1 );
}

.tm-review-author {
	font-weight: 600;
	color: var( --wp--preset--color--primary );
}

.tm-stars {
	white-space: nowrap;
	line-height: 1;
}

.tm-star {
	display: inline-block;
	color: var( --tm-star-empty );
	font-size: 1.5em;
}

.tm-star.is-filled {
	position: relative;
	color: var( --tm-star );
	animation: tm-star-sparkle 8s ease-in-out infinite;
}

.tm-star.is-filled::after {
	content: '';
	position: absolute;
	inset: -45%;
	background: radial-gradient( circle, rgba( 255, 255, 255, 0.95 ) 0%, rgba( 255, 255, 255, 0 ) 70% );
	opacity: 0;
	pointer-events: none;
	animation: tm-star-glint 8s ease-in-out infinite;
}

.tm-star.is-filled:nth-child( 1 ) { animation-delay: -0.6s; }
.tm-star.is-filled:nth-child( 2 ) { animation-delay: -0.3s; }
.tm-star.is-filled:nth-child( 3 ) { animation-delay: 0s; }
.tm-star.is-filled:nth-child( 4 ) { animation-delay: 0.3s; }
.tm-star.is-filled:nth-child( 5 ) { animation-delay: 0.6s; }

@keyframes tm-star-sparkle {
	0%, 95%, 100% {
		filter: none;
		transform: scale( 1 );
	}
	96% {
		filter: drop-shadow( 0 0 1px var( --tm-star ) ) brightness( 1.1 );
		transform: scale( 1.12 );
	}
	98% {
		filter: drop-shadow( 0 0 3px var( --tm-star ) ) brightness( 1.3 );
		transform: scale( 1.25 );
	}
	99% {
		filter: drop-shadow( 0 0 1px var( --tm-star ) ) brightness( 1.1 );
		transform: scale( 1.05 );
	}
}

@keyframes tm-star-glint {
	0%, 95%, 100% { opacity: 0; }
	98% { opacity: 0.9; }
}

@media ( prefers-reduced-motion: reduce ) {
	.tm-star.is-filled,
	.tm-star.is-filled::after {
		animation: none;
	}
}

.tm-review-rating {
	margin-top:.6em;
	display: block;
}

.tm-review-body {
	flex: 1 1 auto;
	color: #333;
	line-height: 1.5;
}

.tm-review-body::before {
	content: '\201C';
	display: block;
	margin-bottom: -25px;
	font-family: Georgia, 'Times New Roman', serif;
	font-size: 50px;
	line-height: 50px;
	color: var( --wp--preset--color--primary, #3c6b8c );
	opacity: 0.3;
}

.tm-review p {
	margin-block-start: 0;
	margin-block-end: 0;
	margin: 0;
}

.tm-review-more-text {
	/* stays hidden until cloned into the dialog by frontend.js; kept in the
	   DOM (not stripped server-side) so crawlers still see the full text */
	display: none;
}

.tm-review-readmore {
	align-self: center;
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--text, #333);
	background-color: var( --wp--preset--color--grey-1, #f0f0f0 );
	border-radius: 2px;
	padding-bottom: var(--wp--custom--button-padding--bottom);
	padding-left: var(--wp--custom--button-padding--left);
	padding-right: var(--wp--custom--button-padding--right);
	padding-top: var(--wp--custom--button-padding--top);
	font: inherit;
	font-size: 0.9rem;
	cursor: pointer;
	text-decoration: none;
}

.tm-review-readmore:hover,
.tm-review-readmore:focus-visible {
	text-decoration: none;
}

.tm-review-date {
	font-size: 0.85rem;
	color: #6b7280;
}

.tm-review-source {
	font-size: 0.85rem;
}

/* Swiper buttons, more subtle. Siblings of .tm-reviews-swiper (not inside
   it), positioned relative to .tm-reviews-track and sitting in its side
   padding above – see the comment there for why they live out here. */
.tm-reviews-track .swiper-button-prev,
.tm-reviews-track .swiper-button-next {
	color: #111;
	background: #fff;
	width: 40px;
	height: 40px;
	margin-top: -20px; /* half the height, since Swiper sets top:50% */
	border-radius: 50%;
	border: 1px solid #e5e7eb;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.12 );
}

.tm-reviews-track .swiper-button-prev {
	left: 0;
}

.tm-reviews-track .swiper-button-next {
	right: 0;
}

.tm-reviews-track .swiper-button-prev::after,
.tm-reviews-track .swiper-button-next::after {
	font-size: 1rem;
	font-weight: 700;
}

/* A sibling of .tm-reviews-track (see the buttons above), one level further
   up in .tm-reviews-wrap. Swiper positions it absolutely by default, which
   would anchor it to that ancestor instead of sitting right under the
   slider, so it's put back into normal flow here. */
.tm-reviews-wrap .swiper-pagination {
	position: static;
	margin-top: 1rem;
	text-align: center;
}

/* Not enough room for side buttons on narrow screens – rely on touch swipe instead */
@media ( max-width: 640px ) {
	.tm-reviews-track {
		padding-left: 0.25rem;
		padding-right: 0.25rem;
	}

	.tm-reviews-track .swiper-button-prev,
	.tm-reviews-track .swiper-button-next {
		display: none;
	}
}

/* "Alles lesen" dialog */
.tm-review-dialog {
	width: min( 40rem, calc( 100vw - 2.5rem ) );
	max-height: min( 32rem, calc( 100vh - 2.5rem ) );
	padding: 1.5rem;
	border: 0;
	border-radius: 12px;
	box-shadow: 0 10px 40px rgba( 0, 0, 0, 0.2 );
}

.tm-review-dialog::backdrop {
	background: rgba( 0, 0, 0, 0.5 );
}

.tm-review-dialog-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin: 0 0 0.75rem;
}

.tm-review-dialog-author {
	font-weight: 600;
}

.tm-review-dialog-close {
	flex: 0 0 auto;
	width: 2rem;
	height: 2rem;
	border: 0;
	border-radius: 50%;
	background: none;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
}

.tm-review-dialog-close:hover,
.tm-review-dialog-close:focus-visible {
	background: #f0f0f0;
}

.tm-review-dialog-body {
	overflow-y: auto;
	max-height: calc( 100% - 3rem );
	line-height: 1.6;
	color: #333;
}

.tm-review-dialog-body .tm-review-more-text {
	/* unhidden by frontend.js in the cloned copy shown here */
	display: inline;
}

/* Visually hidden but readable for screen readers/crawlers */
.tm-review .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	border: 0;
}
