/* © 2025 Mark Kats. Все права защищены. Копирование и переработка запрещены. */

:where(.toast-container, .toast) {
	--toast-radius: 14px;
	--toast-gap: 12px;
	--toast-pad-y: 12px;
	--toast-pad-x: 14px;
	--toast-shadow: 0 10px 28px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.22);
	--toast-bg: rgba(0, 0, 0, 0.5);
	--toast-bg-overlay: linear-gradient(0deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.03));
	--toast-fg: #fff;
	--toast-fg-soft: rgba(255, 255, 255, 0.92);
	--toast-fg-muted: rgba(255, 255, 255, 0.72);
	--toast-fg-faint: rgba(255, 255, 255, 0.58);
	--toast-border: rgba(255, 255, 255, 0.2);
	--toast-action-bg: rgba(255, 255, 255, 0.055);
	--toast-action-bg-hover: rgba(255, 255, 255, 0.1);
	--toast-action-border: rgba(255, 255, 255, 0.18);
	--toast-action-border-hover: rgba(255, 255, 255, 0.24);
	--toast-progress-bg: rgba(255, 255, 255, 0.085);
	--toast-progress-fill: linear-gradient(90deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.12));
	--toast-status-badge-bg: color-mix(in oklab, var(--accent), transparent 82%);
	--toast-status-badge-border: color-mix(in oklab, var(--accent), white 18%);
	--toast-status-badge-fg: #fff;
	--toast-status-dot: #35d07f;
	--toast-status-dot-ring: rgba(53, 208, 127, 0.16);
	--toast-indicator-bg: color-mix(in oklab, var(--accent), #000 18%);
	--toast-info-tint: #2c65d2;
	--toast-success-tint: #009555;
	--toast-warning-tint: #ffa500;
	--toast-error-tint: #d81e00;
	--indicator-w: 9px;
}

html[data-ui-theme='light'] :where(.toast-container, .toast) {
	--toast-shadow: 0 0 0 1px rgba(15, 23, 42, 0.07), 0 8px 22px rgba(15, 23, 42, 0.11);
	--toast-bg: #f8fafc;
	--toast-bg-overlay: linear-gradient(0deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0));
	--toast-fg: rgb(29, 31, 37);
	--toast-fg-soft: rgba(29, 31, 37, 0.88);
	--toast-fg-muted: rgba(83, 89, 101, 0.72);
	--toast-fg-faint: rgba(83, 89, 101, 0.58);
	--toast-border: rgba(31, 41, 55, 0.16);
	--toast-action-bg: #eef2f6;
	--toast-action-bg-hover: #e7edf3;
	--toast-action-border: rgba(0, 0, 0, 0.1);
	--toast-action-border-hover: rgba(0, 0, 0, 0.16);
	--toast-progress-bg: rgba(0, 0, 0, 0.08);
	--toast-progress-fill: linear-gradient(90deg, rgba(29, 31, 37, 0.34), rgba(29, 31, 37, 0.1));
	--toast-status-badge-bg: color-mix(in oklab, var(--accent), transparent 88%);
	--toast-status-badge-border: color-mix(in oklab, var(--accent), transparent 56%);
	--toast-status-badge-fg: rgb(29, 31, 37);
	--toast-status-dot: #15803d;
	--toast-status-dot-ring: rgba(21, 128, 61, 0.16);
	--toast-indicator-bg: color-mix(in oklab, var(--accent), #fff 10%);
	--toast-info-tint: rgb(83, 89, 101);
	--toast-success-tint: #047857;
	--toast-warning-tint: #9a6700;
	--toast-error-tint: #b42318;
}

.toast-container {
	position: fixed;
	left: calc(env(safe-area-inset-left) + 16px);
	bottom: calc(env(safe-area-inset-bottom) + 16px);
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--toast-gap);
	max-width: min(92vw, 520px);
	z-index: 100001;
	pointer-events: none;
}

.toast {
	pointer-events: all;
	position: relative;
	display: inline-grid;
	align-self: flex-start;
	width: fit-content;
	max-width: min(92vw, 520px);
	grid-template-columns: auto 1fr;
	align-items: center;
	gap: 6px;
	padding: 8px 8px 8px 15px;
	border-radius: var(--toast-radius);
	background: var(--toast-bg-overlay), var(--toast-bg);
	color: var(--toast-fg);
	box-shadow: var(--toast-shadow);
	backdrop-filter: blur(8px) saturate(115%);
	transform: translateY(10px);
	opacity: 0;
	transition:
		transform 0.22s ease,
		opacity 0.22s ease;
	contain: content;
	--accent: var(--toast-info-tint);
	--icon-color: var(--accent);
}

.toast.enter {
	transform: translateY(10px);
	opacity: 0;
}
.toast:not(.enter) {
	transform: translateY(0);
	opacity: 1;
}
.toast.leaving {
	opacity: 0;
	transform: translateY(10px);
}
.toast.dragging {
	transition: none;
}

.toast::before {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: var(--toast-radius);
	pointer-events: none;
	box-shadow: inset 0 0 0 1px var(--toast-border);
}

.toast::after {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: var(--indicator-w);
	border-radius: var(--toast-radius) 0 0 var(--toast-radius);
	background: var(--toast-indicator-bg);
}

.toast.info {
	--accent: var(--toast-info-tint);
}
.toast.success {
	--accent: var(--toast-success-tint);
}
.toast.warning {
	--accent: var(--toast-warning-tint);
}
.toast.error {
	--accent: var(--toast-error-tint);
}

.toast-icon {
	width: 20px;
	height: 20px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	box-shadow: none;
	color: var(--icon-color);
	cursor: pointer;
}

.toast-icon svg {
	display: block;
	width: 18px;
	height: 18px;
	overflow: visible;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	background: none;
}

.toast-icon .toast-copy-icon svg {
	width: 15px;
	height: 15px;
	stroke-width: 1.35;
}

.toast-content {
	display: grid;
	grid-template-columns: 1fr auto;
	grid-template-rows: auto auto;
	align-items: center;
	column-gap: 8px;
	row-gap: 6px;
	min-width: 220px;
	max-width: min(86vw, 460px);
}

.toast-message {
	grid-column: 1/2;
	font-family:
		'IBM Plex Sans Condensed',
		system-ui,
		-apple-system,
		Segoe UI,
		Roboto,
		sans-serif;
	font-size: 0.95rem;
	line-height: 1.25rem;
	white-space: pre-line;
	word-break: break-word;
	color: var(--toast-fg-soft);
}

.toast-message .toast-status-block {
	display: grid;
	gap: 5px;
}

.toast-message .toast-status-head {
	display: flex;
	align-items: center;
}

.toast-message .toast-status-badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	border-radius: 999px;
	background: var(--toast-status-badge-bg);
	border: 1px solid var(--toast-status-badge-border);
	color: var(--toast-status-badge-fg);
	font-size: 0.74rem;
	line-height: 1;
	letter-spacing: 0.01em;
}

.toast-message .toast-status-users {
	display: grid;
	gap: 2px;
}

.toast-message .toast-status-user {
	display: flex;
	align-items: center;
	gap: 6px;
}

.toast-message .toast-status-dot {
	width: 6px;
	height: 6px;
	flex: 0 0 6px;
	border-radius: 999px;
	background: var(--toast-status-dot);
	box-shadow: 0 0 0 2px var(--toast-status-dot-ring);
}

.toast-message .toast-status-name {
	font-size: 0.88rem;
	line-height: 1.15;
}

.toast-message .toast-status-meta {
	color: var(--toast-fg-muted);
	font-size: 0.74rem;
	line-height: 1.1;
}

.toast-message .toast-notification {
	display: grid;
	gap: 3px;
	min-width: min(320px, 72vw);
	max-width: min(72vw, 440px);
	white-space: normal;
}

.toast-message .toast-notification-top {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	flex-wrap: nowrap;
	gap: 10px;
	min-width: 0;
}

.toast-message .toast-notification-title {
	flex: 1 1 auto;
	min-width: 0;
	color: var(--toast-fg);
	font:
		0.86rem/1.25 'Artifakt Element',
		system-ui,
		sans-serif;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.toast-message .toast-notification-time {
	flex: 0 0 auto;
	margin-left: auto;
	color: var(--toast-fg-faint);
	font:
		0.68rem/1.25 'Artifakt Element',
		system-ui,
		sans-serif;
	white-space: nowrap;
	text-align: right;
}

.toast-message .toast-notification-body {
	color: var(--toast-fg-muted);
	font:
		0.76rem/1.35 'Artifakt Element',
		system-ui,
		sans-serif;
	text-align: left;
	overflow-wrap: anywhere;
}

.toast-message .toast-notification-context {
	color: var(--toast-fg-faint);
	font:
		0.72rem/1.25 'Artifakt Element',
		system-ui,
		sans-serif;
	text-align: left;
	overflow-wrap: anywhere;
}

.toast-progress {
	grid-column: 1/3;
	position: relative;
	height: 3px;
	border-radius: 2px;
	background: var(--toast-progress-bg);
	overflow: hidden;
}

.toast-progress::after {
	content: '';
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 100%;
	background: var(--toast-progress-fill);
	animation: toast-progress var(--dur, 4500ms) linear forwards;
}

@keyframes toast-progress {
	from {
		transform: translateX(0);
	}
	to {
		transform: translateX(-100%);
	}
}

.toast.paused .toast-progress::after {
	animation-play-state: paused;
}

.toast-action {
	justify-self: start;
	padding: 6px 10px;
	border-radius: 10px;
	border: 1px solid var(--toast-action-border);
	background: var(--toast-action-bg);
	color: var(--toast-fg);
	font-size: 0.85rem;
	cursor: pointer;
	transition:
		transform 0.15s ease,
		background 0.15s ease,
		border-color 0.15s ease;
}

.toast-action:hover {
	transform: translateY(-1px);
	background: var(--toast-action-bg-hover);
	border-color: var(--toast-action-border-hover);
}

@media (max-width: 767px) {
	.toast-container {
		left: 7px;
		bottom: calc(env(safe-area-inset-bottom) + 7px);
		align-items: stretch;
	}
	.toast {
		display: grid;
		width: auto;
		max-width: none;
	}
	.toast-content {
		max-width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.toast {
		transition: none;
	}
	.toast-progress::after {
		animation: none;
		display: none;
	}
}

#notification {
	display: none;
}
