/* =============================================================================
   FOOX BRICKS: SITE SEARCH (header field, suggestions, results page)
   Built on the live tokens (pico-custom.css) and header rules (layout.css).
   The field and the suggestions panel live inside <header data-theme="dark">,
   so they are black chrome in both themes, like the header itself. The results
   page uses the page tokens and follows light/dark.

   One markup for both variants:
     .site-search--bar   always-present field
     .site-search--icon  magnifier that expands to the left (header.is-searching)
   ============================================================================= */

/* ---- field ----------------------------------------------------------------- */
/* <search> is the landmark; the form inside is layout-neutral. (Not
   role="search" on the form: Pico turns that into a rounded input group.) */
.site-search-form {
  display: contents;
}

.site-search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0;
}

.site-search-field {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.site-search-field > .fa-magnifying-glass {
  position: absolute;
  z-index: 3;
  left: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-gray-300);
  pointer-events: none;
}

body > header .site-search input[type="search"] {
  position: relative;
}

/* search.js: while the phone's suggestions panel is open the page behind it doesn't scroll */
html.is-scroll-locked {
  overflow: hidden;
}

body > header .site-search input[type="search"] {
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 var(--space-10) 0 calc(var(--space-3) + 22px);
  border: 1px solid var(--color-black-muted);
  border-radius: 0;
  background: var(--color-black-soft);
  color: var(--color-white);
  font-size: var(--text-sm);
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}

body > header .site-search input[type="search"]::placeholder {
  color: var(--color-gray-400);
  opacity: 1;
}

body > header .site-search input[type="search"]:focus {
  border-color: var(--color-yellow);
  box-shadow: none;
  outline: none;
}

body > header .site-search input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

/* "/" shortcut hint (desktop), swaps for a clear button while typing */
.site-search-kbd,
.site-search-clear {
  position: absolute;
  z-index: 3;
  right: var(--space-2);
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin: 0;
  padding: 0 6px;
  border: 1px solid var(--color-gray-500);
  background: transparent;
  color: var(--color-gray-400);
  font-family: var(--pico-font-family-monospace);
  font-size: 11px;
  line-height: 1;
}

.site-search-clear {
  border: 0;
  width: 28px;
  height: 28px;
  right: var(--space-1);
  color: var(--color-gray-300);
  font-family: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
}

.site-search input:placeholder-shown ~ .site-search-clear,
.site-search input:not(:placeholder-shown) ~ .site-search-kbd {
  display: none;
}

/* Magnifier button (icon variant) and close button share .icon-btn */
.site-search-toggle,
.site-search-close {
  flex-shrink: 0;
}

.site-search-cancel {
  display: none;
}

/* ---- variant: always present ----------------------------------------------- */
/* The field is a block in the header bar, like the yellow cart button: the
   same 56px height, flush, no outline box. It grows into the free space
   between the nav links and the icons. Focus = lighter fill + a yellow
   underline that runs on into the suggestions panel's yellow top edge. */
body > header nav > ul:last-child:has(.site-search--bar) {
  flex: 1 1 auto;
}

/* the nav keeps its natural width; the field sits centred in the space between
   the nav links and the icons (auto margins on both sides) */
body > header:has(.site-search--bar) .nav-links {
  flex: 0 0 auto;
}

body > header nav > ul:last-child > li:has(.site-search--bar) {
  position: relative; /* the suggestions panel hangs from the field */
  flex: 0 1 20rem;
  min-width: 13rem;
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.site-search--bar {
  position: static;
  width: 100%;
}

.site-search--bar .site-search-toggle,
.site-search--bar .site-search-close {
  display: none;
}

body > header .site-search--bar input[type="search"] {
  height: var(--icon-btn-size);
  padding: 0 calc(var(--space-10) + var(--space-2)) 0 calc(var(--space-4) + 26px);
  border: 0;
  border-bottom: 2px solid transparent;
  background: var(--color-black-soft);
  font-size: var(--text-base);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

body > header .site-search--bar input[type="search"]:hover {
  background: color-mix(in srgb, var(--color-black-soft) 70%, var(--color-black-muted));
}

body > header .site-search--bar input[type="search"]:focus {
  background: var(--color-black-muted);
  border-bottom-color: var(--color-yellow);
}

.site-search--bar .site-search-field > .fa-magnifying-glass {
  left: var(--space-4);
  font-size: var(--text-base);
  color: var(--color-gray-300);
}

.site-search--bar .site-search-field:focus-within > .fa-magnifying-glass {
  color: var(--color-yellow);
}

.site-search--bar .site-search-kbd {
  right: var(--space-3);
  height: 24px;
  border: 0;
  background: var(--color-black-muted);
  color: var(--color-gray-300);
}

.site-search--bar .site-search-field:focus-within .site-search-kbd {
  background: var(--color-black-soft);
}

/* panel: centred under the field, at least 36rem wide */
.site-search--bar .site-search-panel {
  top: calc(100% + (var(--header-height) - var(--icon-btn-size)) / 2 + 1px);
  left: 50%;
  right: auto;
  width: max(calc(100% - 2 * var(--space-6)), 36rem);
  transform: translateX(-50%);
}

/* Below 1200px the nav, field and icons don't all fit: drop "Shop" (the logo
   already goes home), as the phone tab bar does. */
@media (max-width: 1199px) {
  body > header:has(.site-search--bar) .nav-links > li:first-child {
    display: none;
  }

  body > header:has(.site-search--bar) nav > ul:first-child {
    margin-right: var(--space-6);
  }
}

/* ---- variant: icon that expands to the left -------------------------------- */
.site-search--icon .site-search-field,
.site-search--icon .site-search-close {
  display: none;
}

/* Open: the nav links make room and the field fills the space between the logo
   and the icons. Plain flex, no absolute positioning. */
body > header.is-searching .nav-links {
  display: none;
}

body > header.is-searching nav > ul:last-child {
  flex: 1;
  margin-left: 0;
}

body > header.is-searching nav > ul:last-child > li:has(.site-search--icon),
body > header.is-searching .site-search--icon {
  flex: 1;
}

body > header.is-searching .site-search--icon .site-search-field {
  display: flex;
  animation: site-search-grow 0.18s ease-out;
}

body > header.is-searching .site-search--icon .site-search-close {
  display: flex;
}

body > header.is-searching .site-search--icon .site-search-toggle,
body > header.is-searching #theme-toggle-wrapper {
  display: none;
}

@keyframes site-search-grow {
  from { clip-path: inset(0 0 0 100%); }
  to { clip-path: inset(0 0 0 0); }
}

/* ---- suggestions panel ----------------------------------------------------- */
/* The panel sits inside the header <nav>, so undo Pico's nav list/link styles
   (including the negative margins on nav ul:first/last-of-type) */
body > header .site-search-panel ul,
body > header .site-search-panel li {
  display: block;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-search-panel a {
  margin: 0;
  border-radius: 0;
}

.site-search-panel .ss-chips {
  display: flex;
  padding: var(--space-1) var(--space-4) var(--space-3);
}

.site-search-panel .ss-chips > li {
  display: block;
}

.site-search-panel {
  position: absolute;
  z-index: 110;
  top: calc(100% + (var(--header-height) - 40px) / 2 + 1px); /* flush with the header's bottom edge */
  right: 0;
  width: min(40rem, calc(100vw - 2 * var(--space-4)));
  max-height: calc(100dvh - var(--header-height) - var(--space-8));
  overflow-y: auto;
  background: var(--color-black);
  border: 1px solid var(--color-black-muted);
  border-top: 2px solid var(--color-yellow);
  box-shadow: 0 24px 48px rgb(0 0 0 / 40%);
  color: var(--color-white);
}

.site-search--icon .site-search-panel {
  left: 0;
  right: auto;
  width: 100%;
  max-width: 44rem;
}

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

.ss-group {
  padding-block: var(--space-2);
}

.ss-group + .ss-group {
  border-top: 1px solid var(--color-black-muted);
}

.ss-label {
  margin: 0;
  padding: var(--space-2) var(--space-4) var(--space-1);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-gray-400);
}

.ss-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ss-list > li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ss-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  color: var(--color-gray-200);
  text-decoration: none;
  cursor: pointer;
}

.ss-option:hover,
.ss-option[aria-selected="true"] {
  background: var(--color-black-soft);
  box-shadow: inset 2px 0 0 var(--color-yellow);
  color: var(--color-white);
}

.ss-option mark {
  background: none;
  color: var(--color-white);
  font-weight: 700;
  padding: 0;
}

/* query completions: typed part normal, completion bold */
.ss-option--query > .fa-solid {
  width: 20px;
  color: var(--color-gray-400);
  font-size: var(--text-sm);
  text-align: center;
}

body > header .ss-option--query {
  display: flex;
  min-height: 40px;
  padding-block: var(--space-1);
}

.ss-option--query > .ss-fill {
  margin-left: auto;
  font-size: var(--text-xs);
  transform: rotate(-45deg); /* "fill in" arrow */
}

/* parts */
.ss-thumb {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  background: var(--color-gray-200);
}

.ss-thumb img {
  max-width: 40px;
  max-height: 40px;
  /* The width/height attributes make the box square; BrickLink images are 4:3, so fit them in instead of squashing */
  object-fit: contain;
  mix-blend-mode: multiply;
}

.ss-name {
  display: block;
  overflow: hidden;
  font-size: var(--text-sm);
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: inherit;
}

.ss-name mark {
  color: var(--color-yellow);
}

.ss-meta {
  display: block;
  margin-top: 2px;
  font-family: var(--pico-font-family-monospace);
  font-size: 11.5px;
  color: var(--color-gray-400);
}

.ss-price {
  text-align: right;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-white);
  white-space: nowrap;
}

.ss-price small {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--color-gray-400);
}

/* categories as chips */
.ss-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-1) var(--space-4) var(--space-2);
  list-style: none;
}

.ss-chips > li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ss-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-gray-500);
  color: var(--color-gray-200);
  font-size: var(--text-sm);
  text-decoration: none;
}

.ss-chip span {
  font-family: var(--pico-font-family-monospace);
  font-size: 11px;
  color: var(--color-gray-400);
}

.ss-chip:hover {
  border-color: var(--color-yellow);
  color: var(--color-white);
}

/* footer: all results + keyboard hints */
.ss-all > span:first-child {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ss-all {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 52px;
  padding: 0 var(--space-4);
  border-top: 1px solid var(--color-black-muted);
  background: var(--color-black-soft);
  color: var(--color-yellow);
  font-weight: 700;
  font-size: var(--text-sm);
  text-decoration: none;
}

.ss-keys {
  flex-shrink: 0;
  white-space: nowrap;
  font-family: var(--pico-font-family-monospace);
  font-weight: 400;
  font-size: 11px;
  color: var(--color-gray-400);
}

.ss-keys kbd {
  padding: 1px 5px;
  border: 1px solid var(--color-gray-500);
  background: none;
  color: var(--color-gray-300);
  font-size: 10.5px;
}

/* =============================================================================
   PHONES (the site's 767px breakpoint)
   ============================================================================= */
@media (max-width: 767px) {
  body > header .site-search input[type="search"] {
    height: var(--tap-target);
    font-size: 16px; /* 16px stops iOS zooming into the field */
  }

  .site-search-kbd,
  .ss-keys {
    display: none;
  }

  /* Always-present: its own full-width row between the logo row and the tab
     bar. The actions list dissolves (display: contents) so its items join the
     header's flex row: icons stay right, the field wraps onto a row. */
  body > header nav > ul:last-child:has(.site-search--bar) {
    display: contents;
  }

  body > header nav > ul:last-child:has(.site-search--bar) > li:has(.site-search--bar) + li {
    margin-left: auto;
  }

  body > header nav > ul:last-child > li:has(.site-search--bar) {
    order: 2;
    flex-basis: 100%;
    padding-bottom: var(--space-2);
  }

  body > header nav > ul:last-child > li:has(.site-search--bar) {
    min-width: 0;
    margin-inline: 0;
    padding-inline: 0;
  }

  body > header .site-search--bar input[type="search"] {
    height: 48px;
  }

  /* while suggestions are open, the tab row steps aside for them */
  body > header:has(.site-search-panel:not([hidden])) .nav-links {
    display: none;
  }

  /* Icon variant open: the field takes over the whole logo row; "Annuleer"
     closes it. */
  body > header.is-searching nav > ul:first-child,
  body > header.is-searching nav > ul:last-child > li:not(:has(.site-search)) {
    display: none;
  }

  body > header.is-searching .site-search--icon .site-search-close {
    display: none;
  }

  body > header.is-searching .site-search-cancel {
    display: inline-flex;
    align-items: center;
    height: var(--tap-target);
    margin: 0 0 0 var(--space-3);
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-white);
    font-size: var(--text-sm);
    font-weight: 500;
  }

  body > header.is-searching nav > ul:last-child {
    height: var(--icon-btn-size);
  }

  /* Panel: full width under the header, down to the bottom of the screen */
  .site-search-panel,
  .site-search--icon .site-search-panel,
  .site-search--bar .site-search-panel {
    transform: none;
    position: fixed;
    top: var(--ss-panel-top, 0);
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: none;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .ss-option {
    min-height: 52px;
  }

  .ss-all {
    position: sticky;
    bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* =============================================================================
   RESULTS PAGE (/catalogus?q=…): the catalogue with a search head
   ============================================================================= */
.search-head {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.search-head-eyebrow {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--label-color);
}

.search-head .catalog-page-title {
  margin: 0;
  overflow-wrap: anywhere;
}

.search-head .catalog-page-title q {
  quotes: "“" "”";
}

/* related queries */
.search-related {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-sm);
  color: var(--label-color);
}

.search-related a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-color);
  color: var(--ink-color);
  text-decoration: none;
}

.search-related a:hover {
  border-color: var(--ink-color);
}

/* the search term as an active filter in the sidebar */
.filter-active {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line-color);
}

.filter-active-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding: 0 var(--space-2) 0 var(--space-3);
  background: var(--color-black);
  color: var(--color-white);
  font-size: var(--text-sm);
  text-decoration: none;
}

.filter-active-chip i {
  color: var(--color-gray-300);
  font-size: var(--text-xs);
}

html[data-theme="dark"] .filter-active-chip {
  background: var(--color-white);
  color: var(--color-black);
}

html[data-theme="dark"] .filter-active-chip i {
  color: var(--color-gray-600);
}

/* matched words in result card names */
.product-card-name mark {
  background: color-mix(in srgb, var(--color-yellow) 45%, transparent);
  color: inherit;
  padding: 0 1px;
}

/* no results */
.search-empty {
  display: grid;
  justify-items: start;
  gap: var(--space-4);
  max-width: 36rem;
  padding: var(--space-10) 0;
}

.search-empty h2 {
  margin: 0;
  font-size: var(--text-2xl);
}

.search-empty p {
  margin: 0;
  color: var(--copy-color);
}

.search-empty p a {
  color: var(--ink-color);
  font-weight: 700;
  text-decoration-color: var(--color-yellow);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.search-empty-actions .outline {
  border-color: var(--ink-color);
  color: var(--ink-color);
}

.search-empty ul {
  margin: 0;
  padding-left: var(--space-5);
  color: var(--copy-color);
}

.search-empty ul li {
  margin-bottom: var(--space-1);
}

.search-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.search-empty-actions [role="button"] {
  margin: 0;
}

/* Pico and the site's button styles (border, uppercase, tracking) don't apply
   to the header's small field buttons */
.site-search .icon-btn,
body > header .site-search .site-search-clear,
body > header .site-search .site-search-cancel {
  width: auto;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  text-transform: none;
  letter-spacing: 0;
}

body > header .site-search .site-search-clear {
  width: 28px;
}

body > header .site-search .site-search-cancel {
  font-family: var(--pico-font-family);
  font-size: var(--text-base);
  font-weight: 500;
}

/* =============================================================================
   FIELD STYLE W3: White field 56px, light suggestions
   ============================================================================= */
/* WHITE FIELD (style 1 details: icon, "/" hint, clear, yellow underline on focus)
   A light field reads clearly against the black bar AND doesn't merge with the
   dark promo bar above it, which a dark field did. */
body > header .site-search--bar input[type="search"] {
  border: 0;
  border-bottom: 3px solid transparent;
  background: var(--color-gray-50);
  color: var(--color-black);
}
body > header .site-search--bar input[type="search"]::placeholder { color: var(--color-gray-500); }
body > header .site-search--bar input[type="search"]:hover { background: var(--color-white); }
body > header .site-search--bar input[type="search"]:focus { background: var(--color-white); border-bottom-color: var(--color-yellow); }
.site-search--bar .site-search-field > .fa-magnifying-glass,
.site-search--bar .site-search-field:focus-within > .fa-magnifying-glass { color: var(--color-gray-500); }
.site-search--bar .site-search-field:focus-within > .fa-magnifying-glass { color: var(--color-black); }
.site-search--bar .site-search-kbd,
.site-search--bar .site-search-field:focus-within .site-search-kbd { background: var(--color-gray-100); color: var(--color-gray-600); }
body > header .site-search--bar .site-search-clear { color: var(--color-gray-500); }

/* phone: a gap between the logo row (cart button) and the field strip */
@media (max-width: 767px) {
  body > header nav > ul:last-child > li:has(.site-search--bar) { padding-top: var(--space-2); padding-bottom: var(--space-3); }
}

/* light suggestions panel to match the white field */
.site-search--bar .site-search-panel { background: var(--color-white); color: var(--color-gray-600); border-color: var(--color-gray-100); border-top: 3px solid var(--color-yellow); box-shadow: 0 24px 48px rgb(0 0 0 / 28%); }
.site-search--bar .ss-group + .ss-group { border-top-color: var(--color-gray-100); }
.site-search--bar .ss-label { color: var(--color-gray-500); }
.site-search--bar .ss-option { color: var(--color-gray-600); }
.site-search--bar .ss-option:hover, .site-search--bar .ss-option[aria-selected="true"] { background: var(--color-gray-50); color: var(--color-black); box-shadow: inset 3px 0 0 var(--color-yellow); }
.site-search--bar .ss-option mark { color: var(--color-black); }
.site-search--bar .ss-name mark { color: var(--color-black); background: color-mix(in srgb, var(--color-yellow) 45%, transparent); padding: 0 1px; }
.site-search--bar .ss-option--query > .fa-solid, .site-search--bar .ss-meta, .site-search--bar .ss-price small, .site-search--bar .ss-keys { color: var(--color-gray-500); }
.site-search--bar .ss-price { color: var(--color-black); }
.site-search--bar .ss-thumb { background: var(--color-gray-50); }
.site-search--bar .ss-chip { border-color: var(--color-gray-200); color: var(--color-gray-600); }
.site-search--bar .ss-chip span { color: var(--color-gray-500); }
.site-search--bar .ss-chip:hover { border-color: var(--color-black); color: var(--color-black); }
.site-search--bar .ss-all { background: var(--color-gray-50); border-top-color: var(--color-gray-100); color: var(--color-black); }
.site-search--bar .ss-all > span:first-child { text-decoration: underline; text-decoration-color: var(--color-yellow); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.site-search--bar .ss-keys kbd { border-color: var(--color-gray-200); color: var(--color-gray-600); }
