/* ==========================================================================
   Site search (Even theme)
   Kept dependency-free so the search box can be used on every page.
   ========================================================================== */

.search-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header trigger ---------- */

.search-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 1.75em;
  margin: 0;
  padding: 0 3px;
  border: 0;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  line-height: 1;
  vertical-align: middle;
  cursor: pointer;
}

.search-trigger:hover,
.search-trigger:focus-visible {
  color: #b22222;
}

.search-trigger:focus-visible {
  outline: 2px solid rgba(178, 34, 34, 0.35);
  outline-offset: 3px;
}

.search-trigger-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Mobile trigger ---------- */

.mobile-search-toggle {
  display: none;
}

.mobile-search-toggle:focus-visible {
  outline: 2px solid rgba(178, 34, 34, 0.35);
  outline-offset: 2px;
}

.mobile-menu-item-search {
  display: flex;
  align-items: center;
}

.mobile-menu-search-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Modal ---------- */

html.search-modal-open,
html.search-modal-open body {
  overflow: hidden;
  overscroll-behavior: none;
}

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh 20px 30px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(10, 10, 10, 0.46);
  opacity: 0;
  transition: opacity 0.16s ease;
}

.search-overlay[hidden] {
  display: none !important;
}

.search-overlay.is-open {
  opacity: 1;
}

.search-dialog {
  width: 100%;
  max-width: 720px;
  padding: 22px 24px 16px;
  border: 1px solid #e6e6e6;
  border-radius: 4px;
  background: #fefefe;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  transform: translateY(-8px);
  transition: transform 0.16s ease;
}

.search-overlay.is-open .search-dialog {
  transform: translateY(0);
}

.search-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.search-dialog-title {
  margin: 0;
  padding: 0;
  font-family: inherit;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.3;
  color: #000;
}

.search-close {
  flex: none;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: #8a8a8a;
  font-family: inherit;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.search-close:hover,
.search-close:focus-visible {
  color: #b22222;
  background: #f8f5ec;
}

.search-close:focus-visible {
  outline: 2px solid rgba(178, 34, 34, 0.35);
  outline-offset: 1px;
}

/* ---------- Input ---------- */

.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.search-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 11px 13px;
  border: 1px solid #e6e6e6;
  border-radius: 3px;
  background: #fff;
  color: #000;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.4;
  outline: none;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

.search-input::placeholder {
  color: #a9a9a9;
}

.search-input:focus {
  border-color: #b22222;
  box-shadow: 0 0 0 2px rgba(178, 34, 34, 0.12);
}

.search-kbd,
.search-hint kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid #e6e6e6;
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #f8f5ec;
  color: #8a8a8a;
  font-family: Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.search-status {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: #8a8a8a;
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- Results ---------- */

.search-results {
  margin-top: 8px;
  border-bottom: 0;
}

.search-overlay .search-results {
  max-height: 58vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.search-results .post {
  padding: 0.72em 0;
}

.search-results .post:first-child {
  padding-top: 0.55em;
}

.search-results .post-header {
  margin-bottom: 5px;
}

/* even-custom.css adds a large top margin to .post-content; not wanted here. */
.search-results .post .post-content {
  margin-top: 0;
}

.search-results .post-title {
  font-size: 17px;
  line-height: 1.35;
}

.search-results .post-title .post-link {
  color: #000;
}

.search-results .post-title .post-link:hover {
  color: #b22222;
}

.search-results .post-meta {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.5;
}

.search-results .post-header .post-meta .post-time {
  font-size: 12px;
}

.search-results .post-summary {
  margin-bottom: 0;
  color: #333;
  font-size: 13.5px;
  line-height: 1.55;
}

.search-results .post-summary p {
  margin: 0;
}

.search-result-category::before {
  content: '·';
  margin: 0 4px;
  color: #8a8a8a;
}

.search-result-tags {
  word-break: break-word;
}

.search-result.is-active {
  padding-right: 10px;
  padding-left: 10px;
  border-radius: 3px;
  background: rgba(178, 34, 34, 0.045);
  box-shadow: inset 3px 0 0 #b22222;
}

.search-results mark {
  padding: 0 0.1em;
  border-radius: 2px;
  background: rgba(178, 34, 34, 0.16);
  color: inherit;
}

.search-hint {
  margin: 14px 0 0;
  color: #8a8a8a;
  font-size: 12px;
  line-height: 1.6;
  text-align: right;
}

/* ---------- Dedicated /search/ page ---------- */

.search-page {
  margin-bottom: 3em;
}

.search-page .search-form {
  max-width: 100%;
}

.search-page .search-status {
  margin-top: 14px;
}

.search-page .search-results {
  margin-top: 1.4em;
}

.search-page .search-results .post:first-child {
  padding-top: 1.5em;
}

/* ---------- Responsive ---------- */

@media screen and (max-width: 800px) {
  .mobile-search-toggle {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: #b22222;
    cursor: pointer;
  }

  .mobile-search-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Let the dialog grow with its results. Flex+stretch would cap the dialog
     at one viewport height, so overflowing result cards lose the white
     dialog background and show the page through the overlay. */
  .search-overlay {
    display: block;
    padding: 0;
  }

  .search-dialog {
    min-height: 100vh;
    min-height: 100dvh;
    max-width: none;
    padding: 16px 16px 24px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
  }

  .search-overlay.is-open .search-dialog {
    transform: none;
  }

  .search-overlay .search-results {
    max-height: none;
    overflow-y: visible;
  }

  .search-kbd {
    display: none;
  }

  .search-hint {
    text-align: left;
  }
}
