/**
 * Рейтинг бирж (главная) и страница обзора биржи.
 *
 * Раскладка зависит от ширины самого блока (container queries), а не окна:
 * блок одинаково хорошо смотрится и на всю ширину, и в узкой колонке.
 */

.exr,
.exv {
	--exr-blue: #2563eb;
	--exr-blue-hover: #1d4ed8;
	--exr-green: #15803d;
	--exr-green-hover: #166534;
	--exr-text: var(--wp--preset--color--contrast, #0f172a);
	--exr-surface: var(--wp--preset--color--base, #fff);
	--exr-border: color-mix(in srgb, var(--exr-text) 12%, transparent);
	--exr-muted: color-mix(in srgb, var(--exr-text) 60%, transparent);
	--exr-subtle: color-mix(in srgb, var(--exr-text) 5%, var(--exr-surface));
	--exr-radius: 16px;
	--exr-logo: 56px;

	box-sizing: border-box;
	color: var(--exr-text);
	container-type: inline-size;
}

.exr *,
.exr *::before,
.exr *::after,
.exv *,
.exv *::before,
.exv *::after {
	box-sizing: border-box;
}

.exr .screen-reader-text,
.exv .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.exr__heading {
	margin: 0 0 1.25rem;
	font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: -0.02em;
}

.exr__empty {
	margin: 0;
	padding: 1.5rem;
	border: 1px dashed var(--exr-border);
	border-radius: var(--exr-radius);
	color: var(--exr-muted);
	text-align: center;
}

.exr__list {
	display: grid;
	gap: 12px;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Строка биржи: № · логотип · название · рейтинг · кнопки. */
.exr-item {
	display: grid;
	grid-template-areas: "rank logo name rating actions";
	grid-template-columns: 2rem var(--exr-logo) minmax(0, 1fr) auto auto;
	gap: 12px 20px;
	align-items: center;
	margin: 0;
	padding: 16px 20px;
	background: var(--exr-surface);
	border: 1px solid var(--exr-border);
	border-radius: var(--exr-radius);
	box-shadow: 0 1px 2px rgb(15 23 42 / 4%);
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.exr-item:hover {
	border-color: color-mix(in srgb, var(--exr-blue) 35%, transparent);
	box-shadow: 0 8px 24px rgb(15 23 42 / 8%);
}

.exr-item__rank {
	grid-area: rank;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	border-radius: 999px;
	background: var(--exr-subtle);
	color: var(--exr-muted);
	font-size: 0.875rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.exr-item:nth-child(1) .exr-item__rank {
	background: #fef3c7;
	color: #92400e;
}

.exr-item:nth-child(2) .exr-item__rank {
	background: #e2e8f0;
	color: #334155;
}

.exr-item:nth-child(3) .exr-item__rank {
	background: #fde6d4;
	color: #9a3412;
}

.exr-logo {
	grid-area: logo;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--exr-logo);
	height: var(--exr-logo);
	flex: none;
	padding: 6px;
	overflow: hidden;
	background: #fff;
	border: 1px solid var(--exr-border);
	border-radius: 12px;
}

.exr-logo img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.exr-logo__placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	border-radius: 8px;
	background: linear-gradient(135deg, #2563eb, #7c3aed);
	color: #fff;
	font-size: 1.25rem;
	font-weight: 700;
	text-transform: uppercase;
}

.exr-item__name {
	grid-area: name;
	min-width: 0;
	margin: 0;
	font-size: 1.125rem;
	font-weight: 600;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

.exr-item__name a {
	color: inherit;
	text-decoration: none;
}

.exr-item__name a:hover {
	color: var(--exr-blue);
}

.exr-rating {
	grid-area: rating;
	display: inline-flex;
	align-items: baseline;
	gap: 4px;
	justify-self: start;
	padding: 6px 12px;
	border-radius: 999px;
	background: var(--exr-subtle);
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.exr-rating__star {
	align-self: center;
	width: 1em;
	height: 1em;
	color: #f59e0b;
}

.exr-rating__value {
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1;
}

.exr-rating__max,
.exr-rating__none {
	color: var(--exr-muted);
	font-size: 0.8125rem;
	font-weight: 500;
}

.exr-rating--high {
	background: #dcfce7;
}

.exr-rating--high .exr-rating__value {
	color: #166534;
}

.exr-rating--mid {
	background: #fef3c7;
}

.exr-rating--mid .exr-rating__value {
	color: #92400e;
}

.exr-rating--low {
	background: #fee2e2;
}

.exr-rating--low .exr-rating__value {
	color: #991b1b;
}

.exr-rating--high .exr-rating__max,
.exr-rating--mid .exr-rating__max,
.exr-rating--low .exr-rating__max {
	color: #475569;
}

.exr-item__actions {
	grid-area: actions;
	display: flex;
	gap: 8px;
}

/* Кнопки. */
.exr-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 10px 18px;
	border: 0;
	border-radius: 10px;
	color: #fff !important;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	text-decoration: none !important;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.15s ease;
	-webkit-tap-highlight-color: transparent;
}

.exr-btn:active {
	transform: translateY(1px);
}

.exr-btn:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--exr-blue) 45%, transparent);
	outline-offset: 2px;
}

.exr-btn--review {
	background: var(--exr-blue);
}

.exr-btn--review:hover {
	background: var(--exr-blue-hover);
}

.exr-btn--site {
	background: var(--exr-green);
}

.exr-btn--site:hover {
	background: var(--exr-green-hover);
}

.exr-btn--site::after {
	content: "";
	width: 0.8em;
	height: 0.8em;
	margin-left: 6px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M8 7h9v9'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M8 7h9v9'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Средняя ширина (планшет, узкая колонка): кнопки уходят на отдельную строку. */
@container (max-width: 760px) {
	.exr-item {
		grid-template-areas:
			"rank logo name rating"
			"actions actions actions actions";
		grid-template-columns: 2rem var(--exr-logo) minmax(0, 1fr) auto;
		gap: 14px 16px;
	}

	.exr-item__actions > .exr-btn {
		flex: 1 1 0;
	}
}

/* Телефон: логотип слева, название и рейтинг друг под другом, кнопки на всю ширину. */
@container (max-width: 480px) {
	.exr-item {
		--exr-logo: 52px;

		grid-template-areas:
			"logo name"
			"logo rating"
			"actions actions";
		grid-template-columns: var(--exr-logo) minmax(0, 1fr);
		gap: 6px 14px;
		padding: 14px;
	}

	.exr-item__rank {
		z-index: 1;
		align-self: start;
		justify-self: start;
		width: 1.5rem;
		height: 1.5rem;
		margin: -8px 0 0 -8px;
		font-size: 0.75rem;
		box-shadow: 0 0 0 2px var(--exr-surface);
		grid-area: logo;
	}

	.exr-logo {
		align-self: center;
	}

	.exr-item__name {
		align-self: end;
		font-size: 1.0625rem;
	}

	.exr-rating {
		align-self: start;
		padding: 4px 10px;
	}

	.exr-rating__value {
		font-size: 1.125rem;
	}

	/* Кнопки в ряд, если помещаются; иначе каждая на свою строку во всю ширину. */
	.exr-item__actions {
		flex-wrap: wrap;
		margin-top: 8px;
	}

	.exr-item__actions > .exr-btn {
		flex: 1 1 auto;
		min-height: 48px;
		padding-inline: 14px;
	}
}

/*
 * Страница обзора биржи: разделы .exv (каждый — отдельный контейнер для container queries).
 */
.exv {
	--exv-good-bg: #dcfce7;
	--exv-good-fg: #166534;
	--exv-mid-bg: #fef3c7;
	--exv-mid-fg: #92400e;
	--exv-bad-bg: #fee2e2;
	--exv-bad-fg: #991b1b;
	--exv-neutral-bg: #dbeafe;
	--exv-neutral-fg: #1d4ed8;
}

.wp-block-my-site-child-exchange-section {
	margin-block-start: clamp(1.5rem, 1rem + 2vw, 2.5rem);
}

.exv--header {
	margin-block-start: 0;
}

.exv--indicators + .wp-block-post-content {
	margin-block-start: clamp(2rem, 1.5rem + 2vw, 3rem);
}

.exv-icon {
	display: block;
	width: 20px;
	height: 20px;
}

.exv-card {
	padding: 20px 24px;
	background: var(--exr-surface);
	border: 1px solid var(--exr-border);
	border-radius: var(--exr-radius);
}

.exv-card__title {
	margin: 0 0 14px;
	font-size: 1.125rem;
	font-weight: 700;
	line-height: 1.3;
}

.exv-section-title {
	margin: 0 0 16px;
	font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -0.01em;
}

/* Шапка. */
.exv-header {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 16px 24px;
	align-items: center;
	padding-bottom: 20px;
	border-bottom: 1px solid var(--exr-border);
}

.exv-header__main {
	display: flex;
	gap: 16px;
	align-items: center;
	min-width: 0;
}

.exv-header__logo {
	--exr-logo: 72px;

	border-radius: 16px;
}

.exv-header__text {
	min-width: 0;
}

.exv-header__title {
	margin: 0;
	font-size: clamp(1.75rem, 1.3rem + 2vw, 2.5rem);
	font-weight: 700;
	line-height: 1.15;
	letter-spacing: -0.02em;
	overflow-wrap: anywhere;
}

.exv-score {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 8px;
	align-items: center;
	margin-top: 8px;
}

.exv-stars {
	--size: 1.125rem;

	display: inline-block;
	width: calc(var(--size) * 5);
	height: var(--size);
	background: linear-gradient(90deg, #f59e0b var(--exv-fill), color-mix(in srgb, var(--exr-text) 18%, transparent) var(--exv-fill));
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2.5 2.9 6 6.6.9-4.8 4.6 1.2 6.5L12 17.4l-5.9 3.1 1.2-6.5L2.5 9.4l6.6-.9z'/%3E%3C/svg%3E") left center / var(--size) var(--size) repeat-x;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2.5 2.9 6 6.6.9-4.8 4.6 1.2 6.5L12 17.4l-5.9 3.1 1.2-6.5L2.5 9.4l6.6-.9z'/%3E%3C/svg%3E") left center / var(--size) var(--size) repeat-x;
}

.exv-score__value {
	font-size: 1.125rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.exv-score__max,
.exv-score__label {
	color: var(--exr-muted);
	font-size: 0.875rem;
}

.exv-score__label::before {
	content: "·";
	margin-right: 8px;
}

.exv-header__cta {
	min-width: 200px;
}

.exv-byline {
	display: flex;
	flex-wrap: wrap;
	grid-column: 1 / -1;
	gap: 4px 16px;
	margin: 0;
	color: var(--exr-muted);
	font-size: 0.875rem;
	line-height: 1.4;
}

.exv-byline__author {
	color: var(--exr-text);
	font-weight: 600;
}

/* Быстрые факты. */
.exv-facts__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr));
	gap: 8px;
	margin: 0;
}

.exv-facts__item {
	min-width: 0;
	padding: 12px 14px;
	background: var(--exr-subtle);
	border-radius: 12px;
}

.exv-facts__item--wide {
	grid-column: 1 / -1;
}

.exv-facts__item dt {
	margin: 0 0 2px;
	color: var(--exr-muted);
	font-size: 0.8125rem;
	line-height: 1.3;
}

.exv-facts__item dd {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.4;
	overflow-wrap: anywhere;
}

/* Визуальные индикаторы. */
.exv-indicators__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.exv-badge {
	--tone-bg: var(--exv-neutral-bg);
	--tone-fg: var(--exv-neutral-fg);

	display: flex;
	flex-wrap: wrap;
	gap: 8px 10px;
	align-items: center;
	align-content: center;
	min-width: 0;
	margin: 0;
	padding: 10px 12px;
	background: var(--exr-surface);
	border: 1px solid var(--exr-border);
	border-radius: 12px;
}

.exv-badge--good,
.exv-badge--high {
	--tone-bg: var(--exv-good-bg);
	--tone-fg: var(--exv-good-fg);
}

.exv-badge--mid {
	--tone-bg: var(--exv-mid-bg);
	--tone-fg: var(--exv-mid-fg);
}

.exv-badge--bad,
.exv-badge--low {
	--tone-bg: var(--exv-bad-bg);
	--tone-fg: var(--exv-bad-fg);
}

.exv-badge__icon {
	display: grid;
	flex: none;
	place-items: center;
	width: 36px;
	height: 36px;
	background: var(--tone-bg);
	border-radius: 10px;
	color: var(--tone-fg);
}

.exv-badge__text {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
}

.exv-badge__value {
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.25;
	overflow-wrap: anywhere;
}

.exv-badge__max {
	color: var(--exr-muted);
	font-size: 0.75rem;
	font-weight: 500;
}

.exv-badge__label {
	color: var(--exr-muted);
	font-size: 0.75rem;
	line-height: 1.3;
}

.exv-meter {
	display: flex;
	flex-basis: 100%;
	gap: 3px;
}

.exv-meter__seg {
	flex: 1;
	height: 4px;
	background: var(--exr-border);
	border-radius: 2px;
}

.exv-meter__seg.is-on {
	background: var(--tone-fg);
}

.exv-footnote {
	margin: 10px 0 0;
	color: var(--exr-muted);
	font-size: 0.75rem;
	line-height: 1.45;
}

/* Плюсы и минусы. */
.exv-proscons__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 16px;
}

.exv-proscons__col--pros {
	border-top: 3px solid var(--exv-good-fg);
}

.exv-proscons__col--cons {
	border-top: 3px solid var(--exv-bad-fg);
}

.exv-proscons__list {
	display: grid;
	gap: 10px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.exv-proscons__list li {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	margin: 0;
	font-size: 1rem;
	line-height: 1.45;
}

.exv-proscons__list .exv-icon {
	flex: none;
	width: 22px;
	height: 22px;
	margin-top: 1px;
	padding: 4px;
	border-radius: 50%;
	stroke-width: 3;
}

.exv-proscons__col--pros .exv-icon {
	background: var(--exv-good-bg);
	color: var(--exv-good-fg);
}

.exv-proscons__col--cons .exv-icon {
	background: var(--exv-bad-bg);
	color: var(--exv-bad-fg);
}

/* FAQ. */
.exv-faq__list {
	display: grid;
	gap: 8px;
}

.exv-faq__item {
	background: var(--exr-surface);
	border: 1px solid var(--exr-border);
	border-radius: 12px;
	overflow: hidden;
}

.exv-faq__item summary {
	display: flex;
	gap: 16px;
	align-items: center;
	justify-content: space-between;
	min-height: 56px;
	padding: 14px 20px;
	font-size: 1.0625rem;
	font-weight: 600;
	line-height: 1.4;
	list-style: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.exv-faq__item summary::-webkit-details-marker {
	display: none;
}

.exv-faq__item summary:hover {
	background: var(--exr-subtle);
}

.exv-faq__item summary:focus:not(:focus-visible) {
	outline: none;
}

.exv-faq__item summary:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--exr-blue) 45%, transparent);
	outline-offset: -3px;
}

.exv-faq__item summary .exv-icon {
	flex: none;
	color: var(--exr-muted);
	transition: transform 0.2s ease;
}

.exv-faq__item[open] summary .exv-icon {
	transform: rotate(180deg);
}

.exv-faq__answer {
	padding: 0 20px 16px;
	color: color-mix(in srgb, var(--exr-text) 85%, transparent);
	font-size: 1rem;
	line-height: 1.6;
}

.exv-faq__answer p {
	margin: 0 0 0.75em;
}

.exv-faq__answer p:last-child {
	margin-bottom: 0;
}

/* Автор. */
.exv-author {
	display: flex;
	gap: 14px;
	align-items: center;
	padding: 16px 20px;
}

.exv-author__avatar {
	display: grid;
	flex: none;
	place-items: center;
	width: 48px;
	height: 48px;
	background: linear-gradient(135deg, #2563eb, #7c3aed);
	border-radius: 50%;
	color: #fff;
	font-size: 1.25rem;
	font-weight: 700;
}

.exv-author__label {
	margin: 0;
	color: var(--exr-muted);
	font-size: 0.8125rem;
}

.exv-author__name {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
}

/* Узкий раздел (телефон). */
@container (max-width: 560px) {
	.exv-header {
		grid-template-columns: minmax(0, 1fr);
	}

	.exv-header__logo {
		--exr-logo: 56px;
	}

	.exv-header__cta {
		width: 100%;
		min-width: 0;
		min-height: 48px;
		font-size: 1rem;
	}

	.exv-proscons__grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

@container (max-width: 480px) {
	.exv-card {
		padding: 16px;
	}

	.exv-faq__item summary {
		padding: 14px 16px;
	}

	.exv-faq__answer {
		padding: 0 16px 14px;
	}

	/* Две плашки в ряд: иконка над текстом, чтобы подписи не переносились по слогам. */
	.exv-indicators__list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.exv-badge {
		flex-direction: column;
		flex-wrap: nowrap;
		align-items: flex-start;
		gap: 8px;
		padding: 12px;
	}

	.exv-badge__icon {
		width: 32px;
		height: 32px;
	}

	.exv-meter {
		flex-basis: auto;
		width: 100%;
	}

	.exv-score__label {
		flex-basis: 100%;
	}

	.exv-score__label::before {
		content: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.exr-item,
	.exr-btn,
	.exv-faq__item summary .exv-icon {
		transition: none;
	}
}
