/* Styles for the parts the static site adds: the demo's static preview, the
   header Search button and its dialog, search forms and results, and the 404
   picture. Everything else is the theme's own CSS. */

/* Header Search: a 44px icon (a link without JavaScript, a button that opens
   the dialog with it). Takes the header scheme's text color, like the menu;
   the label is for screen readers only. Hover and focus copy the theme's
   accessibility gear (.bgcandy-a11y-trigger in the theme's style.css), so
   the two icons behave alike. */
.mnc4-search-link,
.mnc4-search-dialog__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.mnc4-search-link:hover,
.mnc4-search-link:focus-visible,
.mnc4-search-link[aria-current="page"],
.mnc4-search-dialog__close:hover,
.mnc4-search-dialog__close:focus-visible {
  color: var(--accent, #a4552c);
  background: rgba(0, 0, 0, 0.05);
}

.mnc4-search-link:focus-visible,
.mnc4-search-dialog__close:focus-visible {
  outline: 2px solid var(--accent, #a4552c);
  outline-offset: 2px;
}

.mnc4-search-link__icon {
  flex: none;
}

/* When the header puts the preferences gear before the menu, the theme
   pushes the gear to the end of the row with an auto margin. The Search link
   sits just before the gear, so it takes that margin instead, or it was left
   alone beside the logo with the gap after it. */
.site-header > .mnc4-search-link:has(+ .wp-block-bgcandy-a11y-preferences ~ nav) {
  margin-inline-start: auto;
}

.site-header > .mnc4-search-link + .wp-block-bgcandy-a11y-preferences:has(~ nav) {
  margin-inline-start: 0;
}

.mnc4-search-link__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The header's 24px gaps shrink so the row (logo, Search, preferences with
   Pause, menu button) still fits on one line at 360px. */
@media (max-width: 600px) {
  /* Out-specifies the theme's body.header-layout-inline .site-header gap. */
  header .site-header,
  body.header-layout-inline header .site-header {
    column-gap: 12px;
  }
}

/* Search forms: the dialog and the 404 page (.mnc4-search-form), and the
   docs plugin's form on the search pages and in the docs sidebar
   (.ppdocs-search). The theme styles buttons (wp-element-button) but not
   fields, so the fields are styled here. */
.mnc4-search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.mnc4-search-form__label,
.ppdocs-search__label {
  flex: 1 0 100%;
  font-weight: 600;
}

.mnc4-search-form__input,
.ppdocs-search__input {
  flex: 1 1 12em;
  min-width: 0;
  min-height: 44px;
  box-sizing: border-box;
  padding: 0.5rem 0.75rem;
  border: 1px solid currentColor;
  border-radius: 8px;
  background: var(--paper, Canvas);
  color: inherit;
  font: inherit;
}

.mnc4-search-form__input:focus-visible,
.ppdocs-search__input:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

/* The browser's clear button would sit next to the dialog's close button,
   two crosses side by side. Select the text and delete it to clear the
   field. */
.mnc4-search-form__input::-webkit-search-cancel-button,
.ppdocs-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.ppdocs-search__form {
  align-items: center;
}

.mnc4-search-form--page {
  margin-block: 1.5rem;
}

/* Search dialog: covers the whole window, opaque. The body scheme's colors
   (so it follows the skin, dark mode and high contrast); the top band gets
   the header's color-scheme-N class from search-dialog.js and the header's
   height (--mnc4-header-height), and stays at the top while results scroll. */
.mnc4-search-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  border: 0;
  background: var(--paper, Canvas);
  color: var(--ink, CanvasText);
}

.mnc4-search-dialog::backdrop {
  background: var(--paper, Canvas);
}

html:has(.mnc4-search-dialog[open]) {
  overflow: hidden;
}

.mnc4-search-dialog__bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  min-height: var(--mnc4-header-height, 92px);
}

.mnc4-search-dialog__bar-inner {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.75rem;
  padding-block: 0.75rem;
}

/* A copy of the header's logo, in the same place, so the logo stays. */
.mnc4-search-dialog__logo {
  flex: none;
  margin-inline-end: clamp(0.5rem, 4vw, 3rem);
}

.mnc4-search-dialog__logo a,
.mnc4-search-dialog__logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.mnc4-search-dialog__bar .mnc4-search-form {
  flex: 1;
  flex-wrap: nowrap;
  column-gap: 1.25rem;
  min-width: 0;
}

.mnc4-search-dialog__bar .mnc4-search-form__label {
  flex: none;
  white-space: nowrap;
}

.mnc4-search-dialog__bar .mnc4-search-form__input {
  background: transparent;
  font-size: 1.125rem;
}

.mnc4-search-dialog__body {
  max-width: var(--wp--style--global--content-size, 760px);
  margin-inline: auto;
  padding: 2rem 1.25rem 3rem;
}

.mnc4-search-dialog__hint {
  margin: 0;
}

.mnc4-search-dialog__close {
  flex: none;
}

.mnc4-search-dialog .mnc4-search__status {
  margin: 0;
}

/* Not display: none, which can stop screen readers announcing the region. */
.mnc4-search-dialog .mnc4-search__status:empty {
  margin: 0;
}

.mnc4-search-dialog__all {
  margin: 1.5rem 0 0;
  font-weight: 600;
}

/* Narrow windows: the label goes above the field. */
@media (max-width: 600px) {
  .mnc4-search-dialog__bar-inner {
    align-items: flex-end;
  }

  .mnc4-search-dialog__bar .mnc4-search-form {
    flex-wrap: wrap;
  }

  .mnc4-search-dialog__bar .mnc4-search-form__label {
    flex: 1 0 100%;
  }

  .mnc4-search-dialog__body {
    padding: 1.5rem 1rem 2rem;
  }
}

.mnc4-404-cat {
  margin: 2rem 0 0;
}

.mnc4-404-cat img {
  display: block;
  width: min(100%, 28rem);
  height: auto;
  border-radius: 12px;
}

.mnc4-search__section {
  font-size: 0.8125rem;
  font-weight: 600;
  vertical-align: middle;
}

.mnc4-typost-specimen__text {
  font-size: clamp(2rem, 7vw, 4rem);
  line-height: 1.15;
  margin: 0 0 1rem;
}

.mnc4-typost-status {
  margin: 0.5rem 0 0;
}

.mnc4-search__results {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
}

.mnc4-search__result + .mnc4-search__result {
  margin-top: 1.5rem;
}

.mnc4-search__title {
  font-size: 1.25rem;
  margin: 0 0 0.25rem;
}

.mnc4-search__excerpt {
  margin: 0;
}
