/*
 * Header search dropdown built by js/shopro-search.js (side column with categories, brands and related searches +
 * products + "view all"; recent and popular searches on an empty input).
 * Loaded on every page by journal3/event/header.php. Same tokens as menu.css / category.css.
 *
 * Journal's skin CSS is printed inline after this file, so every selector starts with #search and at least two
 * classes to stay ahead of rules like `#search .dropdown-menu a`.
 */

#search .ss-panel {
  --ss-accent: #2563eb;
  --ss-accent-hover: #1d4ed8;
  --ss-accent-soft: #eff6ff;
  --ss-accent-ring: rgba(37, 99, 235, .18);
  --ss-text: #111827;
  --ss-text-soft: #374151;
  --ss-muted: #6b7280;
  --ss-border: #e5e7eb;
  --ss-surface: #fff;
  --ss-surface-soft: #f8fafc;
  --ss-danger: #dc2626;
  --ss-radius: 14px;
  --ss-radius-sm: 10px;
  --ss-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 24px 48px -16px rgba(15, 23, 42, .22);
}

#search .header-search.ss-host {
  position: relative;
}

/* Journal's typeahead menu, never wanted next to ours */
#search .tt-menu {
  display: none !important;
}

#search .ss-panel.ss-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  width: 680px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - var(--ss-vtop, 120px) - 16px);
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: var(--ss-radius);
  box-shadow: var(--ss-shadow);
  color: var(--ss-text);
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
}

#search .ss-panel.ss-panel[hidden] {
  display: none;
}

/* Journal's category selector menu (z-index 3) must stay above our open panel */
#search .search-categories .dropdown-menu.dropdown-menu {
  z-index: 1001;
}

/* screen-reader-only status line next to the listbox */
#search .ss-host .ss-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#search .ss-panel .ss-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* keyboard-highlighted rows scroll clear of the sticky "view all" */
  scroll-padding-bottom: 68px;
}

/* ---------- loading bar ---------- */

#search .ss-panel .ss-progress {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}

#search .ss-panel.ss-loading .ss-progress {
  opacity: 1;
}

#search .ss-panel .ss-progress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: var(--ss-accent);
  border-radius: 2px;
  transform: translateX(-100%);
}

#search .ss-panel.ss-loading .ss-progress::before {
  animation: ss-progress 1s cubic-bezier(.4, 0, .2, 1) infinite;
}

@keyframes ss-progress {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(250%);
  }
}

/* ---------- layout ---------- */

#search .ss-panel .ss-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

#search .ss-panel .ss-cols.ss-has-cats {
  grid-template-columns: 220px minmax(0, 1fr);
}

#search .ss-panel .ss-group {
  min-width: 0;
  padding: 6px 8px 8px;
}

#search .ss-panel .ss-side {
  min-width: 0;
  background: var(--ss-surface-soft);
  border-right: 1px solid var(--ss-border);
}

#search .ss-panel .ss-side .ss-group + .ss-group {
  border-top: 1px solid var(--ss-border);
}

#search .ss-panel .ss-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 8px 8px 4px;
  color: var(--ss-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: .06em;
  text-transform: uppercase;
}

#search .ss-panel .ss-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#search .ss-panel .ss-msg,
#search .ss-panel .ss-empty {
  padding: 18px 16px;
  color: var(--ss-muted);
  font-size: 14px;
}

#search .ss-panel .ss-group .ss-empty {
  padding: 10px 8px 14px;
}

/* ---------- options ---------- */

#search .ss-panel .ss-item {
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 0;
  color: var(--ss-text);
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
  border-radius: var(--ss-radius-sm);
  outline: none;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease;
}

#search .ss-panel .ss-item.ss-active {
  background: var(--ss-accent-soft);
}

#search .ss-panel mark {
  padding: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
}

/* categories */

#search .ss-panel .ss-cat {
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  color: var(--ss-text-soft);
}

#search .ss-panel .ss-cat.ss-active {
  color: var(--ss-accent-hover);
}

#search .ss-panel .ss-cat-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#search .ss-panel .ss-count {
  flex: 0 0 auto;
  min-width: 24px;
  padding: 1px 7px;
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: 999px;
  color: var(--ss-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  text-align: center;
}

#search .ss-panel .ss-cat.ss-active .ss-count {
  border-color: var(--ss-accent-ring);
  color: var(--ss-accent);
}

/* products */

#search .ss-panel .ss-product {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  /* the brand / spec line runs under the price: specs are long, prices short */
  grid-template-areas:
    "thumb name price"
    "thumb brand brand";
  grid-template-rows: auto auto;
  align-content: start;
  align-items: start;
  column-gap: 12px;
  row-gap: 2px;
  padding: 8px 10px;
}

#search .ss-panel .ss-thumb {
  grid-area: thumb;
  position: relative;
  display: block;
  width: 56px;
  height: 56px;
  overflow: hidden;
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: 8px;
}

#search .ss-panel .ss-thumb img {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  max-width: none;
  object-fit: contain;
}

#search .ss-panel .ss-name {
  grid-area: name;
  display: -webkit-box;
  overflow: hidden;
  color: var(--ss-text);
  font-size: 14px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
}

#search .ss-panel .ss-brand {
  grid-area: brand;
  overflow: hidden;
  color: var(--ss-muted);
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#search .ss-panel .ss-brand-name {
  color: var(--ss-text-soft);
  font-weight: 500;
}

#search .ss-panel .ss-brand-name + .ss-specs::before {
  content: "\00b7";
  margin: 0 6px;
  color: var(--ss-muted);
}

#search .ss-panel .ss-price {
  grid-area: price;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-top: 1px;
  white-space: nowrap;
}

#search .ss-panel .ss-price-cur,
#search .ss-panel .ss-price-new {
  color: var(--ss-text);
  font-size: 14px;
  font-weight: 700;
}

#search .ss-panel .ss-price-new {
  color: var(--ss-danger);
}

#search .ss-panel .ss-price-old {
  color: var(--ss-muted);
  font-size: 12px;
  text-decoration: line-through;
}

/* view all (pinned to the bottom of the scroll area; the white shadow hides rows scrolling underneath) */

#search .ss-panel .ss-all {
  position: sticky;
  bottom: 12px;
  z-index: 1;
  justify-content: center;
  margin: 4px 12px 12px;
  padding: 11px 16px;
  background: var(--ss-accent);
  color: #fff;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 0 0 12px var(--ss-surface);
}

#search .ss-panel .ss-all:hover,
#search .ss-panel .ss-all.ss-active {
  background: var(--ss-accent-hover);
  color: #fff;
  box-shadow: 0 0 0 3px var(--ss-accent-ring), 0 0 0 12px var(--ss-surface);
}

/* recent searches */

#search .ss-panel .ss-clear {
  padding: 2px 4px;
  background: none;
  border: 0;
  color: var(--ss-accent);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
}

#search .ss-panel .ss-clear:hover {
  color: var(--ss-accent-hover);
  text-decoration: underline;
}

#search .ss-panel .ss-recent-row {
  position: relative;
  display: flex;
  align-items: center;
}

#search .ss-panel .ss-recent {
  flex: 1 1 auto;
  gap: 10px;
  min-height: 40px;
  padding: 8px 44px 8px 10px;
  color: var(--ss-text-soft);
}

#search .ss-panel .ss-recent-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#search .ss-panel .ss-recent-icon {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  background: var(--ss-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* related searches */

#search .ss-panel .ss-query {
  justify-content: flex-start;
  gap: 8px;
}

#search .ss-panel .ss-query-icon {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  background: var(--ss-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

#search .ss-panel .ss-query.ss-active .ss-query-icon {
  background: var(--ss-accent);
}

/* popular searches (empty input) */

#search .ss-panel .ss-group-recent + .ss-group-popular {
  border-top: 1px solid var(--ss-border);
}

#search .ss-panel .ss-list.ss-chips {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 8px 6px;
}

#search .ss-panel .ss-chip {
  max-width: 100%;
  min-height: 32px;
  padding: 5px 12px;
  overflow: hidden;
  background: var(--ss-surface-soft);
  border: 1px solid var(--ss-border);
  border-radius: 999px;
  color: var(--ss-text-soft);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#search .ss-panel .ss-chip.ss-active {
  background: var(--ss-accent-soft);
  border-color: var(--ss-accent-ring);
  color: var(--ss-accent-hover);
}

#search .ss-panel .ss-remove {
  position: absolute;
  top: 50%;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-top: -15px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--ss-muted);
  font-size: 0;
  cursor: pointer;
}

#search .ss-panel .ss-remove::before {
  content: "\00d7";
  font-size: 20px;
  line-height: 1;
}

#search .ss-panel .ss-remove:hover {
  background: var(--ss-border);
  color: var(--ss-text);
}

/* ---------- phones ---------- */

/* Journal leaves an identity transform on the open search dropdown (`.full-search #search > .dropdown-menu`), which
   would make it the containing block of the position:fixed panel */
#search.ss-open > .dropdown-menu.dropdown-menu {
  transform: none !important;
}

#search .ss-panel.ss-panel.ss-mobile {
  position: fixed;
  top: var(--ss-vtop, 64px);
  right: 8px;
  left: 8px;
  width: auto;
  max-width: none;
  max-height: calc(100vh - var(--ss-vtop, 64px) - 8px);
  /* --ss-vbottom (visualViewport, set by the JS) keeps the panel above the on-screen keyboard */
  max-height: min(calc(100dvh - var(--ss-vtop, 64px) - 8px), calc(var(--ss-vbottom, 100dvh) - var(--ss-vtop, 64px) - 8px));
  border-radius: var(--ss-radius-sm);
}

#search .ss-panel.ss-mobile .ss-body {
  scroll-padding-bottom: 64px;
}

#search .ss-panel.ss-mobile .ss-cols.ss-has-cats {
  grid-template-columns: minmax(0, 1fr);
}

#search .ss-panel.ss-mobile .ss-side {
  background: none;
  border-top: 1px solid var(--ss-border);
  border-right: 0;
}

#search .ss-panel.ss-mobile .ss-side .ss-list {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px 6px;
}

#search .ss-panel.ss-mobile .ss-cat {
  max-width: 100%;
  min-height: 40px;
  padding: 8px 8px 8px 14px;
  background: var(--ss-surface-soft);
  border: 1px solid var(--ss-border);
  border-radius: 999px;
}

#search .ss-panel.ss-mobile .ss-cat:not(:has(.ss-count)) {
  padding-right: 14px;
}

#search .ss-panel.ss-mobile .ss-chip {
  min-height: 40px;
  padding: 9px 14px;
}

#search .ss-panel.ss-mobile .ss-product {
  grid-template-columns: 52px minmax(0, 1fr);
  grid-template-areas:
    "thumb name"
    "thumb brand"
    "thumb price";
  grid-template-rows: auto auto auto;
  min-height: 68px;
  padding: 8px;
}

#search .ss-panel.ss-mobile .ss-thumb {
  width: 52px;
  height: 52px;
}

#search .ss-panel.ss-mobile .ss-price {
  flex-direction: row;
  align-items: baseline;
  gap: 8px;
}

#search .ss-panel.ss-mobile .ss-recent {
  min-height: 48px;
}

#search .ss-panel.ss-mobile .ss-remove {
  width: 40px;
  height: 40px;
  margin-top: -20px;
  right: 2px;
}

#search .ss-panel.ss-mobile .ss-all {
  margin: 4px 8px 8px;
  padding: 13px 16px;
  bottom: 8px;
  box-shadow: 0 0 0 8px var(--ss-surface);
}

@media (prefers-reduced-motion: reduce) {
  #search .ss-panel .ss-item,
  #search .ss-panel .ss-progress {
    transition: none;
  }

  #search .ss-panel.ss-loading .ss-progress::before {
    width: 100%;
    opacity: .45;
    transform: none;
    animation: none;
  }
}
