/**
 * PrestaHU
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Commercial License
 * you can't distribute, modify or sell this code
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file
 * If you need help please contact info@presta.hu
 *
 * @author    PrestaHU <info@presta.hu>
 * @copyright PrestaHU
 * @license   commercial
 */

/* Site search. Header: an icon that opens a sheet below the header with the field and the
   results. Inline (404 page): an open field with a floating results card.
   Colours, radii, shadows and timing come from the theme's --ph-* tokens. */
.pshu-search,
.pshu-search__sheet {
  --pshu-search-field-h: 48px;
  font-family: var(--ph-font-sans);
  color: var(--ph-ink);
  text-align: left;
}

.pshu-search *,
.pshu-search *::before,
.pshu-search *::after,
.pshu-search__sheet *,
.pshu-search__sheet *::before,
.pshu-search__sheet *::after { box-sizing: border-box; }

.pshu-search {
  position: relative;
  width: 100%;
  max-width: 100%;
}

.pshu-search--header {
  width: auto;
  display: inline-flex;
  align-items: center;
}

/* Header icon */
.pshu-search__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--ph-radius-pill);
  background: transparent;
  color: var(--ph-ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--ph-dur-fast) var(--ph-ease-out), color var(--ph-dur-fast) var(--ph-ease-out);
}

.pshu-search__toggle:hover,
.pshu-search.is-expanded .pshu-search__toggle {
  background: var(--ph-brand-soft);
  color: var(--ph-brand-strong);
}

.pshu-search__toggle .material-icons { font-size: 24px; }

/* Header sheet: fixed, placed by search.js below the header. */
.pshu-search__sheet {
  position: fixed;
  z-index: 1060;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 8px;
  padding: 12px;
  overflow: hidden;
  background: var(--ph-bg);
  border: var(--ph-border-w, 1px) solid var(--ph-border);
  border-radius: var(--ph-radius-md);
  box-shadow: var(--ph-shadow-lg);
  animation: pshu-search-in var(--ph-dur) var(--ph-ease-out);
}

.pshu-search__sheet[hidden] { display: none; }

.pshu-search__sheet .pshu-search__panel,
.pshu-search__sheet .pshu-search__status { grid-column: 1 / -1; }

.pshu-search__dismiss {
  grid-row: 1;
  grid-column: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--ph-radius-pill);
  background: transparent;
  color: var(--ph-ink-muted);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color var(--ph-dur-fast) var(--ph-ease-out), color var(--ph-dur-fast) var(--ph-ease-out);
}

.pshu-search__dismiss:hover { background: var(--ph-surface-sand); color: var(--ph-ink); }

/* Field */
.pshu-search__form {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 0;
}

.pshu-search__lead {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  color: var(--ph-ink-subtle);
  pointer-events: none;
}

.pshu-search__input {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: var(--pshu-search-field-h);
  margin: 0;
  padding: 0 136px 0 48px;
  border: var(--ph-border-w, 1px) solid var(--ph-border-strong);
  border-radius: var(--ph-radius-pill);
  background: var(--ph-surface-cream);
  color: var(--ph-ink);
  font: inherit;
  font-size: var(--ph-text-base);
  line-height: 20px;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  transition: background-color var(--ph-dur-fast) var(--ph-ease-out), border-color var(--ph-dur-fast) var(--ph-ease-out), box-shadow var(--ph-dur-fast) var(--ph-ease-out);
}

.pshu-search__input::-webkit-search-cancel-button,
.pshu-search__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

.pshu-search__input::placeholder {
  color: var(--ph-ink-muted);
  opacity: 1;
}

.pshu-search__input:focus {
  outline: none;
  background: var(--ph-bg);
  border-color: var(--ph-brand);
  box-shadow: 0 0 0 4px var(--ph-focus-ring);
}

.pshu-search__clear,
.pshu-search__submit {
  position: absolute;
  top: 4px;
  height: calc(var(--pshu-search-field-h) - 8px);
  margin: 0;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background-color var(--ph-dur-fast) var(--ph-ease-out), color var(--ph-dur-fast) var(--ph-ease-out);
}

.pshu-search__submit {
  right: 4px;
  padding: 0 18px;
  border-radius: var(--ph-radius-pill);
  background: var(--ph-brand);
  color: var(--ph-brand-ink);
  font: inherit;
  font-size: var(--ph-text-sm);
  font-weight: 600;
  line-height: 1;
}

.pshu-search__submit:hover { background: var(--ph-brand-strong); color: var(--ph-brand-ink); }

.pshu-search__clear {
  right: 100px;
  width: 40px;
  padding: 0;
  border-radius: var(--ph-radius-pill);
  background: transparent;
  color: var(--ph-ink-muted);
}

.pshu-search__clear .material-icons { font-size: 20px; }
.pshu-search__clear:hover { background: var(--ph-surface-sand); color: var(--ph-ink); }
.pshu-search__clear[hidden] { display: none; }

.pshu-search__toggle:focus-visible,
.pshu-search__dismiss:focus-visible,
.pshu-search__clear:focus-visible,
.pshu-search__submit:focus-visible {
  outline: 2px solid var(--ph-brand-strong);
  outline-offset: 2px;
}

/* Loading: a thin moving line along the bottom edge of the field. */
.pshu-search__form::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--ph-brand), transparent);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  opacity: 0;
  pointer-events: none;
}

.is-loading .pshu-search__form::after,
.is-loading.pshu-search__sheet .pshu-search__form::after {
  opacity: 1;
  animation: pshu-search-loading 1s linear infinite;
}

@keyframes pshu-search-loading {
  from { background-position: -50% 0; }
  to { background-position: 150% 0; }
}

@keyframes pshu-search-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* Results. Inline: a floating card under the field. Sheet: part of the sheet, scrolling inside. */
.pshu-search__panel {
  background: var(--ph-bg);
  text-align: left;
  overscroll-behavior: contain;
}

.pshu-search__panel[hidden] { display: none; }

.pshu-search--inline .pshu-search__panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1050;
  width: min(880px, calc(100vw - 32px));
  max-height: min(78vh, 720px);
  overflow-y: auto;
  border: var(--ph-border-w, 1px) solid var(--ph-border);
  border-radius: var(--ph-radius-md);
  box-shadow: var(--ph-shadow-lg);
  animation: pshu-search-in var(--ph-dur) var(--ph-ease-out);
}

.pshu-search__sheet .pshu-search__panel {
  max-height: calc(var(--pshu-sheet-max, 70vh) - 24px - var(--pshu-search-field-h) - 12px);
  margin: 0 -12px -12px;
  overflow-y: auto;
  border-top: var(--ph-border-w, 1px) solid var(--ph-border);
}

.pshu-search__panel.has-side {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
}

.pshu-search--inline .pshu-search__panel.is-empty { width: min(480px, calc(100vw - 32px)); }

.pshu-search__side {
  position: sticky;
  top: 0;
  align-self: stretch;
  padding: 12px 8px 16px;
  border-right: var(--ph-border-w, 1px) solid var(--ph-border);
  background: var(--ph-surface-cream);
}

.pshu-search__main {
  min-width: 0;
  padding: 12px 12px 0;
}

.pshu-search__group { display: block; }
.pshu-search__group + .pshu-search__group { margin-top: 12px; }

/* Result count for screen readers only. */
.pshu-search__status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.pshu-search__head {
  padding: 4px 12px 8px;
  font-size: var(--ph-text-xs);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ph-ink-muted);
}

.pshu-search__list { display: block; }

.pshu-search__option {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--ph-radius-sm);
  color: var(--ph-ink);
  text-decoration: none;
  line-height: 1.35;
  cursor: pointer;
  transition: background-color var(--ph-dur-fast) var(--ph-ease-out);
}

.pshu-search__option:hover,
.pshu-search__option:focus,
.pshu-search__option[aria-selected="true"] {
  background: var(--ph-brand-soft);
  color: var(--ph-ink);
  text-decoration: none;
}

.pshu-search__option[aria-selected="true"] { box-shadow: inset 0 0 0 2px var(--ph-brand); }

/* Text inside the options keeps its own colour: the theme recolours hovered links. */
.pshu-search__label,
.pshu-search__name,
.pshu-search__current,
.pshu-search__all-text,
.pshu-search__all-icon,
.pshu-search__arrow { color: var(--ph-ink); }
.pshu-search__count,
.pshu-search__regular { color: var(--ph-ink-muted); }

/* Categories and brands */
.pshu-search__term {
  font-size: var(--ph-text-sm);
  font-weight: 500;
}

.pshu-search__side .pshu-search__option:hover,
.pshu-search__side .pshu-search__option[aria-selected="true"] { background: var(--ph-bg); }

.pshu-search__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pshu-search__count {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: var(--ph-text-xs);
  font-variant-numeric: tabular-nums;
}

/* Products: one column of rows; two on a wide inline card. */
.pshu-search__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}

.pshu-search--inline .pshu-search__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; }

.pshu-search__product {
  gap: 16px;
  padding: 8px;
  scroll-margin: 8px 0 72px;
}

.pshu-search__media {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--ph-radius-sm);
  background: var(--ph-surface-sand);
}

.pshu-search__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pshu-search__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.pshu-search__name {
  font-family: var(--ph-font-display);
  font-weight: 600;
  font-size: var(--ph-text-sm);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pshu-search__price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 8px;
  font-variant-numeric: tabular-nums;
}

.pshu-search__current {
  font-size: var(--ph-text-base);
  font-weight: 700;
  line-height: 1.2;
}

.pshu-search__product.has-discount .pshu-search__current { color: var(--ph-brand-strong); }

.pshu-search__regular {
  font-size: var(--ph-text-sm);
  text-decoration: line-through;
}

/* All results: stays visible at the bottom of the results column. */
.pshu-search__footer {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin: 4px -12px 0;
  padding: 8px 12px 10px;
  background: var(--ph-bg);
  border-top: var(--ph-border-w, 1px) solid var(--ph-border);
}

.pshu-search__panel.is-empty .pshu-search__footer { margin: 0; border-top: 0; }

.pshu-search__all,
#header .pshu-search .pshu-search__all {
  gap: 10px;
  color: var(--ph-ink);
  font-weight: 600;
}

.pshu-search__all:hover,
.pshu-search__all[aria-selected="true"],
#header .pshu-search .pshu-search__all:hover,
#header .pshu-search .pshu-search__all[aria-selected="true"] {
  background: var(--ph-brand-soft);
  color: var(--ph-ink);
}

.pshu-search__all-icon { width: 20px; height: 20px; flex: 0 0 20px; }
.pshu-search__arrow { width: 18px; height: 18px; flex: 0 0 18px; margin-left: auto; }

/* No results */
.pshu-search__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 24px 8px;
  text-align: center;
  color: var(--ph-ink-muted);
}

.pshu-search__empty-icon {
  width: 44px;
  height: 44px;
  padding: 10px;
  border-radius: var(--ph-radius-pill);
  background: var(--ph-surface-sand);
  color: var(--ph-ink-muted);
}

.pshu-search__empty-text {
  font-size: var(--ph-text-base);
  color: var(--ph-ink);
}

.pshu-search mark,
.pshu-search__sheet mark {
  padding: 0;
  background: none;
  color: inherit;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .pshu-search__panel,
  .pshu-search__sheet,
  .is-loading .pshu-search__form::after { animation: none; }
  .pshu-search *,
  .pshu-search__sheet * { transition: none; }
}

@media (max-width: 1023px) {
  .pshu-search--inline .pshu-search__grid { grid-template-columns: minmax(0, 1fr); }
}

/* Phones: the sheet spans the width under the header; categories and brands above the products. */
@media (max-width: 767px) {
  .pshu-search__sheet {
    align-content: start;
    padding: 8px 8px 12px;
    gap: 8px 4px;
    border-width: 0 0 var(--ph-border-w, 1px);
    border-radius: 0 0 var(--ph-radius-md) var(--ph-radius-md);
  }

  .pshu-search__input { padding-right: 52px; }
  .pshu-search__submit { width: 40px; padding: 0; font-size: 0; }
  .pshu-search__submit::before {
    content: "search";
    font-family: 'Material Icons';
    font-size: 22px;
    line-height: 1;
    font-feature-settings: 'liga';
    -webkit-font-feature-settings: 'liga';
  }
  .pshu-search__clear { right: 46px; }
  .pshu-search__input:not(:placeholder-shown) { padding-right: 92px; }

  .pshu-search__sheet .pshu-search__panel {
    margin: 0 -8px -12px;
    max-height: calc(var(--pshu-sheet-max, 70vh) - 20px - var(--pshu-search-field-h) - 8px);
  }

  .pshu-search--inline .pshu-search__panel,
  .pshu-search--inline .pshu-search__panel.is-empty {
    width: 100%;
    max-height: 74vh;
  }

  .pshu-search__panel.has-side { display: block; }

  .pshu-search__side {
    position: static;
    padding: 8px;
    border-right: 0;
    border-bottom: var(--ph-border-w, 1px) solid var(--ph-border);
  }

  .pshu-search__main { padding: 8px 8px 0; }
  .pshu-search__option { min-height: 48px; }
  .pshu-search__product { gap: 12px; }
  .pshu-search__footer { margin: 4px -8px 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
}
