/**
 * DH Search.
 *
 * Everything here is existing Denimhunters vocabulary: the #c98f69 accent, the
 * rgba(50,65,84,.5) darkening used on post banners, the #f6f6f6 panel, and the
 * uppercase wide-tracked label treatment from the site's buttons. Typography
 * is inherited from Astra rather than declared, so a global type change flows
 * through here without a second edit.
 *
 * The one signature element is the selvedge rule — a 2px accent line on the
 * left edge of the active row. It's the same mark used on the category cards,
 * so the modal reads as part of the site rather than as a bolted-on widget.
 */

:root {
	--dhs-accent: #c98f69;
	--dhs-ink: #111111;
	--dhs-body: #5b5e5e;
	--dhs-panel: #f6f6f6;
	--dhs-line: #e4e4e4;
	--dhs-white: #ffffff;
	--dhs-scrim: rgba( 50, 65, 84, 0.5 );
}

/* ------------------------------------------------------------------ shell */

.dhs {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	justify-content: center;
	align-items: flex-start;
}

.dhs[hidden] {
	display: none;
}

body.dhs-open {
	position: fixed;
	width: 100%;
	overflow: hidden;
}

.dhs__scrim {
	position: absolute;
	inset: 0;
	background: var( --dhs-scrim );
	backdrop-filter: blur( 3px );
	animation: dhs-fade 160ms ease-out;
}

.dhs__panel {
	position: relative;
	width: min( 640px, calc( 100vw - 32px ) );
	margin-top: min( 12vh, 96px );
	max-height: min( 640px, calc( 100vh - 24vh ) );
	display: flex;
	flex-direction: column;
	background: var( --dhs-white );
	border-radius: 4px;
	box-shadow: 0 24px 64px rgba( 17, 17, 17, 0.28 );
	overflow: hidden;
	animation: dhs-rise 180ms cubic-bezier( 0.2, 0.7, 0.3, 1 );
}

@keyframes dhs-fade {
	from { opacity: 0; }
}

@keyframes dhs-rise {
	from { opacity: 0; transform: translateY( 8px ); }
}

@media ( prefers-reduced-motion: reduce ) {
	.dhs__scrim,
	.dhs__panel {
		animation: none;
	}
}

/* -------------------------------------------------------------- input bar */

.dhs__bar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 0 20px;
	border-bottom: 1px solid var( --dhs-line );
	flex: 0 0 auto;
}

.dhs__glass {
	width: 20px;
	height: 20px;
	flex: 0 0 auto;
	color: var( --dhs-body );
}

.dhs__input {
	flex: 1 1 auto;
	border: 0;
	outline: 0;
	background: transparent;
	padding: 20px 0;
	font-size: 17px;
	line-height: 1.4;
	color: var( --dhs-ink );
	box-shadow: none;
}

.dhs__input::placeholder {
	color: #9a9a9a;
}

.dhs__input::-webkit-search-cancel-button {
	display: none;
}

.dhs__clear {
	flex: 0 0 auto;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var( --dhs-panel );
	color: var( --dhs-body );
	cursor: pointer;
	display: grid;
	place-items: center;
}

.dhs__clear svg {
	width: 16px;
	height: 16px;
}

.dhs__clear:hover {
	background: #ececec;
	color: var( --dhs-ink );
}

/* ----------------------------------------------------------------- results */

.dhs__body {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 8px 0;
}

.dhs__group + .dhs__group {
	border-top: 1px solid var( --dhs-line );
	margin-top: 8px;
	padding-top: 8px;
}

.dhs__grouphead {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 20px 6px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var( --dhs-body );
}

.dhs__count {
	color: var( --dhs-accent );
	letter-spacing: 0;
}

.dhs__row {
	position: relative;
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 10px 20px;
	text-decoration: none;
	color: inherit;
	cursor: pointer;
}

/* The selvedge rule. Same mark as the category cards. */
.dhs__row::before {
	content: "";
	position: absolute;
	left: 0;
	top: 6px;
	bottom: 6px;
	width: 2px;
	background: var( --dhs-accent );
	transform: scaleY( 0 );
	transform-origin: center;
	transition: transform 140ms ease-out;
}

.dhs__row.is-active {
	background: var( --dhs-panel );
}

.dhs__row.is-active::before {
	transform: scaleY( 1 );
}

@media ( prefers-reduced-motion: reduce ) {
	.dhs__row::before {
		transition: none;
	}
}

.dhs__thumb {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	border-radius: 2px;
	overflow: hidden;
	background: var( --dhs-panel );
}

.dhs__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.dhs__thumb--letter {
	display: grid;
	place-items: center;
	background: var( --dhs-ink );
	color: var( --dhs-white );
	font-size: 15px;
	font-weight: 700;
}

.dhs__text {
	flex: 1 1 auto;
	min-width: 0;
}

.dhs__title {
	display: block;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35;
	color: var( --dhs-ink );
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.dhs__title mark {
	background: transparent;
	color: inherit;
	font-weight: 800;
	box-shadow: 0 -2px 0 0 var( --dhs-accent ) inset;
}

.dhs__meta {
	display: block;
	margin-top: 2px;
	font-size: 12.5px;
	line-height: 1.35;
	color: var( --dhs-body );
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.dhs__tag {
	flex: 0 0 auto;
	padding: 4px 9px;
	border: 1px solid var( --dhs-line );
	border-radius: 2px;
	font-size: 9.5px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var( --dhs-body );
	white-space: nowrap;
}

.dhs__row.is-active .dhs__tag {
	border-color: var( --dhs-accent );
	color: var( --dhs-accent );
}

/* --------------------------------------------------------------- see all */

.dhs__row--all {
	justify-content: space-between;
	margin-top: 4px;
	border-top: 1px solid var( --dhs-line );
	padding-top: 14px;
	padding-bottom: 14px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.04em;
	color: var( --dhs-ink );
}

.dhs__arrow {
	color: var( --dhs-accent );
	font-size: 15px;
}

/* ----------------------------------------------------------------- pills */

.dhs__pills {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 4px 20px 12px;
}

.dhs__pill {
	padding: 7px 14px;
	border: 1px solid var( --dhs-line );
	border-radius: 2px;
	background: var( --dhs-panel );
	font-size: 12.5px;
	font-weight: 600;
	color: var( --dhs-ink );
	text-decoration: none;
	cursor: pointer;
}

.dhs__pill:hover,
.dhs__pill.is-active {
	border-color: var( --dhs-accent );
	background: var( --dhs-white );
	color: var( --dhs-ink );
}

/* ----------------------------------------------------------------- empty */

.dhs__empty {
	padding: 28px 20px 8px;
	text-align: center;
}

.dhs__emptytitle {
	margin: 0 0 6px;
	font-size: 15px;
	font-weight: 700;
	color: var( --dhs-ink );
}

.dhs__emptybody {
	margin: 0 0 18px;
	font-size: 13.5px;
	color: var( --dhs-body );
}

.dhs__empty .dhs__row--all {
	text-align: left;
}

/* ------------------------------------------------------------------ foot */

.dhs__foot {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 10px 20px;
	border-top: 1px solid var( --dhs-line );
	background: var( --dhs-panel );
	font-size: 11.5px;
	color: var( --dhs-body );
}

.dhs__keys {
	display: inline-flex;
	align-items: center;
	gap: 5px;
}

.dhs__foot kbd {
	display: inline-grid;
	place-items: center;
	min-width: 19px;
	height: 19px;
	padding: 0 4px;
	border: 1px solid var( --dhs-line );
	border-radius: 2px;
	background: var( --dhs-white );
	font-family: inherit;
	font-size: 10.5px;
	line-height: 1;
	color: var( --dhs-ink );
}

.dhs__hint {
	margin-left: auto;
}

.dhs__live {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	white-space: nowrap;
}

/* -------------------------------------------------------------- trigger */

.dhs-trigger {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 11px 16px;
	border: 1px solid var( --dhs-line );
	border-radius: 2px;
	background: var( --dhs-panel );
	color: var( --dhs-body );
	font-size: 14px;
	cursor: pointer;
}

.dhs-trigger svg {
	width: 17px;
	height: 17px;
}

.dhs-trigger:hover {
	border-color: var( --dhs-accent );
	color: var( --dhs-ink );
}

.dhs-trigger--field {
	width: 100%;
	max-width: 420px;
	justify-content: flex-start;
}

.dhs-trigger--button {
	background: var( --dhs-ink );
	border-color: var( --dhs-ink );
	color: var( --dhs-white );
	text-transform: uppercase;
	font-weight: 700;
	letter-spacing: 0.18em;
	font-size: 11.5px;
}

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

.dhs :focus-visible {
	outline: 2px solid var( --dhs-accent );
	outline-offset: 2px;
}

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

@media ( max-width: 600px ) {
	.dhs__panel {
		width: 100vw;
		max-width: none;
		height: 100dvh;
		max-height: none;
		margin-top: 0;
		border-radius: 0;
	}

	.dhs__bar {
		padding: 0 16px;
	}

	.dhs__input {
		/* 16px minimum or iOS zooms the viewport on focus. */
		font-size: 16px;
		padding: 16px 0;
	}

	.dhs__row,
	.dhs__grouphead,
	.dhs__pills {
		padding-left: 16px;
		padding-right: 16px;
	}

	.dhs__tag {
		display: none;
	}

	.dhs__foot {
		display: none;
	}
}
