/*
 * Блок отзывов главной (guru/reviews, виджет guru-reviews) — разметка blocks/reviews/render.php.
 *
 * Шапка со счетчиком, три крупные цитаты и лента остальных отзывов в две строки навстречу друг другу.
 * Лента движется только там, где есть наведение и нет prefers-reduced-motion; пауза — наведением,
 * фокусом и кнопкой (WCAG 2.2.2), за экраном — сама (assets/js/reviews.js). На тач-экранах и при
 * reduced-motion строки листаются пальцем, копия для цикла скрыта.
 *
 * Цвета — свои токены секции: светлая тема, явная темная (html[data-theme=dark]) и системная темная
 * (без атрибута) — как гейтит тема (style.css).
 */

.sg-rv {
	--rv-card: #ffffff;
	--rv-card-big: #ffffff;
	--rv-line: rgba(20, 32, 46, 0.09);
	--rv-line-strong: rgba(20, 32, 46, 0.14);
	--rv-ink: #14202e;
	--rv-ink-2: #4a5b6d;
	--rv-ink-3: #8193a6;
	--rv-accent: #28a745;
	--rv-accent-soft: rgba(40, 167, 69, 0.1);
	--rv-glow: rgba(40, 167, 69, 0.08);
	--rv-shadow: 0 1px 2px rgba(20, 32, 46, 0.04), 0 14px 36px -18px rgba(20, 32, 46, 0.18);
	--rv-gap: 16px;
	--rv-speed: 36; /* px/с ленты, читает reviews.js */

	position: relative;
	padding: 96px 0;
	color: var(--rv-ink);
	font-family: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	overflow: hidden;
}

html[data-theme="dark"] .sg-rv {
	--rv-card: #161b22;
	--rv-card-big: #1a2029;
	--rv-line: rgba(230, 237, 243, 0.08);
	--rv-line-strong: rgba(230, 237, 243, 0.14);
	--rv-ink: #e6edf3;
	--rv-ink-2: #a3afbc;
	--rv-ink-3: #6f7c8a;
	--rv-accent: #3fb950;
	--rv-accent-soft: rgba(63, 185, 80, 0.14);
	--rv-glow: rgba(63, 185, 80, 0.07);
	--rv-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -20px rgba(0, 0, 0, 0.7);
}


/* мягкое пятно акцента за крупными карточками */
.sg-rv::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 34%;
	width: min(1100px, 90vw);
	height: 420px;
	transform: translateX(-50%);
	background: radial-gradient(closest-side, var(--rv-glow), transparent);
	pointer-events: none;
}

.sg-rv .container {
	position: relative;
}

/* сброс списков — нулевой специфичностью: не должен перебивать отступ набора ленты (.sg-rv__set) */
.sg-rv :where(ul) {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* ---- шапка ---- */
.sg-rv__head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 32px;
	margin-bottom: 40px;
}

.sg-rv__intro {
	max-width: 720px;
}

.sg-rv__eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 14px;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--rv-accent);
}

.sg-rv__eyebrow::before {
	content: "";
	width: 22px;
	height: 2px;
	border-radius: 2px;
	background: currentColor;
}

.sg-rv__title {
	margin: 0;
	font-size: clamp(28px, 3.3vw, 42px);
	line-height: 1.12;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--rv-ink);
	text-wrap: balance;
}

.sg-rv__lead {
	margin: 14px 0 0;
	font-size: 17px;
	line-height: 1.6;
	color: var(--rv-ink-2);
}

.sg-rv__stat {
	display: flex;
	align-items: center;
	gap: 14px;
	margin: 0;
	flex-shrink: 0;
}

.sg-rv__stat b {
	font-size: clamp(48px, 5vw, 64px);
	line-height: 0.9;
	font-weight: 800;
	letter-spacing: -0.04em;
	color: var(--rv-accent);
	font-variant-numeric: tabular-nums;
}

.sg-rv__stat span {
	font-size: 14px;
	line-height: 1.35;
	color: var(--rv-ink-2);
}

/* ---- карточки ---- */
.sg-rv__card {
	display: flex;
}

.sg-rv__fig {
	display: flex;
	flex-direction: column;
	width: 100%;
	margin: 0;
	padding: 20px 22px;
	background: var(--rv-card);
	border: 1px solid var(--rv-line);
	border-radius: 18px;
	box-shadow: var(--rv-shadow);
}

.sg-rv__text {
	margin: 0;
	padding: 0;
	border: 0;
	quotes: none;
}

.sg-rv__text p {
	margin: 0;
	font-size: 15px;
	line-height: 1.55;
	color: var(--rv-ink);
	overflow-wrap: anywhere;
}

.sg-rv__who {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-top: auto;
	padding-top: 14px;
}

.sg-rv__who b {
	font-size: 14px;
	font-weight: 600;
	color: var(--rv-ink);
}

.sg-rv__who span {
	font-size: 13px;
	color: var(--rv-ink-3);
}

/* крупные цитаты */
.sg-rv__featured {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 20px;
}

.sg-rv__card--big .sg-rv__fig {
	padding: 30px 30px 26px;
	background: var(--rv-card-big);
	border-color: var(--rv-line-strong);
	border-radius: 24px;
}

.sg-rv__q {
	display: block;
	width: 30px;
	height: auto;
	margin-bottom: 18px;
	color: var(--rv-accent);
}

.sg-rv__card--big .sg-rv__text p {
	font-size: 19px;
	line-height: 1.55;
	font-weight: 500;
	letter-spacing: -0.005em;
}

.sg-rv__card--big .sg-rv__who {
	flex-direction: row;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 4px 10px;
	margin-top: auto;
	padding-top: 22px;
}

.sg-rv__card--big .sg-rv__who b {
	font-size: 15px;
}

.sg-rv__card--big .sg-rv__who b::before {
	content: "— ";
	color: var(--rv-ink-3);
	font-weight: 400;
}

/* ---- лента ---- */
.sg-rv__wall {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: var(--rv-gap);
	margin-top: 28px;
	padding-top: 50px;
}

.sg-rv__row {
	overflow: hidden;
	/* края растворяются: строка «уходит» за экран, а не обрывается */
	-webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
	mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}

.sg-rv__track {
	display: flex;
	width: max-content;
	animation: sg-rv-marquee var(--rv-dur, 90s) linear infinite;
	will-change: transform;
}

.sg-rv__row--rev .sg-rv__track {
	animation-direction: reverse;
}

.sg-rv__set {
	display: flex;
	align-items: stretch;
	gap: var(--rv-gap);
	/* отступ после набора = gap: сдвиг на -50% совпадает с началом копии */
	padding-right: var(--rv-gap);
}

.sg-rv__set .sg-rv__card {
	/* --rv-w — под 1–3 строки текста, считает render.php */
	width: var(--rv-w, 320px);
	max-width: 440px;
}

.sg-rv__set .sg-rv__fig {
	padding: 18px 20px 16px;
	box-shadow: none;
}

.sg-rv__set .sg-rv__text p {
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

@keyframes sg-rv-marquee {
	to {
		transform: translateX(-50%);
	}
}

/* пауза: наведение, фокус внутри, кнопка, секция за экраном */
.sg-rv__wall:hover .sg-rv__track,
.sg-rv__wall:focus-within .sg-rv__track,
.sg-rv__wall.is-paused .sg-rv__track,
.sg-rv__wall.is-offscreen .sg-rv__track {
	animation-play-state: paused;
}

.sg-rv__toggle {
	position: absolute;
	top: 0;
	right: 0;
	display: inline-grid;
	place-items: center;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 1px solid var(--rv-line-strong);
	border-radius: 50%;
	background: var(--rv-card);
	color: var(--rv-ink-2);
	cursor: pointer;
	transition: color 0.15s, border-color 0.15s;
}

.sg-rv__toggle:hover {
	color: var(--rv-accent);
	border-color: var(--rv-accent);
}

.sg-rv__toggle:focus-visible {
	outline: 2px solid var(--rv-accent);
	outline-offset: 2px;
}

.sg-rv__i-play,
.sg-rv__wall.is-paused .sg-rv__i-pause {
	display: none;
}

.sg-rv__wall.is-paused .sg-rv__i-play {
	display: block;
}

/* ---- без движения: тач-экраны и reduced-motion — строки листаются пальцем ---- */
@media (hover: none), (prefers-reduced-motion: reduce) {
	.sg-rv__wall {
		padding-top: 0;
	}

	.sg-rv__toggle,
	.sg-rv__set--clone {
		display: none;
	}

	.sg-rv__row {
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x proximity;
		scrollbar-width: none;
		-webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
		mask-image: linear-gradient(90deg, #000 88%, transparent);
	}

	.sg-rv__row::-webkit-scrollbar {
		display: none;
	}

	.sg-rv__track {
		animation: none;
	}

	.sg-rv__set .sg-rv__card {
		scroll-snap-align: start;
	}
}

/* ---- планшет ---- */
@media (max-width: 1199px) {
	.sg-rv__featured {
		gap: 16px;
	}

	.sg-rv__card--big .sg-rv__fig {
		padding: 24px 24px 22px;
	}

	.sg-rv__card--big .sg-rv__text p {
		font-size: 17px;
	}
}

/* ---- телефон: крупные цитаты — горизонтальная лента с краем следующей ---- */
@media (max-width: 767px) {
	.sg-rv {
		padding: 64px 0;
	}

	.sg-rv__head {
		flex-direction: column;
		align-items: flex-start;
		gap: 18px;
		margin-bottom: 28px;
	}

	.sg-rv__lead {
		font-size: 16px;
	}

	.sg-rv__stat b {
		font-size: 44px;
	}

	.sg-rv__featured {
		display: grid;
		grid-auto-flow: column;
		grid-template-columns: none;
		grid-auto-columns: 84%;
		gap: 12px;
		margin: 0 calc(-1 * var(--bs-gutter-x, 24px) / 2);
		padding: 2px calc(var(--bs-gutter-x, 24px) / 2) 6px;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: calc(var(--bs-gutter-x, 24px) / 2);
		scrollbar-width: none;
	}

	.sg-rv__featured::-webkit-scrollbar {
		display: none;
	}

	.sg-rv__featured .sg-rv__card {
		scroll-snap-align: start;
	}

	.sg-rv__card--big .sg-rv__fig {
		padding: 22px 20px 20px;
		border-radius: 20px;
	}

	.sg-rv__card--big .sg-rv__text p {
		font-size: 17px;
	}

	.sg-rv__q {
		width: 24px;
		margin-bottom: 14px;
	}

	.sg-rv__wall {
		margin-top: 20px;
		--rv-gap: 12px;
	}

	.sg-rv__row {
		margin: 0 calc(-1 * var(--bs-gutter-x, 24px) / 2);
		padding: 0 calc(var(--bs-gutter-x, 24px) / 2);
		scroll-padding-inline: calc(var(--bs-gutter-x, 24px) / 2);
	}

	.sg-rv__set .sg-rv__card {
		max-width: 78vw;
	}
}

/* ---- кнопка «Оставить отзыв» ---- */
.sg-rv__aside {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 16px;
	flex-shrink: 0;
}

.sg-rv__cta {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	white-space: nowrap;
	height: 44px;
	padding: 0 20px 0 16px;
	border: 1px solid var(--rv-accent);
	border-radius: 100px;
	background: var(--rv-card);
	color: var(--rv-accent);
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s, transform 0.15s;
}

.sg-rv__cta:hover {
	background: var(--rv-accent);
	color: #fff;
}

.sg-rv__cta:focus-visible {
	outline: 2px solid var(--rv-accent);
	outline-offset: 3px;
}

.sg-rv__cta:active {
	transform: translateY(1px);
}

/* ---- окно «Оставить отзыв» ---- */
/* позиция — явно: сброс стилей темы обнуляет margin у <dialog>, и окно уезжало в левый верхний угол */
.sg-rv-dlg {
	position: fixed;
	inset: 0;
	height: fit-content;
	margin: auto;
	width: min(520px, calc(100vw - 32px));
	max-height: calc(100dvh - 32px);
	padding: 0;
	border: 1px solid var(--rv-line-strong);
	border-radius: 24px;
	background: var(--rv-card);
	color: var(--rv-ink);
	box-shadow: 0 30px 80px -20px rgba(10, 20, 30, 0.45);
	overflow: auto;
}

.sg-rv-dlg::backdrop {
	background: rgba(10, 16, 24, 0.55);
	backdrop-filter: blur(3px);
}

.sg-rv-dlg[open] {
	animation: sg-rv-dlg-in 0.18s ease-out;
}

@keyframes sg-rv-dlg-in {
	from {
		opacity: 0;
		transform: translateY(8px) scale(0.98);
	}
}

.sg-rv-dlg__form {
	position: relative;
	margin: 0;
}

.sg-rv-dlg__body {
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: 28px 28px 26px;
}

.sg-rv-dlg__body[hidden] {
	display: none;
}

.sg-rv-dlg__x {
	position: absolute;
	top: 14px;
	right: 14px;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--rv-ink-3);
	cursor: pointer;
}

.sg-rv-dlg__x:hover {
	background: var(--rv-accent-soft);
	color: var(--rv-ink);
}

.sg-rv-dlg__title {
	margin: 0;
	padding-right: 40px;
	font-size: 24px;
	line-height: 1.2;
	font-weight: 700;
	letter-spacing: -0.015em;
	color: var(--rv-ink);
	outline: none;
}

.sg-rv-dlg__intro {
	margin: -8px 0 4px;
	font-size: 15px;
	line-height: 1.5;
	color: var(--rv-ink-2);
}

.sg-rv-dlg__field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.sg-rv-dlg__label {
	font-size: 14px;
	font-weight: 600;
	color: var(--rv-ink);
}

.sg-rv-dlg input[type="text"],
.sg-rv-dlg textarea {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--rv-line-strong);
	border-radius: 12px;
	background: transparent;
	color: var(--rv-ink);
	font-family: inherit;
	font-size: 16px;
	line-height: 1.45;
	resize: vertical;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.sg-rv-dlg textarea {
	min-height: 128px;
}

.sg-rv-dlg input[type="text"]::placeholder,
.sg-rv-dlg textarea::placeholder {
	color: var(--rv-ink-3);
}

.sg-rv-dlg input[type="text"]:focus,
.sg-rv-dlg textarea:focus {
	outline: none;
	border-color: var(--rv-accent);
	box-shadow: 0 0 0 3px var(--rv-accent-soft);
}

.sg-rv-dlg [aria-invalid="true"],
.sg-rv-dlg [aria-invalid="true"]:focus {
	border-color: #d94848;
	box-shadow: 0 0 0 3px rgba(217, 72, 72, 0.14);
}

.sg-rv-dlg__meta {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	font-size: 12.5px;
	color: var(--rv-ink-3);
	font-variant-numeric: tabular-nums;
}

.sg-rv-dlg__err {
	font-size: 13px;
	line-height: 1.4;
	color: #d94848;
}

.sg-rv-dlg__err:empty {
	display: none;
}

html[data-theme="dark"] .sg-rv-dlg__err,
html[data-theme="dark"] .sg-rv-dlg [aria-invalid="true"] {
	color: #ff8a8a;
	border-color: #ff8a8a;
}


/* ловушка для ботов — вне экрана, не display:none (некоторые боты такое поле пропускают) */
.sg-rv-dlg__trap {
	position: absolute;
	left: -10000px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.sg-rv-dlg__check {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	font-size: 14px;
	line-height: 1.45;
	color: var(--rv-ink-2);
	cursor: pointer;
}

.sg-rv-dlg__check input {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	margin: 1px 0 0;
	accent-color: var(--rv-accent);
}

.sg-rv-dlg__privacy {
	display: block;
	margin-top: 2px;
	color: var(--rv-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.sg-rv-dlg__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: 50px;
	margin-top: 4px;
	padding: 0 24px;
	border: 0;
	border-radius: 100px;
	background: var(--rv-accent);
	color: #fff;
	font-family: inherit;
	font-size: 16px;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	transition: filter 0.15s;
}

.sg-rv-dlg__submit:hover {
	filter: brightness(1.06);
}

.sg-rv-dlg__submit:focus-visible {
	outline: 2px solid var(--rv-accent);
	outline-offset: 3px;
}

.sg-rv-dlg__submit:disabled {
	opacity: 0.7;
	cursor: progress;
}

.sg-rv-dlg__done {
	align-items: center;
	text-align: center;
	padding-top: 40px;
}

.sg-rv-dlg__done .sg-rv-dlg__title {
	padding-right: 0;
}

/* заголовок «Спасибо» получает фокус программно (объявление скринридеру) — рамка темы ему не нужна */
.sg-rv-dlg .sg-rv-dlg__title:focus,
.sg-rv-dlg .sg-rv-dlg__title:focus-visible {
	outline: none;
	box-shadow: none;
}

.sg-rv-dlg__done .sg-rv-dlg__intro {
	margin: -6px 0 6px;
}

.sg-rv-dlg__ok {
	color: var(--rv-accent);
}

@media (max-width: 767px) {
	/* Счетчик (~217px) и кнопка «Оставить отзыв» (166px, nowrap) рядом требуют ~400px: на телефонах
	   уже ~420px кнопка уходила за край, а overflow:hidden секции ее срезал. Не помещаются — кнопка
	   переносится под счетчик. */
	.sg-rv__aside {
		flex-direction: row;
		flex-wrap: wrap;
		row-gap: 14px;
		align-items: center;
		justify-content: space-between;
		width: 100%;
	}

	.sg-rv__cta {
		height: 42px;
		padding: 0 16px 0 14px;
		font-size: 14px;
	}

	/* окно на телефоне — лист снизу */
	.sg-rv-dlg {
		width: 100vw;
		max-width: 100vw;
		max-height: 92dvh;
		margin: auto 0 0;
		inset: auto 0 0 0;
		border-radius: 22px 22px 0 0;
		border-bottom: 0;
	}

	.sg-rv-dlg__body {
		padding: 24px 18px calc(20px + env(safe-area-inset-bottom));
	}

	@keyframes sg-rv-dlg-in {
		from {
			transform: translateY(24px);
			opacity: 0.6;
		}
	}
}

@media (prefers-reduced-motion: reduce) {
	.sg-rv-dlg[open] {
		animation: none;
	}
}
