/* ==========================================================
   NAV SEARCH OVERLAY
   ========================================================== */

/* ── Trigger button — matches cart / portal icon sizing exactly ── */

.nav-item--search {
  display: flex;
  align-items: center;
}

.nav-actions .nav-link--search {
  position: relative;
  width: var(--nav-action-size);
  min-width: var(--nav-action-size);
  height: var(--nav-action-size);
  min-height: var(--nav-action-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 1px solid var(--theme-surface-white-12);
  border-radius: var(--nav-item-radius);
  color: var(--theme-text-main-soft);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease,
    transform 0.22s cubic-bezier(0.34, 1.28, 0.64, 1),
    box-shadow 0.22s ease;
}

.nav-actions .nav-link--search:hover {
  background: var(--theme-surface-white-08, rgba(255, 255, 255, 0.08));
  color: #fff;
}

/* ── Overlay backdrop ── */

.nav-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* Same navbar gap as the menu megas / cart / portal dropdowns */
  padding: calc(var(--nav-h) + var(--nav-dropdown-gap, 0.75rem)) 1rem 2rem;
  overflow-y: auto;
}

.nav-search-overlay[hidden] {
  display: none !important;
}

.nav-search-overlay__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 7, 0.78);
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);

  opacity: 0;
  transition: opacity 180ms ease;
}

.nav-search-overlay.is-open .nav-search-overlay__backdrop {
  opacity: 1;
  transition: opacity 220ms ease;
}

/* ── Panel ── */

.nav-search-overlay__panel {
  position: relative;
  width: 100%;
  max-width: 660px;
  display: flex;
  flex-direction: column;

  /* Liquid glass surface — diagonal light refraction */
  background: linear-gradient(
    155deg,
    rgba(255, 255, 255, 0.13) 0%,
    rgba(255, 255, 255, 0.06) 38%,
    rgba(255, 255, 255, 0.025) 100%
  );

  border: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom-color: rgba(255, 255, 255, 0.09);

  border-radius: 1.1rem;

  box-shadow:
    /* specular top-edge highlight */
    inset 0 1.5px 0 rgba(255, 255, 255, 0.32),
    /* subtle side rim lights */
    inset 1px 0 0 rgba(255, 255, 255, 0.07),
    inset -1px 0 0 rgba(255, 255, 255, 0.04),
    /* depth shadows */
    0 2rem 5rem rgba(0, 0, 0, 0.55),
    0 0.5rem 1.4rem rgba(0, 0, 0, 0.32);

  overflow: hidden;
  isolation: isolate;

  /* Closed/exit state — .is-open on the overlay transitions it in.
     The exit (this rule) is slightly faster than the entry. */
  opacity: 0;
  transform: translateY(-12px) scale(0.97);
  transition:
    opacity 160ms ease,
    transform 200ms ease-in;
}

.nav-search-overlay.is-open .nav-search-overlay__panel {
  opacity: 1;
  transform: none;
  transition:
    opacity 220ms ease,
    transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Backdrop blur layer — heavier blur + slight dark tint for glass depth */
.nav-search-overlay__panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(6, 7, 12, 0.18);
  backdrop-filter: blur(54px) saturate(175%) brightness(0.65);
  -webkit-backdrop-filter: blur(54px) saturate(175%) brightness(0.65);
}

.nav-search-overlay__header,
.nav-search-overlay__body,
.nav-search-overlay__hint {
  position: relative;
  z-index: 1;
}

/* ── Header / input row ── */

.nav-search-overlay__header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  /* Keeps the input area its original dark tone, distinct from the glass body */
  background: rgba(4, 5, 9, 0.56);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.nav-search-overlay__input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.nav-search-overlay__input-icon {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.36);
  font-size: 0.95rem;
}

.nav-search-overlay__input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 450;
  line-height: 1.4;
  caret-color: rgba(255, 255, 255, 0.7);
}

.nav-search-overlay__input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

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

/* Clear (×) button */
.nav-search-overlay__clear {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  width: 1.5rem;
  height: 1.5rem;
  background: transparent;
  border: none;
  border-radius: 99px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.95rem;
  cursor: pointer;
  transition:
    background 140ms ease,
    color 140ms ease;
}

.nav-search-overlay__clear[hidden],
.nav-search-overlay__close[hidden] {
  display: none;
}

.nav-search-overlay__clear:hover {
  transition:
    background 140ms ease,
    color 140ms ease;

  transform: scale(1.1);
  color: #fff;
}

/* Esc close button */
.nav-search-overlay__close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
  padding: 0.2rem 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.38rem;
  color: rgba(255, 255, 255, 0.38);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    background 140ms ease,
    color 140ms ease,
    border-color 140ms ease;
  white-space: nowrap;
}

.nav-search-overlay__close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  border-color: rgba(255, 255, 255, 0.18);
}

/* ── Body / results ── */

.nav-search-overlay__body {
  overflow-y: auto;
  max-height: calc(100vh - 14rem);
  padding: 0.5rem 0.5rem 1rem;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.nav-search-overlay__body::-webkit-scrollbar {
  width: 4px;
}

.nav-search-overlay__body::-webkit-scrollbar-track {
  background: transparent;
}

.nav-search-overlay__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  transition: background 140ms ease;
}

.nav-search-overlay__body:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
}

.nav-search-overlay__body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Group */
.nav-search-overlay__group + .nav-search-overlay__group {
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
}

.nav-search-overlay__group-label,
.nav-search-overlay__suggested-label {
  padding: 0.55rem 0.7rem 0.35rem;
  color: rgba(255, 255, 255, 0.28);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-search-overlay__group-items,
.nav-search-overlay__suggested {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Empty / loading */
.nav-search-overlay__empty,
.nav-search-overlay__loading {
  padding: 2.5rem 1rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.88rem;
  line-height: 1.6;
}

.nav-search-overlay__empty strong {
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
}

/* ── Result rows ── */

.nav-search-result {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 0.8rem;
  border-radius: 0.7rem;
  border: 1px solid transparent;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  min-width: 0;
  transition:
    background 140ms ease,
    border-color 140ms ease;
}

.nav-search-result:hover,
.nav-search-result.is-active {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.09);
}

/* ── Page result icon ── */

.nav-search-result__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.95rem;
  transition:
    background 140ms ease,
    color 140ms ease;
}

.nav-search-result:hover .nav-search-result__icon,
.nav-search-result.is-active .nav-search-result__icon {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.78);
}

/* ── Item thumbnail ── */

.nav-search-result__thumb {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  overflow: hidden;
  padding: 0.25rem;
}

.nav-search-result__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0.3rem;
}

.nav-search-result__img-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: rgba(255, 255, 255, 0.2);
  font-size: 1rem;
}

/* ── Text body ── */

.nav-search-result__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.nav-search-result__name {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-search-result__sub {
  color: rgba(255, 255, 255, 0.36);
  font-size: 0.76rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Type badge ── */

.nav-search-result__badge {
  flex-shrink: 0;
  padding: 0.2rem 0.55rem;
  border-radius: 2rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.nav-search-result__badge--page {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.38);
}

.nav-search-result__badge--service {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.25);
  color: rgba(147, 197, 253, 0.9);
}

.nav-search-result__badge--upgrade {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.25);
  color: rgba(216, 180, 254, 0.9);
}

/* ── Arrow ── */

.nav-search-result__arrow {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0);
  font-size: 0.68rem;
  transition:
    color 140ms ease,
    transform 140ms ease;
}

.nav-search-result:hover .nav-search-result__arrow,
.nav-search-result.is-active .nav-search-result__arrow {
  color: rgba(255, 255, 255, 0.4);
  transform: translateX(3px);
}

/* ── Keyboard hint ── */
.nav-search-overlay__hint {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0.72rem 1rem;
  /* Keeps the hint bar its original dark tone, matching the header */
  background: rgba(4, 5, 9, 0.56);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.22);
  font-size: 0.76rem;
}

.nav-search-overlay__hint-key {
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
}

.nav-search-overlay__hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.14rem 0.42rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.28rem;
  font-family: inherit;
  font-size: 0.74rem;
  line-height: 1.4;
}

/* ── Mobile nav search bar (inside nav-panel) ── */

.nav-mobile-search-bar {
  display: none;
}

@media (max-width: 1200px) {
  /* Border matches the mobile menu's frosted dropdown containers
     (and the mobile cart sheet) */
  .nav-search-overlay__panel {
    border-color: rgba(255, 255, 255, 0.08);
  }

  .nav-mobile-search-bar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 3.35rem;
    margin-top: 1rem;
    padding: 0.72rem 1.1rem;
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.065) 0%,
      rgba(255, 255, 255, 0.04) 100%
    );
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 3rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition:
      background 0.18s ease,
      border-color 0.18s ease,
      box-shadow 0.18s ease;
  }

  .nav-mobile-search-bar:hover,
  .nav-mobile-search-bar:focus-visible {
    background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.09) 0%,
      rgba(255, 255, 255, 0.06) 100%
    );
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.055),
      0 10px 24px rgba(0, 0, 0, 0.2);
    outline: none;
  }

  .nav-mobile-search-bar__icon {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.25rem;
  }

  .nav-mobile-search-bar__placeholder {
    flex: 1;
    min-width: 0;
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

}

/* ── Mobile overlay ── */

@media (max-width: 640px) {
  .nav-search-overlay {
    top: var(--nav-h);
    bottom: auto;

    /* Keyboard-aware: --nav-search-vvh mirrors visualViewport.height
       (synced by nav-search.js), so the overlay ends where the keyboard
       starts instead of running underneath it */
    height: calc(var(--nav-search-vvh, 100svh) - var(--nav-h));

    padding: 0.3rem 0.75rem 0.6rem;
    align-items: flex-start;

    /* The overlay itself never scrolls — only the results body does,
       so the input row stays fixed in place */
    overflow: hidden;
  }

  .nav-search-overlay__backdrop {
    top: var(--nav-h);
  }

  .nav-search-overlay__panel {
    max-width: 100%;
    max-height: 100%;
  }

  /* Input row pinned — never shrinks or scrolls away */
  .nav-search-overlay__header {
    flex-shrink: 0;
  }

  /* Hamburger acts as close on mobile — hide the in-panel X button */
  .nav-search-overlay__close,
  .nav-search-overlay__close[hidden] {
    display: none !important;
  }

  .nav-search-overlay__input {
    font-size: 1.15rem;
  }

  .nav-search-overlay__input-icon {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.18s ease;
  }

  .nav-search-overlay.has-query .nav-search-overlay__input-icon {
    color: #fff;
  }

  /* Results scroll within the remaining space above the keyboard */
  .nav-search-overlay__body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;

    /* Always-visible side scrollbar — no hover states on touch */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) rgba(255, 255, 255, 0.05);
  }

  .nav-search-overlay__body::-webkit-scrollbar {
    width: 5px;
  }

  .nav-search-overlay__body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 99px;
    margin: 0.4rem 0;
  }

  .nav-search-overlay__body::-webkit-scrollbar-thumb,
  .nav-search-overlay__body:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.28);
    border-radius: 99px;
  }

  .nav-search-overlay__body::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.4);
  }

  .nav-search-overlay__hint {
    display: none;
  }
}

/* ── Reduced motion — instant open/close ── */

@media (prefers-reduced-motion: reduce) {
  .nav-search-overlay__panel,
  .nav-search-overlay__backdrop {
    transition-duration: 0.01ms !important;
  }
}
