/* ===========================================================================
 * Mota Notices — v1.0
 * Dismissible, self-destructing WooCommerce notices.
 *
 * Enhances .woocommerce-message / .woocommerce-info / .woocommerce-error:
 *   - shrink-to-fit width (no more full-width banner for three words)
 *   - close ✕ at the top right
 *   - "This notice will self-destruct in N" countdown (success/info only)
 *   - implosion + mini explosion on self-destruct
 *   - quiet slide-up fade on manual close
 *
 * Markup is built by js/mota-notices.js. Nothing here fires unless that
 * script has wrapped the notice in .mota-notice-wrap, so the stock notice
 * styling in style.css remains the fallback.
 * ========================================================================= */

/* ---------------------------------------------------------------- wrapper */

.mota-notice-wrap {
	position: relative;
	display: block;
	clear: both;
	float: none;
	width: 100%;
	margin: 2em 0;
	text-align: center;
	transform-origin: 50% 50%;
	will-change: transform, opacity;
}

/* The notice keeps all of its own styling (skew, shadow, colour) — we only
   take over sizing and make room for the close button. */
.mota-notice-wrap > .woocommerce-message,
.mota-notice-wrap > .woocommerce-info,
.mota-notice-wrap > .woocommerce-error,
.mota-notice-wrap > ul.woocommerce-error {
	display: inline-block !important;
	float: none !important;
	width: auto !important;
	min-width: 300px;
	max-width: 100%;
	position: relative;
	margin: 0 !important;
	padding-right: 58px !important;
	box-sizing: border-box;
	text-align: left;
}

.mota-notice-wrap > .woocommerce-message {
	text-align: center;
}

/* Some pages float the notice or force 100% further down style.css. */
.woocommerce .mota-notice-wrap > .woocommerce-error,
.inner-merchandise .mota-notice-wrap > .woocommerce-info,
.inner-merchandise .mota-notice-wrap > .woocommerce-message {
	width: auto !important;
	float: none !important;
	height: auto !important;
}

/* ---------------------------------------------------------- close button */

.mota-notice-actions {
	position: absolute !important;
	top: 0;
	right: 0;
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
	line-height: 1 !important;
	background: none !important;
	z-index: 4;
}

/* kill the inherited ✗ / ✓ bullet when the actions node is an <li> */
.mota-notice-actions::before,
.mota-notice-actions::after {
	content: none !important;
	display: none !important;
}

.mota-notice-close {
	display: block;
	width: 34px;
	height: 34px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: #b4b1b2;
	font-family: "ShowMetheMono", "Traverse60", sans-serif;
	font-size: 19px;
	font-weight: normal;
	line-height: 34px;
	text-align: center;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: color .16s ease, transform .16s ease;
}

.mota-notice-close:hover,
.mota-notice-close:focus {
	color: #21a119;
	background: none;
	transform: scale(1.18);
	outline: none;
}

.mota-notice-close:focus-visible {
	outline: 2px solid #21a119;
	outline-offset: 2px;
}

.mota-notice-close:active {
	color: #3a3738;
	transform: scale(.92);
}

/* --------------------------------------------------------- countdown row */

.mota-notice-timer {
	display: block;
	margin: 8px 0 0 0 !important;
	padding: 0 !important;
	background: none !important;
	list-style: none !important;
	font-family: "ShowMetheMono", "Traverse60", sans-serif;
	font-size: 13px;
	font-weight: normal;
	font-style: normal;
	line-height: 20px;
	letter-spacing: .01em;
	color: #a09d9e;
	transition: opacity .2s ease;
}

.mota-notice-timer::before,
.mota-notice-timer::after {
	content: none !important;
	display: none !important;
}

/* SS07 turns the digits into black circled numerals in ShowMetheMono. */
.mota-notice-count {
	display: inline-block;
	margin-left: 2px;
	color: #3a3738;
	font-size: 19px;
	font-weight: 700;
	line-height: 20px;
	vertical-align: -2px;
	-moz-font-feature-settings: "ss07" 1;
	-webkit-font-feature-settings: "ss07" 1;
	font-feature-settings: "ss07" 1;
	font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------- implode + boom  */

.mota-notice-wrap.is-imploding {
	animation: motaNoticeImplode .2s cubic-bezier(.55, 0, .85, .3) forwards;
	pointer-events: none;
}

@keyframes motaNoticeImplode {
	0% {
		transform: scale(1, 1);
		opacity: 1;
	}
	35% {
		transform: scale(1.035, 1.07);
		opacity: 1;
	}
	100% {
		transform: scale(.02, .02);
		opacity: .85;
	}
}

/* The explosion is an animated GIF (1.19s) pinned to the page at the point
   where the notice imploded. It lives on <body>, NOT inside the wrapper —
   the wrapper is collapsing to zero height with overflow:hidden underneath
   it and would otherwise clip the burst. */
.mota-notice-boom {
	position: absolute;
	width: 169px;
	height: 120px;
	margin: -60px 0 0 -84.5px;
	pointer-events: none;
	z-index: 9999;
	animation: motaBoomIn .09s ease-out;
}

.mota-notice-boom img {
	display: block;
	width: 169px;
	height: 120px;
	border: 0;
	max-width: none;
}

@keyframes motaBoomIn {
	from {
		opacity: 0;
		transform: scale(.7);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

/* --------------------------------------------------- manual close + gap  */

.mota-notice-wrap.is-closing {
	animation: motaNoticeSlideUp .26s cubic-bezier(.4, 0, .6, 1) forwards;
	pointer-events: none;
}

@keyframes motaNoticeSlideUp {
	0% {
		transform: translateY(0) scale(1);
		opacity: 1;
	}
	100% {
		transform: translateY(-16px) scale(.98);
		opacity: 0;
	}
}

/* Collapse the space the notice occupied so the page doesn't jump. The
   duration is set inline by the script: a quick 260ms for a manual close,
   a slow 1100ms for a self-destruct so the page eases back up underneath
   the explosion instead of snapping. */
.mota-notice-wrap.is-collapsing {
	overflow: hidden;
	transition: height .26s ease, margin-top .26s ease, margin-bottom .26s ease;
	margin-top: 0 !important;
	margin-bottom: 0 !important;
	height: 0 !important;
}

.mota-notice-wrap.is-collapsing-slow {
	transition-duration: 1.1s;
	transition-timing-function: cubic-bezier(.33, .1, .3, 1);
}

/* -------------------------------------------------------------- a11y     */

@media (prefers-reduced-motion: reduce) {

	.mota-notice-wrap.is-imploding,
	.mota-notice-wrap.is-closing {
		animation: motaNoticeFadeOnly .18s linear forwards;
	}

	.mota-notice-boom {
		display: none;
	}

	.mota-notice-wrap.is-collapsing {
		transition: none;
	}

	@keyframes motaNoticeFadeOnly {
		to {
			opacity: 0;
		}
	}
}

/* -------------------------------------------------------------- mobile   */

@media (max-width: 767px) {

	.mota-notice-wrap > .woocommerce-message,
	.mota-notice-wrap > .woocommerce-info,
	.mota-notice-wrap > .woocommerce-error,
	.mota-notice-wrap > ul.woocommerce-error {
		min-width: 0;
		width: 100% !important;
		padding-right: 48px !important;
	}

	.mota-notice-close {
		width: 30px;
		height: 30px;
		line-height: 30px;
		font-size: 17px;
	}

	.mota-notice-timer {
		font-size: 12px;
	}
}
