/* ============================================================
   ParticleSearch — Theme-Agnostic Production Styles
   ============================================================ */

/* ------------------------------------------------------------
   1. GLOBAL / BODY LOCK
------------------------------------------------------------ */
.ps-body-lock {
  overflow: hidden !important;
  touch-action: none;
}

/* ------------------------------------------------------------
   2. LAYERING SYSTEM
------------------------------------------------------------ */
:root {
  --ps-z-overlay: 999998;
  --ps-z-modal: 999999;
  --ps-z-fallback: 999997;

  --ps-radius: 12px;
  --ps-bg: #ffffff;
  --ps-text: #111111;
  --ps-muted: #6b7280;
  --ps-border: rgba(0, 0, 0, 0.08);

  --ps-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

/* ------------------------------------------------------------
   3. OVERLAY
------------------------------------------------------------ */
.ps-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);

  opacity: 0;
  pointer-events: none;

  z-index: var(--ps-z-overlay);
  transition: opacity 0.2s ease;
}

.ps-overlay--open {
  opacity: 1;
  pointer-events: all;
}

/* ------------------------------------------------------------
   4. MODAL
------------------------------------------------------------ */
.ps-modal {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);

  width: min(680px, 95%);
  z-index: var(--ps-z-modal);

  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}

.ps-modal--open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: all;
}

/* ------------------------------------------------------------
   5. CLOSE BUTTON
------------------------------------------------------------ */
.ps-modal__close {
  position: fixed;
  top: 20px;
  right: 20px;

  width: 36px;
  height: 36px;
  border-radius: 999px;

  background: rgba(0, 0, 0, 0.5);
  color: #ffffff;
  border: none;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  z-index: var(--ps-z-modal);

  transition:
    transform 0.15s ease,
    background 0.15s ease;
}

.ps-modal__close:hover {
  transform: rotate(90deg);
  background: rgba(0, 0, 0, 0.7);
}

/* ------------------------------------------------------------
   6. CONTAINER
------------------------------------------------------------ */
.ps-container {
  width: 100%;
  font-family: inherit;
}

/* ------------------------------------------------------------
   7. INPUT
------------------------------------------------------------ */
.ps-input-wrapper {
  position: relative;
}

.ps-search-input {
  width: 100%;
  padding: 16px 48px 16px 16px;

  font-size: 16px;
  border-radius: var(--ps-radius);

  border: 1px solid var(--ps-border);
  background: var(--ps-bg);
  color: var(--ps-text);

  outline: none;
  box-shadow: var(--ps-shadow);

  appearance: none;
  -webkit-appearance: none;
}

.ps-search-input::placeholder {
  color: var(--ps-muted);
}

.ps-search-input:focus {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

/* ------------------------------------------------------------
   8. ICON / LOADING
------------------------------------------------------------ */
.ps-search-icon,
.ps-loading {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
}

.ps-search-icon {
  color: var(--ps-muted);
}

.ps-loading {
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  animation: ps-spin 0.6s linear infinite;
}

@keyframes ps-spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

/* ------------------------------------------------------------
   9. RESULTS
------------------------------------------------------------ */
.ps-results {
  margin-top: 8px;
  display: none;

  background: var(--ps-bg);
  border-radius: var(--ps-radius);

  box-shadow: var(--ps-shadow);
  max-height: 420px;
  overflow-y: auto;
}

.ps-results.ps-visible {
  display: block;
}

/* ------------------------------------------------------------
   10. RESULT ITEM
------------------------------------------------------------ */
.ps-result-item {
  display: flex;
  gap: 12px;
  padding: 12px;

  text-decoration: none;
  color: inherit;

  border-bottom: 1px solid var(--ps-border);
  transition: background 0.15s ease;
}

.ps-result-item:last-child {
  border-bottom: none;
}

.ps-result-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* ------------------------------------------------------------
   11. RESULT CONTENT
------------------------------------------------------------ */
.ps-result-image {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3f4f6;
}

.ps-result-content {
  flex: 1;
  min-width: 0;
}

.ps-result-title {
  font-size: 14px;
  font-weight: 500;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ps-result-title mark {
  background: rgba(255, 200, 0, 0.3);
  padding: 0 2px;
  border-radius: 2px;
}

.ps-result-meta {
  font-size: 13px;
  color: var(--ps-muted);
  display: flex;
  gap: 6px;
}

.ps-result-price {
  font-weight: 600;
}

/* ------------------------------------------------------------
   12. STATES
------------------------------------------------------------ */
.ps-no-results,
.ps-loading-state {
  padding: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--ps-muted);
}

/* ------------------------------------------------------------
   13. VIEW ALL
------------------------------------------------------------ */
.ps-view-all {
  padding: 12px;
  text-align: center;

  font-size: 13px;
  font-weight: 500;
  cursor: pointer;

  border-top: 1px solid var(--ps-border);
  background: rgba(0, 0, 0, 0.02);
}

.ps-view-all:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* ------------------------------------------------------------
   14. FALLBACK BUTTON
------------------------------------------------------------ */
.ps-fallback-btn {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: calc(24px + env(safe-area-inset-right));

  width: 48px;
  height: 48px;
  border-radius: 999px;

  border: none;
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;

  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);

  z-index: var(--ps-z-fallback);

  opacity: 0;
  transform: scale(0.8);
  animation: ps-fade-in 0.2s ease forwards;
}

.ps-fallback-btn:hover {
  transform: scale(1.05);
}

.ps-fallback-btn:focus {
  outline: 2px solid rgba(0, 0, 0, 0.5);
  outline-offset: 2px;
}

.ps-fallback-btn--hidden {
  opacity: 0;
  pointer-events: none;
}

@keyframes ps-fade-in {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ------------------------------------------------------------
   15. MOBILE
------------------------------------------------------------ */
@media (max-width: 640px) {
  .ps-modal {
    top: 20px;
    width: 94%;
  }

  .ps-search-input {
    font-size: 16px;
  }
}

/* ------------------------------------------------------------
   16. ACCESSIBILITY
------------------------------------------------------------ */
.ps-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
