/**
 * Kawah Buku Press — header UI.
 *
 * Search overlay and Subjects panel. Measurements are lifted from the main
 * site's child theme so the two behave and read identically; colours resolve
 * through this theme's tokens rather than the literals used there.
 */

/* ==========================================================================
   Search overlay
   ========================================================================== */

.fs-search-overlay {
	position: fixed;
	top: var(--fs-header-offset, 0px);
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 100000;
	box-sizing: border-box;
	background: rgba(255, 255, 255, 0.98);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	overflow-y: auto;
	transition: opacity 260ms ease, visibility 260ms ease;
}

.fs-search-overlay.is-active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* The header stays above the overlay, so the wordmark and nav remain usable
   while searching. */
body.fs-search-open .kb-header { position: relative; z-index: 100001; }
body.fs-search-open { overflow: hidden; }

.fs-search-content {
	width: 100%;
	max-width: 800px;
	margin: 0 auto;
	padding: 40px 20px 56px;
	box-sizing: border-box;
}

.fs-search-bar {
	display: flex;
	align-items: center;
	gap: 14px;
	border-bottom: 1px solid var(--kb-border-hover);
	padding-bottom: 12px;
	transition: border-color 180ms ease;
}
.fs-search-bar:focus-within { border-bottom-color: var(--kb-ink); }

.fs-search-bar-icon { line-height: 0; flex-shrink: 0; color: var(--kb-muted); }

.fs-search-input {
	flex: 1;
	min-width: 0;
	font-family: var(--kb-font-heading);
	/* The main site declares 3rem. At 800px wide that fills most of the line
	   with about four words, which suits a shop where the query is browsing.
	   A catalogue query is usually a known title or an ISBN, and 48px makes
	   a 13-digit number look like a headline. */
	font-size: 30px;
	font-weight: 300;
	line-height: 1.25;
	color: var(--kb-ink);
	border: none;
	background: transparent;
	padding: 0;
	outline: none;
}
.fs-search-input::placeholder { color: #B3AB9C; opacity: 1; }

/* WebKit draws its own clear control inside type=search; two of them side by
   side is worse than none. */
.fs-search-input::-webkit-search-cancel-button,
.fs-search-input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
}

/* The chip empties the field; Cancel closes the overlay. Two different jobs,
   so they are drawn differently. */
.fs-search-clear {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	margin: 0 14px 0 8px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--kb-border-hover);
	color: #fff;
	font-size: 17px;
	line-height: 1;
	cursor: pointer;
}
.fs-search-clear:hover { background: #C9BDA6; }
.fs-search-clear[hidden] { display: none; }

.fs-search-close {
	display: inline-flex;
	align-items: center;
	align-self: center;
	flex-shrink: 0;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	color: var(--kb-body);
	font-family: var(--kb-font-body);
}
.fs-search-close:hover { color: var(--kb-primary-deep); }
.fs-cancel-label { font-size: 15px; letter-spacing: 0.3px; line-height: 1; }


/* --- Empty state --------------------------------------------------------- */

.fs-search-default { margin-top: 32px; width: 100%; }
.fs-search-default.is-hidden { display: none; }

.fs-quicklinks-label {
	font-family: var(--kb-font-heading);
	font-size: 12px;
	letter-spacing: 1px;
	text-transform: uppercase;
	color: var(--kb-muted);
	margin: 0 0 4px;
}

.fs-quicklink {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 0;
	border-bottom: 1px solid var(--kb-border);
	text-decoration: none;
	color: var(--kb-ink);
	font-size: 16px;
	transition: color 180ms ease;
}
.fs-quicklink:last-child { border-bottom: none; }
.fs-quicklink:hover { color: var(--kb-primary-deep); text-decoration: none; }

.fs-quicklink-chevron {
	color: var(--kb-border-hover);
	flex-shrink: 0;
	transition: transform 180ms ease, color 180ms ease;
}
.fs-quicklink:hover .fs-quicklink-chevron {
	color: var(--kb-primary-deep);
	transform: translateX(3px);
}


/* --- Results ------------------------------------------------------------- */

.fs-search-results { margin-top: 32px; width: 100%; }

.fs-results-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 16px;
	margin-bottom: 24px;
}

.fs-result-item {
	display: flex;
	align-items: center;
	background: var(--kb-surface);
	border: 1px solid var(--kb-border);
	padding: 10px;
	border-radius: 4px;
	text-decoration: none !important;
	transition: background-color 160ms ease, border-color 160ms ease;
}
.fs-result-item:hover {
	background: #EFEAE0;
	border-color: var(--kb-border-hover);
}

/* Covers are portrait. A 60px square would crop every one of them. */
.fs-item-image {
	position: relative;
	width: 48px;
	height: 68px;
	flex-shrink: 0;
	margin-right: 14px;
	background: var(--kb-border);
}
.fs-item-image img {
	width: 48px;
	height: 68px;
	object-fit: cover;
	display: block;
}
.fs-item-placeholder { display: block; width: 100%; height: 100%; }

.fs-item-details { min-width: 0; }
.fs-item-details h4 {
	margin: 0 0 4px;
	font-family: var(--kb-font-heading);
	font-size: 15px;
	font-weight: 500;
	line-height: 1.25;
	color: var(--kb-ink);
}
.fs-item-price { font-size: 13px; color: var(--kb-body); line-height: 1.35; }

.fs-no-results,
.fs-error-text {
	text-align: center;
	font-size: 17px;
	color: var(--kb-body);
	padding: 24px 0;
}

.fs-actions {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	flex-wrap: wrap;
	margin-top: 18px;
}
.fs-view-all-btn {
	background: none;
	border: none;
	color: var(--kb-primary-deep);
	font-family: var(--kb-font-heading);
	font-size: 16px;
	cursor: pointer;
	text-decoration: none;
}
.fs-view-all-btn:hover { color: var(--kb-ink); text-decoration: underline; }


/* ==========================================================================
   Subjects panel
   ========================================================================== */

.kb-subjects-panel {
	position: fixed;
	top: 0;          /* replaced inline by the script on open */
	left: 0;
	right: 0;
	z-index: 999;
	background: var(--kb-card);
	border-bottom: 1px solid var(--kb-border);
	box-shadow: 0 18px 40px -24px rgba(23, 20, 15, 0.35);
	max-height: calc(100vh - var(--kb-topbar-min, 36px));
	overflow-y: auto;
}
.kb-subjects-panel[hidden] { display: none; }

.kb-subjects-panel__inner {
	max-width: var(--kb-max);
	margin-inline: auto;
	padding: 40px var(--kb-gutter) 32px;
}

/* The main site uses column-count over a flat list of 27. Eleven terms in
   two named groups read better as real columns, and it gives Fiction and
   Non-fiction somewhere to live — they carry no books directly, so their
   own archives are not worth sending anyone to. */
.kb-subjects-panel__cols {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 34px;
}

.kb-subjects-panel__group { min-width: 0; }

.kb-subjects-panel__parent {
	display: block;
	font-family: var(--kb-font-heading);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--kb-muted);
	text-decoration: none;
	margin-bottom: 12px;
}
.kb-subjects-panel__parent:hover { color: var(--kb-primary-deep); }

.kb-subjects-panel__cols a {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	font-size: 15px;
	font-weight: 400;
	line-height: 1.4;
	padding: 5px 0;
	color: var(--kb-ink);
	text-decoration: none;
}
.kb-subjects-panel__cols a:hover {
	color: var(--kb-primary-deep);
	text-decoration: none;
}

.kb-subjects-panel__count {
	font-size: 12px;
	color: var(--kb-muted);
	font-variant-numeric: tabular-nums;
	flex: none;
}

.kb-subjects-panel__foot {
	margin-top: 28px;
	padding-top: 18px;
	border-top: 1px solid var(--kb-border);
}
.kb-subjects-panel__foot a {
	font-family: var(--kb-font-heading);
	font-size: 15px;
	color: var(--kb-primary-deep);
	text-decoration: none;
}
.kb-subjects-panel__foot a:hover { text-decoration: underline; }


/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 781px) {
	.fs-search-content { padding: 28px 20px 40px; }
	.fs-search-input { font-size: 20px; }
	.fs-search-bar-icon svg { width: 19px; height: 19px; }

	/* Cancel is redundant when Escape and the back gesture both work, and it
	   competes with the clear chip for the same corner. */
	.fs-search-close { display: none; }

	.fs-search-default { margin-top: 24px; }
	.fs-quicklinks-label { margin-bottom: 2px; }
	.fs-quicklink { font-size: 15px; padding: 13px 0; }

	.fs-results-grid { grid-template-columns: 1fr; }

	.kb-subjects-panel__inner { padding: 28px var(--kb-gutter) 24px; }
	.kb-subjects-panel__cols { gap: 22px; }
}

@media (prefers-reduced-motion: reduce) {
	.fs-search-overlay { transition: none; }
}
