/* =========================================================================
   Site search — brand-styled surface for the Pagefind-backed search.
   Two consumers share the result styles below:
     1. The nav overlay (#agSearch) — a modal opened from the nav magnifier.
     2. The /search results page (.search-page) — the "press Enter" view.
   Pristine design layers (colors_and_type.css, modern.css) are untouched;
   this is a production layer like site-extras.css.
   ========================================================================= */

/* Nav magnifier button sits in .nav-actions (gap:0), so give it breathing room. */
.nav-actions .nav-search__btn { margin-right: 10px; }

/* -------------------------------------------------------------------------
   Overlay shell
   ------------------------------------------------------------------------- */
.ag-search {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.ag-search[hidden] { display: none; }

.ag-search__backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-moss-dark-90, rgba(41, 53, 46, 0.90));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity var(--dur-2, 0.32s) var(--ease, ease);
}
.ag-search.is-open .ag-search__backdrop { opacity: 1; }

.ag-search__panel {
  position: relative;
  width: min(720px, calc(100vw - 32px));
  margin-top: clamp(56px, 12vh, 140px);
  background: var(--surface, #fff);
  border: 1px solid var(--rule-soft, #DDD9CC);
  border-top: 3px solid var(--color-gold-antique, #AA8F57);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(27, 35, 29, 0.32);
  overflow: hidden;
  transform: translateY(-12px);
  opacity: 0;
  transition: transform var(--dur-2, 0.32s) var(--ease, ease),
              opacity var(--dur-2, 0.32s) var(--ease, ease);
}
.ag-search.is-open .ag-search__panel { transform: translateY(0); opacity: 1; }

/* -------------------------------------------------------------------------
   Search bar
   ------------------------------------------------------------------------- */
.ag-search__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px;
  border-bottom: 1px solid var(--rule-soft, #DDD9CC);
}
.ag-search__glass {
  width: 22px; height: 22px; flex: none;
  stroke: var(--color-gold-antique, #AA8F57);
  stroke-width: 1.7; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}
.ag-search__input {
  flex: 1 1 auto;
  border: 0;
  outline: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--text-lg, 20px);
  color: var(--color-ink, #1B231D);
  letter-spacing: .01em;
}
.ag-search__input::placeholder { color: var(--fg-muted, #7A7E73); font-style: italic; }
.ag-search__input::-webkit-search-cancel-button { -webkit-appearance: none; }

.ag-search__dismiss {
  appearance: none; background: transparent; border: 0;
  width: 34px; height: 34px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg-2, #4A5249); cursor: pointer; border-radius: 50%;
  transition: color var(--dur-1, 0.18s) var(--ease, ease),
              background var(--dur-1, 0.18s) var(--ease, ease);
}
.ag-search__dismiss:hover { color: var(--color-oxblood, #6B2D2D); background: var(--color-gold-soft, rgba(170,143,87,.18)); }
.ag-search__dismiss svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; }

/* -------------------------------------------------------------------------
   Results region (shared between overlay and page)
   ------------------------------------------------------------------------- */
.ag-search__results {
  max-height: min(56vh, 520px);
  overflow-y: auto;
  padding: 6px;
}

.ag-result {
  display: block;
  padding: 14px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
  transition: background var(--dur-1, 0.18s) var(--ease, ease),
              border-color var(--dur-1, 0.18s) var(--ease, ease);
}
.ag-result + .ag-result { margin-top: 2px; }
.ag-result:hover,
.ag-result.is-active {
  background: var(--color-gold-soft, rgba(170,143,87,.18));
  border-color: rgba(170, 143, 87, 0.35);
}
.ag-result:focus-visible {
  outline: none;
  box-shadow: var(--focus, 0 0 0 2px #AA8F57);
}

.ag-result__type {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--text-xs, 12px);
  text-transform: uppercase;
  letter-spacing: var(--track-eyebrow, 0.18em);
  color: var(--color-gold-antique, #AA8F57);
  margin-bottom: 6px;
}
.ag-result__title {
  font-family: var(--font-display);
  font-weight: 560;
  font-size: var(--text-md, 18px);
  line-height: var(--lh-snug, 1.18);
  color: var(--color-ink, #1B231D);
  margin: 0 0 4px;
}
.ag-result__excerpt {
  font-family: var(--font-body);
  font-size: var(--text-sm, 14px);
  line-height: var(--lh-normal, 1.45);
  color: var(--fg-2, #4A5249);
  margin: 0;
}
/* Pagefind wraps matched terms in <mark>. */
.ag-result__excerpt mark {
  background: transparent;
  color: var(--color-moss-light, #2B4F3A);
  font-weight: 640;
  padding: 0;
}

/* Empty / prompt / loading states */
.ag-search__state {
  padding: 28px 18px 34px;
  text-align: center;
  font-family: var(--font-body);
  color: var(--fg-muted, #7A7E73);
  font-size: var(--text-sm, 14px);
}
.ag-search__state strong { color: var(--color-ink, #1B231D); font-weight: 600; }

/* Footer hint row */
.ag-search__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--rule-soft, #DDD9CC);
  background: var(--surface-sand, #EDEBE4);
}
.ag-search__hint { font-family: var(--font-body); font-size: var(--text-xs, 12px); color: var(--fg-muted, #7A7E73); }
.ag-search__hint kbd {
  font-family: var(--font-body);
  font-size: 11px;
  background: #fff;
  border: 1px solid var(--rule-soft, #DDD9CC);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--fg-2, #4A5249);
}
.ag-search__all {
  font-family: var(--font-body);
  font-size: var(--text-sm, 14px);
  color: var(--color-moss-light, #2B4F3A);
  text-decoration: none;
  font-weight: 600;
}
.ag-search__all:hover { color: var(--color-gold-antique, #AA8F57); }
.ag-search__all[hidden] { display: none; }

@media (max-width: 760px) {
  .ag-search__foot { flex-direction: column-reverse; align-items: flex-start; gap: 8px; }
  .ag-search__input { font-size: var(--text-md, 18px); }
}

/* -------------------------------------------------------------------------
   /search results page
   ------------------------------------------------------------------------- */
.search-page { background: var(--surface-sand, #EDEBE4); min-height: 60vh; }
.search-page__head {
  padding: clamp(48px, 9vh, 96px) 0 24px;
}
.search-page__eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs, 12px);
  text-transform: uppercase;
  letter-spacing: var(--track-eyebrow, 0.18em);
  color: var(--color-gold-antique, #AA8F57);
  margin: 0 0 10px;
}
.search-page h1 {
  font-family: var(--font-display);
  font-size: var(--text-3xl, 42px);
  line-height: var(--lh-tight, 1.05);
  color: var(--color-ink, #1B231D);
  margin: 0 0 18px;
}
.search-page h1 em { font-style: italic; color: var(--color-moss-light, #2B4F3A); }

.search-page__bar {
  display: flex; align-items: center; gap: 12px;
  background: #fff;
  border: 1px solid var(--rule-soft, #DDD9CC);
  border-radius: 10px;
  padding: 14px 16px;
  max-width: 640px;
}
.search-page__bar svg { width: 20px; height: 20px; flex: none; stroke: var(--color-gold-antique,#AA8F57); stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.search-page__bar input {
  flex: 1 1 auto; border: 0; outline: none; background: transparent;
  font-family: var(--font-body); font-size: var(--text-md, 18px); color: var(--color-ink, #1B231D);
}
.search-page__bar input::placeholder { color: var(--fg-muted, #7A7E73); font-style: italic; }

.search-page__count {
  font-family: var(--font-body);
  font-size: var(--text-sm, 14px);
  color: var(--fg-2, #4A5249);
  margin: 20px 0 10px;
}
.search-page__count strong { color: var(--color-ink, #1B231D); }

.search-page__results { padding-bottom: clamp(64px, 12vh, 128px); }
.search-page__results .ag-result {
  background: #fff;
  border: 1px solid var(--rule-soft, #DDD9CC);
  margin-bottom: 12px;
  padding: 20px 22px;
}
.search-page__results .ag-result:hover {
  border-color: var(--color-gold-antique, #AA8F57);
  background: #fff;
  transform: translateY(-1px);
}
.search-page__results .ag-result__title { font-size: var(--text-xl, 24px); }
.search-page__results .ag-result__excerpt { font-size: var(--text-base, 16px); }

/* Pagination */
.search-page__pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0 clamp(64px, 12vh, 128px);
}
.search-page__pager:empty { display: none; }
.pager-btn {
  appearance: none;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: var(--text-sm, 14px);
  color: var(--fg-2, #4A5249);
  background: #fff;
  border: 1px solid var(--rule-soft, #DDD9CC);
  border-radius: 8px;
  cursor: pointer;
  transition: color var(--dur-1, 0.18s) var(--ease, ease),
              border-color var(--dur-1, 0.18s) var(--ease, ease),
              background var(--dur-1, 0.18s) var(--ease, ease);
}
.pager-btn:hover:not(:disabled):not(.is-current) {
  color: var(--color-moss-light, #2B4F3A);
  border-color: var(--color-gold-antique, #AA8F57);
}
.pager-btn:focus-visible { outline: none; box-shadow: var(--focus, 0 0 0 2px #AA8F57); }
.pager-btn:disabled { opacity: .45; cursor: default; }
.pager-btn.is-current {
  color: var(--color-sand-warm, #EDEBE4);
  background: var(--color-moss-light, #2B4F3A);
  border-color: var(--color-moss-light, #2B4F3A);
  font-weight: 600;
  cursor: default;
}
.pager-edge { font-weight: 600; }
.pager-gap {
  min-width: 24px;
  text-align: center;
  color: var(--fg-muted, #7A7E73);
  font-family: var(--font-body);
  user-select: none;
}
@media (max-width: 560px) {
  .pager-edge { font-size: 0; padding: 0 10px; } /* collapse "Prev"/"Next" labels */
  .pager-edge::after { font-size: var(--text-sm, 14px); }
  .pager-btn[aria-label="Previous page"]::after { content: '←'; }
  .pager-btn[aria-label="Next page"]::after { content: '→'; }
}

@media (prefers-reduced-motion: reduce) {
  .ag-search__backdrop,
  .ag-search__panel,
  .ag-result { transition: none; }
}
