/**
 * 10mile Toast: front-end and admin-preview styles.
 * Vanilla CSS only, no external requests.
 *
 * Class contract (used by toast.js):
 *   .tenmile-toast                     fixed wrapper (z-index 9990)
 *   .tenmile-toast--bottom-left | --bottom-right | --top-left | --top-right
 *   .tenmile-toast--bg-transparent | --bg-white | --bg-color
 *   .tenmile-toast--shadow             soft text-shadow (transparent mode)
 *   .tenmile-toast--clickable          a link is set
 *   .tenmile-toast.is-visible          shown state; .is-leaving = fading out
 *   .tenmile-toast__inner              body (div or a)
 *   .tenmile-toast__image / __content / __headline / __message / __link
 *   .tenmile-toast__close              the close (x) button
 *
 * Custom properties set inline by toast.js on .tenmile-toast:
 *   --tmt-offset   bottom offset in px (bottom positions)
 *   --tmt-bg       background color (color mode)
 *   --tmt-fg       text color (color mode, or the override in any mode)
 */

/* The live-region root takes no space and never blocks the page. */
.tenmile-toast-root {
	display: block;
	height: 0;
	margin: 0;
	padding: 0;
	pointer-events: none;
}

/* ------------------------------------------------------------------
 * Wrapper and positioning
 * ---------------------------------------------------------------- */
.tenmile-toast,
.tenmile-toast *,
.tenmile-toast *::before,
.tenmile-toast *::after {
	box-sizing: border-box;
}

.tenmile-toast {
	position: fixed;
	z-index: 9990;
	width: max-content;
	max-width: 340px;
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.4;
	text-align: left;
	pointer-events: auto;
	opacity: 0;
	transition: opacity 0.4s ease, transform 0.4s ease;
	-webkit-font-smoothing: antialiased;
}

/* Bottom positions: configurable offset clears a fixed player bar. */
.tenmile-toast--bottom-left,
.tenmile-toast--bottom-right {
	bottom: calc(var(--tmt-offset, 24px) + env(safe-area-inset-bottom, 0px));
	transform: translateY(14px);
}

/* Top positions: slide down from above; clear the WP admin bar when present. */
.tenmile-toast--top-left,
.tenmile-toast--top-right {
	top: calc(24px + env(safe-area-inset-top, 0px));
	transform: translateY(-14px);
}

body.admin-bar .tenmile-toast--top-left,
body.admin-bar .tenmile-toast--top-right {
	top: calc(56px + env(safe-area-inset-top, 0px));
}

.tenmile-toast--bottom-left,
.tenmile-toast--top-left {
	left: 16px;
}

.tenmile-toast--bottom-right,
.tenmile-toast--top-right {
	right: 16px;
}

/* Shown / leaving states. */
.tenmile-toast.is-visible {
	opacity: 1;
	transform: none;
}

.tenmile-toast.is-leaving {
	opacity: 0;
	transition-duration: 0.3s;
}

.tenmile-toast--bottom-left.is-leaving,
.tenmile-toast--bottom-right.is-leaving {
	transform: translateY(10px);
}

.tenmile-toast--top-left.is-leaving,
.tenmile-toast--top-right.is-leaving {
	transform: translateY(-10px);
}

/* ------------------------------------------------------------------
 * Body layout
 * ---------------------------------------------------------------- */
.tenmile-toast__inner {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	color: inherit;
	text-decoration: none;
	border: 0;
	background: none;
}

a.tenmile-toast__inner:hover,
a.tenmile-toast__inner:focus {
	color: inherit;
	text-decoration: none;
}

.tenmile-toast--clickable .tenmile-toast__inner {
	cursor: pointer;
}

.tenmile-toast__image {
	display: block;
	flex: 0 0 auto;
	width: auto;
	height: auto;
	max-width: 96px;
	max-height: 96px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: contain;
}

.tenmile-toast__content {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
}

.tenmile-toast__headline {
	display: block;
	margin: 0;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.3;
}

.tenmile-toast__message {
	display: block;
	margin: 2px 0;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.4;
}

.tenmile-toast__headline:empty,
.tenmile-toast__message:empty {
	display: none;
}

.tenmile-toast__link {
	display: inline-block;
	margin-top: 4px;
	font-size: 13px;
	font-weight: 600;
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
}

/* ------------------------------------------------------------------
 * Background mode 1: transparent (default). No box; image and text
 * float on the page.
 * ---------------------------------------------------------------- */
.tenmile-toast--bg-transparent {
	padding: 0;
	background: transparent;
	border: 0;
	box-shadow: none;
	color: var(--tmt-fg, #ffffff);
}

.tenmile-toast--bg-transparent.tenmile-toast--shadow .tenmile-toast__content,
.tenmile-toast--bg-transparent.tenmile-toast--shadow .tenmile-toast__link {
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(0, 0, 0, 0.35);
}

.tenmile-toast--bg-transparent.tenmile-toast--shadow .tenmile-toast__image {
	filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
}

/* ------------------------------------------------------------------
 * Background mode 2: white card.
 * ---------------------------------------------------------------- */
.tenmile-toast--bg-white {
	padding: 12px 16px 12px 12px;
	background: #ffffff;
	color: var(--tmt-fg, #1d2327);
	border: 1px solid rgba(0, 0, 0, 0.06);
	border-radius: 12px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14), 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ------------------------------------------------------------------
 * Background mode 3: custom color. toast.js sets --tmt-bg and --tmt-fg
 * (auto black/white by luminance unless overridden).
 * ---------------------------------------------------------------- */
.tenmile-toast--bg-color {
	padding: 12px 16px 12px 12px;
	background: var(--tmt-bg, #1d2327);
	color: var(--tmt-fg, #ffffff);
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 12px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ------------------------------------------------------------------
 * Close button: always present, readable on any background.
 * ---------------------------------------------------------------- */
.tenmile-toast__close {
	position: absolute;
	top: -8px;
	right: -8px;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	margin: 0;
	padding: 0;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 16px;
	font-weight: 400;
	line-height: 1;
	color: #ffffff;
	background: rgba(0, 0, 0, 0.7);
	border: 1px solid rgba(255, 255, 255, 0.7);
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color 0.15s ease, transform 0.15s ease;
}

.tenmile-toast__close:hover {
	background: rgba(0, 0, 0, 0.9);
	transform: scale(1.08);
}

.tenmile-toast__close:focus {
	outline: none;
}

.tenmile-toast__close:focus-visible,
.tenmile-toast__inner:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.tenmile-toast__inner:focus-visible {
	border-radius: 8px;
}

/* ------------------------------------------------------------------
 * Small screens: 92vw, centered gutters.
 * ---------------------------------------------------------------- */
@media (max-width: 480px) {
	.tenmile-toast {
		max-width: 92vw;
	}

	.tenmile-toast--bottom-left,
	.tenmile-toast--top-left {
		left: 4vw;
	}

	.tenmile-toast--bottom-right,
	.tenmile-toast--top-right {
		right: 4vw;
	}

	.tenmile-toast__image {
		max-width: 72px;
		max-height: 72px;
	}
}

@media (max-width: 782px) {
	body.admin-bar .tenmile-toast--top-left,
	body.admin-bar .tenmile-toast--top-right {
		top: calc(70px + env(safe-area-inset-top, 0px));
	}
}

/* ------------------------------------------------------------------
 * Reduced motion: no slide, plain short fade (effectively instant).
 * ---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.tenmile-toast,
	.tenmile-toast--bottom-left,
	.tenmile-toast--bottom-right,
	.tenmile-toast--top-left,
	.tenmile-toast--top-right,
	.tenmile-toast.is-visible,
	.tenmile-toast.is-leaving {
		transform: none;
		transition: opacity 0.15s linear;
	}

	.tenmile-toast__close,
	.tenmile-toast__close:hover {
		transform: none;
		transition: none;
	}
}
