/**
 * Enhanced Search Modal — Styles
 * File: search-modal.css (child theme root)
 */

/* ═══════════════════════════════════════════════
   0. Custom Properties — Light Mode (default)
   ═══════════════════════════════════════════════ */
.gp-search-modal {
	--esm-accent: var(--accent, #e05555);
	--esm-accent-soft: rgba(224, 85, 85, 0.12);
	--esm-accent-soft: color-mix(in oklch, var(--esm-accent) 12%, transparent);
	--esm-bg: var(--lm-background-primary, #fafafa);
	--esm-surface: #f0f0f0;
	--esm-surface: color-mix(in oklch, var(--lm-background-primary, #fafafa) 92%, white);
	--esm-text: var(--lm-text-primary, #1a1a1a);
	--esm-text-muted: rgba(26, 26, 26, 0.55);
	--esm-text-muted: color-mix(in oklch, var(--lm-text-primary, #1a1a1a) 55%, transparent);
	--esm-border: rgba(26, 26, 26, 0.1);
	--esm-border: color-mix(in oklch, var(--lm-text-primary, #1a1a1a) 10%, transparent);
	--esm-radius: 10px;
	--esm-font: inherit;
	--esm-transition: 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ═══════════════════════════════════════════════
   0b. Custom Properties — Dark Mode
   ═══════════════════════════════════════════════ */
.dark-mode .gp-search-modal {
	--esm-bg: var(--dm-background-primary, #1a1a1a);
	--esm-surface: #2a2a2a;
	--esm-surface: color-mix(in oklch, var(--dm-background-primary, #1a1a1a) 85%, white);
	--esm-text: var(--dm-text-primary, #e8e8e8);
	--esm-text-muted: rgba(232, 232, 232, 0.55);
	--esm-text-muted: color-mix(in oklch, var(--dm-text-primary, #e8e8e8) 55%, transparent);
	--esm-border: rgba(232, 232, 232, 0.12);
	--esm-border: color-mix(in oklch, var(--dm-text-primary, #e8e8e8) 12%, transparent);
}

/* ═══════════════════════════════════════════════
   1. Override GP Modal — full-screen
   ═══════════════════════════════════════════════ */

/* When closed: no layout impact */
.gp-search-modal:not(.gp-modal--open) {
	display: none !important;
}

/* Full-screen overlay when open */
.gp-search-modal.gp-modal--open {
	position: fixed !important;
	top: 0 !important;
	left: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	z-index: 99999 !important;
	display: flex !important;
	flex-direction: column !important;
	align-items: stretch !important;
	justify-content: flex-start !important;
	background: var(--esm-bg) !important;
	overflow: hidden !important;
}

/* Override GP overlay padding and background */
.gp-search-modal .gp-modal__overlay {
	padding-top: 0 !important;
	background-color: var(--esm-bg) !important;
}

/* Hide the default GP search form */
.gp-search-modal .gp-modal__container > form,
.gp-search-modal .gp-modal__container > .search-form,
.gp-search-modal .gp-modal__container > .gp-search-modal-form {
	display: none !important;
}

/* Full-screen container */
.gp-search-modal .gp-modal__container {
	width: 100% !important;
	max-width: 100% !important;
	height: 100% !important;
	max-height: 100% !important;
	margin: 0 !important;
	border-radius: 0 !important;
	background: var(--esm-bg) !important;
	box-shadow: none !important;
	transform: translateY(-20px);
	opacity: 0;
	transition: transform var(--esm-transition), opacity var(--esm-transition) !important;
	overflow-y: auto !important;
	overscroll-behavior: contain;
	padding: 0 !important;
}

.gp-search-modal.gp-modal--open .gp-modal__container {
	transform: translateY(0);
	opacity: 1;
}

/* Hide the default GP close button */
.gp-search-modal .gp-modal__close {
	display: none !important;
}

/* ═══════════════════════════════════════════════
   2. ESM Layout
   ═══════════════════════════════════════════════ */

/* Header bar — full width with 1280px container */
.esm__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	max-width: 1280px;
	margin: 0 auto;
	padding: 1.5rem 2rem 1.5rem;
	border-bottom: 1px solid var(--esm-border);
}

.esm__header-left {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.esm__logo {
	height: 62px;
	width: auto;
}

.esm__header-title {
	font-size: 1.3rem;
	font-weight: 600;
	color: var(--esm-text);
	margin: 0;
	line-height: 1.2;
}

/* Top-right close button — flat, circular on hover */
.esm__close-top {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border: 2px solid transparent;
	background: none;
	color: var(--esm-accent);
	cursor: pointer;
	border-radius: 50%;
	padding: 0;
	transition: border-color 0.2s, background 0.2s;
}

.esm__close-top:hover {
	border-color: var(--esm-accent);
	background: var(--esm-accent-soft);
}

.esm__close-top svg {
	width: 28px;
	height: 28px;
}

/* Content area — narrower for readability */
.esm__inner {
	max-width: 780px;
	margin: 0 auto;
	padding: 2rem 2rem 2rem;
}

@media (max-width: 768px) {
	.esm__header {
		padding: 1rem 1.25rem;
	}
	.esm__inner {
		padding: 1.25rem 1.25rem 1.25rem;
	}
	.esm__logo {
		height: 48px;
	}
	.esm__header-title {
		font-size: 1.05rem;
	}
	.esm__close-top {
		width: 38px;
		height: 38px;
	}
	.esm__close-top svg {
		width: 24px;
		height: 24px;
	}
}

/* ═══════════════════════════════════════════════
   3. Search Input
   ═══════════════════════════════════════════════ */
.esm__form {
	margin: 0;
	padding: 0;
}

.esm__input-wrap {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	background: var(--esm-surface);
	border: 2px solid var(--esm-border);
	border-radius: var(--esm-radius);
	padding: 0.85rem 1.25rem;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.esm__input-wrap:focus-within {
	border-color: var(--esm-accent);
	box-shadow: 0 0 0 4px var(--esm-accent-soft);
}

.esm__icon {
	flex-shrink: 0;
	color: var(--esm-text-muted);
	transition: color 0.2s ease;
}

.esm__input-wrap:focus-within .esm__icon {
	color: var(--esm-accent);
}

.esm__input {
	flex: 1;
	border: none !important;
	outline: none !important;
	background: transparent !important;
	font-family: var(--esm-font);
	font-size: 1.2rem;
	font-weight: 500;
	color: var(--esm-text) !important;
	padding: 0 !important;
	margin: 0;
	box-shadow: none !important;
	line-height: 1.4;
}

.esm__input::placeholder {
	color: var(--esm-text-muted);
	opacity: 0.7;
}

.esm__input::-webkit-search-cancel-button,
.esm__input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
}

/* Close (X) button */
.esm__close-btn {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: none;
	background: none;
	color: var(--esm-accent);
	cursor: pointer;
	border-radius: 6px;
	padding: 0;
	transition: background 0.15s, transform 0.15s;
}

.esm__close-btn:hover {
	background: var(--esm-accent-soft);
	transform: scale(1.1);
}

.esm__close-btn svg {
	width: 24px;
	height: 24px;
}

/* ═══════════════════════════════════════════════
   4. Category Pills
   ═══════════════════════════════════════════════ */
.esm__cats {
	display: flex;
	flex-wrap: wrap;
	gap: 0.45rem;
	margin-top: 1rem;
	padding-bottom: 0.25rem;
}

.esm__pill {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	font-family: var(--esm-font);
	font-size: 0.82rem;
	font-weight: 500;
	line-height: 1;
	color: var(--esm-text-muted);
	background: var(--esm-surface);
	border: 1.5px solid var(--esm-border);
	border-radius: 100px;
	padding: 0.45em 0.9em;
	cursor: pointer;
	transition: all 0.2s ease;
	white-space: nowrap;
}

.esm__pill:hover {
	color: var(--esm-text);
	border-color: rgba(224, 85, 85, 0.4);
	border-color: color-mix(in oklch, var(--esm-accent) 40%, transparent);
	background: var(--esm-accent-soft);
}

.esm__pill--active,
.esm__pill--active:hover {
	color: #fff;
	background: var(--esm-accent);
	border-color: var(--esm-accent);
}

.esm__pill-count {
	font-size: 0.7rem;
	font-weight: 600;
	opacity: 0.6;
}

.esm__pill--active .esm__pill-count {
	opacity: 0.8;
}

/* ═══════════════════════════════════════════════
   5. Results Area
   ═══════════════════════════════════════════════ */
.esm__results {
	margin-top: 1.25rem;
	min-height: 2rem;
}

.esm__results-list {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.esm__result {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0.75rem;
	background: var(--esm-surface);
	border: 1px solid var(--esm-border);
	border-radius: var(--esm-radius);
	text-decoration: none !important;
	color: var(--esm-text) !important;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
	opacity: 0;
	animation: esm-fade-in 0.2s ease forwards;
}

.esm__result:nth-child(1)  { animation-delay: 0.02s; }
.esm__result:nth-child(2)  { animation-delay: 0.04s; }
.esm__result:nth-child(3)  { animation-delay: 0.06s; }
.esm__result:nth-child(4)  { animation-delay: 0.08s; }
.esm__result:nth-child(5)  { animation-delay: 0.10s; }
.esm__result:nth-child(6)  { animation-delay: 0.12s; }
.esm__result:nth-child(7)  { animation-delay: 0.14s; }
.esm__result:nth-child(8)  { animation-delay: 0.16s; }
.esm__result:nth-child(9)  { animation-delay: 0.18s; }
.esm__result:nth-child(10) { animation-delay: 0.20s; }
.esm__result:nth-child(n+11) { animation-delay: 0.22s; }

@keyframes esm-fade-in {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.esm__result:hover {
	border-color: var(--esm-accent);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
	transform: translateY(-1px);
}

.esm__result-thumb {
	flex-shrink: 0;
	width: 48px;
	height: 48px;
	border-radius: 8px;
	object-fit: cover;
	background: var(--esm-bg);
}

.esm__result-body {
	flex: 1;
	min-width: 0;
}

.esm__result-title {
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.3;
	margin: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.esm__result-meta {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.2rem;
	font-size: 0.78rem;
	color: var(--esm-text-muted);
}

.esm__result-cat {
	display: inline-block;
	font-weight: 600;
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--esm-accent);
	background: var(--esm-accent-soft);
	padding: 0.15em 0.5em;
	border-radius: 4px;
}

.esm__result-type {
	display: inline-block;
	font-weight: 600;
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--esm-text-muted);
	background: color-mix(in oklch, var(--esm-text) 8%, transparent);
	padding: 0.15em 0.5em;
	border-radius: 4px;
}

.esm__result-grad {
	color: var(--esm-text-muted);
}

.esm__result-arrow {
	flex-shrink: 0;
	color: var(--esm-text-muted);
	opacity: 0;
	transform: translateX(-4px);
	transition: opacity 0.15s, transform 0.15s;
}

.esm__result:hover .esm__result-arrow {
	opacity: 1;
	transform: translateX(0);
}

/* ═══════════════════════════════════════════════
   6. Status Messages
   ═══════════════════════════════════════════════ */
.esm__status {
	text-align: center;
	font-size: 0.88rem;
	color: var(--esm-text-muted);
	padding: 1.25rem 0 0.5rem;
	margin: 0;
}

.esm__status[hidden] {
	display: none !important;
}

.esm__spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid var(--esm-border);
	border-top-color: var(--esm-accent);
	border-radius: 50%;
	vertical-align: middle;
	margin-right: 0.4em;
	animation: esm-spin 0.6s linear infinite;
}

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

/* ═══════════════════════════════════════════════
   7. Scrollbar
   ═══════════════════════════════════════════════ */
.gp-search-modal .gp-modal__container::-webkit-scrollbar {
	width: 6px;
}

.gp-search-modal .gp-modal__container::-webkit-scrollbar-track {
	background: transparent;
}

.gp-search-modal .gp-modal__container::-webkit-scrollbar-thumb {
	background: color-mix(in oklch, var(--esm-text) 12%, transparent);
	border-radius: 3px;
}

.gp-search-modal .gp-modal__container::-webkit-scrollbar-thumb:hover {
	background: color-mix(in oklch, var(--esm-text) 25%, transparent);
}

/* ═══════════════════════════════════════════════
   SEARCH RESULTS PAGE
   Styles the GP search results to match the modal.
   ═══════════════════════════════════════════════ */

/* ── Variable scope for search results page ───── */
.search-results,
.search-no-results {
	--esm-accent: var(--accent, #e05555);
	--esm-accent-soft: rgba(224, 85, 85, 0.12);
	--esm-accent-soft: color-mix(in oklch, var(--esm-accent) 12%, transparent);
	--esm-bg: var(--lm-background-primary, #fafafa);
	--esm-surface: #f0f0f0;
	--esm-surface: color-mix(in oklch, var(--lm-background-primary, #fafafa) 92%, white);
	--esm-text: var(--lm-text-primary, #1a1a1a);
	--esm-text-muted: rgba(26, 26, 26, 0.55);
	--esm-text-muted: color-mix(in oklch, var(--lm-text-primary, #1a1a1a) 55%, transparent);
	--esm-border: rgba(26, 26, 26, 0.1);
	--esm-border: color-mix(in oklch, var(--lm-text-primary, #1a1a1a) 10%, transparent);
	--esm-radius: 10px;
}

.dark-mode .search-results,
.dark-mode .search-no-results {
	--esm-bg: var(--dm-background-primary, #1a1a1a);
	--esm-surface: #2a2a2a;
	--esm-surface: color-mix(in oklch, var(--dm-background-primary, #1a1a1a) 85%, white);
	--esm-text: var(--dm-text-primary, #e8e8e8);
	--esm-text-muted: rgba(232, 232, 232, 0.55);
	--esm-text-muted: color-mix(in oklch, var(--dm-text-primary, #e8e8e8) 55%, transparent);
	--esm-border: rgba(232, 232, 232, 0.12);
	--esm-border: color-mix(in oklch, var(--dm-text-primary, #e8e8e8) 12%, transparent);
}

/* ── Page Header ──────────────────────────────── */
.search-results .page-header {
	background: var(--esm-bg) !important;
	border: 1px solid var(--esm-border);
	border-radius: var(--esm-radius);
	padding: 1.25rem 1.5rem;
	margin-bottom: 1.5rem;
}

.search-results .page-header h1 {
	font-size: 1.875rem !important;
	font-weight: 600;
	color: var(--esm-text);
	margin: 0;
	line-height: 1.3;
}

/* ── Result Cards — entire card clickable ─────── */
.search-results article {
	position: relative;
	margin-bottom: 0;
	padding: 0;
	border: none;
	width: 75%;
}

.search-results .inside-article {
	background: var(--esm-surface);
	border: 1px solid var(--esm-border);
	border-radius: var(--esm-radius);
	padding: 1rem 1.5rem;
	margin-bottom: 0.5rem;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
	position: relative;
}

.search-results .inside-article:hover {
	border-color: var(--esm-accent);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
	transform: translateY(-1px);
}

/* Stretch the title link to cover the entire card */
.search-results h2.entry-title a::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1;
}

/* Arrow on hover — SVG injected via PHP element */
.esm-search-arrow {
	position: absolute;
	right: 1.5rem;
	top: 50%;
	transform: translateY(-50%) translateX(-4px);
	color: var(--esm-text-muted);
	opacity: 0;
	transition: opacity 0.15s, transform 0.15s;
	pointer-events: none;
	z-index: 2;
}

.search-results .inside-article:hover .esm-search-arrow {
	opacity: 1;
	transform: translateY(-50%) translateX(0);
}

/* ── Titles ───────────────────────────────────── */
.search-results .entry-header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	column-gap: 1rem;
	row-gap: 0.15rem;
	margin-bottom: 0;
}

/* Thumbnail */
.esm-search-thumb {
	width: 64px;
	height: 64px;
	flex-shrink: 0;
	border-radius: 8px;
	object-fit: cover;
	background: var(--esm-bg);
	position: relative;
	z-index: 2;
}

.search-results h2.entry-title {
	flex: 1;
	min-width: 0;
	font-size: 1.0625rem;
	font-weight: 600;
	line-height: 1.3;
	margin: 0;
}

/* Meta wraps to next line, indented past thumbnail */
.esm-search-meta {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	width: 100%;
	padding-left: calc(64px + 1rem);
	margin: 0.15rem 0 0 0;
	font-size: 0.82rem;
	color: var(--esm-text-muted);
	position: relative;
	z-index: 2;
}

/* When no thumbnail, remove indent */
.search-results .entry-header:not(:has(.esm-search-thumb)) .esm-search-meta {
	padding-left: 0;
}

.search-results h2.entry-title a {
	color: var(--esm-text);
	text-decoration: none;
}

.search-results .inside-article:hover h2.entry-title a {
	color: var(--esm-accent);
}

/* ── Badge styles in search results context ───── */
.esm-search-meta .esm__result-cat {
	display: inline-block;
	font-weight: 600;
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--esm-accent);
	background: var(--esm-accent-soft);
	padding: 0.15em 0.5em;
	border-radius: 4px;
}

.esm-search-meta .esm__result-type {
	display: inline-block;
	font-weight: 600;
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--esm-text-muted);
	background: color-mix(in oklch, var(--esm-text) 8%, transparent);
	padding: 0.15em 0.5em;
	border-radius: 4px;
}

.esm-search-meta .esm__result-grad {
	color: var(--esm-text-muted);
}

/* ── Hide default post meta, excerpts, featured images ── */
.search-results .entry-meta,
.search-results .entry-summary,
.search-results .entry-content,
.search-results .post-image,
.search-results .entry-image,
.search-results footer.entry-meta {
	display: none !important;
}

/* ── Remove default article spacing ───────────── */
.search-results .generate-columns-container article,
.search-results #main article {
	margin-bottom: 0;
}

@media (max-width: 768px) {
	.search-results article {
		width: 100%;
	}
	.esm-search-thumb {
		width: 48px;
		height: 48px;
	}
	.esm-search-meta {
		padding-left: calc(48px + 1rem);
	}
	.search-results .entry-header:not(:has(.esm-search-thumb)) .esm-search-meta {
		padding-left: 0;
	}
}

/* ── Pagination ───────────────────────────────── */
.search-results .paging-navigation {
	margin-top: 1.5rem;
}

.search-results .paging-navigation a {
	background: var(--esm-surface);
	border: 1px solid var(--esm-border);
	border-radius: var(--esm-radius);
	padding: 0.5rem 1rem;
	color: var(--esm-text);
	text-decoration: none;
	font-size: 0.88rem;
	transition: border-color 0.15s, background 0.15s;
}

.search-results .paging-navigation a:hover {
	border-color: var(--esm-accent);
	background: var(--esm-accent-soft);
	color: var(--esm-accent);
}

/* ── No Results Page ──────────────────────────── */
.search-no-results .inside-article {
	background: var(--esm-bg) !important;
	border: 1px solid var(--esm-border);
	border-radius: var(--esm-radius);
	padding: 3rem 2rem;
	text-align: left;
}

.search-no-results .entry-header {
	margin-bottom: 0.5rem;
}

.search-no-results h1.entry-title {
	font-size: 2.9rem !important;
	font-weight: 700;
	color: var(--esm-text);
	margin: 0 0 0.5rem 0;
}

.search-no-results .entry-content p {
	color: var(--esm-text-muted);
	font-size: 1rem;
	margin-bottom: 1.5rem;
}

.search-no-results .search-form {
	max-width: 100%;
	margin: 0;
	display: flex;
	gap: 0.75rem;
	align-items: center;
}

.search-no-results .search-form .search-field {
	flex: 1;
	background: var(--esm-surface) !important;
	border: 2px solid var(--esm-border) !important;
	border-radius: var(--esm-radius) !important;
	padding: 0.85rem 1.25rem !important;
	font-size: 1rem;
	color: var(--esm-text) !important;
	transition: border-color 0.2s;
}

.search-no-results .search-form .search-field:focus {
	border-color: var(--esm-accent) !important;
	outline: none !important;
	box-shadow: 0 0 0 4px var(--esm-accent-soft) !important;
}

.search-no-results .search-form .search-submit {
	flex-shrink: 0;
	width: 48px;
	height: 48px;
	background: var(--esm-accent) !important;
	color: #fff !important;
	border: none !important;
	border-radius: 50% !important;
	padding: 0 !important;
	font-size: 0;
	cursor: pointer;
	transition: opacity 0.15s, transform 0.15s;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") !important;
	background-repeat: no-repeat !important;
	background-position: center !important;
	background-size: 20px !important;
}

.search-no-results .search-form .search-submit:hover {
	opacity: 0.85;
	transform: scale(1.05);
}

/* ═══════════════════════════════════════════════
   OFF-CANVAS SEARCH BUTTON
   ═══════════════════════════════════════════════ */
.esm-offcanvas-search {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	background: #ef4d58;
	border: none;
	border-radius: 50%;
	padding: 0;
	color: #ffffff;
	cursor: pointer;
	transition: background 0.2s, transform 0.2s;
	margin-bottom: 1rem;
}

.esm-offcanvas-search:hover {
	background: #d94048;
	transform: scale(1.05);
}

.esm-offcanvas-search svg {
	width: 22px;
	height: 22px;
	flex-shrink: 0;
	color: #ffffff;
}
