/* ==========================================================================
   Search Palette — Command palette-style global search overlay
   ========================================================================== */

/* Overlay container */
.search-palette {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.search-palette[hidden] {
  display: none;
}

/* Dark backdrop */
.search-palette__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 31, 53, 0.7);
  animation: sp-backdrop-in 150ms ease-out;
}

@keyframes sp-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Main panel */
.search-palette__panel {
  position: relative;
  width: 100%;
  max-width: 680px;
  max-height: 70vh;
  margin: 0 16px;
  background: #fff;
  border-radius: 8px;
  box-shadow:
    0 16px 70px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sp-panel-in 150ms ease-out;
}

@keyframes sp-panel-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Input area */
.search-palette__input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.search-palette__icon {
  flex-shrink: 0;
  color: #6b7280;
}

.search-palette__input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 18px;
  font-family: 'Noto Sans', sans-serif;
  color: var(--color-navy, #0b1f35);
  background: transparent;
  line-height: 1.4;
}

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

.search-palette__input::-webkit-search-cancel-button {
  display: none;
}

.search-palette__kbd {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  font-family: 'Noto Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  line-height: 1;
}

/* Results area */
.search-palette__results {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scroll-behavior: smooth;
}

/* Empty / hint state */
.search-palette__empty-state {
  padding: 32px 20px;
  text-align: center;
}

.search-palette__hint {
  color: #6b7280;
  font-size: 14px;
  margin: 0;
  line-height: 1.5;
}

/* No results */
.search-palette__no-results {
  padding: 32px 20px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
  line-height: 1.5;
}

.search-palette__no-results strong {
  color: var(--color-navy, #0b1f35);
}

/* Loading */
.search-palette__loading {
  padding: 24px 20px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}

.search-palette__loading::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  border: 2px solid #e5e7eb;
  border-top-color: var(--color-gov-blue, #1d70b8);
  border-radius: 50%;
  animation: sp-spin 0.6s linear infinite;
  vertical-align: middle;
}

@keyframes sp-spin {
  to { transform: rotate(360deg); }
}

/* Type group heading */
.search-palette__group-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px 4px;
  margin-top: 4px;
}

.search-palette__group-heading:first-child {
  margin-top: 0;
}

.search-palette__type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 3px;
  line-height: 1.6;
}

.search-palette__type-badge--guide {
  background: #e0edfa;
  color: #1d70b8;
}

.search-palette__type-badge--journey {
  background: #d1fae5;
  color: #047857;
}

.search-palette__type-badge--regulator {
  background: #ede9fe;
  color: #6d2066;
}

.search-palette__type-badge--legislation {
  background: #fef4ed;
  color: #c25614;
}

.search-palette__type-badge--topic {
  background: #d1fae5;
  color: #065f46;
}

.search-palette__type-badge--activity {
  background: #fef3c7;
  color: #92400e;
}

.search-palette__group-count {
  font-size: 12px;
  color: #9ca3af;
}

/* Result item */
.search-palette__result {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background-color 80ms ease;
}

.search-palette__result:hover,
.search-palette__result[aria-selected="true"] {
  background: var(--color-bg-alt, #f4f8fb);
}

.search-palette__result:focus-visible {
  outline: 3px solid var(--color-focus, #ffdd00);
  outline-offset: -3px;
}

.search-palette__result-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: #9ca3af;
}

.search-palette__result[aria-selected="true"] .search-palette__result-icon {
  color: var(--color-gov-blue, #1d70b8);
}

.search-palette__result-content {
  flex: 1;
  min-width: 0;
}

.search-palette__result-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-navy, #0b1f35);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-palette__result-description {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.4;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-palette__result-meta {
  flex-shrink: 0;
  font-size: 12px;
  color: #9ca3af;
  margin-top: 2px;
}

/* Footer */
.search-palette__footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #9ca3af;
}

.search-palette__footer kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  font-family: 'Noto Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  line-height: 1;
  margin: 0 2px;
}

/* Header trigger — wide search bar style */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.5);
  font-family: 'Noto Sans', sans-serif;
  font-size: 16px;
  cursor: text;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  line-height: 1.4;
  min-width: 0;
}

.search-trigger:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.32);
  color: rgba(255, 255, 255, 0.7);
}

.search-trigger:focus-visible {
  outline: none;
  border-color: var(--color-focus, #ffdd00);
  box-shadow: 0 0 0 2px var(--color-focus, #ffdd00);
}

.search-trigger__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.6;
}

.search-trigger__label {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-trigger__shortcut {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.45);
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .search-palette {
    padding-top: 0;
    align-items: stretch;
  }

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

  .search-palette__footer {
    display: none;
  }

  .search-trigger {
    padding: 10px 14px;
    font-size: 15px;
  }

  .search-trigger__shortcut {
    display: none;
  }
}
