/**
 * Search Component Styles
 * Integrates with existing Melanie Magidow site design
 */

/* Header layout adjustments */
.header-right {
  display: flex;
  align-items: center;
  flex: 1;
}

/* Search container - positioned below nav */
.search-container {
  position: relative;
  max-width: 600px;
  width: 100%;
  margin-top: 1rem;
}

/* Search form */
.search-form {
  position: relative;
  width: 100%;
}

/* Search input */
.search-input {
  width: 100%;
  padding: 0.625rem 1rem;
  font-family: 'Manrope', sans-serif;
  font-size: 0.9375rem;
  font-weight: 300;
  line-height: 1.5;
  color: var(--color-text, #333);
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: #999;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

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

/* Search toggle button (mobile only) */
.search-toggle {
  display: none;
  padding: 0.5rem;
  background: none;
  border: none;
  color: var(--color-text, #333);
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.search-toggle:hover {
  opacity: 0.7;
}

.search-toggle:focus {
  outline: 2px solid #999;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Search results dropdown */
.search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  max-height: 500px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 1000;
}

.search-results.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Search result items */
.search-result-item {
  display: block;
  padding: 1rem;
  border-bottom: 1px solid #eee;
  text-decoration: none;
  color: var(--color-text, #333);
  transition: background-color 0.2s ease;
}

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

.search-result-item:hover,
.search-result-item:focus {
  background-color: #f5f5f5;
  outline: none;
}

/* Search result title */
.search-result-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: var(--color-text, #333);
}

/* Search result metadata */
.search-result-meta {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: #666;
}

.search-date {
  color: #666;
}

.search-categories {
  color: #888;
  font-style: italic;
}

/* Search result summary */
.search-result-summary {
  font-size: 0.9375rem;
  line-height: 1.5;
  color: #555;
}

/* Highlight matching terms */
.search-result-item mark {
  background-color: #fffacd;
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
  font-weight: inherit;
}

/* Loading and no results states */
.search-result-item.loading,
.search-result-item.no-results {
  padding: 1.5rem;
  text-align: center;
  color: #666;
  font-style: italic;
}

/* Scrollbar styling for results */
.search-results::-webkit-scrollbar {
  width: 8px;
}

.search-results::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.search-results::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Responsive design - Mobile */
@media (max-width: 782px) {
  .search-toggle {
    display: block;
  }

  .search-input {
    opacity: 0;
    visibility: hidden;
    height: 0;
    padding: 0;
    border: 0;
    transition: opacity 0.2s ease, height 0.2s ease, visibility 0.2s, padding 0.2s ease;
  }

  .search-container.active .search-input {
    opacity: 1;
    visibility: visible;
    height: auto;
    padding: 0.625rem 1rem;
    border: 1px solid #ddd;
    margin-top: 1rem;
  }

  .search-results {
    max-height: 400px;
  }
}

/* Accessibility - Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .search-results,
  .search-container,
  .search-input,
  .search-result-item {
    transition: none;
  }
}

/* Focus visible for keyboard navigation */
.search-input:focus-visible {
  outline: 2px solid #999;
  outline-offset: 2px;
}

.search-result-item:focus-visible {
  outline: 2px solid #999;
  outline-offset: -2px;
}
