/**
 * Oznámenia.
 *
 * Potvrdenia ako malé oznámenie (na počítači vpravo hore pod hlavičkou, na
 * mobile dole – tam nezakryje polia, ktoré zákazník práve vypĺňa). Chyby
 * a informácie zostávajú na svojom mieste, len dostanú vzhľad značky.
 *
 * Farby, rozostupy a písmo berieme z assets/css/tokens.css.
 *
 * @package TulipoBox\Notices
 */

/* --- Oblasť pre oznámenia -------------------------------------------------- */

.tlpb-toasts {
	position: fixed;
	top: var( --tlpb-toast-top, 96px );
	right: var( --tlpb-space-5 );
	z-index: 99999;
	display: flex;
	flex-direction: column;
	gap: var( --tlpb-space-2 );
	width: 360px;
	max-width: calc( 100vw - 2 * var( --tlpb-space-5 ) );
	margin: 0;
	padding: 0;
	pointer-events: none; /* prázdna oblasť nesmie blokovať klikanie pod ňou */
}

/* Prihlásený správca má hore ešte lištu WordPressu. */
body.admin-bar .tlpb-toasts {
	top: calc( var( --tlpb-toast-top, 96px ) + 32px );
}

/* --- Samotné oznámenie ------------------------------------------------------- */

.tlpb-toast {
	position: relative;
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: start;
	gap: var( --tlpb-space-3 );
	padding: var( --tlpb-space-3 ) var( --tlpb-space-1 ) var( --tlpb-space-3 ) var( --tlpb-space-4 );
	overflow: hidden;
	border-radius: var( --tlpb-radius-md );
	background: var( --tlpb-panel );
	box-shadow: 0 2px 4px rgba( 90, 70, 66, 0.08 ), 0 12px 32px rgba( 90, 70, 66, 0.18 );
	color: var( --tlpb-ink );
	pointer-events: auto;
	opacity: 0;
	transform: translateY( -8px );
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.tlpb-toast.is-visible {
	opacity: 1;
	transform: none;
}

.tlpb-toast.is-leaving {
	opacity: 0;
	transform: translateY( -8px );
}

/* Ikona v slivkovej – šalviová by na bielej nemala potrebný kontrast 3 : 1. */
.tlpb-toast__icon {
	display: block;
	width: 22px;
	height: 22px;
	margin-top: 1px;
	color: var( --tlpb-plum );
	line-height: 0;
}

.tlpb-toast__icon svg {
	display: block;
	width: 100%;
	height: 100%;
}

.tlpb-toast__body {
	min-width: 0;
	padding-top: 1px;
	font-family: var( --tlpb-font-body );
	font-size: var( --tlpb-text-sm );
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.tlpb-toast__title {
	display: block;
	margin-bottom: 2px;
	color: var( --tlpb-ink );
	font-family: var( --tlpb-font-heading );
	font-size: 15px;
	font-weight: 800;
	line-height: 1.3;
}

/* Názov a cena sú podstatné – plná farba, nie stlmená. */
.tlpb-toast__text {
	display: block;
	color: var( --tlpb-ink );
}

.tlpb-toast__text .woocommerce-Price-amount {
	font-weight: 700;
	white-space: nowrap;
}

/* --- Akcia a zatvorenie ------------------------------------------------------ */

/*
 * Téma štýluje <button> a odkazy razantne (rámik, farba, výplň pri hover),
 * preto selektory s triedou oznámenia – inak by sme prehrali.
 */
.tlpb-toast a.tlpb-toast__action,
.tlpb-toast button.tlpb-toast__action {
	display: inline-flex;
	align-items: center;
	min-height: 32px;
	margin: var( --tlpb-space-1 ) 0 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: var( --tlpb-plum );
	font-family: var( --tlpb-font-heading );
	font-size: var( --tlpb-text-sm );
	font-weight: 700;
	line-height: 1.3;
	text-decoration: underline;
	text-underline-offset: 3px;
	white-space: normal;
	cursor: pointer;
}

.tlpb-toast a.tlpb-toast__action:hover,
.tlpb-toast button.tlpb-toast__action:hover,
.tlpb-toast a.tlpb-toast__action:focus,
.tlpb-toast button.tlpb-toast__action:focus {
	background: none;
	color: var( --tlpb-plum );
	text-decoration-thickness: 2px;
}

.tlpb-toast .tlpb-toast__action:focus-visible,
.tlpb-toast button.tlpb-toast__close:focus-visible {
	outline: 2px solid var( --tlpb-plum );
	outline-offset: 2px;
}

.tlpb-toast button.tlpb-toast__close {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var( --tlpb-ink-muted );
	font-size: 22px;
	font-weight: 400;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

/* Kresba 32 px, dotyková plocha 44 px. */
.tlpb-toast button.tlpb-toast__close::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 44px;
	height: 44px;
	transform: translate( -50%, -50% );
}

.tlpb-toast button.tlpb-toast__close:hover,
.tlpb-toast button.tlpb-toast__close:focus {
	background: var( --tlpb-surface );
	color: var( --tlpb-ink );
}

/* --- Ukazovateľ zostávajúceho času ------------------------------------------- */

.tlpb-toast__bar {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	height: 3px;
	background: var( --tlpb-plum );
	opacity: 0.35;
	transform-origin: left center;
	animation: tlpb-toast-bar var( --tlpb-toast-duration, 5000ms ) linear forwards;
}

/* Kým je myš nad oznámením alebo je v ňom kurzor, čas stojí – aj čiara. */
.tlpb-toast.is-paused .tlpb-toast__bar {
	animation-play-state: paused;
}

@keyframes tlpb-toast-bar {
	from {
		transform: scaleX( 1 );
	}

	to {
		transform: scaleX( 0 );
	}
}

/* --- Mobil: dole, cez celú šírku -------------------------------------------- */

@media screen and ( max-width: 767px ) {
	.tlpb-toasts,
	body.admin-bar .tlpb-toasts {
		top: auto;
		right: var( --tlpb-space-4 );
		bottom: calc( var( --tlpb-space-4 ) + env( safe-area-inset-bottom, 0px ) );
		left: var( --tlpb-space-4 );
		width: auto;
		max-width: none;
	}

	.tlpb-toast,
	.tlpb-toast.is-leaving {
		transform: translateY( 8px );
	}

	.tlpb-toast.is-visible:not( .is-leaving ) {
		transform: none;
	}

	/* Palcom sa mieri horšie – akcia dostane vyšší terč. */
	.tlpb-toast a.tlpb-toast__action,
	.tlpb-toast button.tlpb-toast__action {
		min-height: 40px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.tlpb-toast,
	.tlpb-toast.is-leaving,
	.tlpb-toast.is-visible {
		transform: none;
		transition: none;
	}

	.tlpb-toast__bar {
		display: none;
	}
}

/* --- Chyby a informácie na mieste ------------------------------------------- */

/*
 * WooCommerce ich štýluje selektorom o sile (0,1,0), preto body + trieda.
 * Nemiznú – chybu si zákazník musí stihnúť prečítať a opraviť. Bez pásika
 * po ľavom okraji (dizajnový systém), signál nesie ikona a podklad.
 */
body .woocommerce-error,
body .woocommerce-info,
body .woocommerce-message {
	position: relative;
	width: auto;
	margin: 0 0 var( --tlpb-space-4 );
	padding: var( --tlpb-space-3 ) var( --tlpb-space-4 ) var( --tlpb-space-3 ) calc( var( --tlpb-space-4 ) + 30px );
	border: 0;
	border-radius: var( --tlpb-radius-sm );
	background: var( --tlpb-surface );
	color: var( --tlpb-ink );
	font-size: var( --tlpb-text-sm );
	line-height: 1.5;
	list-style: none;
	outline: none;
}

body .woocommerce-error {
	background: var( --tlpb-danger-soft );
}

/* Pôvodné ikony WooCommerce (vlastné písmo) nahrádzame vlastnou kresbou. */
body .woocommerce-error::before,
body .woocommerce-info::before,
body .woocommerce-message::before {
	content: '';
	position: absolute;
	top: calc( var( --tlpb-space-3 ) + 1px );
	left: var( --tlpb-space-4 );
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background-color: var( --tlpb-ink-muted );
	background-position: center;
	background-repeat: no-repeat;
	background-size: 12px 12px;
	font-family: inherit;
}

/* Výkričník v kruhu. */
body .woocommerce-error::before {
	background-color: var( --tlpb-danger );
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 2.2v4.6' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3Ccircle cx='6' cy='9.6' r='1.1' fill='%23fff'/%3E%3C/svg%3E" );
}

/* „i“ v kruhu. */
body .woocommerce-info::before {
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='2.6' r='1.1' fill='%23fff'/%3E%3Cpath d='M6 5.2v4.6' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E" );
}

/* Fajka – keď potvrdenie zostane na mieste (bez JavaScriptu). */
body .woocommerce-message::before {
	background-color: var( --tlpb-plum );
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 6.3l2.3 2.3 4.6-4.9' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E" );
}

/*
 * Prázdne stavy v sekcii Môj účet („Zatiaľ ste nevytvorili žiadnu
 * objednávku“) nesú obe triedy naraz. Nie je to potvrdenie, tak fajka nie.
 */
body .woocommerce-message.woocommerce-info::before {
	background-color: var( --tlpb-ink-muted );
	background-image: url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='2.6' r='1.1' fill='%23fff'/%3E%3Cpath d='M6 5.2v4.6' stroke='%23fff' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E" );
}

body .woocommerce-error::after,
body .woocommerce-info::after,
body .woocommerce-message::after {
	display: none;
}

/* Zoznam chýb na pokladni – každá chyba na vlastnom riadku, bez odrážok. */
body .woocommerce-error li,
body .woocommerce-info li,
body .woocommerce-message li {
	margin: 0;
	padding: 0;
	list-style: none;
}

body .woocommerce-error li + li {
	margin-top: var( --tlpb-space-1 );
}

body .woocommerce-error a,
body .woocommerce-info a,
body .woocommerce-message a:not( .button ) {
	color: var( --tlpb-plum );
	font-weight: 700;
	text-decoration: underline;
}

/* Tlačidlo v hlásení (napr. „Prejsť do obchodu“) – slivková pilulka. */
body .woocommerce-error .button,
body .woocommerce-info .button,
body .woocommerce-message .button {
	float: right;
	margin: -4px 0 0 var( --tlpb-space-3 );
	padding: var( --tlpb-space-2 ) var( --tlpb-space-4 );
	border: 0;
	border-radius: var( --tlpb-radius-pill );
	background: var( --tlpb-plum );
	color: var( --tlpb-on-accent );
	font-family: var( --tlpb-font-heading );
	font-size: var( --tlpb-text-sm );
	font-weight: 700;
	line-height: 1.3;
	text-decoration: none;
}

body .woocommerce-error .button:hover,
body .woocommerce-info .button:hover,
body .woocommerce-message .button:hover {
	background: var( --tlpb-plum );
	color: var( --tlpb-on-accent );
	filter: brightness( 1.1 );
}

/* Na úzkom displeji by tlačidlo vpravo prekážalo textu – ide pod neho. */
@media screen and ( max-width: 767px ) {
	body .woocommerce-error .button,
	body .woocommerce-info .button,
	body .woocommerce-message .button {
		display: table;
		float: none;
		margin: var( --tlpb-space-2 ) 0 0;
	}
}

/* Zameranie (WooCommerce po chybe presunie kurzor na hlásenie) – jemne. */
body .woocommerce-error:focus-visible,
body .woocommerce-info:focus-visible,
body .woocommerce-message:focus-visible {
	outline: 2px solid var( --tlpb-plum );
	outline-offset: 2px;
}
