/* =============================================================================
   Site search. Every colour, radius and shadow comes from the design system's
   tokens, so this inherits the brand rather than restating it.

   A real stylesheet rather than inline style attributes, deliberately: the audit
   flagged that 50% of every document is inline style, and new work should not
   make that worse.
   ============================================================================= */

/* Announced, never seen. `display:none` would remove it from the accessibility
   tree and silence the live region, which defeats the point. */
.lapg-visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ---- the header trigger ---------------------------------------------------- */
.lapg-search__open {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 7px 12px 7px 11px;
  color: var(--text-muted);
  font-family: var(--font-body); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: border-color .15s ease, color .15s ease;
}
.lapg-search__open:hover { border-color: var(--action-primary); color: var(--text-strong); }
.lapg-search__open:focus-visible { outline: 3px solid var(--action-primary); outline-offset: 2px; }
.lapg-search__open svg { flex: none; }

/* The keyboard hint is a promise to people who use keyboards, so hide it on
   touch where the shortcut does not exist. */
.lapg-search__kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem; line-height: 1;
  border: 1px solid var(--border-subtle); border-bottom-width: 2px;
  border-radius: 4px; padding: 3px 5px; color: var(--text-muted);
  background: var(--surface-alt);
}
@media (hover: none) { .lapg-search__kbd { display: none; } }
@media (max-width: 1180px) { .lapg-search__label { display: none; } .lapg-search__open { padding: 8px; } }

/* ---- the dialog ------------------------------------------------------------ */
.lapg-search__dialog {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(7, 24, 41, 0.55);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(16px, 8vh, 96px) 16px 16px;
  animation: lapg-search-in .16s ease-out;
}
.lapg-search__dialog[hidden] { display: none; }

.lapg-search__panel {
  width: 100%; max-width: 640px;
  background: var(--surface-card, #fff);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  max-height: min(70vh, 620px);
  overflow: hidden;
  animation: lapg-search-rise .18s ease-out;
}

@keyframes lapg-search-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes lapg-search-rise { from { transform: translateY(-8px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .lapg-search__dialog, .lapg-search__panel { animation: none; }
}

/* ---- the input row --------------------------------------------------------- */
.lapg-search__field {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
  flex: none;
}
.lapg-search__field svg { flex: none; color: var(--action-primary); }

.lapg-search__input {
  flex: 1; min-width: 0;
  border: none; outline: none; background: none;
  font-family: var(--font-body); font-size: 1.0625rem; color: var(--text-strong);
}
.lapg-search__input::placeholder { color: var(--text-muted); }

.lapg-search__clear, .lapg-search__dismiss {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; padding: 6px;
  border-radius: var(--radius-sm); color: var(--text-muted);
}
.lapg-search__clear:hover, .lapg-search__dismiss:hover { color: var(--text-strong); background: var(--surface-alt); }
.lapg-search__clear:focus-visible, .lapg-search__dismiss:focus-visible {
  outline: 3px solid var(--action-primary); outline-offset: 1px;
}
.lapg-search__dismiss {
  font-family: var(--font-body); font-size: 0.8rem; font-weight: 600;
  padding: 6px 10px; border: 1px solid var(--border-subtle);
}

/* ---- results --------------------------------------------------------------- */
.lapg-search__results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.lapg-search__results[hidden] { display: none; }

.lapg-search__item {
  display: grid; gap: 3px;
  padding: 11px 13px; border-radius: var(--radius-md);
  cursor: pointer;
  border-left: 3px solid transparent;
}
.lapg-search__item.is-active { background: var(--surface-tint); border-left-color: var(--action-primary); }

.lapg-search__title {
  font-family: var(--font-heading); font-weight: 700; font-size: 1rem;
  color: var(--text-strong); line-height: 1.3;
}
.lapg-search__kicker {
  font-size: 0.75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent-teal);
}
.lapg-search__snippet {
  font-size: 0.9rem; line-height: 1.5; color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Highlight without the yellow-marker look: tint the brand blue instead. */
.lapg-search__item mark, .lapg-search__result mark {
  background: color-mix(in srgb, var(--action-primary) 16%, transparent);
  color: inherit; font-weight: 700; border-radius: 2px; padding: 0 1px;
}
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .lapg-search__item mark, .lapg-search__result mark { background: var(--surface-tint); }
}

.lapg-search__empty { padding: 26px 20px 30px; text-align: center; color: var(--text-muted); }
.lapg-search__empty[hidden] { display: none; }
.lapg-search__empty b { color: var(--text-strong); }

.lapg-search__foot {
  flex: none; display: flex; gap: 16px; align-items: center;
  padding: 9px 16px; border-top: 1px solid var(--border-subtle);
  background: var(--surface-alt);
  font-size: 0.75rem; color: var(--text-muted);
}
@media (hover: none) { .lapg-search__foot { display: none; } }

/* ---- the /search/ results page --------------------------------------------- */
.lapg-search__result {
  display: grid; gap: 4px; padding: 18px 0;
  border-bottom: 1px solid var(--border-subtle);
  text-decoration: none;
}
.lapg-search__result:hover .lapg-search__title { color: var(--action-primary); }
.lapg-search__result:focus-visible { outline: 3px solid var(--action-primary); outline-offset: 3px; }
.lapg-search__result .lapg-search__snippet { -webkit-line-clamp: 3; }
.lapg-search__hint { color: var(--text-muted); line-height: 1.6; }
