/* =========================================================================
   Fast Publish Journal — header search
   Mobile header: menu (left), logo (centre), search (right). The search
   button opens a native <dialog> with live AJAX results from the journal
   directory. Loaded after main.css on every page.
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Search trigger + mobile header geometry
   ---------------------------------------------------------------------- */
.search-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	background: transparent;
	color: var(--navy-900);
	cursor: pointer;
	transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
		color 0.18s var(--ease);
}

.search-toggle:hover {
	border-color: var(--navy-800);
	background: var(--cream-100);
	color: var(--navy-900);
}

.search-toggle .icon {
	width: 19px;
	height: 19px;
}

@media (max-width: 900px) {
	.header__inner {
		display: grid;
		grid-template-columns: 42px minmax(0, 1fr) 42px;
		align-items: center;
		gap: 8px;
		min-height: 64px;
	}

	.nav-toggle {
		grid-column: 1;
		grid-row: 1;
		justify-self: start;
		display: inline-flex;
	}

	.brand {
		grid-column: 2;
		grid-row: 1;
		justify-self: center;
	}

	.brand__logo {
		height: 42px;
	}

	.header__actions {
		grid-column: 3;
		grid-row: 1;
		justify-self: end;
		gap: 0;
	}

	.header__actions .btn {
		display: none;
	}

	.search-toggle {
		display: inline-flex;
	}

	.nav {
		grid-column: 1 / -1;
	}
}

@media (max-width: 560px) {
	.header__inner {
		grid-template-columns: 38px minmax(0, 1fr) 38px;
	}

	.nav-toggle,
	.search-toggle {
		width: 38px;
		height: 38px;
	}

	.brand__logo {
		height: 40px;
	}
}

@media (max-width: 480px) {
	.brand__logo {
		height: 38px;
	}
}

body.search-open {
	overflow: hidden;
}

/* -------------------------------------------------------------------------
   2. The dialog shell
   ---------------------------------------------------------------------- */
.searchmodal {
	position: fixed;
	inset: 0;
	z-index: 120;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--ink);
	overflow: hidden;
}

.searchmodal[open] {
	display: flex;
	align-items: flex-start;
	justify-content: center;
}

.searchmodal::backdrop {
	background: rgba(8, 24, 44, 0.58);
	-webkit-backdrop-filter: blur(3px);
	        backdrop-filter: blur(3px);
}

.searchmodal__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(680px, calc(100% - 32px));
	max-height: min(80vh, 720px);
	margin-top: 8vh;
	overflow: hidden;
	border: 1px solid var(--line);
	border-radius: 18px;
	background: var(--cream-50);
	box-shadow: 0 40px 90px -40px rgba(8, 24, 44, 0.7);
}

.searchmodal__head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	padding: 22px 24px 0;
}

.searchmodal__head .eyebrow {
	margin-bottom: 0.45rem;
}

.searchmodal__title {
	margin: 0;
	font-size: 1.6rem;
	line-height: 1.15;
}

.searchmodal__close {
	display: grid;
	place-items: center;
	flex: none;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 1px solid var(--line);
	border-radius: 50%;
	background: transparent;
	color: var(--navy-800);
	cursor: pointer;
	transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}

.searchmodal__close:hover {
	border-color: var(--navy-800);
	background: var(--cream-100);
}

/* -------------------------------------------------------------------------
   3. Search field
   ---------------------------------------------------------------------- */
.searchmodal__form {
	padding: 16px 24px 0;
}

.searchmodal__label {
	display: block;
	color: var(--muted);
	font-size: 0.72rem;
	line-height: 1.4;
}

.searchmodal__field {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 7px;
	padding: 0 12px;
	border: 1px solid var(--line-strong);
	border-radius: 10px;
	background: #fff;
	transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.searchmodal__field:focus-within {
	border-color: var(--brass);
	box-shadow: 0 0 0 3px rgba(176, 141, 87, 0.16);
}

.searchmodal__field > .icon {
	flex: none;
	color: var(--muted);
}

.searchmodal__field input {
	flex: 1;
	min-width: 0;
	padding: 13px 0;
	border: 0;
	background: transparent;
	color: var(--ink);
	font: inherit;
	font-size: 0.98rem;
	outline: none;
}

.searchmodal__field input::placeholder {
	color: #8a8f96;
}

/* The browser's native clear button is blue and clashes with the palette. */
.searchmodal__field input[type="search"]::-webkit-search-cancel-button,
.searchmodal__field input[type="search"]::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
	display: none;
}

.searchmodal__spinner {
	flex: none;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(10, 31, 60, 0.18);
	border-top-color: var(--navy-800);
	border-radius: 50%;
	animation: fpj-search-spin 0.7s linear infinite;
}

.searchmodal__spinner[hidden] {
	display: none;
}

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

.searchmodal__hint {
	margin: 7px 0 0;
	color: var(--muted);
	font-size: 0.71rem;
	line-height: 1.5;
}

/* -------------------------------------------------------------------------
   4. Results
   ---------------------------------------------------------------------- */
.searchmodal__results {
	flex: 1;
	min-height: 120px;
	max-height: 50vh;
	overflow-y: auto;
	padding: 10px 16px 4px;
	overscroll-behavior: contain;
}

.searchmodal__results[aria-busy="true"] {
	opacity: 0.7;
}

.sresults {
	margin: 0;
	padding: 0;
	list-style: none;
}

.sresult + .sresult {
	border-top: 1px solid var(--line);
}

.sresult__link {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 14px;
	padding: 12px 8px;
	border-radius: 8px;
	color: inherit;
	text-decoration: none;
	transition: background 0.16s var(--ease);
}

.sresult__link:hover {
	background: var(--cream-100);
}

.sresult__body {
	min-width: 0;
}

.sresult__name {
	display: block;
	color: var(--navy-900);
	font-family: var(--font-serif);
	font-size: 0.98rem;
	font-weight: 600;
	line-height: 1.3;
	transition: color 0.16s var(--ease);
}

.sresult__link:hover .sresult__name {
	color: var(--brass-dark);
}

.sresult__meta {
	display: block;
	margin-top: 2px;
	color: var(--muted);
	font-size: 0.72rem;
	line-height: 1.4;
}

.sresult__badges {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin-top: 6px;
}

.sresult__badge {
	padding: 2px 6px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: #fff;
	color: var(--ink-soft);
	font-size: 0.61rem;
	line-height: 1.5;
}

.sresult__side {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	flex: none;
	gap: 6px;
	color: var(--muted);
}

.sresult__fee {
	color: var(--navy-800);
	font-size: 0.72rem;
	font-weight: 600;
	white-space: nowrap;
}

.searchmodal__empty {
	margin: 0;
	padding: 28px 8px;
	color: var(--muted);
	font-size: 0.86rem;
	line-height: 1.6;
	text-align: center;
}

/* -------------------------------------------------------------------------
   5. Footer of the dialog
   ---------------------------------------------------------------------- */
.searchmodal__foot {
	display: flex;
	align-items: center;
	gap: 1rem;
	min-height: 54px;
	padding: 12px 24px 18px;
	border-top: 1px solid var(--line);
}

.searchmodal__all {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	border-bottom: 1px solid var(--brass-soft);
	color: var(--navy-800);
	font-size: 0.8rem;
	font-weight: 600;
	text-decoration: none;
}

.searchmodal__all[hidden] {
	display: none;
}

.searchmodal__all:hover {
	border-color: var(--brass);
	color: var(--brass-dark);
}

.searchmodal__count {
	margin-left: auto;
	color: var(--muted);
	font-size: 0.72rem;
	white-space: nowrap;
}

/* -------------------------------------------------------------------------
   6. Small screens: the dialog becomes a full-height sheet
   ---------------------------------------------------------------------- */
@media (max-width: 640px) {
	.searchmodal[open] {
		align-items: stretch;
	}

	.searchmodal__panel {
		width: 100%;
		height: 100%;
		max-height: none;
		margin-top: 0;
		border: 0;
		border-radius: 0;
	}

	.searchmodal__head {
		padding: 18px 18px 0;
	}

	.searchmodal__form {
		padding: 14px 18px 0;
	}

	.searchmodal__results {
		max-height: none;
		padding: 10px 10px 4px;
	}

	.searchmodal__foot {
		padding: 12px 18px 18px;
	}

	.sresult__link {
		padding: 12px 8px;
	}
}

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