/* ==========================================================================
   Ninja theme — Katana motion system
   THE CUT    static diagonal edges at var(--cut) (-14deg). clip-path never animates.
   THE SLASH  a thin lavender line that draws in fast (scaleX) — title underlines,
              seams, the hero intro, button sweeps.
   REVEALS    things fade + rise (or wipe diagonally) in once when scrolled into view.

   Hidden start states only exist under html.nk-motion, which inc/motion.php sets in
   <head> when IntersectionObserver exists and reduced motion is NOT requested (and
   removes again if assets/js/motion.js never boots). html.nk-low (weak device):
   fades only, no wipes. Everything animates transform/opacity only (no CLS).

   Run of a -14deg cut: run = rise / tan(14deg) = rise * 4.0108
   Length of that diagonal:  rise / sin(14deg)    = rise * 4.1336
   ========================================================================== */

:root {
	--nk-seam-x: max(var(--gutter), calc((100% - var(--container)) / 2 + var(--gutter)));
	--nk-stagger: 70ms;
}

/* ---------------------------------------------------------------------------
   1. THE CUT — static edges
   ------------------------------------------------------------------------ */

/* Hero: bottom edge rises to the right at -14deg, with a 1px lavender seam. */
.hero {
	--nk-cut-h: clamp(28px, 6vw, 88px);
	padding-bottom: calc(64px + var(--nk-cut-h) * .5);
	clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--nk-cut-h)), calc(100% - var(--nk-cut-h) * 4.0108) 100%, 0 100%);
}
.hero::before {
	content: "";
	position: absolute;
	z-index: 2;
	left: calc(100% - var(--nk-cut-h) * 4.0108);
	bottom: 0;
	width: calc(var(--nk-cut-h) * 4.1336);
	height: 1px;
	background: var(--slash);
	transform-origin: left bottom;
	transform: rotate(var(--cut));
	pointer-events: none;
}

/* The hero's one-time slash (span.nk-hero-slash, decorative). */
.nk-hero-slash {
	position: absolute;
	z-index: 2;
	left: -5%;
	top: 72%;
	width: 115%;
	height: 2px;
	background: var(--slash);
	box-shadow: 0 0 12px var(--slash);
	transform-origin: left center;
	transform: rotate(var(--cut)) scaleX(0);
	opacity: 0;
	pointer-events: none;
}

/* Footer: top edge, flat then rising to the right at -14deg. */
.site-footer {
	--nk-cut-h: clamp(20px, 4vw, 56px);
	position: relative;
	padding-top: var(--nk-cut-h);
	border-top: 0;
	clip-path: polygon(0 var(--nk-cut-h), calc(100% - var(--nk-cut-h) * 4.0108) var(--nk-cut-h), 100% 0, 100% 100%, 0 100%);
}
.site-footer::before,
.site-footer::after {
	content: "";
	position: absolute;
	top: var(--nk-cut-h);
	height: 1px;
	pointer-events: none;
}
.site-footer::before {   /* flat hairline */
	left: 0;
	right: calc(var(--nk-cut-h) * 4.0108);
	background: var(--c-line);
}
.site-footer::after {    /* lavender seam along the cut */
	left: calc(100% - var(--nk-cut-h) * 4.0108);
	width: calc(var(--nk-cut-h) * 4.1336);
	background: var(--slash);
	transform-origin: left top;
	transform: rotate(var(--cut));
}

/* Section seams: a hairline with a lavender -14deg slash through its start.
   Drawn on every .nk-seam that follows another one (front page sections). */
.nk-seam + .nk-seam { position: relative; }
.nk-seam + .nk-seam::before,
.nk-seam + .nk-seam::after {
	content: "";
	position: absolute;
	top: 0;
	left: var(--nk-seam-x);
	pointer-events: none;
}
.nk-seam + .nk-seam::before {
	right: var(--nk-seam-x);
	height: 1px;
	background: linear-gradient(90deg, var(--slash), var(--c-line) 140px, var(--c-line) 70%, transparent);
	transform-origin: left center;
}
.nk-seam + .nk-seam::after {
	width: 64px;
	height: 2px;
	margin-top: -1px;
	background: var(--slash);
	transform-origin: left center;
	transform: rotate(var(--cut));
}

/* One small corner cut (bottom right, -14deg) on cards and product images.
   The cut clips outlines, so focus rings on clipped links go inside. */
.category-card {
	--nk-corner: 64px;
	clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--nk-corner) * .2493), calc(100% - var(--nk-corner)) 100%, 0 100%);
}
.category-card:focus-visible { outline-offset: -4px; }

ul.products li.product img,
.woocommerce div.product div.images .woocommerce-product-gallery__image {
	--nk-corner: 48px;
	clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--nk-corner) * .2493), calc(100% - var(--nk-corner)) 100%, 0 100%);
}
.woocommerce div.product div.images .woocommerce-product-gallery__image { --nk-corner: 96px; }

/* 404: the page is split by one big diagonal. */
.nk-404 {
	position: relative;
	isolation: isolate;
	display: flex;
	align-items: center;
	min-height: min(88vh, 860px);
	overflow: hidden;
}
.nk-404::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: var(--c-surface);
	/* line through the centre at -14deg: rises 12.47vw over half the width */
	clip-path: polygon(0 0, 100% 0, 100% calc(50% - 12.47vw), 0 calc(50% + 12.47vw));
}
.nk-404 > .container { position: relative; z-index: 1; }
.nk-404-slash {
	position: absolute;
	left: -10%;
	top: 50%;
	width: 120%;
	height: 1px;
	background: var(--slash);
	transform: rotate(var(--cut));
	pointer-events: none;
}
.nk-404-num {
	display: grid;
	justify-items: center;
	margin: 0 0 8px;
	font-family: var(--f-display);
	font-size: clamp(120px, 34vw, 300px);
	font-weight: 700;
	line-height: .9;
	letter-spacing: -.01em;
}
.nk-404-num > span { grid-area: 1 / 1; }
/* Two copies of the number, sliced along the cut and slid apart. */
.nk-404-num > span:first-child { clip-path: polygon(0 0, 100% 0, 100% 25%, 0 75%); }
.nk-404-num > span:last-child {
	color: var(--slash);
	clip-path: polygon(0 75%, 100% 25%, 100% 100%, 0 100%);
	transform: translate(-.05em, .035em);
}

/* ---------------------------------------------------------------------------
   2. THE SLASH — title underlines and button sweeps
   ------------------------------------------------------------------------ */

.section-title::after,
.page-title::after,
.woocommerce-products-header__title::after,
.related > h2::after,
.upsells > h2::after,
.cross-sells > h2::after {
	content: "";
	display: block;
	width: 56px;
	height: 4px;
	margin-top: 12px;
	background: var(--slash);
	transform-origin: left center;
	transform: skewX(var(--cut));
}
.center .page-title::after {
	margin-left: auto;
	margin-right: auto;
	transform-origin: center;
}

/* Primary buttons: a light diagonal band sweeps across on hover / focus.
   ::before sits under the label (isolation), above the button background.
   (::after is left alone: WooCommerce uses it for its loading/added icons.) */
@media (prefers-reduced-motion: no-preference) {
	.btn-primary,
	.button.alt,
	.single_add_to_cart_button,
	.wc-block-cart__submit-button,
	.wc-block-components-checkout-place-order-button {
		position: relative;
		overflow: hidden;
		isolation: isolate;
	}
	.btn-primary::before,
	.button.alt::before,
	.single_add_to_cart_button::before,
	.wc-block-cart__submit-button::before,
	.wc-block-components-checkout-place-order-button::before {
		content: "";
		position: absolute;
		z-index: -1;
		top: 0;
		bottom: 0;
		left: 0;
		width: 45%;
		background: linear-gradient(90deg, transparent, rgba(139, 133, 255, .45), transparent);
		transform: translateX(-130%) skewX(var(--cut));
		pointer-events: none;
	}
	.btn-primary:hover::before,
	.btn-primary:focus-visible::before,
	.button.alt:hover::before,
	.button.alt:focus-visible::before,
	.single_add_to_cart_button:hover::before,
	.single_add_to_cart_button:focus-visible::before,
	.wc-block-cart__submit-button:hover::before,
	.wc-block-components-checkout-place-order-button:hover::before,
	.wc-block-cart__submit-button:focus-visible::before,
	.wc-block-components-checkout-place-order-button:focus-visible::before {
		transform: translateX(260%) skewX(var(--cut));
		transition: transform .55s var(--ease-katana);
	}

	/* Add to cart pressed: a bright slash flashes across (class set by motion.js). */
	.nk-slashed {
		position: relative;
		overflow: hidden;
		isolation: isolate;
	}
	.nk-slashed.nk-slashed::before {
		content: "";
		position: absolute;
		z-index: -1;
		top: 0;
		bottom: 0;
		left: 0;
		pointer-events: none;
		width: 22%;
		background: linear-gradient(90deg, transparent, var(--slash) 40%, #fff 50%, var(--slash) 60%, transparent);
		animation: nk-btn-slash .42s var(--ease-katana) forwards;
	}
}
@keyframes nk-btn-slash {
	from { transform: translateX(-130%) skewX(var(--cut)); opacity: 1; }
	to   { transform: translateX(520%) skewX(var(--cut)); opacity: 0; }
}

/* ---------------------------------------------------------------------------
   3. MOTION — only under html.nk-motion
   ------------------------------------------------------------------------ */

/* Hero intro (pure CSS, runs on load): words slice up, the slash draws across,
   then eyebrow / text / button fade in. --n (word count) is set on .hero,
   --i (word index) on each .nk-word, both server side. */
.nk-word {
	display: inline-block;
	overflow: hidden;
	vertical-align: bottom;
	padding: .1em 0;   /* room for glyphs, cancelled by the margin: no layout change */
	margin: -.1em 0;
}
.nk-word > span { display: inline-block; }

html.nk-motion .nk-word > span {
	animation: nk-word-up .62s var(--ease-out) calc(120ms + var(--i, 0) * 60ms) both;
}
html.nk-motion .nk-hero-slash {
	animation: nk-slash .46s ease-out calc(var(--n, 4) * 60ms + 380ms) both;
}
html.nk-motion .hero-inner > .eyebrow,
html.nk-motion .hero-inner > .hero-text,
html.nk-motion .hero-inner > .btn {
	animation: nk-rise .5s var(--ease-out) calc(var(--n, 4) * 60ms + 560ms) both;
}
html.nk-motion .hero-inner > .hero-text { animation-delay: calc(var(--n, 4) * 60ms + 640ms); }
html.nk-motion .hero-inner > .btn { animation-delay: calc(var(--n, 4) * 60ms + 720ms); }
html.nk-motion.nk-low .nk-word > span { animation-name: nk-fade; }

/* 404: the slash draws, then the number slides apart along the cut. */
html.nk-motion .nk-404-slash { animation: nk-draw .5s var(--ease-katana) .15s both; }
html.nk-motion .nk-404-num > span:last-child { animation: nk-slice .45s var(--ease-katana) .5s both; }

/* Scroll reveals: fade + rise. JS sets --i (stagger) and adds .is-in. */
html.nk-motion [data-nk-reveal]:not([data-nk-reveal="group"]),
html.nk-motion [data-nk-reveal="group"] > *,
html.nk-motion .shop-single div.product > .woocommerce-tabs,
html.nk-motion .site-footer .footer-inner > * {
	transition: opacity .6s var(--ease-out), transform .6s var(--ease-out);
	transition-delay: calc(var(--i, 0) * var(--nk-stagger));
}
html.nk-motion [data-nk-reveal]:not([data-nk-reveal="group"]):not(.is-in),
html.nk-motion [data-nk-reveal="group"] > :not(.is-in),
html.nk-motion .shop-single div.product > .woocommerce-tabs:not(.is-in),
html.nk-motion .site-footer .footer-inner > :not(.is-in) {
	opacity: 0;
	transform: translate3d(0, 24px, 0);
}
html.nk-motion.nk-low [data-nk-reveal]:not([data-nk-reveal="group"]):not(.is-in),
html.nk-motion.nk-low [data-nk-reveal="group"] > :not(.is-in),
html.nk-motion.nk-low .shop-single div.product > .woocommerce-tabs:not(.is-in),
html.nk-motion.nk-low .site-footer .footer-inner > :not(.is-in) {
	transform: none;
}

/* Keyboard focus inside a not-yet-revealed block shows it at once
   (backup for the focusin handler in motion.js). */
html.nk-motion [data-nk-reveal]:not([data-nk-reveal="group"]):not(.is-in):focus-within,
html.nk-motion [data-nk-reveal="group"] > :not(.is-in):focus-within,
html.nk-motion .shop-single div.product > .woocommerce-tabs:not(.is-in):focus-within,
html.nk-motion .site-footer .footer-inner > :not(.is-in):focus-within {
	opacity: 1;
	transform: none;
}

/* Product buy box is above the fold: CSS-only entrance, never waits for JS. */
html.nk-motion .shop-single div.product > .summary {
	animation: nk-rise .5s var(--ease-out) .1s both;
}
html.nk-motion.nk-low .shop-single div.product > .summary { animation-name: nk-fade; }

/* Cards: DIAGONAL WIPE — a navy blade (skewed at the cut) slides off the card. */
html.nk-motion:not(.nk-low) .site-content ul.products > li.product .woocommerce-LoopProduct-link { overflow: hidden; }
html.nk-motion:not(.nk-low) .site-content ul.products > li.product .woocommerce-LoopProduct-link::before,
html.nk-motion:not(.nk-low) .category-card::before {
	content: "";
	position: absolute;
	z-index: 3;
	top: -2px;
	bottom: -2px;
	left: -30%;
	width: 160%;
	background: var(--c-bg);
	transform: skewX(var(--cut));
	pointer-events: none;
	transition: transform .7s var(--ease-katana), visibility 0s linear;
	transition-delay: calc(var(--i, 0) * 80ms), calc(var(--i, 0) * 80ms + .7s);
}
html.nk-motion:not(.nk-low) .site-content ul.products > li.product.is-in .woocommerce-LoopProduct-link::before,
html.nk-motion:not(.nk-low) .category-card.is-in::before {
	transform: translateX(105%) skewX(var(--cut));
	visibility: hidden;
}
/* A focused card never hides behind the blade. */
html.nk-motion .site-content ul.products > li.product .woocommerce-LoopProduct-link:focus-visible::before,
html.nk-motion .category-card:focus-visible::before { visibility: hidden; }
/* Weak devices: cards just fade. */
html.nk-motion.nk-low .site-content ul.products > li.product,
html.nk-motion.nk-low .category-card {
	transition: opacity .45s ease-out;
	transition-delay: calc(var(--i, 0) * var(--nk-stagger));
}
html.nk-motion.nk-low .site-content ul.products > li.product:not(.is-in),
html.nk-motion.nk-low .category-card:not(.is-in) { opacity: 0; }

/* Title underlines draw in. */
html.nk-motion .section-title::after,
html.nk-motion .page-title::after,
html.nk-motion .woocommerce-products-header__title::after,
html.nk-motion .related > h2::after,
html.nk-motion .upsells > h2::after,
html.nk-motion .cross-sells > h2::after {
	transition: transform .28s var(--ease-katana) .12s;
}
html.nk-motion .section-title:not(.is-in)::after,
html.nk-motion .page-title:not(.is-in)::after,
html.nk-motion .woocommerce-products-header__title:not(.is-in)::after,
html.nk-motion .related > h2:not(.is-in)::after,
html.nk-motion .upsells > h2:not(.is-in)::after,
html.nk-motion .cross-sells > h2:not(.is-in)::after {
	transform: skewX(var(--cut)) scaleX(0);
}

/* Seams draw in: the slash first (fast), then the hairline runs out. */
html.nk-motion .nk-seam + .nk-seam::after { transition: transform .14s var(--ease-katana), opacity .14s; }
html.nk-motion .nk-seam + .nk-seam::before { transition: transform .7s var(--ease-katana) .1s; }
html.nk-motion .nk-seam + .nk-seam:not(.is-in)::after { opacity: 0; transform: rotate(var(--cut)) scaleX(0); }
html.nk-motion .nk-seam + .nk-seam:not(.is-in)::before { transform: scaleX(0); }

html.nk-motion .site-footer::after { transition: transform .3s var(--ease-katana) .1s; }
html.nk-motion .site-footer:not(.is-in)::after { transform: rotate(var(--cut)) scaleX(0); }

/* Keyframes ---------------------------------------------------------------- */
@keyframes nk-word-up {
	from { transform: translate3d(0, 105%, 0); }
	to   { transform: none; }
}
@keyframes nk-rise {
	from { opacity: 0; transform: translate3d(0, 16px, 0); }
	to   { opacity: 1; transform: none; }
}
@keyframes nk-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}
/* Draw fast (~140ms), hold, fade. */
@keyframes nk-slash {
	0%   { opacity: 1; transform: rotate(var(--cut)) scaleX(0); }
	30%  { opacity: 1; transform: rotate(var(--cut)) scaleX(1); }
	100% { opacity: 0; transform: rotate(var(--cut)) scaleX(1); }
}
@keyframes nk-draw {
	from { transform: rotate(var(--cut)) scaleX(0); }
}
@keyframes nk-slice {
	from { transform: none; }
}

/* Belt and braces: reduced motion never animates, the static cuts stay. */
@media (prefers-reduced-motion: reduce) {
	.nk-word > span,
	.nk-hero-slash,
	.hero-inner > *,
	.nk-404-slash,
	.nk-404-num > span { animation: none !important; }
}
