/**
 * Стили UI-блока: Карточка
 *
 * @package medexpress-by-fin-code
 */

.me-card {
	position: relative;
	background: var(--card-background-color);
	padding: 24px;
	display: flex;
	flex-direction: column;
	gap: var(--me-card-gap, 40px);
	justify-content: space-between;
	transition: background-color 0.2s ease;
}

.me-card-link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.me-card__cover-link {
	position: absolute;
	inset: 0;
	z-index: 1;
	color: inherit;
	text-decoration: none;
}

.me-card--clickable {
	cursor: pointer;
}

.me-card-link:hover,
.me-card__cover-link:hover {
	text-decoration: none;
}

.me-card__cover-link:focus-visible {
	outline: 2px solid var(--primary-color);
	outline-offset: 2px;
}

.me-card__top {
	display: flex;
	flex-direction: column;
	gap: 15px;
}

.me-card__head {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	justify-content: space-between;
}

.me-card__title {
	flex: 1 1 auto;
	margin: 0;
	min-width: 0;
	transition: color 0.2s ease;
}

.me-card__corner-tags {
	display: flex;
	flex: 0 0 auto;
	gap: 6px;
}

.me-card__corner-tag {
	align-items: center;
	background-color: var(--primary-color);
	color: #fff;
	display: inline-flex;
	font-size: 16px;
	height: 32px;
	justify-content: center;
	line-height: 1;
	min-width: 32px;
	padding: 0 8px;
	transition: background-color 0.2s ease, color 0.2s ease;
	white-space: nowrap;
}

.me-card__caption {
	margin: 0;
	max-width: none;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.me-card__subtitle {
	color: rgba(255, 255, 255, 0.6) !important;
	margin: 0;
	opacity: 0;
	pointer-events: none;
}

.me-card--fading .me-card__bottom {
	opacity: 0;
	pointer-events: none;
}

.me-card__subtitle-doubler {
	opacity: 1;
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 24px;
	opacity: 1;
	pointer-events: none;
}

.me-card__bottom,
.me-card__subtitle,
.me-card__subtitle-doubler {
	transition: opacity 0.2s ease;
}

.me-card__bottom svg path {
	transition: fill 0.2s ease;
}

/* всегда видимое описание */

.me-card__text {
	margin: 0;
	font-size: 16px;
	line-height: 1.3;
	color: var(--font-color-muted);
	transition: color 0.2s ease, opacity 0.2s ease;
}

/* text_on_hover: описание скрыто, проявляется только при ховере (на мобилке — всегда видно) */

.me-card--text-hover .me-card__text {
	opacity: 0;
	pointer-events: none;
}

/* text_clamp_bottom: один text — 3 строки внизу по умолчанию, полный текст под заголовком на ховере */

.me-card--text-clamp-bottom .me-card__bottom {
	position: relative;
	z-index: 2;
}

.me-card--text-clamp-bottom .me-card__text-doubler {
	position: absolute;
	bottom: 24px;
	left: 24px;
	right: 24px;
	z-index: 0;
	margin: 0;
	max-width: none;
	overflow: hidden;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	line-height: 1.3;
	max-height: calc(1.3em * 3);
	transition: opacity 0.2s ease, visibility 0.2s ease;
	pointer-events: none;
}

@media (min-width: 769px) {
	.me-card--text-clamp-bottom .me-card__top .me-card__text {
		opacity: 0;
		visibility: hidden;
		max-width: none;
		margin: 0;
	}

	/* caption и text под заголовком — одна ячейка сетки, высота = max(оба) */
	.me-card--text-clamp-bottom:has(.me-card__caption) .me-card__top {
		display: grid;
		grid-template-columns: 1fr;
		gap: 15px;
	}

	.me-card--text-clamp-bottom:has(.me-card__caption) .me-card__title {
		grid-row: 1;
	}

	.me-card--text-clamp-bottom:has(.me-card__caption) .me-card__caption,
	.me-card--text-clamp-bottom:has(.me-card__caption) .me-card__top .me-card__text {
		grid-row: 2;
		grid-column: 1;
	}

	.me-card--text-clamp-bottom:has(.me-card__caption) .me-card__subtitle {
		grid-row: 3;
	}
}

@media (max-width: 768px) {
	.me-card--text-clamp-bottom .me-card__top .me-card__text {
		max-width: none;
	}
}

/* декоративная иконка в правом нижнем углу */

.me-card--corner-icon {
	min-height: 300px;
}

.me-card__icon {
	position: absolute;
	right: 24px;
	bottom: 24px;
	width: 80px;
	height: 80px;
	pointer-events: none;
}

.me-card__icon svg {
	width: 100%;
	height: 100%;
}

/* десктоп/мобилка: при двух svg (icon + icon_mobile) показываем первую, мобильную прячем */

.me-card__icon > svg:nth-child(2),
.me-card__icons > svg:nth-child(2) {
	display: none;
}

.me-card__icon svg path,
.me-card__icon svg circle,
.me-card__icon svg rect,
.me-card__icons svg path,
.me-card__icons svg circle,
.me-card__icons svg rect {
	transition: stroke 0.2s ease, fill 0.2s ease;
}

/* CTA — ширина по содержимому; запас справа под иконку */

.me-card--corner-icon .me-card__bottom {
	padding-right: 80px;
}

.me-card--static {
	padding: 40px;
}

.me-card--static>.me-columns {
	align-items: center;
}

/* hover */

@media (min-width: 769px) {
	.me-card:not(.me-card--static):hover {
		background-color: var(--primary-color);
	}

	.me-card--fading:hover .me-card__bottom {
		opacity: 1;
		pointer-events: auto;
		z-index: 1;
	}

	.me-card:not(.me-card--static):hover,
	.me-card:not(.me-card--static):hover .me-card__title {
		color: #fff;
	}

	.me-card:not(.me-card--static):hover .me-card__bottom svg path {
		fill: #fff;
	}

	.me-card:not(.me-card--static):hover .me-card__text {
		color: #fff;
	}

	.me-card:not(.me-card--static):hover .me-card__corner-tag {
		background-color: #fff;
		color: var(--primary-color);
	}

	/* синяя кнопка → белая на ховере карточки */
	.me-card:not(.me-card--static):hover .me-card__bottom .me-btn--primary {
		background-color: #fff;
		border-color: #fff;
		color: var(--primary-color);
	}

	/* декоративная иконка карточки (corner + with_icon) на ховере → все линии #4F79CD */
	.me-card:not(.me-card--static):hover .me-card__icon svg path,
	.me-card:not(.me-card--static):hover .me-card__icon svg circle,
	.me-card:not(.me-card--static):hover .me-card__icon svg rect,
	.me-card:not(.me-card--static):hover .me-card__icons svg path,
	.me-card:not(.me-card--static):hover .me-card__icons svg circle,
	.me-card:not(.me-card--static):hover .me-card__icons svg rect {
		fill: #4F79CD;
		stroke: #4F79CD;
	}

	/* text_on_hover: на ховере описание проявляется белым с прозрачностью 0.6 */
	.me-card--text-hover:not(.me-card--static):hover .me-card__text {
		opacity: 1;
		color: rgba(255, 255, 255, 0.6);
	}

	.me-card--fading:hover .me-card__subtitle {
		opacity: 1;
	}

	.me-card--fading:hover .me-card__subtitle-doubler {
		opacity: 0;
	}

	.me-card--text-clamp-bottom:hover .me-card__top .me-card__text {
		opacity: 1;
		visibility: visible;
		color: rgba(255, 255, 255, 0.6);
	}

	.me-card--text-clamp-bottom:hover .me-card__text-doubler {
		opacity: 0;
		visibility: hidden;
	}

	.me-card:not(.me-card--static):hover .me-card__caption {
		opacity: 0;
		visibility: hidden;
	}

	/* bottom без обёртки .me-card__bottom-buttons — белая ссылка и стрелка на синем фоне */
	.me-card--text-clamp-bottom:hover .me-card__bottom .me-btn--text {
		color: #fff;
	}

	.me-card--text-clamp-bottom:hover .me-card__bottom .me-btn--text img {
		filter: brightness(0) invert(1);
	}
}

/* cards */

.me-cards {
	display: flex;
	gap: 24px;
	width: 100%;
}

.me-cards .me-card,
.me-cards > .me-card-link {
	flex: 1 1 0;
	min-width: 0;
}

.me-cards > .me-card-link {
	display: flex;
	flex-direction: column;
}

.me-cards > .me-card-link > .me-card {
	flex: 1 1 auto;
	height: 100%;
}

/* card with icon */

.me-card--with-icon .me-card__bottom {
	display: flex;
	align-items: flex-end;
	gap: 10px;
	justify-content: space-between;
}

.me-card--with-icon .icon-top-right-arrow {
	margin-left: 9px;
	margin-bottom: 9px;
}

/* compact: заголовок слева, стрелка и иконка в одной строке справа */

.me-card--compact {
	flex-direction: row;
	align-items: center;
	min-height: auto;
	--me-card-gap: 24px !important;
}

.me-card--compact .me-card__top {
	flex: 0 1 auto;
	min-width: 0;
}

.me-card--compact .me-card__bottom {
	flex: 1 1 auto;
	align-items: center;

}

.me-card--compact .icon-top-right-arrow {
	flex-shrink: 0;
	width: 15px;
	height: 15px;
	margin: 0;
}

.me-card--compact .me-card__icons svg {
	width: 80px;
	height: 80px;
}

/* misc */

.me-card__bottom-buttons {
	display: flex;
	gap: 24px;
}

.me-card:has(.me-card__cover-link) .me-card__bottom {
	position: relative;
	z-index: 2;
	pointer-events: none;
}

.me-card:has(.me-card__cover-link) .me-card__bottom a,
.me-card:has(.me-card__cover-link) .me-card__bottom button,
.me-card:has(.me-card__cover-link) .me-card__bottom .me-btn,
.me-card:has(.me-card__cover-link) .me-card__bottom [data-me-card-skip],
.me-card:has(.me-card__cover-link) .me-card__bottom [data-me-feedback-trigger],
.me-card:has(.me-card__cover-link) .me-card__bottom [data-me-offcanvas-trigger],
.me-card:has(.me-card__cover-link) .me-card__bottom [data-me-offcanvas-switch] {
	position: relative;
	z-index: 3;
	pointer-events: auto;
}

@media (min-width: 769px) {
	.me-card:not(.me-card--static):hover .me-card__bottom-buttons .me-btn--text {
		color: #fff;
	}

	.me-card:not(.me-card--static):hover .me-card__bottom-buttons .me-btn--text img {
		filter: brightness(0) invert(1);
	}
}


/* mobile */

@media (max-width: 768px) {
	.me-cards:not(.me-cards--slider) {
		flex-flow: column nowrap;
		gap: 12px;
	}

	.me-card {
		padding: 20px;
		--me-card-gap: 30px !important;
	}

	.me-card--with-icon {
		--me-card-gap: 18px !important;
		padding: 16px;
	}

	.me-card--with-icon .icon-top-right-arrow+svg {
		width: 70px;
		height: 70px;
	}

	.me-card--compact {
		--me-card-gap: 16px !important;
		padding: 16px;
	}

	.me-card--compact .me-card__icons svg {
		width: 60px;
		height: 60px;
	}

	.me-card--compact .icon-top-right-arrow {
		width: 24px;
		height: 24px;
	}

	.me-card__title {
		font-size: 20px;
	}

	.me-card__subtitle {
		opacity: 1;
		color: var(--font-color-muted) !important;
	}

	.me-card__bottom-buttons {
		flex-flow: column nowrap;
	}

	.me-card--fading .me-card__bottom {
		opacity: 1;
		pointer-events: auto;
	}

	/* text_on_hover: на мобилке нет ховера — описание видно всегда, в приглушённом цвете */
	.me-card--text-hover .me-card__text {
		opacity: 1;
		pointer-events: auto;
	}

	.me-card__bottom-buttons .me-btn--text {
		color: var(--primary-color)
	}

	.me-card__bottom-buttons .me-btn--text img {
		filter: unset;
	}

	.me-card__bottom-buttons .me-btn--white {
		color: #fff;
		background-color: var(--primary-color);
	}

	.me-card__subtitle-doubler {
		display: none;
	}

	.me-card--text-clamp-bottom .me-card__text-doubler {
		display: none;
	}

	.me-card--text-clamp-bottom .me-card__top .me-card__text {
		display: block;
		max-width: none;
	}

	.me-card--text-clamp-bottom .me-card__bottom .me-btn--text {
		color: var(--primary-color);
	}

	.me-card--static {
		padding: 20px;
	}

	.me-card--static>.me-columns {
		align-items: flex-start;
		gap: 40px;
	}

	.me-card--static>.me-columns p {
		font-size: 16px;
	}

	/* десктоп/мобилка: ≤768px показываем мобильную иконку (icon_mobile), десктопную прячем */
	.me-card__icon > svg:first-child:not(:only-child),
	.me-card__icons > svg:first-child:not(:only-child) {
		display: none;
	}

	.me-card__icon > svg:nth-child(2),
	.me-card__icons > svg:nth-child(2) {
		display: block;
	}

	/* corner-icon: на мобилке иконка сверху слева, кнопка на всю ширину внизу */
	.me-card--corner-icon {
		min-height: 276px;
		padding: 20px;
		--me-card-gap: 0 !important;
		justify-content: flex-start;
	}

	.me-card--corner-icon:has(.me-card__text) {
		min-height: 294px;
	}

	.me-card--corner-icon .me-card__icon {
		position: static;
		order: -1;
		width: 60px;
		height: 60px;
		margin: 0 0 20px;
	}

	.me-card--corner-icon .me-card__top {
		gap: 12px;
	}

	.me-card--corner-icon .me-card__text {
		max-width: none;
		font-size: 16px;
		line-height: 1.1;
	}

	.me-card--corner-icon .me-card__bottom {
		padding-right: 0;
		margin-top: auto;
		width: 100%;
	}

	/* горизонтальный слайдер: peek следующей карточки + scroll-snap по одной */
	.me-cards--slider {
		--me-cards-slider-peek: 16px;

		flex-flow: row nowrap;
		gap: 12px;
		width: 100vw;
		max-width: 100vw;
		margin-inline: calc(50% - 50vw);
		padding-inline: var(--content-side-padding);
		scroll-padding-inline: var(--content-side-padding);
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		scroll-behavior: smooth;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		-ms-overflow-style: none;
	}

	.me-cards--slider::-webkit-scrollbar {
		display: none;
	}

	.me-cards--slider .me-card,
	.me-cards--slider > .me-card-link {
		flex: 0 0 calc(100vw - var(--content-side-padding) * 2 - var(--me-cards-slider-peek));
		width: calc(100vw - var(--content-side-padding) * 2 - var(--me-cards-slider-peek));
		min-width: 0;
		scroll-snap-align: start;
		scroll-snap-stop: always;
	}

	.me-cards--slider > .me-card-link {
		display: flex;
		flex-direction: column;
	}

	.me-cards--slider > .me-card-link > .me-card {
		flex: 1 1 auto;
		height: 100%;
	}

	.me-cards--slider::after {
		content: '';
		flex: 0 0 var(--content-side-padding);
		scroll-snap-align: none;
	}
}