/* =============================================================================
   VIEW-SEARCH — the search button in the top left of the inventory and spell
   sheet, the bar that slides out of it, and the greying of what doesn't match
   ============================================================================= */

/* ─── THE BUTTON ─────────────────────────────────────────── */
/* A zero-height row like the grid/list switch under it. z-index 4 stays under
   #gm-placeholder (5): a GM with nobody picked has nothing to search. */
#view-search-dock {
  position: relative;
  height: 0;
  flex-shrink: 0;
  z-index: 4;
}
#inventory-panel.sheet-view #view-search-dock,
#inventory-panel.map-view #view-search-dock { display: none; }

#view-search-btn {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 1; /* over the bar that slides out from behind */
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--panel);
  border: 1px solid var(--border2);
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
#view-search-btn:hover,
#view-search-dock.open #view-search-btn,
#view-search-dock.filtering #view-search-btn {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
}
#view-search-btn:hover { transform: translateY(-2px); }
#view-search-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
#view-search-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* A search is still greying things with the bar folded: a dot on the button. */
#view-search-dock.filtering:not(.open) #view-search-btn::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid var(--panel);
}

/* ─── THE BAR ────────────────────────────────────────────── */
/* Starts behind the button's centre and slides out to the right, so it reads
   as pulled from the button. Laid out while closed so it can animate back. */
#view-search-tray {
  position: absolute;
  top: 13px;
  left: 33px;
  width: 240px;
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 14px 0 30px;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  clip-path: inset(0 100% 0 0 round 18px);
  transition: clip-path 0.22s cubic-bezier(0.4, 0, 0.6, 1), opacity 0.16s ease,
              visibility 0s linear 0.22s;
}
#view-search-dock.open #view-search-tray {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
  clip-path: inset(0 0 0 0 round 18px);
  transition: clip-path 0.26s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.12s ease,
              visibility 0s;
}

#view-search-input {
  flex: 1;
  min-width: 0;
  padding: 0;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
}
#view-search-input::placeholder { color: var(--text-dim); }

/* Keep clear of the left panel's reopen button, like the grid/list switch. */
#app.equip-collapsed #view-search-btn  { left: 46px; }
#app.equip-collapsed #view-search-tray { left: 67px; }

/* ─── GREYING ────────────────────────────────────────────── */
/* Still there and still usable, only faded back so the matches stand out. */
.search-miss {
  opacity: 0.3;
  filter: grayscale(1);
}

@media (prefers-reduced-motion: reduce) {
  #view-search-tray, #view-search-dock.open #view-search-tray { clip-path: none; }
}
