/**
 * WE Google Reviews — Frontend.
 *
 * Alle Farben und Abstaende laufen ueber lokale Custom Properties. Wer das
 * Plugin in ein Design-System einbettet, ueberschreibt sie einfach am
 * Container — es braucht keine Aenderung an dieser Datei.
 */

.we-gr {
	--we-gr-card-width: 240px;
	--we-gr-gap: 1rem;
	--we-gr-radius: .75rem;
	--we-gr-star: #f5a623;
	/* An currentColor gekoppelt statt an feste Grautoene: so traegt das Plugin
	   auf hellem UND dunklem Grund, ohne dass etwas ueberschrieben werden muss.
	   Die Akzentfarbe bleibt bewusst fest — Sterne sind Google-Gold. */
	--we-gr-star-empty: color-mix(in srgb, currentColor 25%, transparent);
	--we-gr-border: color-mix(in srgb, currentColor 20%, transparent);
	--we-gr-surface: transparent;
	--we-gr-muted: color-mix(in srgb, currentColor 65%, transparent);

	position: relative;
	display: flex;
	flex-direction: column;
	gap: var(--we-gr-gap);
}

/* ---------- Kopfzeile ---------- */
.we-gr__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--we-gr-gap);
}

.we-gr__title {
	margin: 0;
}

.we-gr__badge {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .4em;
}

.we-gr__score {
	font-weight: 700;
}

.we-gr__count {
	color: var(--we-gr-muted);
}

/* Link zur Google-Seite: Akzentfarbe des Projekts. Die Kette faellt sauber
   zurueck — eigener Regler, dann die Primaerfarbe des Design Systems, zuletzt
   currentColor, damit das Plugin auch ohne Design-System traegt. */
.we-gr__link,
.we-gr-summary__link {
	color: var(--we-gr-link, var(--color-primary, currentColor));
	text-decoration: underline;
}

.we-gr__link:hover,
.we-gr__link:focus-visible,
.we-gr-summary__link:hover,
.we-gr-summary__link:focus-visible {
	color: var(--we-gr-link-hover, var(--color-primary-hover, currentColor));
}

/* ---------- Sterne ----------
   Textzeichen mit farbigem Ueberzug statt Bilddatei oder Icon-Schrift: so sind
   auch halbe Sterne exakt darstellbar. Der Wert kommt als --we-gr-stars (0..5)
   per style-Attribut, die Vorlesefassung steht im aria-label am Element. */
.we-gr__stars {
	--we-gr-stars: 5;

	position: relative;
	display: inline-block;
	color: var(--we-gr-star-empty);
	white-space: nowrap;
	line-height: 1;
}

.we-gr__stars::before {
	content: "★★★★★";
	position: absolute;
	inset: 0;
	width: calc(var(--we-gr-stars) / 5 * 100%);
	overflow: hidden;
	color: var(--we-gr-star);
}

/* ---------- Karten ---------- */
.we-gr__viewport {
	position: relative;
}

.we-gr__track {
	display: grid;
	gap: var(--we-gr-gap);
}

.we-gr--slider .we-gr__track {
	grid-auto-flow: column;
	grid-auto-columns: min(var(--we-gr-card-width), 100%);
	overflow-x: auto;
	overscroll-behavior-inline: contain;
	scroll-snap-type: inline proximity;
	scroll-behavior: smooth;
	padding-bottom: .25rem;
}

.we-gr--slider .we-gr__card {
	scroll-snap-align: start;
}

.we-gr--grid .we-gr__track {
	grid-template-columns: repeat(auto-fill, minmax(min(var(--we-gr-card-width), 100%), 1fr));
}

.we-gr__card {
	display: flex;
	flex-direction: column;
	gap: .6rem;
	min-width: 0;
	padding: 1rem;
	border: 1px solid var(--we-gr-border);
	border-radius: var(--we-gr-radius);
	background: var(--we-gr-surface);
}

.we-gr__person {
	display: flex;
	align-items: center;
	gap: .6rem;
}

.we-gr__avatar {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	object-fit: cover;
}

/* Platzhalter, wenn kein Bild geladen werden konnte — es wird NIE auf die
   Google-URL zurueckgefallen (DSGVO). */
.we-gr__avatar--initial {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: color-mix(in srgb, currentColor 14%, transparent);
	color: inherit;
	font-weight: 700;
	line-height: 1;
}

.we-gr__meta {
	display: flex;
	flex-direction: column;
	gap: .15rem;
	min-width: 0;
}

.we-gr__author {
	font-weight: 600;
	overflow-wrap: anywhere;
	color: inherit;
}

a.we-gr__author,
a.we-gr__source {
	text-decoration: none;
}

a.we-gr__author:hover,
a.we-gr__author:focus-visible,
a.we-gr__source:hover,
a.we-gr__source:focus-visible {
	text-decoration: underline;
}

.we-gr__source {
	color: inherit;
}

/* Sechs Zeilen, damit alle Karten gleich hoch bleiben. */
.we-gr__text {
	display: -webkit-box;
	-webkit-line-clamp: 6;
	line-clamp: 6;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin: 0;
	overflow-wrap: anywhere;
}

.we-gr__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
	margin-top: auto;
	color: var(--we-gr-muted);
	font-size: .875em;
}

/* ---------- Sortier-/Filterhinweis ----------
   Von Google gefordert: der Hinweis, wie die Bewertungen sortiert und
   gefiltert sind. Bewusst dezent, aber lesbar. */
.we-gr__notice {
	margin: 0;
	color: var(--we-gr-muted);
	font-size: .8125em;
}

/* ---------- Slider-Pfeile ---------- */
.we-gr__nav {
	display: flex;
	gap: .5rem;
	justify-content: flex-end;
}

.we-gr__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	border: 1px solid var(--we-gr-border);
	border-radius: 50%;
	background: transparent;
	color: inherit;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
}

.we-gr__arrow[disabled] {
	opacity: .35;
	cursor: default;
}

/* ---------- Zusammenfassung ----------
   Eine Zeile: Logo, Sterne, Schnitt, Stimmenzahl, Link. Umbricht bei Bedarf.
   Erbt Farben wie alles andere aus currentColor. */
.we-gr-summary {
	--we-gr-star: #f5a623;
	--we-gr-star-empty: color-mix(in srgb, currentColor 25%, transparent);
	--we-gr-muted: color-mix(in srgb, currentColor 65%, transparent);

	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .5em;
	line-height: 1.3;
}

.we-gr-summary__logo {
	flex: 0 0 auto;
	width: 1.25em;
	height: 1.25em;
}

.we-gr-summary__score {
	font-weight: 700;
}

.we-gr-summary__count {
	color: var(--we-gr-muted);
}

/* ---------- Trust-Streifen ----------
   Steht ausserhalb von .we-gr und braucht die Regler deshalb selbst. */
.we-gr-trustbar {
	--we-gr-star: #f5a623;
	--we-gr-star-empty: color-mix(in srgb, currentColor 25%, transparent);

	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: .5em;
	padding: .75rem 1rem;
	font-size: .9375rem;
}

/* ---------- Optionaler Farbkontext ----------
   Greift nur, wenn in den Einstellungen „Dunkel“ oder „Hell“ gewaehlt ist. Die
   Sektion bekommt dann zusaetzlich die Kontext- und Flaechenklassen des Themes
   (im NOW Design System .theme-default|.theme-alt + .layer-base). Die Textfarbe
   holt sie sich aus --context-text; existiert die Variable nicht (fremdes
   Theme), bleibt es beim geerbten Wert. */
.we-gr--themed {
	color: var(--context-text, inherit);
	padding: var(--we-gr-themed-padding, clamp(1.25rem, 3vw, 2.5rem));
	border-radius: var(--we-gr-themed-radius, var(--radius-lg, .75rem));
}

/* ---------- Editor-Hinweis ---------- */
.we-gr__hint {
	padding: 1rem;
	border: 1px dashed var(--we-gr-border, rgba(0, 0, 0, .2));
	border-radius: .5rem;
}

@media (prefers-reduced-motion: reduce) {
	.we-gr--slider .we-gr__track {
		scroll-behavior: auto;
	}
}
