/* SPDX-License-Identifier: Apache-2.0 */

/* The site bar (site-bar.mjs) and its search dialog (search.js), shared by the
   docs and the website pages. Colors and fonts come from tokens.css (--os-*).
   The page around the bar only places it: the docs header stacks the topic
   tabs below it, and the website pages make it sticky. */
:root {
  --site-text: color-mix(in srgb, var(--os-fg) 88%, var(--os-bg));
}

.site-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--os-header-h);
  padding-inline: 1.25rem;
  border-bottom: 1px solid var(--os-border);
  font-family: var(--os-font-sans);
  line-height: 1.5;
}
@media (min-width: 50rem) {
  .site-bar {
    padding-inline: 1.5rem;
  }
}
@media print {
  .site-bar {
    display: none;
  }
}
.site-bar .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-bar__wordmark {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.55rem;
  color: var(--os-fg);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.site-bar__wordmark svg {
  width: auto;
  height: 1.625rem;
}

/* Site links, set off from the wordmark by a divider */
.site-bar__links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-inline-start: 0.75rem;
  margin-inline-end: auto;
  padding-inline-start: 1rem;
  border-inline-start: 1px solid var(--os-border);
}
.site-bar__link {
  padding: 0.25rem 0.5rem;
  color: var(--os-fg);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.site-bar__link:hover,
.site-bar__link[aria-current="page"] {
  color: var(--os-accent-text);
}
@media (width < 50rem) {
  .site-bar {
    gap: 0.5rem;
  }
  .site-bar__links {
    gap: 0;
    margin-inline-start: 0.25rem;
    padding-inline-start: 0.5rem;
  }
  .site-bar__link {
    padding-inline: 0.375rem;
  }
}

.site-bar__end {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
/* GitHub link and theme toggle */
.icon-button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--os-radius);
  background: none;
  color: var(--os-muted);
  cursor: pointer;
}
.icon-button:hover {
  color: var(--os-fg);
  background: var(--os-surface);
}
.icon-button svg {
  width: 1.125rem;
  height: 1.125rem;
}
/* theme-toggle.js sets data-theme-choice: auto, light, or dark */
:root:not([data-theme-choice="light"]) .theme-toggle__light,
:root:not([data-theme-choice="dark"]) .theme-toggle__dark,
:root[data-theme-choice="light"] .theme-toggle__auto,
:root[data-theme-choice="dark"] .theme-toggle__auto {
  display: none;
}

/* ---------- search ---------- */
.search-button {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.5rem;
  width: 16rem;
  height: 2.25rem;
  padding: 0 0.5rem 0 0.75rem;
  border: 1px solid var(--os-border);
  border-radius: var(--os-radius);
  background: var(--os-surface);
  color: var(--os-muted);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}
.search-button:hover {
  color: var(--os-fg);
}
.search-button svg {
  width: 1rem;
  height: 1rem;
  flex: none;
}
.search-button__label {
  margin-inline-end: auto;
}
.search-button__kbd {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--os-border);
  border-radius: 4px;
  background: var(--os-bg);
  font-family: var(--os-font-sans);
  font-size: 0.75rem;
}
.search-dialog {
  width: min(100% - 2rem, 45rem);
  max-height: calc(100% - 8rem);
  margin: 4rem auto auto;
  padding: 0;
  border: 1px solid var(--os-border);
  border-radius: var(--os-radius);
  background: var(--os-bg);
  color: var(--site-text);
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.25);
}
.search-dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(2px);
}
.search-dialog__frame {
  position: relative;
  padding: 1rem;
}
/* The close button sits at the end of the search field's row */
.search-dialog__close {
  position: absolute;
  top: calc(1rem + (64px * 0.8 - 2rem) / 2);
  right: 1rem;
  /* Above the search form, which spans the full width */
  z-index: 10;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--os-radius);
  background: none;
  color: var(--os-muted);
  cursor: pointer;
}
.search-dialog__close:hover {
  color: var(--os-fg);
  background: var(--os-surface);
}
.search-dialog__close svg {
  width: 1.25rem;
  height: 1.25rem;
}
/* Room for the close button next to the field (the results stay full width) */
#site-search .pagefind-ui__search-input {
  width: calc(100% - 2.5rem);
}
/* Clear reads as a link */
#site-search .pagefind-ui__search-clear {
  right: calc(2.5rem + 1px);
  padding: 0 0.75rem;
  color: var(--os-accent-text);
  font-size: 0.875rem;
  font-weight: 500;
}
#site-search .pagefind-ui__search-clear:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
#site-search {
  --pagefind-ui-scale: 0.8;
  --pagefind-ui-primary: var(--os-fg);
  --pagefind-ui-text: var(--site-text);
  --pagefind-ui-background: var(--os-bg);
  --pagefind-ui-border: var(--os-border);
  --pagefind-ui-tag: var(--os-surface);
  --pagefind-ui-border-radius: var(--os-radius);
  --pagefind-ui-font: var(--os-font-sans);
}
/* Whole result rows are clickable: each result title link stretches over its
   row (the page row, or one section row nested under it). */
#site-search .pagefind-ui__result-inner,
#site-search .pagefind-ui__result-nested {
  position: relative;
  border-radius: var(--os-radius);
}
/* Tighter results; each page gets a page icon before its title */
#site-search .pagefind-ui__result {
  padding: 0.35rem 0;
}
#site-search .pagefind-ui__result-inner {
  padding: 0.5rem 0.75rem;
}
#site-search .pagefind-ui__result-inner > .pagefind-ui__result-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
#site-search .pagefind-ui__result-inner > .pagefind-ui__result-title::before {
  content: "";
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  background: var(--os-muted);
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5M9 13h6M9 17h6'/%3E%3C/svg%3E")
    center / contain no-repeat;
}
/* Excerpts and sections line up with the title text, after the icon */
#site-search .pagefind-ui__result-inner > .pagefind-ui__result-excerpt {
  margin-inline-start: 1.625rem;
}
#site-search .pagefind-ui__result-nested {
  /* Full row width, not the width of the text (Pagefind lays rows out with
     align-items: flex-start) */
  align-self: stretch;
  z-index: 1;
  /* Cancel the page row's side padding so both highlights are equally wide */
  margin-inline: -0.75rem;
  padding: 0.35rem 0.75rem 0.35rem calc(0.75rem + 1.625rem);
}
/* Pagefind positions section links (for the arrow), which would limit their
   overlay to the link text; keep the arrow inline instead. */
#site-search .pagefind-ui__result-nested .pagefind-ui__result-link,
#site-search .pagefind-ui__result-nested .pagefind-ui__result-link::before {
  position: static;
}
#site-search .pagefind-ui__result-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
#site-search .pagefind-ui__result-inner:hover:not(:has(.pagefind-ui__result-nested:hover)),
#site-search .pagefind-ui__result-nested:hover,
#site-search .pagefind-ui__result-inner:has(> .pagefind-ui__result-title .pagefind-ui__result-link:focus-visible),
#site-search .pagefind-ui__result-nested:has(.pagefind-ui__result-link:focus-visible) {
  background: var(--os-surface);
}
#site-search .pagefind-ui__result-link:focus-visible {
  outline: none;
}
/* Keyboard focus: the row's highlight plus an accent bar on its left edge */
#site-search .pagefind-ui__result-link:focus-visible::after {
  box-shadow: inset 3px 0 0 var(--os-accent);
}
/* Where a result comes from (Core, Go SDK, Community), top right of its row */
#site-search .pagefind-ui__result-tags {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  margin: 0;
}
#site-search .pagefind-ui__result-tag {
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--os-accent) 14%, transparent);
  color: var(--os-accent-text);
  font-size: 0.75rem;
  font-weight: 500;
}
#site-search .pagefind-ui__result-title {
  padding-inline-end: 6rem;
}
/* Type scale of the rest of the site: semibold titles, a regular-weight query,
   and excerpts at the docs' small-text size (Pagefind defaults to bold and
   12.8px at this scale) */
#site-search .pagefind-ui__search-input {
  font-weight: 400;
}
#site-search .pagefind-ui__result-title {
  font-weight: 600;
}
#site-search .pagefind-ui__result-excerpt {
  font-size: 0.875rem;
  line-height: 1.5;
}
#site-search .pagefind-ui__message,
#site-search .pagefind-ui__button {
  font-weight: 600;
}
#site-search mark {
  background: none;
  color: var(--os-accent-text);
  font-weight: 600;
}
@media (width < 50rem) {
  .search-button {
    width: 2rem;
    height: 2rem;
    padding: 0;
    justify-content: center;
    border: 0;
    background: none;
  }
  .search-button svg {
    width: 1.125rem;
    height: 1.125rem;
  }
  .search-button__label,
  .search-button__kbd {
    display: none;
  }
}
