/**
 * Deadly Threads — site-wide motion system (docs/motion-spec.md §M).
 *
 * Every effect is a reusable class, applied through Elementor → Advanced → CSS Classes or in theme
 * templates. Shared tokens only (style.css): --dt-dur-micro 160 · --dt-dur-ui 240 ·
 * --dt-dur-overlay 320 · --dt-dur-reveal 480; --dt-ease-entrance / --dt-ease-ui.
 *
 * Contract
 * - Animate transform / opacity / clip-path only (one documented exception: the Join the Yarn
 *   success tick stroke, M9).
 * - Pre-hide only under html.dt-motion (JS on, motion allowed, not the Elementor editor; 3s
 *   failsafe). Without JS, with reduced motion, or in the editor, everything is visible and static.
 * - Hover transforms only for (hover: hover) and (pointer: fine).
 * - Cart and checkout get nothing new.
 */

/* ---------------------------------------------------------------------------
 * M1 dt-split-heading — masked line reveal (SplitText). Real text stays in the DOM; SplitText
 * adds aria-label to the heading and aria-hidden to the line wrappers.
 * ------------------------------------------------------------------------ */
html.dt-motion .dt-split-heading:not(.is-split) {
	visibility: hidden;
}

/* Line masks: a little room for descenders/diacritics without changing the line box. */
.dt-split-heading .dt-line-mask {
	padding-block: 0.08em 0.14em;
	margin-block: -0.08em -0.14em;
}

.dt-split-heading .dt-line {
	will-change: auto;
}

/* ---------------------------------------------------------------------------
 * M2 dt-hero-zoom — hero image 1.06 → 1 over 1200ms on load. Opacity is never touched (LCP).
 * Background-image containers scale a ::before copy of their own background (shared with
 * dt-tilt / dt-img-reveal); <img> heroes scale the image itself.
 * ------------------------------------------------------------------------ */
.e-con.dt-hero-zoom,
.e-con.dt-img-reveal {
	position: relative;
	overflow: hidden;
	isolation: isolate;
}

.e-con.dt-hero-zoom::before,
.e-con.dt-img-reveal::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 0;
	background: inherit;
	border: 0;
	border-radius: inherit;
	opacity: 1;
	mix-blend-mode: normal;
	pointer-events: none;
}

/* One scale for the shared layer: tilt hover × reveal settle × hero zoom. */
.e-con.dt-tilt::before,
.e-con.dt-img-reveal::before,
.e-con.dt-hero-zoom::before {
	transform: scale(calc(var(--dt-tilt-scale, 1) * var(--dt-img-scale, 1)));
}

.e-con.dt-hero-zoom > .elementor-element,
.e-con.dt-hero-zoom > .e-con-inner,
.e-con.dt-img-reveal > .elementor-element,
.e-con.dt-img-reveal > .e-con-inner {
	position: relative;
	z-index: 2;
}

@keyframes dt-hero-zoom {
	from {
		transform: scale(1.06);
	}

	to {
		transform: scale(1);
	}
}

html.dt-motion .e-con.dt-hero-zoom::before,
html.dt-motion .dt-hero-zoom img.dt-hero-zoom__img {
	animation: dt-hero-zoom 1200ms var(--dt-ease-entrance);
}

.dt-hero-zoom {
	overflow: hidden;
}

/* ---------------------------------------------------------------------------
 * M3 dt-img-reveal (agency override O3) — clip-path inset(0 0 100% 0) → inset(0) with the image
 * settling 1.08 → 1, 900ms, once at 15%. Hidden only by img-reveal.js at run time.
 * ------------------------------------------------------------------------ */
.dt-img-reveal img {
	transform: scale(var(--dt-img-scale, 1));
}

.dt-img-reveal.is-revealing,
.dt-img-reveal.is-revealing::before,
.dt-img-reveal.is-revealing img {
	will-change: transform, clip-path;
}

/* ---------------------------------------------------------------------------
 * M6 dt-btn-fx — button fill sweep from the left (pseudo scaleX, 240ms), arrow nudge 4px (160ms),
 * press 1px (100ms). The pass in scripts/lib/motion-classes.php adds dt-btn-fx plus the button's
 * own Kit colours as dt-bg-* (rest) and dt-sweep-* (hover), so the sweep IS the hover colour and
 * the rest colour holds underneath it. Link-style buttons (no fill) get --link: arrow + press only.
 * ------------------------------------------------------------------------ */
.dt-bg-primary { --dt-btn-bg: var(--e-global-color-primary); }
.dt-bg-secondary { --dt-btn-bg: var(--e-global-color-secondary); }
.dt-bg-accent { --dt-btn-bg: var(--e-global-color-accent); }
.dt-bg-darkpurple { --dt-btn-bg: var(--e-global-color-darkpurple); }
.dt-bg-deepplum { --dt-btn-bg: var(--e-global-color-deepplum); }
.dt-bg-obsidian { --dt-btn-bg: var(--e-global-color-obsidian); }
.dt-bg-warmwhite { --dt-btn-bg: var(--e-global-color-warmwhite); }
.dt-bg-none { --dt-btn-bg: transparent; }
.dt-sweep-primary { --dt-sweep: var(--e-global-color-primary); }
.dt-sweep-secondary { --dt-sweep: var(--e-global-color-secondary); }
.dt-sweep-accent { --dt-sweep: var(--e-global-color-accent); }
.dt-sweep-darkpurple { --dt-sweep: var(--e-global-color-darkpurple); }
.dt-sweep-deepplum { --dt-sweep: var(--e-global-color-deepplum); }
.dt-sweep-obsidian { --dt-sweep: var(--e-global-color-obsidian); }
.dt-sweep-warmwhite { --dt-sweep: var(--e-global-color-warmwhite); }

html.dt-js:not(.dt-editor) .dt-btn-fx .elementor-button,
html.dt-js:not(.dt-editor) .dt-btn-fx-native {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	transition: color var(--dt-dur-micro) var(--dt-ease-ui), border-color var(--dt-dur-micro) var(--dt-ease-ui), transform 100ms var(--dt-ease-ui);
}

html.dt-js:not(.dt-editor) .dt-btn-fx[class*="dt-sweep-"] .elementor-button::before,
html.dt-js:not(.dt-editor) .dt-btn-fx-native::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	border-radius: inherit;
	background: var(--dt-sweep, transparent);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--dt-dur-ui) var(--dt-ease-ui);
	pointer-events: none;
}

/* The sweep replaces the instant hover fill: keep the rest colour under it. */
html.dt-js:not(.dt-editor) .dt-btn-fx[class*="dt-sweep-"][class*="dt-bg-"] .elementor-button:hover,
html.dt-js:not(.dt-editor) .dt-btn-fx[class*="dt-sweep-"][class*="dt-bg-"] .elementor-button:focus-visible {
	background-color: var(--dt-btn-bg) !important;
}

html.dt-js:not(.dt-editor) .dt-btn-fx .elementor-button:focus-visible::before,
html.dt-js:not(.dt-editor) .dt-btn-fx-native:focus-visible::before {
	transform: scaleX(1);
}

html.dt-js:not(.dt-editor) .dt-btn-fx .elementor-button-icon,
html.dt-js:not(.dt-editor) .dt-btn-fx-native .dt-btn-fx__icon {
	transition: transform var(--dt-dur-micro) var(--dt-ease-ui);
}

@media (hover: hover) and (pointer: fine) {
	html.dt-js:not(.dt-editor) .dt-btn-fx .elementor-button:hover::before,
	html.dt-js:not(.dt-editor) .dt-btn-fx-native:hover::before {
		transform: scaleX(1);
	}

	html.dt-js:not(.dt-editor) .dt-btn-fx .elementor-button:hover .elementor-button-icon,
	html.dt-js:not(.dt-editor) .dt-btn-fx-native:hover .dt-btn-fx__icon {
		transform: translateX(4px);
	}

	html.dt-js:not(.dt-editor) .dt-btn-fx.dt-btn-fx--back .elementor-button:hover .elementor-button-icon {
		transform: translateX(-4px);
	}
}

html.dt-js:not(.dt-editor) .dt-btn-fx .elementor-button:active,
html.dt-js:not(.dt-editor) .dt-btn-fx-native:active {
	transform: translateY(1px);
}

/* ---------------------------------------------------------------------------
 * M7 Product cards — image 1.025 / 240ms clipped (product-grid.css / woo.css) and quick add that
 * rises 8px + fades in on hover. Always visible on touch, keyboard focus and without JS.
 * ------------------------------------------------------------------------ */
@media (hover: hover) and (pointer: fine) {
	html.dt-js:not(.dt-editor) .dt-pcard .dt-pcard__add:not(.is-disabled),
	html.dt-js:not(.dt-editor) .dt-shop-card .dt-shop-card__add:not(.is-disabled) {
		opacity: 0;
		transform: translateY(8px);
		transition: background-color var(--dt-dur-micro) var(--dt-ease-ui), opacity var(--dt-dur-ui) var(--dt-ease-ui), transform var(--dt-dur-ui) var(--dt-ease-ui);
	}

	html.dt-js:not(.dt-editor) .dt-pcard:hover .dt-pcard__add,
	html.dt-js:not(.dt-editor) .dt-pcard:focus-within .dt-pcard__add,
	html.dt-js:not(.dt-editor) .dt-pcard .dt-pcard__add.loading,
	html.dt-js:not(.dt-editor) .dt-pcard .dt-pcard__add.added,
	html.dt-js:not(.dt-editor) .dt-shop-card:hover .dt-shop-card__add,
	html.dt-js:not(.dt-editor) .dt-shop-card:focus-within .dt-shop-card__add,
	html.dt-js:not(.dt-editor) .dt-shop-card .dt-shop-card__add.loading,
	html.dt-js:not(.dt-editor) .dt-shop-card .dt-shop-card__add.added {
		opacity: 1;
		transform: none;
	}

	html.dt-js:not(.dt-editor) .dt-pcard .dt-pcard__add:active,
	html.dt-js:not(.dt-editor) .dt-shop-card .dt-shop-card__add:active {
		transform: translateY(1px);
	}
}

/* ---------------------------------------------------------------------------
 * M8 Bag feedback — real server responses only.
 * Bag icon pulse (1 → 1.15 → 1, 240ms) after a confirmed add, then the drawer opens.
 * Button states: label → spinner (request pending) → tick (confirmed) → label.
 * ------------------------------------------------------------------------ */
@keyframes dt-bag-pulse {
	0% { transform: scale(1); }
	50% { transform: scale(1.15); }
	100% { transform: scale(1); }
}

html.dt-motion .dt-cart-trigger.is-pulsing .dt-cart-trigger__icon {
	animation: dt-bag-pulse var(--dt-dur-ui) var(--dt-ease-ui);
}

.dt-cart-trigger__icon {
	display: inline-flex;
}

/* Spinner / tick layers on a button that keeps its width (no layout shift). */
.dt-btn-state {
	position: relative;
}

.dt-btn-state .dt-btn-state__label {
	transition: opacity var(--dt-dur-micro) linear;
}

.dt-btn-state .dt-btn-state__icon {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;
	opacity: 0;
	transition: opacity var(--dt-dur-micro) linear;
	pointer-events: none;
}

.dt-btn-state .dt-btn-state__spinner {
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
}

html.dt-motion .dt-btn-state.is-loading .dt-btn-state__spinner {
	animation: dt-spin 700ms linear infinite;
}

@keyframes dt-spin {
	to { transform: rotate(360deg); }
}

.dt-btn-state.is-loading .dt-btn-state__label,
.dt-btn-state.is-added .dt-btn-state__label,
.dt-btn-state.loading .dt-btn-state__label,
.dt-btn-state.added .dt-btn-state__label {
	opacity: 0;
}

.dt-btn-state.is-loading .dt-btn-state__spinner,
.dt-btn-state.loading .dt-btn-state__spinner,
.dt-btn-state.is-added .dt-btn-state__tick,
.dt-btn-state.added .dt-btn-state__tick {
	opacity: 1;
}

.dt-btn-state.added:not(.is-added) .dt-btn-state__tick {
	opacity: 0;
}

.dt-btn-state.added:not(.is-added) .dt-btn-state__label {
	opacity: 1;
}

/* ---------------------------------------------------------------------------
 * M9 Form fields — focus underline grows from the left (scaleX 0 → 1, 240ms). Success tick in
 * Join the Yarn draws its stroke over 320ms (documented exception to transform/opacity-only).
 * ------------------------------------------------------------------------ */
.dt-field-fx {
	position: relative;
	display: block;
	min-width: 0;
	border-radius: 8px;
}

.dt-field-fx::after {
	content: "";
	position: absolute;
	right: 1px;
	bottom: 1px;
	left: 1px;
	height: 2px;
	border-radius: 0 0 8px 8px;
	background: var(--e-global-color-primary);
	transform: scaleX(0);
	transform-origin: left center;
	pointer-events: none;
}

html.dt-js:not(.dt-editor) .dt-field-fx:focus-within::after {
	transform: scaleX(1);
}

html.dt-motion .dt-field-fx::after {
	transition: transform var(--dt-dur-ui) var(--dt-ease-ui);
}

.dt-yarn__tick {
	display: inline-block;
	width: 16px;
	height: 16px;
	margin-right: 8px;
	vertical-align: -3px;
}

.dt-yarn__status:not(.is-success) .dt-yarn__tick {
	display: none;
}

html.dt-motion .dt-yarn__status.is-success .dt-yarn__tick path {
	stroke-dasharray: 24;
	stroke-dashoffset: 24;
	animation: dt-tick-draw var(--dt-dur-overlay) var(--dt-ease-entrance) forwards;
}

@keyframes dt-tick-draw {
	to { stroke-dashoffset: 0; }
}

/* ---------------------------------------------------------------------------
 * M11 dt-drift (agency override O4) — scroll-linked horizontal drift, ≥768px, no reduced motion.
 * ------------------------------------------------------------------------ */
.dt-drift-clip {
	overflow-x: clip;
}

/* ---------------------------------------------------------------------------
 * M12 Reading progress (single posts) — 3px purple bar under the sticky header.
 * ------------------------------------------------------------------------ */
.dt-read-progress {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	height: 3px;
	background: var(--e-global-color-primary);
	transform: scaleX(0);
	transform-origin: left center;
	pointer-events: none;
}

/* Elements driven by GSAP: drop Elementor's built-in transform transition. */
.dt-img-reveal,
.dt-stagger > *,
.dt-stagger > .e-con-inner > *,
.dt-drift {
	--e-con-transform-transition-duration: 0s;
	--e-transform-transition-duration: 0s;
}

/* Quick-add label keeps its flex layout inside the state wrapper. */
.dt-btn-state .dt-btn-state__label {
	display: inline-flex;
	align-items: center;
	gap: inherit;
}

.dt-btn-state .dt-btn-state__tick {
	width: 20px;
	height: 20px;
}

/* Add to bag (single product): sweep in the accent colour over the primary rest colour. */
html.dt-js:not(.dt-editor) .dt-product form.cart .single_add_to_cart_button.dt-btn-fx-native {
	--dt-sweep: var(--e-global-color-accent);
}

html.dt-js:not(.dt-editor) .dt-product form.cart .single_add_to_cart_button.dt-btn-fx-native:hover {
	background: var(--e-global-color-primary);
}

/* Contact form fields are 12px-radius boxes. */
.dt-cf .dt-field-fx,
.dt-cf .dt-field-fx::after {
	border-radius: 0 0 12px 12px;
}

.dt-cf .dt-field-fx {
	border-radius: 12px;
}

.dt-cf .dt-field-fx textarea {
	display: block;
}
