/* ... keep your :root and reset as they are ... */
.search_header{margin-bottom:2rem; }
/* 1. Hide the clear button by default */
.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  cursor: pointer;
  background: transparent;
  border: none;
  
  /* Critical: Hide it completely when collapsed */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition);
}

/* 2. Only show the clear button when the search bar is open AND has text */
.search.is-active .search-clear.visible, 
.search.open .search-clear.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 3. Ensure the search icon (toggle) stays on its own layer */
.search-toggle {
  position: relative;
  z-index: 25; /* Higher than clear button to ensure it's always clickable */
  flex-shrink: 0;
}

/* Remove background from all search-related buttons */
.search-toggle, 
.search-clear {
  background: none !important;      /* Removes the background color */
  background-color: transparent !important;
  border: none;                     /* Removes any default borders */
  box-shadow: none !important;      /* Removes shadows or focus rings */
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

/* Ensure no background appears on hover/focus */
.search-toggle:hover, 
.search-toggle:focus,
.search-clear:hover,
.search-clear:focus {
  background: transparent !important;
  background-color: transparent !important;
  color: var(--accent);             /* Optional: Change icon color on hover instead */
}

/* Ensure the container itself has no background if you want it fully transparent */
.search {
  background: transparent;
  /* border: 1px solid var(--search-border); */ /* Uncomment if you want the border gone too */
}
/* Remove the default browser-provided clear button */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

/* Search container */
.search {
  display: inline-flex;
  align-items: center;
  background: var(--search-bg);
  border: 1px solid var(--search-border);
  border-radius: 999px;
  padding: 4px; /* Slightly tighter padding for a modern look */
  height: var(--search-height);
  transition: all var(--transition);
  position: relative;
  overflow: visible; /* Ensure suggestions aren't cut off */
}

/* Wrapper to hold input and suggestions together */
.search-field-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

/* The search input: collapsed by default */
.search-input {
  width: 0;
  padding: 0;
  border: none;
  font-size: 15px;
  transition: width var(--transition), padding var(--transition), opacity var(--transition);
  background: transparent;
  outline: none;
  color: inherit;
  opacity: 0;
  pointer-events: none; /* Prevent typing when closed */
}

/* Open state: triggered by JS adding .is-active or .open */
.search.is-active, .search.open {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(11, 118, 239, 0.15);
}

.search.is-active .search-input, .search.open .search-input {
  width: var(--input-width);
  padding: 0 32px 0 8px; /* Room for 'X' button on right */
  opacity: 1;
  pointer-events: auto;
}

.search-clear:hover {
  color: #333;
}

/* Suggestions dropdown - 2026 Polish */
.suggestions {
  position: absolute;
  top: calc(100% + 10px); /* Gap below the bar */
  left: 0;
  width: 100%; /* Spans the width of the expanded search bar */
  min-width: 200px;
  padding: 8px 0;
  list-style: none;
  background: var(--suggestion-bg);
  border: 1px solid var(--suggestion-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 9999;
  font-size: 14px;
  animation: slideIn 0.2s ease-out;
}

/* SVG sizing */
.icon{
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Show clear button overlaid */
.search-clear{
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #666;
}


@keyframes slideIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Individual Suggestion Item */
.suggestions li {
  padding: 10px 16px;
  cursor: pointer;
  color: #444;
  transition: background 0.1s;
}

.suggestions li:hover {
  background: var(--suggestion-hover);
  color: var(--accent);
}

/* Highlighting the match - added via JS if you want bolding */
.suggestions b {
  color: var(--accent);
  font-weight: 600;
}
