/**
 * @file
 * Site search overlay — 1:1 replication of kaindl.com.
 *
 * Structure & measurements taken from kaindl.com computed styles:
 *   .search.search--as-overlay         → fixed panel below sticky header
 *   .search__header (bg #f5f5f5)       → grey top band, 272px tall
 *   .filter-bar__primary-level         → black input row, centered
 *   .filter-bar__search-field-input    → white text, 2px dark-grey underline
 *   .filter-bar__search-field-button   → 52×52 white square with dark icon
 *   .search__body                      → white, padding 50px 0
 *   .search-results__headline          → 22.69px, bold, black, mb 40px
 *   .search-results__item              → flex row, border-top #d2d2d2, 86px tall
 *   .search-results__item-label        → ft1 (~16.85px), padding 30px 0
 *   .search-results__item-icon         → 24px-wide right arrow
 *   Hover transition: background-color 0.25s ease-in-out
 *   Open animation: top + opacity transition, ~500ms
 */

/* ═════════════════════════════════════════════════════════════════════════
   Overlay shell — dark backdrop + centered card
   ═════════════════════════════════════════════════════════════════════════ */
.kaindl-search {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 130px 20px 40px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  font-family: var(--kaindl-font-family);
  color: #616161;
  transition:
    opacity 400ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 400ms;
}

.kaindl-search.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 400ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

body.is-search-open {
  overflow: hidden;
}

/* Dimmed backdrop — click anywhere outside the card to close */
.kaindl-search__backdrop {
  position: absolute;
  inset: 0;
  background: #f5f4f3ad;
  cursor: pointer;
  z-index: 0;
}

/* Extend the same backdrop tint over the site header while the modal is
   open. Targets .site-header__main (not .site-header) so it still covers
   the desktop scrolled state, where .headerbar__main detaches to
   position:fixed with its own white background. Uses a pseudo-element so
   it does not block clicks on the header's own trigger. */
body.is-search-open .site-header__main {
  position: relative;
}

body.is-search-open .site-header__main::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #f5f4f3ad;
  pointer-events: none;
  z-index: 10;
}

/* ═════════════════════════════════════════════════════════════════════════
   Card — centered white container holding both input row and list
   ═════════════════════════════════════════════════════════════════════════ */
.kaindl-search__card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 170px);
  background: #fff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-24px);
  transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

.kaindl-search.is-open .kaindl-search__card {
  transform: translateY(0);
}

/* ═════════════════════════════════════════════════════════════════════════
   Header area inside the card — just wraps the black input row
   ═════════════════════════════════════════════════════════════════════════ */
.kaindl-search__header {
  flex: 0 0 auto;
}

/* Black input row — full width of the card */
.kaindl-search__filter-bar {
  background: #000;
  display: flex;
  align-items: center;
  padding: 12px 20px;
}

.kaindl-search__prefix {
  flex: 0 0 auto;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0 20px 0 0;
  white-space: nowrap;
}

@media (max-width: 991px) {
  .kaindl-search__prefix {
    display: none;
  }
}

.kaindl-search__form {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 0;
}

.kaindl-search__input {
  flex: 1;
  min-width: 0;
  background: transparent;
  color: #fff;
  border: 0;
  border-bottom: 2px solid #616161;
  padding: 14px 0;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  outline: none;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  margin-right: 34px;
  transition: border-color 0.25s ease-in-out;
}

.kaindl-search__input::placeholder {
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
}

.kaindl-search__input:focus,
.kaindl-search__input:focus-visible,
.kaindl-search__input:active {
  outline: none !important;
  box-shadow: none !important;
  border-bottom-color: #fff;
}

.kaindl-search__input::-webkit-search-cancel-button {
  display: none;
}

.kaindl-search__submit {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  background: #fff;
  color: #000;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.25s ease-in-out, color 0.25s ease-in-out;
}

.kaindl-search__submit:hover,
.kaindl-search__submit:focus-visible {
  background: #000;
  color: #fff;
  box-shadow: inset 0 0 0 1px #fff;
  outline: none;
}

.kaindl-search__submit .svg-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
}

.kaindl-search__submit svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* ═════════════════════════════════════════════════════════════════════════
   Body (white) — scrollable inside the card
   ═════════════════════════════════════════════════════════════════════════ */
.kaindl-search__body {
  background: #fff;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 30px 0;
}

.kaindl-search__body-content {
  width: 100%;
}

.kaindl-search__headline {
  font-size: 18px;
  font-weight: 700;
  color: #000;
  margin: 0 0 20px;
  padding: 0 30px;
}

/* ═════════════════════════════════════════════════════════════════════════
   List of items (shared by Frequent Searches and suggestions)
   ═════════════════════════════════════════════════════════════════════════ */
.kaindl-search__list {
  display: flex;
  flex-direction: column;
}

.kaindl-search__item {
  display: flex;
  align-items: center;
  padding: 0 30px;
  border-top: 1px solid #d2d2d2;
  text-decoration: none;
  color: #616161;
  transition: background-color 0.25s ease-in-out;
}

.kaindl-search__item:last-child {
  border-bottom: 1px solid #d2d2d2;
}

.kaindl-search__item:hover,
.kaindl-search__item.is-active {
  background-color: #f5f5f5;
}

.kaindl-search__item-label {
  flex: 1 1 auto;
  padding: 22px 0;
  font-size: 16.85px;
  line-height: 1.35;
  min-width: 0;
}

.kaindl-search__item-label .f-bold,
.kaindl-search__item-label strong {
  font-weight: 700;
  color: #000;
}

.kaindl-search__item-label .color-dark {
  color: #000;
}

.kaindl-search__item-type {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8e8e8e;
  margin-bottom: 4px;
}

.kaindl-search__item-icon {
  width: 24px;
  color: #000;
  flex: 0 0 auto;
  margin-left: 8px;
  padding-top: 5px;
}

.kaindl-search__item-icon svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ═════════════════════════════════════════════════════════════════════════
   Suggestions-wrap hidden state
   ═════════════════════════════════════════════════════════════════════════ */
.kaindl-search__suggestions-wrap[hidden] {
  display: none !important;
}

/* When suggestions are shown, hide frequent searches to match kaindl pattern */
.kaindl-search.is-showing-suggestions .kaindl-search__frequent {
  display: none;
}

/* ═════════════════════════════════════════════════════════════════════════
   Header trigger — default / close states (matches kaindl.com)
   ═════════════════════════════════════════════════════════════════════════ */
.search-trigger__close {
  display: none;
  align-items: center;
  gap: 8px;
}

.search-trigger__close .close-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.search-trigger__close .svg-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
}

.search-trigger__close svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.search-trigger.search-trigger--active .search-trigger__default,
body.is-search-open .search-trigger .search-trigger__default {
  display: none;
}

.search-trigger.search-trigger--active .search-trigger__close,
body.is-search-open .search-trigger .search-trigger__close {
  display: inline-flex;
}

/* ═════════════════════════════════════════════════════════════════════════
   Mobile
   ═════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .kaindl-search {
    padding: 90px 12px 20px;
  }
  .kaindl-search__card {
    max-height: calc(100vh - 110px);
  }
  .kaindl-search__filter-bar {
    padding: 10px 16px;
  }
  .kaindl-search__input {
    margin-right: 12px;
    font-size: 16px;
  }
  .kaindl-search__submit {
    width: 44px;
    height: 44px;
  }
  .kaindl-search__headline {
    font-size: 16px;
    padding: 0 20px;
    margin-bottom: 16px;
  }
  .kaindl-search__item {
    padding: 0 20px;
  }
  .kaindl-search__item-label {
    padding: 18px 0;
    font-size: 15px;
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   Reduced motion
   ═════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .kaindl-search,
  .kaindl-search.is-open {
    transition: opacity 160ms linear, visibility 0s linear !important;
  }
  .kaindl-search__card,
  .kaindl-search.is-open .kaindl-search__card {
    transition: none !important;
    transform: none !important;
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   Results page (the /search route) — aligned with kaindl.com language
   ═════════════════════════════════════════════════════════════════════════ */
.kaindl-search-results {
  padding: clamp(32px, 6vh, 64px) 0;
  font-family: var(--kaindl-font-family);
  color: #616161;
}

.kaindl-search-results__header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.kaindl-search-results__title {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #000;
}

.kaindl-search-results__form {
  display: flex;
  gap: 0;
  max-width: 540px;
  background: #000;
  padding: 10px 16px;
  align-items: center;
}

.kaindl-search-results__input {
  flex: 1;
  padding: 10px 0;
  border: 0;
  border-bottom: 2px solid #616161;
  font: inherit;
  font-family: inherit;
  font-weight: 700;
  background: transparent;
  color: #fff;
  outline: none;
  margin-right: 16px;
}

.kaindl-search-results__input::placeholder {
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
}

.kaindl-search-results__submit {
  width: 44px;
  height: 44px;
  border: 0;
  background: #fff;
  color: #000;
  cursor: pointer;
  font-family: inherit;
}

.kaindl-search-results__empty {
  color: #616161;
  margin: 16px 0 32px;
}

.kaindl-search-results__group {
  margin-bottom: 40px;
}

.kaindl-search-results__group-title {
  font-size: 22.69px;
  font-weight: 700;
  color: #000;
  margin: 0 0 24px;
}

.kaindl-search-results__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.kaindl-search-results__item {
  border-top: 1px solid #d2d2d2;
}

.kaindl-search-results__item:last-child {
  border-bottom: 1px solid #d2d2d2;
}

.kaindl-search-results__link {
  display: flex;
  align-items: center;
  padding: 30px;
  text-decoration: none;
  color: #616161;
  transition: background-color 0.25s ease-in-out;
  gap: 24px;
}

.kaindl-search-results__link:hover {
  background-color: #f5f5f5;
}

.kaindl-search-results__type {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8e8e8e;
  flex: 0 0 180px;
}

.kaindl-search-results__item-title {
  font-size: 16.85px;
  font-weight: 700;
  color: #000;
  flex: 1;
  min-width: 300px;
}

.kaindl-search-results__excerpt {
  display: block;
  color: #616161;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.55;
  margin-top: 6px;
}

@media (max-width: 640px) {
  .kaindl-search-results__link {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    gap: 8px;
  }
  .kaindl-search-results__type {
    flex: 0 0 auto;
  }
}

/* ═════════════════════════════════════════════════════════════════════════
   Pager — scoped to the search results page
   ═════════════════════════════════════════════════════════════════════════ */
.kaindl-search-results .pager {
  margin-top: 40px;
}

.kaindl-search-results .pager__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.kaindl-search-results .pager__item {
  list-style: none;
  margin: 0;
  padding: 0;
}

.kaindl-search-results .pager__item a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d2d2d2;
  background: #fff;
  color: #000;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition:
    background-color 0.2s ease-in-out,
    color 0.2s ease-in-out,
    border-color 0.2s ease-in-out;
}

.kaindl-search-results .pager__item a:hover,
.kaindl-search-results .pager__item a:focus-visible {
  background: #000;
  color: #fff;
  border-color: #000;
  outline: none;
}

.kaindl-search-results .pager__item.is-active a {
  background: #000;
  color: #fff;
  border-color: #000;
  cursor: default;
}

.kaindl-search-results .pager__item--ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  color: #8e8e8e;
  font-weight: 700;
  user-select: none;
}

/* First/Last/Next/Previous — slightly wider to fit "Next ›" / "Last »" text */
.kaindl-search-results .pager__item--first a,
.kaindl-search-results .pager__item--previous a,
.kaindl-search-results .pager__item--next a,
.kaindl-search-results .pager__item--last a {
  padding: 0 16px;
  text-transform: none;
  letter-spacing: 0.04em;
}

@media (max-width: 640px) {
  .kaindl-search-results .pager__items {
    gap: 4px;
  }
  .kaindl-search-results .pager__item a {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }
  .kaindl-search-results .pager__item--ellipsis {
    min-width: 28px;
    height: 36px;
  }
}
