/**
 * TSV - Thanh liên hệ nổi (Desktop/Tablet), bên trái hoặc phải theo cài đặt Site Contact
 * File: features/contact-rail/assets/css/tsv-contact-rail.css
 *
 * Chỉ hiển thị ở >=769px (Tablet/Desktop nhỏ) và >=1200px (Desktop lớn).
 * Mobile (<=768px) luôn ẩn — Mobile Bottom Bar đảm nhiệm liên hệ ở đó,
 * tránh 2 bộ hiển thị liên hệ cùng lúc trên cùng breakpoint.
 */

.tsv-contact-rail {
	display: none;
}

@media only screen and (min-width: 769px) {
	.tsv-contact-rail {
		display: flex !important;
		flex-direction: column;
		gap: var(--tsv-contact-rail-gap, 14px);

		position: fixed;
		top: var(--tsv-contact-rail-offset-top, 280px);
		z-index: 999;
	}

	.tsv-contact-rail.is-right {
		right: var(--tsv-contact-rail-offset-x, 20px);
		left: auto;
	}

	.tsv-contact-rail.is-left {
		right: auto;
		left: var(--tsv-contact-rail-offset-x, 20px);
	}

	.tsv-contact-rail-item {
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;

		width: 44px;
		height: 44px;

		background-color: #ffffff;
		border-radius: 999px;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);

		color: #111827;
		text-decoration: none;
	}

	.tsv-contact-rail-item--zalo,
	.tsv-contact-rail-item--messenger {
		animation: pulse-blue 2.2s ease-out infinite;
	}

	.tsv-contact-rail-item--phone {
		animation: pulse-green 2s ease-out infinite;
	}

	.tsv-contact-rail-item:focus-visible {
		outline: 2px solid #2271b1;
		outline-offset: 2px;
	}

	.tsv-contact-rail-icon {
		display: block;
		width: 22px;
		height: 22px;
		font-size: 20px;
		line-height: 22px;
		text-align: center;
	}

	/* Cùng SVG với Mobile Bottom Bar (features/mobile-bottom-bar) để icon
	   đồng nhất giữa mọi bề mặt hiển thị liên hệ. Kích thước dưới đây cân
	   visual weight riêng cho rail 769-1199px; >=1200px được override dưới. */
	.tsv-contact-rail-icon--zalo {
		width: 28px;
		height: 24px;
		background-image: url("../../../site-contact/assets/images/tsv-zalo.svg");
		background-repeat: no-repeat;
		background-position: center;
		background-size: contain;
	}

	.tsv-contact-rail-icon--messenger {
		width: 26px;
		height: 26px;
		background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='11' fill='%230078FF'/%3E%3Cpath d='M12 5.7c-4 0-6.9 2.8-6.9 6.5 0 2.1 1 3.9 2.6 5.1v2.5l2.3-1.3c.6.2 1.3.3 2 .3 4 0 6.9-2.8 6.9-6.6S16 5.7 12 5.7Z' fill='%23ffffff'/%3E%3Cpath d='M7.8 13l3-3.3 1.9 2 3-2-3 3.4-1.9-2-3 1.9Z' fill='%230078FF'/%3E%3C/svg%3E");
		background-repeat: no-repeat;
		background-position: center;
		background-size: 26px 26px;
	}

	.tsv-contact-rail-icon--phone {
		display: grid;
		place-items: center;
		width: 30px;
		height: 30px;
		border-radius: 50%;
		background-color: #16a34a;
	}

	.tsv-contact-rail-icon--phone::after {
		content: "";
		display: block;
		width: 22px;
		height: 22px;
		background-color: #ffffff;
		-webkit-mask: url("../../../site-contact/assets/images/tsv-phone.svg") center / contain no-repeat;
		mask: url("../../../site-contact/assets/images/tsv-phone.svg") center / contain no-repeat;
		transform-origin: 50% 50%;
		animation: tsv-contact-phone-ring 1.5s ease-in-out infinite;
	}

	.tsv-contact-rail-tooltip {
		position: absolute;
		right: calc(100% + 10px);
		top: 50%;
		transform: translateY(-50%);

		white-space: nowrap;
		background: #111827;
		color: #ffffff;
		font-size: 12px;
		font-weight: 600;
		padding: 5px 10px;
		border-radius: 6px;

		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		transition: opacity 200ms ease;
	}

	.tsv-contact-rail.is-left .tsv-contact-rail-tooltip {
		right: auto;
		left: calc(100% + 10px);
	}

	.tsv-contact-rail-item:focus-visible .tsv-contact-rail-tooltip {
		opacity: 1;
		visibility: visible;
	}

}

@media (hover: hover) and (pointer: fine) {
	.tsv-contact-rail-item:hover .tsv-contact-rail-tooltip {
		opacity: 1;
		visibility: visible;
	}

}

@keyframes pulse-blue {
	0% {
		box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.45);
	}

	70% {
		box-shadow: 0 0 0 12px rgba(59, 130, 246, 0);
	}

	100% {
		box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
	}
}

@keyframes pulse-green {
	0% {
		box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
	}

	70% {
		box-shadow: 0 0 0 14px rgba(34, 197, 94, 0);
	}

	100% {
		box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
	}
}

@keyframes tsv-contact-phone-ring {
	0% {
		transform: rotate(0deg);
	}

	10% {
		transform: rotate(15deg);
	}

	20% {
		transform: rotate(-10deg);
	}

	30% {
		transform: rotate(15deg);
	}

	40% {
		transform: rotate(-10deg);
	}

	50% {
		transform: rotate(5deg);
	}

	60% {
		transform: rotate(-5deg);
	}

	70%,
	100% {
		transform: rotate(0deg);
	}
}

/* Tablet/Desktop nhỏ: crop viewBox theo painted bounds thay vì chỉ phóng
   wrapper. SVG variant này chỉ tồn tại ở 769-1199px; Desktop lớn tiếp tục
   dùng geometry gốc khai báo trong owner phía trên. */
@media only screen and (min-width: 769px) and (max-width: 1199px) {
	.tsv-contact-rail-icon--zalo {
		width: 28px;
		height: 28px;
	}

	.tsv-contact-rail-icon--messenger {
		width: 32px;
		height: 32px;
		background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='1 1 22 22'%3E%3Ccircle cx='12' cy='12' r='11' fill='%230078FF'/%3E%3Cpath d='M12 5.7c-4 0-6.9 2.8-6.9 6.5 0 2.1 1 3.9 2.6 5.1v2.5l2.3-1.3c.6.2 1.3.3 2 .3 4 0 6.9-2.8 6.9-6.6S16 5.7 12 5.7Z' fill='%23ffffff'/%3E%3Cpath d='M7.8 13l3-3.3 1.9 2 3-2-3 3.4-1.9-2-3 1.9Z' fill='%230078FF'/%3E%3C/svg%3E");
		background-size: 32px 32px;
	}

	.tsv-contact-rail-icon--phone {
		width: 32px;
		height: 32px;
	}

	.tsv-contact-rail-icon--phone::after {
		width: 23px;
		height: 23px;
	}
}

/* Desktop lớn: touch/click area rộng hơn theo yêu cầu 46-52px. */
@media only screen and (min-width: 1200px) {
	.tsv-contact-rail-item {
		width: 50px;
		height: 50px;
	}

	.tsv-contact-rail-icon {
		width: 24px;
		height: 24px;
		font-size: 22px;
		line-height: 24px;
	}

	.tsv-contact-rail-icon--zalo {
		width: 30px;
		height: 30px;
		background-size: contain;
	}

	.tsv-contact-rail-icon--messenger {
		width: 34px;
		height: 34px;
		background-size: 34px 34px;
	}

	.tsv-contact-rail-icon--phone {
		width: 34px;
		height: 34px;
	}

	.tsv-contact-rail-icon--phone::after {
		width: 25px;
		height: 25px;
	}
}

@media only screen and (max-width: 768px) {
	.tsv-contact-rail {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tsv-contact-rail-item {
		transition: none;
		animation: none !important;
	}

	.tsv-contact-rail-icon--phone::after {
		animation: none !important;
	}

	.tsv-contact-rail-tooltip {
		transition: none;
	}

}
