/*
 * search.css
 *
 * Styles for all search components:
 *   .gwill-search-expand  — Combo A: expandable header search
 *   .gwill-search-modal   — Combo B: full-viewport modal + live results
 *   .search-results       — search.php results page
 *   .search-no-results    — no-results state
 *
 * Design tokens used (with fallbacks):
 *   --color-primary, --color-accent, --color-bg, --color-muted,
 *   --color-border, --color-border-input, --color-error,
 *   --font-base, --spacing, --form-radius
 *
 * @package GWill_Starter
 * @since   1.0.23
 */


/* ═══════════════════════════════════════════════════════════════════════
   COMBO A — EXPANDABLE HEADER SEARCH
   Three-zone layout: [ icon | input | Search ]
   One outer border, two internal vertical dividers. No input box border.
   ═══════════════════════════════════════════════════════════════════════ */

.gwill-search-expand {
	position: relative;
	display: flex;
	align-items: center;
}

/* Toggle button */
.gwill-search-expand__toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: var(--form-radius, 4px);
	color: var(--color-primary, #111);
	cursor: pointer;
	transition: color 0.15s ease;
}

.gwill-search-expand__toggle:hover        { color: var(--color-accent, #2563eb); }
.gwill-search-expand__toggle:focus-visible {
	outline: 2px solid var(--color-accent, #2563eb);
	outline-offset: 2px;
}

/* Icon switching */
.gwill-search-expand__icon--close  { display: none; }
.gwill-search-expand__icon--search { display: block; }
.gwill-search-expand.is-open .gwill-search-expand__icon--close  { display: block; }
.gwill-search-expand.is-open .gwill-search-expand__icon--search { display: none; }

/* ── Form container ──────────────────────────────────────────────────── */

.gwill-search-expand__form {
	display: none;
	align-items: stretch;
	position: fixed;
	top: var(--gwill-header-height, 64px);
	right: 1rem;
	min-width: 340px;
	max-width: 480px;
	background: var(--color-bg, #fff);
	border: 1px solid var(--color-border-input, #6b7280);
	border-radius: calc(var(--form-radius, 4px) + 2px);
	box-shadow:
		0 4px 6px -1px rgba(0, 0, 0, 0.07),
		0 12px 28px -4px rgba(0, 0, 0, 0.12);
	overflow: hidden;
	z-index: 9100;
}

.gwill-search-expand.is-open .gwill-search-expand__form {
	display: flex;
	animation: gwill-search-drop 0.16s ease forwards;
}

@keyframes gwill-search-drop {
	from { opacity: 0; transform: translateY(-8px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* Mobile: full viewport width, flush edges, no side/top border */
@media (max-width: 640px) {
	.gwill-search-expand__form {
		right: 0;
		left: 0;
		max-width: none;
		min-width: unset;
		border-radius: 0;
		border-left: none;
		border-right: none;
		border-top: none;
		box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
	}
}

/* ── Zone 1: icon ────────────────────────────────────────────────────── */

.gwill-search-expand__zone-icon {
	display: flex;
	align-items: center;
	flex-shrink: 0;
	padding: 0 0.8rem;
	color: var(--color-muted, #6b7280);
}

/* ── Zone 2: input (border-left = first vertical divider) ────────────── */

.gwill-search-expand__zone-input {
	flex: 1;
	display: flex;
	align-items: center;
	min-width: 0;
	border-left: 1px solid var(--color-border, #e5e7eb);
}

.gwill-search-expand__input {
	width: 100%;
	padding: 0.75rem 0.65rem;
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 1rem;
	color: var(--color-primary, #111);
	background: transparent;
	/* Nuclear suppression — Android Chrome UA stylesheet applies a blue ring
	   to input[type="search"] on focus that survives outline:none alone.
	   All focus styling intentionally moved to the container, not the input. */
	border: none !important;
	outline: none !important;
	outline-width: 0 !important;
	box-shadow: none !important;
	-webkit-box-shadow: none !important;
	-webkit-tap-highlight-color: transparent !important;
	-webkit-appearance: none;
	appearance: none;
}

.gwill-search-expand__input:focus,
.gwill-search-expand__input:focus-visible,
.gwill-search-expand__input:active {
	border: none !important;
	outline: none !important;
	box-shadow: none !important;
	-webkit-box-shadow: none !important;
}

.gwill-search-expand__input::placeholder         { color: var(--color-muted, #6b7280); }
.gwill-search-expand__input::-webkit-search-cancel-button,
.gwill-search-expand__input::-webkit-search-decoration { display: none; }

/* ── Zone 3: submit button (border-left = second vertical divider) ───── */

.gwill-search-expand__submit {
	flex-shrink: 0;
	align-self: stretch;
	padding: 0 1.25rem;
	background: var(--color-btn-bg);
	color: var(--color-btn-text);
	border: none;
	border-left: 1px solid var(--color-border, #e5e7eb);
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.9375rem;
	font-weight: 600;
	letter-spacing: 0.01em;
	cursor: pointer;
	white-space: nowrap;
	transition: opacity 0.15s ease;
}

.gwill-search-expand__submit:hover        { opacity: 0.82; }
.gwill-search-expand__submit:focus-visible {
	outline: 2px solid var(--color-accent, #2563eb);
	outline-offset: -3px;
}

/* ═══════════════════════════════════════════════════════════════════════
   COMBO B — MODAL OVERLAY + LIVE SEARCH
   ═══════════════════════════════════════════════════════════════════════ */

/* Trigger button — identical to expandable toggle */
.gwill-search-modal__trigger {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	background: transparent;
	border: none;
	border-radius: var(--form-radius, 4px);
	color: var(--color-primary, #111);
	cursor: pointer;
	transition: color 0.15s ease;
}

.gwill-search-modal__trigger:hover { color: var(--color-accent, #2563eb); }
.gwill-search-modal__trigger:focus-visible {
	outline: 2px solid var(--color-accent, #2563eb);
	outline-offset: 2px;
}

/* The overlay — full viewport */
.gwill-search-modal {
	position: fixed;
	inset: 0;
	z-index: 9000;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding-top: clamp(3rem, 8vh, 6rem);
}

/* Backdrop */
.gwill-search-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
	cursor: pointer;
}

/* Panel — the search card above the backdrop */
.gwill-search-modal__panel {
	position: relative;
	z-index: 1;
	width: min(640px, calc(100vw - 2rem));
	background: var(--color-bg, #fff);
	border-radius: calc(var(--form-radius, 4px) * 2);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.08);
	overflow: hidden;
	/* Slide in from top */
	animation: gwill-modal-in 0.2s ease forwards;
}

@keyframes gwill-modal-in {
	from { opacity: 0; transform: translateY(-12px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* Input row */
.gwill-search-modal__input-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.875rem 1rem;
	border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.gwill-search-modal__input-icon {
	flex-shrink: 0;
	color: var(--color-muted, #6b7280);
}

.gwill-search-modal__input {
	flex: 1;
	min-width: 0;
	padding: 0;
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 1.0625rem;
	color: var(--color-primary, #111);
	background: transparent;
	border: none;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.gwill-search-modal__input::placeholder { color: var(--color-muted, #6b7280); }
.gwill-search-modal__input::-webkit-search-cancel-button { display: none; }

/* Clear button */
.gwill-search-modal__clear {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 1.75rem;
	height: 1.75rem;
	padding: 0;
	background: var(--color-border, #e5e7eb);
	border: none;
	border-radius: 50%;
	color: var(--color-muted, #6b7280);
	cursor: pointer;
	transition: background 0.15s ease;
}

.gwill-search-modal__clear:hover { background: #d1d5db; }

/* Close button — top-right of the panel */
.gwill-search-modal__close {
	position: absolute;
	top: 0.625rem;
	right: 0.75rem;
	display: flex;
	align-items: center;
	gap: 0.25rem;
	padding: 0.25rem 0.5rem;
	background: transparent;
	border: none;
	border-radius: var(--form-radius, 4px);
	color: var(--color-muted, #6b7280);
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.75rem;
	cursor: pointer;
	transition: color 0.15s ease;
}

.gwill-search-modal__close:hover { color: var(--color-primary, #111); }
.gwill-search-modal__close:focus-visible {
	outline: 2px solid var(--color-accent, #2563eb);
	outline-offset: 2px;
}

.gwill-search-modal__esc-hint {
	padding: 0.125rem 0.3rem;
	background: var(--color-border, #e5e7eb);
	border-radius: 3px;
	font-size: 0.6875rem;
	letter-spacing: 0.02em;
}

/* Results container */
.gwill-search-modal__results {
	max-height: min(360px, 50vh);
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* Status message (loading, no results, error) */
.gwill-search-modal__status {
	padding: 1.25rem 1rem;
	margin: 0;
	color: var(--color-muted, #6b7280);
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.9375rem;
	text-align: center;
}

/* Individual result row */
.gwill-search-modal__result {
	display: grid;
	grid-template-areas:
		"title type"
		"excerpt excerpt";
	grid-template-columns: 1fr auto;
	gap: 0.15rem 0.75rem;
	padding: 0.75rem 1rem;
	text-decoration: none;
	border-bottom: 1px solid var(--color-border, #e5e7eb);
	transition: background 0.1s ease;
}

.gwill-search-modal__result:last-of-type {
	border-bottom: none;
}

.gwill-search-modal__result:hover,
.gwill-search-modal__result[aria-selected="true"] {
	background: #f3f4f6;
	outline: none;
}

.gwill-search-modal__result:focus-visible {
	outline: 2px solid var(--color-accent, #2563eb);
	outline-offset: -2px;
}

.gwill-search-modal__result-title {
	grid-area: title;
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.9375rem;
	font-weight: 500;
	color: var(--color-primary, #111);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.gwill-search-modal__result-type {
	grid-area: type;
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.6875rem;
	font-weight: 500;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--color-accent, #2563eb);
	white-space: nowrap;
	align-self: center;
}

.gwill-search-modal__result-excerpt {
	grid-area: excerpt;
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.8125rem;
	color: var(--color-muted, #6b7280);
	line-height: 1.4;
	/* Clamp to 2 lines */
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
}

/* "View all results" footer link */
.gwill-search-modal__view-all {
	display: block;
	padding: 0.75rem 1rem;
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.875rem;
	font-weight: 500;
	color: var(--color-accent, #2563eb);
	text-decoration: none;
	text-align: center;
	border-top: 1px solid var(--color-border, #e5e7eb);
	transition: background 0.1s ease;
}

.gwill-search-modal__view-all:hover { background: #f3f4f6; }
.gwill-search-modal__view-all:focus-visible {
	outline: 2px solid var(--color-accent, #2563eb);
	outline-offset: -2px;
}


/* ═══════════════════════════════════════════════════════════════════════
   SEARCH RESULTS PAGE (search.php)
   ═══════════════════════════════════════════════════════════════════════ */

.search-results {
	padding-block: var(--spacing, 1.5rem);
}

.search-results__header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	padding-bottom: var(--spacing, 1.5rem);
	border-bottom: 1px solid var(--color-border, #e5e7eb);
	margin-bottom: calc(var(--spacing, 1.5rem) * 1.5);
}

.search-results__title {
	margin: 0;
	font-size: clamp(1.25rem, 3vw, 1.75rem);
	font-family: var(--font-base, system-ui, sans-serif);
	font-weight: 700;
	color: var(--color-primary, #111);
}

/* The native get_search_form() output */
.search-results__header .search-form {
	display: flex;
	gap: 0.5rem;
}

.search-results__header .search-field {
	padding: 0.45rem 0.75rem;
	border: 1px solid var(--color-border-input, #6b7280);
	border-radius: var(--form-radius, 4px);
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.9375rem;
	-webkit-appearance: none;
	appearance: none;
}

/* Suppress browser-injected focus ring on the results page search field.
   Android Chrome applies a UA outline to input[type="search"] that survives
   outline:none alone — same treatment as .gwill-search-expand__input. */
.search-results__header .search-field,
.search-results__header .search-field:focus,
.search-results__header .search-field:focus-visible,
.search-results__header .search-field:active {
	outline: none !important;
	outline-width: 0 !important;
	box-shadow: none !important;
	-webkit-box-shadow: none !important;
	-webkit-tap-highlight-color: transparent !important;
}

.search-results__header .search-submit {
	padding: 0.45rem 1rem;
	background: var(--color-btn-bg);
	color: var(--color-btn-text);
	border: none;
	border-radius: var(--form-radius, 4px);
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.9375rem;
	cursor: pointer;
	transition: opacity 0.15s ease;
}

.search-results__header .search-submit:hover { opacity: 0.85; }

/* Results list */
.search-results__list {
	display: flex;
	flex-direction: column;
	gap: 2rem;
}

/* Individual result */
.search-result {
	padding-bottom: 2rem;
	border-bottom: 1px solid var(--color-border, #e5e7eb);
}

.search-result:last-child { border-bottom: none; }

.search-result__meta {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 0.4rem;
}

.search-result__type-badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--color-accent, #2563eb);
	background: rgba(37, 99, 235, 0.07);
	border-radius: 3px;
}

.search-result__date {
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.875rem;
	color: var(--color-muted, #6b7280);
}

.search-result__title {
	margin: 0 0 0.5rem;
	font-size: clamp(1.0625rem, 2.5vw, 1.25rem);
	line-height: 1.3;
}

.search-result__title a {
	color: var(--color-primary, #111);
	text-decoration: none;
}

.search-result__title a:hover { color: var(--color-accent, #2563eb); }

.search-result__excerpt {
	margin: 0;
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.9375rem;
	line-height: 1.6;
	color: var(--color-muted, #6b7280);
}

/* Pagination */
.search-results__pagination {
	margin-top: calc(var(--spacing, 1.5rem) * 2);
}

.search-results__pagination .nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	justify-content: center;
}

.search-results__pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.25rem;
	height: 2.25rem;
	padding: 0 0.75rem;
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.9375rem;
	color: var(--color-primary, #111);
	text-decoration: none;
	border: 1px solid var(--color-border, #e5e7eb);
	border-radius: var(--form-radius, 4px);
	transition: background 0.15s ease, border-color 0.15s ease;
}

.search-results__pagination .page-numbers:hover {
	background: var(--color-border);
	border-color: var(--color-border-input);
}

/* Current page uses btn tokens — correct in both light (#2563eb bg, #fff text)
   and dark (#60a5fa bg, #0f172a text) with no darkmode.css override needed. */
.search-results__pagination .page-numbers.current {
	background: var(--color-btn-bg);
	color: var(--color-btn-text);
	border-color: var(--color-btn-bg);
	cursor: default;
}

.search-results__pagination .page-numbers.dots {
	border: none;
	pointer-events: none;
}


/* ═══════════════════════════════════════════════════════════════════════
   NO-RESULTS STATE
   ═══════════════════════════════════════════════════════════════════════ */

.search-no-results {
	padding: 3rem 0;
	text-align: center;
}

.search-no-results__headline {
	margin: 0 0 1.25rem;
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: clamp(1.0625rem, 2.5vw, 1.25rem);
	font-weight: 600;
	color: var(--color-primary, #111);
}

.search-no-results__tips {
	list-style: none;
	margin: 0 0 2rem;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.4rem;
}

.search-no-results__tips li {
	font-family: var(--font-base, system-ui, sans-serif);
	font-size: 0.9375rem;
	color: var(--color-muted, #6b7280);
}

.search-no-results__tips li::before {
	content: '→  ';
	color: var(--color-accent, #2563eb);
}

.search-no-results__cta {
	display: inline-block;
}


/* ═══════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
	.gwill-search-expand.is-open .gwill-search-expand__form,
	.gwill-search-modal__panel {
		animation: none;
	}
}
