/**
 * Search Modal Styles
 * Responsive, accessible, with smooth animations
 */

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

/* Search trigger button in nav */
.search-trigger {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: var(--text-color, #333);
  transition: color 0.2s ease;
}

.search-trigger:hover,
.search-trigger:focus {
  color: var(--primary-color, #0066cc);
  outline: 2px solid var(--primary-color, #0066cc);
  outline-offset: 2px;
}

/* Search modal container */
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 5vh 1rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.search-modal.active {
  display: flex;
  opacity: 1;
}

/* Overlay */
.search-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

/* Search container */
.search-container {
  position: relative;
  width: 100%;
  max-width: 640px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Search header */
.search-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.search-icon {
  color: #9ca3af;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1.125rem;
  color: #1f2937;
  background: transparent;
  padding: 0;
}

.search-input::placeholder {
  color: #9ca3af;
}

.search-close {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: #6b7280;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.search-close:hover,
.search-close:focus {
  background: #f3f4f6;
  color: #1f2937;
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

.search-help {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: #6b7280;
}

/* Search results */
.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  min-height: 200px;
  max-height: 50vh;
}

.search-results::-webkit-scrollbar {
  width: 8px;
}

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

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

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

/* Result item */
.search-result-item {
  display: block;
  padding: 1rem;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.search-result-item:hover,
.search-result-item:focus,
.search-result-item.selected {
  background: #f9fafb;
  border-color: #0066cc;
  outline: none;
}

.search-result-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 0.375rem;
  line-height: 1.5;
}

.search-result-description {
  font-size: 0.875rem;
  color: #6b7280;
  line-height: 1.6;
  margin-bottom: 0.375rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-url {
  font-size: 0.75rem;
  color: #9ca3af;
  font-family: monospace;
}

/* Highlight matching text */
.search-result-item mark {
  background: #fef3c7;
  color: #92400e;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  font-weight: 600;
}

/* Empty state */
.search-empty {
  padding: 3rem 2rem;
  text-align: center;
  color: #6b7280;
}

.search-empty p {
  margin: 0;
  font-size: 0.9375rem;
}

/* Search footer */
.search-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 0 0 12px 12px;
}

.search-shortcuts {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: #6b7280;
  align-items: center;
}

.search-shortcuts kbd {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.75rem;
  color: #374151;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.search-stats {
  font-size: 0.75rem;
  color: #6b7280;
  font-weight: 500;
}

/* Responsive design */
@media (max-width: 768px) {
  .search-modal {
    padding: 0;
    align-items: stretch;
  }

  .search-container {
    max-width: 100%;
    border-radius: 0;
    max-height: 100vh;
  }

  .search-header {
    padding: 1rem;
  }

  .search-input {
    font-size: 1rem;
  }

  .search-footer {
    padding: 0.5rem 1rem;
  }

  .search-shortcuts {
    font-size: 0.625rem;
    gap: 0.5rem;
  }

  .search-shortcuts kbd {
    padding: 0.125rem 0.375rem;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .search-container {
    background: #1f2937;
  }

  .search-header {
    border-bottom-color: #374151;
  }

  .search-input {
    color: #f9fafb;
  }

  .search-input::placeholder {
    color: #6b7280;
  }

  .search-close {
    color: #9ca3af;
  }

  .search-close:hover,
  .search-close:focus {
    background: #374151;
    color: #f9fafb;
  }

  .search-result-item:hover,
  .search-result-item:focus,
  .search-result-item.selected {
    background: #374151;
  }

  .search-result-title {
    color: #f9fafb;
  }

  .search-result-description {
    color: #d1d5db;
  }

  .search-result-url {
    color: #9ca3af;
  }

  .search-result-item mark {
    background: #78350f;
    color: #fef3c7;
  }

  .search-footer {
    background: #111827;
    border-top-color: #374151;
  }

  .search-shortcuts kbd {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }
}

/* Print styles */
@media print {
  .search-modal,
  .search-trigger {
    display: none !important;
  }
}

/* Focus visible for keyboard navigation */
.search-result-item:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Loading state (optional for future enhancement) */
.search-results.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.search-results.loading::after {
  content: "검색 중...";
  color: #6b7280;
  font-size: 0.875rem;
}
