/**
 * Torjujat: chatbotti.
 */
.screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* Launcher (työpöytä oikea alakulma) */
.tj-bot-launcher {
	position: fixed;
	right: clamp(16px, 2vw, 28px);
	bottom: clamp(16px, 2vw, 28px);
	z-index: 88;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 12px 20px 12px 14px;
	border: 0;
	border-radius: var(--tj-radius-pill);
	background: var(--contrast);
	color: #fff;
	font-family: inherit;
	font-weight: 700;
	font-size: 15px;
	box-shadow: 0 14px 36px rgba(20, 32, 28, 0.3);
	cursor: pointer;
	transition: transform 0.25s var(--tj-ease), box-shadow 0.25s var(--tj-ease);
}
.tj-bot-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(20, 32, 28, 0.36); }
.tj-bot-launcher__icon {
	display: grid; place-items: center;
	width: 32px; height: 32px;
	border-radius: 50%;
	background: var(--accent-3);
	font-size: 16px;
}
.tj-bot-launcher.has-conv .tj-bot-launcher__icon { box-shadow: 0 0 0 3px var(--accent); }
html.tj-bot-open .tj-bot-launcher { opacity: 0; pointer-events: none; }
html.tj-lead-lock .tj-bot-launcher { opacity: 0; pointer-events: none; }

/* Popup launcherin yläpuolelle */
@media (min-width: 901px) {
	.tj-promo { bottom: 96px; }
}

/* Ikkuna */
.tj-bot {
	position: fixed;
	right: clamp(16px, 2vw, 28px);
	bottom: clamp(16px, 2vw, 28px);
	z-index: 195;
	width: min(400px, calc(100vw - 32px));
	height: min(620px, calc(100vh - 48px));
	display: flex;
	flex-direction: column;
	background: var(--base-2);
	border-radius: var(--tj-radius-lg);
	box-shadow: 0 28px 70px rgba(20, 32, 28, 0.32);
	overflow: hidden;
	opacity: 0;
	transform: translateY(16px) scale(0.98);
	transform-origin: bottom right;
	transition: opacity 0.25s var(--tj-ease), transform 0.25s var(--tj-ease);
}
.tj-bot.is-open { opacity: 1; transform: none; }
.tj-bot[hidden] { display: none !important; }
.tj-bot__head {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 14px 14px 16px;
	background: linear-gradient(135deg, var(--accent-3), #4d8e75);
	color: #fff;
}
.tj-bot__avatar {
	display: grid; place-items: center;
	width: 40px; height: 40px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.2);
	font-size: 20px;
}
.tj-bot__who { display: grid; line-height: 1.25; flex: 1; }
.tj-bot__who strong { font-size: 15px; }
.tj-bot__who span { font-size: 12px; opacity: 0.85; }
.tj-bot__close {
	width: 36px; height: 36px;
	border: 0; border-radius: 50%;
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}
.tj-bot__close:hover { background: rgba(255, 255, 255, 0.3); }

.tj-bot__log {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	background: var(--base);
}
.tj-bot__msg {
	max-width: 86%;
	padding: 10px 14px;
	border-radius: 16px;
	font-size: 14.5px;
	line-height: 1.5;
	word-wrap: break-word;
}
.tj-bot__msg--bot { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; box-shadow: var(--tj-shadow-xs); }
.tj-bot__msg--user { align-self: flex-end; background: var(--accent); border-bottom-right-radius: 4px; }
.tj-bot__msg a { color: var(--accent-3); text-decoration: underline; word-break: break-all; }
.tj-bot__msg a[href^="tel:"], .tj-bot__foot a { white-space: nowrap; word-break: normal; }
.tj-bot__typing { display: inline-flex; gap: 4px; padding: 14px; }
.tj-bot__typing span {
	width: 7px; height: 7px;
	border-radius: 50%;
	background: rgba(44, 44, 44, 0.35);
	animation: tj-bot-dot 1.2s infinite ease-in-out;
}
.tj-bot__typing span:nth-child(2) { animation-delay: 0.15s; }
.tj-bot__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes tj-bot-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.tj-bot__actions { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-start; }
.tj-bot__act {
	display: inline-flex;
	align-items: center;
	padding: 8px 14px;
	border-radius: var(--tj-radius-pill);
	border: 1.5px solid var(--accent-3);
	background: #fff;
	color: var(--accent-3);
	font: inherit;
	font-size: 13.5px;
	font-weight: 700;
	cursor: pointer;
	text-decoration: none;
}
.tj-bot__act--primary { background: var(--accent-3); color: #fff; }
.tj-bot__act:hover { filter: brightness(0.95); color: inherit; }
.tj-bot__act--primary:hover { color: #fff; }

.tj-bot__chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; background: var(--base); }
.tj-bot__chips:not(:empty) { padding-bottom: 12px; }
.tj-bot__chip {
	padding: 7px 12px;
	border-radius: var(--tj-radius-pill);
	border: 1.5px solid rgba(44, 44, 44, 0.15);
	background: #fff;
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}
.tj-bot__chip:hover { border-color: var(--accent-3); }

.tj-bot__lead {
	align-self: stretch;
	display: grid;
	gap: 8px;
	padding: 14px;
	background: #fff;
	border-radius: 16px;
	border: 1.5px solid rgba(101, 172, 146, 0.4);
}
.tj-bot__lead-title { margin: 0 0 2px; font-size: 13.5px; line-height: 1.45; }
.tj-bot__lead input {
	width: 100%;
	padding: 10px 12px;
	font: inherit;
	font-size: 16px;
	border: 1.5px solid rgba(44, 44, 44, 0.18);
	border-radius: var(--tj-radius-sm);
}
.tj-bot__lead input:focus { outline: none; border-color: var(--accent-3); }
.tj-bot__lead .tj-bot__act { justify-content: center; padding: 10px; }
.tj-bot__lead-err { margin: 0; font-size: 13px; color: #8a1f1f; }

.tj-bot__input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid rgba(44, 44, 44, 0.08);
	background: #fff;
}
.tj-bot__input textarea {
	flex: 1;
	resize: none;
	max-height: 120px;
	padding: 10px 12px;
	font: inherit;
	font-size: 16px;
	line-height: 1.4;
	border: 1.5px solid rgba(44, 44, 44, 0.15);
	border-radius: 14px;
}
.tj-bot__input textarea:focus { outline: none; border-color: var(--accent-3); }
.tj-bot__input button {
	width: 42px; height: 42px;
	flex: none;
	border: 0;
	border-radius: 50%;
	background: var(--accent-3);
	color: #fff;
	font-size: 16px;
	cursor: pointer;
}
.tj-bot__foot { margin: 0; padding: 0 14px 10px; font-size: 11.5px; opacity: 0.65; background: #fff; }
.tj-bot__foot a { color: inherit; text-decoration: underline; }

/* Mobiili: launcher on palkissa, ikkuna koko ruutu */
.tj-lead-bar__bot { display: none; }
@media (max-width: 900px) {
	.tj-bot-launcher { display: none; }
	.tj-lead-bar { grid-template-columns: auto auto 1fr; }
	.tj-lead-bar__bot {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 48px;
		min-height: 48px;
		border: 0;
		border-radius: var(--tj-radius-pill);
		background: var(--contrast);
		color: #fff;
		font-size: 18px;
	}
	.tj-bot {
		inset: 0;
		width: 100%;
		height: 100%;
		height: 100dvh;
		border-radius: 0;
		transform: translateY(24px);
	}
	html.tj-bot-open { overflow: hidden; }
	html.tj-bot-open .tj-lead-bar { transform: translateY(140%); }
}

@media (prefers-reduced-motion: reduce) {
	.tj-bot, .tj-bot-launcher { transition: none; }
	.tj-bot__typing span { animation: none; }
}
