/* ==========================================================================
   Ninja — search overlay ("Dojo Search"), #nk-search
   The search field is a capsule in the exact place of the header capsule,
   so opening search feels like the header turning into the field.
   Katana: one slash draws under the capsule on open, thumbs carry the -14deg
   cut, active rows get a skewed lavender edge, results sheathe in sideways.
   ========================================================================== */

.nk-search {
	position: fixed;
	inset: 0;
	z-index: var(--z-overlay);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	background: var(--c-bg);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-10px);
	transition: opacity .2s var(--ease-out), transform .2s var(--ease-out), visibility 0s .2s;
}
.nk-search[data-state="open"] {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity .2s var(--ease-out), transform .2s var(--ease-out), visibility 0s;
}
/* Stay below the WordPress admin bar like the header does */
.admin-bar .nk-search { top: 46px; }
@media (min-width: 783px) { .admin-bar .nk-search { top: 32px; } }

/* Capsule bar ------------------------------------------------------------- */
.nk-s-top {
	position: sticky;
	top: 0;
	z-index: 2;
	height: var(--cap-offset);
	background: var(--c-bg);
}
.nk-s-cap {
	position: absolute;
	top: var(--cap-gap);
	left: max(var(--cap-gap), calc((100% - 1240px) / 2));
	right: max(var(--cap-gap), calc((100% - 1240px) / 2));
	height: var(--cap-h);
	display: flex;
	align-items: center;
	gap: 2px;
	margin: 0;
	padding: 0 8px;
	border: 1px solid rgba(139, 133, 255, .55);
	border-radius: 999px;
	background: var(--c-surface);
	box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
	transition: border-color .2s;
}
/* Same geometry as the shrunken header capsule, so the swap lines up */
html.nk-scrolled .nk-s-cap {
	left: max(calc(var(--cap-gap) * 2.4), calc((100% - 1160px) / 2));
	right: max(calc(var(--cap-gap) * 2.4), calc((100% - 1160px) / 2));
	height: calc(var(--cap-h) - 6px);
	top: calc(var(--cap-gap) - 2px);
}
.nk-s-cap:focus-within { border-color: var(--c-highlight); }

.nk-search .nk-s-input {
	flex: 1;
	min-width: 0;
	width: auto;
	height: 44px;
	min-height: 0;
	margin: 0;
	padding: 0 4px;
	border: 0;
	border-radius: 0;
	background: none;
	color: var(--c-text);
	font: 16px/1.2 var(--f-body);   /* 16px: no iOS zoom */
	-webkit-appearance: none;
	appearance: none;
}
.nk-search .nk-s-input:focus,
.nk-search .nk-s-input:focus-visible { outline: none; border: 0; }
.nk-s-input::placeholder { color: var(--c-muted); opacity: 1; }
.nk-s-input::-webkit-search-cancel-button,
.nk-s-input::-webkit-search-decoration { -webkit-appearance: none; }
.nk-s-clear[hidden] { display: none; }

/* The slash: draws under the capsule once on open, then fades */
.nk-s-slash {
	position: absolute;
	left: 6%;
	right: 6%;
	bottom: -9px;
	height: 2px;
	background: var(--slash);
	box-shadow: 0 0 12px var(--slash);
	opacity: 0;
	transform: skewX(var(--cut)) scaleX(0);
	transform-origin: left center;
	pointer-events: none;
}
.nk-search[data-state="open"] .nk-s-slash { animation: nk-s-slash .5s var(--ease-katana) .08s both; }
@keyframes nk-s-slash {
	0%   { opacity: 1; transform: skewX(var(--cut)) scaleX(0); }
	28%  { opacity: 1; transform: skewX(var(--cut)) scaleX(1); }
	100% { opacity: 0; transform: skewX(var(--cut)) scaleX(1); }
}

/* Body ----------------------------------------------------------------------- */
.nk-s-body {
	max-width: 760px;
	margin: 0 auto;
	padding: 4px var(--gutter, 16px) 48px;
}

.nk-s-sec { margin-top: 18px; }
.nk-s-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nk-s-lbl {
	position: relative;
	margin: 0 0 10px;
	padding-left: 18px;
	color: var(--c-muted);
	font: 600 12px/1.4 var(--f-display);
	letter-spacing: .14em;
	text-transform: uppercase;
}
.nk-s-head .nk-s-lbl { margin-bottom: 0; }
/* A tiny static slash marks every label */
.nk-s-lbl::before {
	content: "";
	position: absolute;
	left: 0;
	top: 50%;
	width: 10px;
	height: 2px;
	background: var(--slash);
	transform: rotate(var(--cut));
}
.nk-s-link {
	min-height: 44px;
	padding: 0 4px;
	border: 0;
	background: none;
	color: var(--c-highlight);
	font: 500 13px var(--f-body);
	cursor: pointer;
}
.nk-s-link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Chips */
.nk-s-scopes,
.nk-s-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.nk-s-scopes { padding-top: 6px; }
.nk-s-chip {
	position: relative;
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 16px;
	border: 1px solid var(--c-line);
	border-radius: 999px;
	background: none;
	color: var(--c-text);
	font: 500 14px var(--f-body);
	line-height: 1.2;
	cursor: pointer;
	transition: background .2s, border-color .2s, color .2s;
}
.nk-s-chip:hover { border-color: var(--c-highlight); color: var(--c-text); }
.nk-s-chip[aria-pressed="true"] {
	background: var(--c-accent);
	border-color: var(--c-accent);
	color: var(--c-accent-ink);
	font-weight: 600;
}
.nk-s-brand {
	font: 600 13px var(--f-display);
	letter-spacing: .08em;
	text-transform: uppercase;
}

/* Sizes */
.nk-s-sizes {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
	gap: 8px;
}
.nk-s-size {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	border: 1px solid var(--c-line);
	border-radius: var(--radius, 4px);
	background: var(--c-surface);
	font-weight: 600;
	font-size: 14px;
	transition: border-color .2s, background .2s;
}
.nk-s-size:hover { border-color: var(--c-highlight); color: var(--c-text); }
.nk-s-size.is-mine {
	border-color: var(--c-highlight);
	color: var(--c-highlight);
	box-shadow: inset 0 0 0 1px var(--c-highlight);
}

/* Results ------------------------------------------------------------------ */
.nk-s-results { margin-top: 14px; }
.nk-s-list { margin: 0; padding: 0; list-style: none; }
.nk-s-opt { border-bottom: 1px solid var(--c-line); }
.nk-s-row {
	position: relative;
	display: grid;
	grid-template-columns: 56px minmax(0, 1fr) auto;
	align-items: center;
	gap: 12px;
	min-height: 76px;
	padding: 10px 10px 10px 12px;
	color: var(--c-text);
	transition: background .15s;
	/* Keyboard scrolling clears the sticky capsule bar */
	scroll-margin-top: calc(var(--cap-offset) + 8px);
	scroll-margin-bottom: 8px;
}
.nk-s-row:hover { color: var(--c-text); }
/* Skewed lavender edge sweeps in on hover / keyboard-active */
.nk-s-row::before {
	content: "";
	position: absolute;
	left: 2px;
	top: 14px;
	bottom: 14px;
	width: 3px;
	background: var(--slash);
	transform: skewY(var(--cut)) scaleY(0);
	transform-origin: top;
	transition: transform .14s var(--ease-katana);
}
.nk-s-row:hover,
.nk-s-row[aria-selected="true"] { background: var(--c-surface); }
.nk-s-row:hover::before,
.nk-s-row[aria-selected="true"]::before { transform: skewY(var(--cut)) scaleY(1); }
.nk-s-row[aria-selected="true"] { outline: 2px solid var(--c-highlight); outline-offset: -2px; }

/* Thumb with the -14deg cut on its top-left corner */
.nk-s-thumb {
	width: 56px;
	height: 56px;
	object-fit: cover;
	background: var(--c-surface-2);
	border-radius: 2px;
	clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 40px);
}
.nk-s-info { min-width: 0; }
.nk-s-title {
	display: block;
	overflow: hidden;
	font-weight: 600;
	font-size: 15px;
	line-height: 1.35;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.nk-s-title mark {
	background: none;
	color: inherit;
	box-shadow: inset 0 -2px 0 var(--c-highlight);
}
.nk-s-stock { display: block; margin-top: 3px; color: var(--c-muted); font-size: 12px; line-height: 1.4; }
.nk-s-stock span,
.nk-s-stock em { margin-left: 4px; }
.nk-s-stock em { font-style: normal; font-weight: 700; color: var(--c-highlight); }
.nk-s-price { font-size: 14px; font-weight: 600; text-align: right; white-space: nowrap; }
.nk-s-price del { display: block; color: var(--c-muted); font-weight: 400; font-size: 12px; }
.nk-s-price ins { text-decoration: none; color: var(--c-highlight); }

/* Results sheathe in sideways, staggered */
.nk-s-list.is-in .nk-s-opt { animation: nk-s-in .24s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms); }
@keyframes nk-s-in {
	from { opacity: 0; transform: translateX(-14px); }
	to   { opacity: 1; transform: none; }
}

/* Skeleton rows while loading */
.nk-s-skel { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; min-height: 76px; padding: 10px 12px; border-bottom: 1px solid var(--c-line); }
.nk-s-skel i { display: block; position: relative; overflow: hidden; border-radius: 2px; background: var(--c-surface); }
.nk-s-skel i:first-child { width: 56px; height: 56px; clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 40px); }
.nk-s-skel i + i { height: 12px; width: 70%; box-shadow: 0 22px 0 -2px var(--c-surface); }
.nk-s-skel i::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(100deg, transparent 20%, rgba(139, 133, 255, .14) 50%, transparent 80%);
	transform: translateX(-100%);
	animation: nk-s-shimmer 1.1s linear infinite;
}
@keyframes nk-s-shimmer { to { transform: translateX(100%); } }

/* Empty + footer */
.nk-s-empty { padding: 26px 0 4px; }
.nk-s-empty-title {
	margin: 0 0 4px;
	font: 600 20px/1.2 var(--f-display);
	text-transform: uppercase;
	overflow-wrap: anywhere;
	text-align: center;
}
.nk-s-empty-hint { margin: 0 0 6px; color: var(--c-muted); font-size: 14px; text-align: center; }
.nk-search .nk-s-all { display: flex; width: 100%; margin-top: 18px; }
.nk-search .nk-s-all[hidden],
.nk-search [hidden] { display: none; }

@media (min-width: 960px) {
	.nk-s-body { padding-top: 10px; }
	.nk-s-title { font-size: 16px; }
}

/* Reduced motion / weak devices: short crossfade, no slash, no stagger ------ */
html.nk-reduced .nk-search,
html.nk-low .nk-search { transform: none; transition: opacity .15s linear, visibility 0s .15s; }
html.nk-reduced .nk-search[data-state="open"],
html.nk-low .nk-search[data-state="open"] { transition: opacity .15s linear, visibility 0s; }
html.nk-reduced .nk-search .nk-s-slash,
html.nk-low .nk-search .nk-s-slash,
html.nk-reduced .nk-s-list.is-in .nk-s-opt,
html.nk-low .nk-s-list.is-in .nk-s-opt,
html.nk-reduced .nk-s-skel i::after,
html.nk-low .nk-s-skel i::after { animation: none; }
html.nk-reduced .nk-s-row::before { transition: none; }

@media (prefers-reduced-motion: reduce) {
	.nk-search { transform: none; transition: opacity .15s linear, visibility 0s .15s; }
	.nk-search[data-state="open"] { transform: none; transition: opacity .15s linear, visibility 0s; }
	.nk-search .nk-s-slash,
	.nk-s-list.is-in .nk-s-opt,
	.nk-s-skel i::after { animation: none; }
	.nk-s-row::before { transition: none; }
}
