/* Shared site-wide search: the header trigger button + the Pagefind UI modal.
   Loaded on every surface so search looks and behaves identically. Uses the
   same palette tokens as the rest of the site (falls back gracefully if a
   surface defines them under different names). */

.site-search {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  width: 22rem;
  max-width: 38vw;
  margin-inline-end: auto;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border2, var(--sl-color-gray-5, #3a3f4b));
  border-radius: 0.5rem;
  background: var(--panel, var(--sl-color-bg-nav, #14161d));
  color: var(--text3, var(--sl-color-gray-3, #8b909c));
  font: inherit;
  font-size: 0.875rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.site-search:hover {
  border-color: var(--text3, var(--sl-color-gray-3, #8b909c));
}
.site-search .ss-icon {
  width: 16px;
  height: 16px;
  flex: none;
}
.site-search .ss-label {
  flex: 1;
  text-align: start;
}
.site-search .ss-kbd {
  flex: none;
  font-family: inherit;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border2, var(--sl-color-gray-5, #3a3f4b));
  border-radius: 4px;
  color: var(--text3, var(--sl-color-gray-3, #8b909c));
}

/* ---- Modal ---- */
.search-modal[hidden] {
  display: none;
}
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(16px, 8vh, 96px) 16px 16px;
}
.search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}
.search-dialog {
  position: relative;
  width: min(640px, 100%);
  max-height: 80vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--border2, var(--sl-color-gray-5, #3a3f4b));
  border-radius: 14px;
  background: var(--panel, var(--sl-color-bg, #0c0e14));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.search-error {
  margin: 0;
  color: var(--text3, var(--sl-color-gray-3, #8b909c));
}

/* ---- Pagefind UI theming to match the brand ---- */
:root {
  --pagefind-ui-scale: 0.9;
  --pagefind-ui-primary: var(--accent, var(--sl-color-accent, #f05a28));
  --pagefind-ui-text: var(--text, var(--sl-color-white, #fff));
  --pagefind-ui-background: var(--panel, var(--sl-color-bg, #0c0e14));
  --pagefind-ui-border: var(--border2, var(--sl-color-gray-5, #3a3f4b));
  --pagefind-ui-tag: var(--bg3, var(--sl-color-gray-6, #1b1e26));
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 10px;
  --pagefind-ui-font: 'Inter', ui-sans-serif, system-ui, sans-serif;
}

/* ---- Unified app header (matches the docs/Starlight header: logo,
   site-wide search, Mobile/Client download buttons, GitHub/npm icons,
   theme toggle — no text nav links). Shared by blog, tools, and the
   standalone pages. ---- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: var(--bg, var(--sl-color-bg, #0c0e14));
  border-bottom: 1px solid var(--hairline, var(--sl-color-hairline, rgba(255, 255, 255, 0.08)));
}
.appbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text, var(--sl-color-white, #fff));
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.appbar-brand img {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
}
.appbar-brand .test {
  color: var(--accent, var(--sl-color-accent, #f05a28));
}
.appbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.appbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--text2, var(--sl-color-gray-2, #c2c6cf));
  border: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.appbar-icon:hover {
  color: var(--text, var(--sl-color-white, #fff));
  border-color: var(--border2, var(--sl-color-gray-5, #3a3f4b));
}
.appbar-icon svg {
  width: 18px;
  height: 18px;
}
/* Primary nav link in the app header (e.g. Dev Tools). Text link, not a button,
   so it reads as navigation alongside the download CTAs. */
.appbar-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.42rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  color: var(--text2, var(--sl-color-gray-2, #c2c6cf));
  border: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.appbar-link:hover {
  color: var(--text, var(--sl-color-white, #fff));
  border-color: var(--border2, var(--sl-color-gray-5, #3a3f4b));
  background: rgba(255, 255, 255, 0.03);
}
.appbar-link.active {
  color: var(--accent, var(--sl-color-accent, #f05a28));
}
.appbar-link svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.nav-dl {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.42rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  color: #fff;
  border: 1px solid transparent;
  background: var(--accent, var(--sl-color-accent, #f05a28));
  transition: background 0.15s ease, transform 0.12s ease;
}
.nav-dl:hover {
  background: #ff6a38;
  transform: translateY(-1px);
}
.nav-dl svg {
  width: 14px;
  height: 14px;
}
@media (max-width: 72rem) {
  .nav-dl span {
    display: none;
  }
  .nav-dl {
    padding: 0.42rem 0.5rem;
  }
}
@media (max-width: 640px) {
  .appbar {
    gap: 0.6rem;
    padding: 0 1rem;
  }
  .site-search {
    width: auto;
    padding: 0.5rem;
  }
  .site-search .ss-label,
  .site-search .ss-kbd {
    display: none;
  }
  /* Collapse the Dev Tools link to its icon on small screens. */
  .appbar-link span {
    display: none;
  }
  .appbar-link {
    padding: 0.42rem 0.5rem;
  }
}
