/* ============================================
   Search - client-side filtering
   Staggered fade + exact-height collapse + DOM reorder
   Matched cards float to TOP of list (right under search box)
   ============================================ */

.search-container {
  max-width: 600px;
  margin: 0 auto 40px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #f5f5f5;
  font-size: 1rem;
  font-family: var(--font-sans);
  transition: border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

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

/* ---- Unmatched cards: blur+dim then height collapses via JS ---- */
.is-hidden {
  opacity: 0 !important;
  filter: blur(4px) brightness(0.3) !important;
  transform: translateY(-6px) scale(0.96) !important;
  pointer-events: none !important;
  overflow: hidden;
  transition:
    opacity 0.28s cubic-bezier(0.4, 0, 0.8, 0.25),
    transform 0.28s cubic-bezier(0.4, 0, 0.8, 0.25),
    filter 0.32s cubic-bezier(0.4, 0, 0.8, 0.25),
    height 0.30s ease 0.16s,
    margin-top 0.30s ease 0.16s,
    margin-bottom 0.30s ease 0.16s,
    padding-top 0.30s ease 0.16s,
    padding-bottom 0.30s ease 0.16s;
}

/* ---- Matched cards re-appearing: gentle float up ---- */
.is-revealing {
  opacity: 0 !important;
  transform: translateY(12px) scale(0.98) !important;
  pointer-events: none;
  transition:
    opacity 0.40s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.44s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- FLIP active state: isolate transform layer during position animation ---- */
.is-flipping {
  will-change: transform, opacity;
}

/* Placeholder: full collapse when hidden during search */
.essay-card-placeholder.is-hidden,
.note-card-placeholder.is-hidden {
  max-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  overflow: hidden;
  transition: max-height 0.30s ease, margin 0.30s ease, padding 0.30s ease, opacity 0.25s ease;
}

/* No-results message */
.search-no-results {
  text-align: center;
  color: #666666;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 20px;
  transition: opacity 0.45s ease, max-height 0.45s ease, padding 0.45s ease;
}
.search-no-results.visible {
  opacity: 1;
  max-height: 140px;
  padding: 40px 20px;
}

@media (prefers-reduced-motion: reduce) {
  .is-hidden,
  .is-revealing {
    transition: none !important;
    opacity: 0 !important;
    filter: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .search-no-results { transition: none; }
}

@media (max-width: 768px) {
  .search-container { padding: 0 20px; }
}
