/* Search toggle icon in header */
.search-toggle {
  float: right;
  margin-left: 1rem;
  line-height: 6rem;
  font-size: 1.7rem;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}

.search-toggle:hover,
.search-toggle:focus {
  text-decoration: none;
}

/* Search overlay */
.search-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: flex-start;
  padding-top: 10vh;
}

.search-overlay.active {
  display: flex;
}

.search-overlay-content {
  background-color: #fafafa;
  color: #212121;
  width: 90%;
  max-width: 60rem;
  border-radius: 1rem;
  padding: 2rem;
  position: relative;
  max-height: 80vh;
  overflow-y: auto;
}

/* Close button */
.search-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #212121;
  line-height: 1;
}

.search-close:hover {
  color: #1565c0;
}

/* Search input */
.search-input {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.8rem;
  border: 2px solid #e0e0e0;
  border-radius: 0.6rem;
  background-color: #fafafa;
  color: #212121;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}

.search-input:focus {
  border-color: #1565c0;
}

/* Search results */
.search-results {
  margin-top: 1.5rem;
}

.search-results-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.search-result-item {
  padding: 1.2rem 0;
  border-bottom: 1px solid #e0e0e0;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  text-decoration: none;
  color: #1565c0;
  font-weight: 600;
}

.search-result-item a:hover {
  text-decoration: underline;
}

.search-result-title {
  font-size: 1.8rem;
}

.search-result-date {
  font-size: 1.4rem;
  color: #757575;
  white-space: nowrap;
  margin-left: 1rem;
}

.search-result-summary {
  font-size: 1.4rem;
  color: #616161;
  margin: 0.5rem 0 0 0;
  line-height: 1.5;
}

.search-no-results,
.search-error {
  font-size: 1.6rem;
  color: #757575;
  text-align: center;
  padding: 2rem 0;
}

/* Dark mode */
body.colorscheme-dark .search-overlay-content {
  background-color: #212121;
  color: #dadada;
}

body.colorscheme-dark .search-close {
  color: #dadada;
}

body.colorscheme-dark .search-close:hover {
  color: #42a5f5;
}

body.colorscheme-dark .search-input {
  background-color: #212121;
  color: #dadada;
  border-color: #424242;
}

body.colorscheme-dark .search-input:focus {
  border-color: #42a5f5;
}

body.colorscheme-dark .search-result-item {
  border-bottom-color: #424242;
}

body.colorscheme-dark .search-result-item a {
  color: #42a5f5;
}

body.colorscheme-dark .search-result-date {
  color: #9e9e9e;
}

body.colorscheme-dark .search-result-summary {
  color: #9e9e9e;
}

body.colorscheme-dark .search-no-results,
body.colorscheme-dark .search-error {
  color: #9e9e9e;
}

/* Auto color scheme (follows OS preference) */
@media (prefers-color-scheme: dark) {
  body.colorscheme-auto .search-overlay-content {
    background-color: #212121;
    color: #dadada;
  }

  body.colorscheme-auto .search-close {
    color: #dadada;
  }

  body.colorscheme-auto .search-close:hover {
    color: #42a5f5;
  }

  body.colorscheme-auto .search-input {
    background-color: #212121;
    color: #dadada;
    border-color: #424242;
  }

  body.colorscheme-auto .search-input:focus {
    border-color: #42a5f5;
  }

  body.colorscheme-auto .search-result-item {
    border-bottom-color: #424242;
  }

  body.colorscheme-auto .search-result-item a {
    color: #42a5f5;
  }

  body.colorscheme-auto .search-result-date {
    color: #9e9e9e;
  }

  body.colorscheme-auto .search-result-summary {
    color: #9e9e9e;
  }

  body.colorscheme-auto .search-no-results,
  body.colorscheme-auto .search-error {
    color: #9e9e9e;
  }
}

/* Mobile responsive */
@media only screen and (max-width: 768px) {
  .search-toggle {
    float: none;
    position: absolute;
    right: 5rem;
    top: 0;
  }

  .search-overlay-content {
    width: 95%;
    padding: 1.5rem;
  }

  .search-result-item a {
    flex-direction: column;
  }

  .search-result-date {
    margin-left: 0;
    margin-top: 0.3rem;
  }
}
