/*
 * Product search dialog (inc/search.php, js/search.js), in the home page's language: Neue Haas
 * Unica, brand ink and gold, the cool porcelain tint for quiet surfaces, white photo tiles with
 * a hairline and 14px corners, the gold tracked-capitals button.
 * A rounded panel over the blurred page on larger screens, the whole screen on phones.
 */

.ags-search {
  --ink: #201600;
  --text: #565049;
  --muted: #6F6A63;
  --gold: #C49564;
  --gold-dark: #A97B4B;
  --porcelain: #ECEFED;
  --porcelain-soft: #F4F6F5;
  --line: #E3DED6;
  --border: #DCD3C3;
  --field-line: rgba(144, 150, 154, 0.4);
  --pad: 24px; /* the panel's frame, one on every side */
  --field: 60px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  width: min(860px, calc(100vw - 48px));
  max-width: none;
  max-height: calc(100dvh - 96px);
  margin: 48px auto auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(32, 22, 0, 0.18), 0 2px 8px rgba(32, 22, 0, 0.06);
  color: var(--text);
  font-family: "Neue Haas Unica", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.ags-search[open] {
  display: flex;
  animation: ags-search-in var(--ags-open, 0.45s) var(--ags-ease, ease-out);
}

.ags-search::backdrop {
  background: rgba(32, 22, 0, 0.32);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: ags-search-fade var(--ags-open, 0.45s) var(--ags-ease, ease-out);
}

@keyframes ags-search-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.985); }
}

@keyframes ags-search-fade {
  from { opacity: 0; }
}

/*
 * Scroll lock on body, not html: with html's overflow set, body (overflow-x: hidden from mmenu)
 * becomes its own scroller and the sticky header leaves the screen. The scrollbar's width stays
 * as padding so the page does not shift.
 */
body.ags-search-open {
  overflow: hidden;
  padding-right: var(--ags-scrollbar, 0px);
}

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

.ags-search :focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.ags-search .ags-search-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.ags-search__panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
}

/* Field and the close button: one height, corners and hairline */

.ags-search__head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 14px;
  padding: var(--pad) var(--pad) 8px;
}

.ags-search__form {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  height: var(--field);
  padding: 0 9px 0 11px; /* plus the frame's 1px hairline */
  overflow: hidden;
  border: 0;
  border-radius: 12px;
  isolation: isolate;
}

/*
 * The field's frame (hairline and white) is a layer of its own: the phone opening (js/search.js)
 * stretches it with a transform alone, which iOS runs off the main thread, unlike width and height.
 */
.ags-search__form::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: #fff;
  transform-origin: 0 0;
  transition: border-color 0.2s;
  pointer-events: none;
}

.ags-search__form.is-morphing {
  overflow: visible;
}

/* The site's fields (css/forms.css, from aesthetics): a grey hairline that turns ink on focus */
.ags-search__form:focus-within::before {
  border-color: var(--ink);
}

.ags-search .ags-search__lens,
.ags-search .ags-search__clear {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.ags-search .ags-search__lens .ags-search-icon {
  width: 22px;
  height: 22px;
}

.ags-search .ags-search__clear {
  width: 32px;
  height: 32px;
  background: var(--porcelain);
  color: var(--muted);
}

.ags-search .ags-search__clear .ags-search-icon {
  width: 16px;
  height: 16px;
}

.ags-search .ags-search__clear[hidden] {
  display: none;
}

.ags-search .ags-search__field {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 0 10px 0 6px;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
  -webkit-appearance: none;
  appearance: none;
}

.ags-search .ags-search__field::placeholder {
  color: rgba(144, 150, 154, 0.8);
  opacity: 1;
}

/* The dialog has its own clear button. */
.ags-search .ags-search__field::-webkit-search-cancel-button,
.ags-search .ags-search__field::-webkit-search-decoration {
  display: none;
  -webkit-appearance: none;
}

/* While suggestions load: a gold line runs along the field's bottom edge. */
.ags-search__progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.ags-search__progress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: var(--gold);
  border-radius: 2px;
}

.ags-search.is-loading .ags-search__progress {
  opacity: 1;
  transition-delay: 0.15s;
}

.ags-search.is-loading .ags-search__progress::before {
  animation: ags-search-progress 1s ease-in-out infinite;
}

@keyframes ags-search-progress {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}

.ags-search .ags-search__close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: var(--field);
  height: var(--field);
  margin: 0;
  padding: 0;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.ags-search .ags-search__close .ags-search-icon {
  width: 20px;
  height: 20px;
  transition: transform 0.3s var(--ease);
}

/* Body: scrolls under the field */

.ags-search__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 20px var(--pad) var(--pad);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.ags-search__idle[hidden],
.ags-search__results[hidden],
.ags-search__block[hidden] {
  display: none;
}

.ags-search .ags-search__hint {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 15px;
}

.ags-search__hint em {
  color: var(--ink);
  font-style: normal;
}

/* The gap under the hint is the next block's. */
.ags-search__hint + .ags-search__block {
  margin-top: 28px;
}

.ags-search__block + .ags-search__block,
.ags-search__list + .ags-search__block {
  margin-top: 30px;
}

.ags-search__block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.ags-search .ags-search__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--ink);
  font-family: inherit;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.005em;
  text-transform: none;
}

.ags-search__count {
  min-width: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--porcelain);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.ags-search .ags-search__text-button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.3;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 5px;
  cursor: pointer;
  transition: text-decoration-color 0.2s;
}

/* Query chips */

.ags-search__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ags-search .ags-search__chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin: 0;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.ags-search .ags-search__chip .ags-search-icon {
  width: 16px;
  height: 16px;
  margin-left: -4px;
  color: var(--gold-dark);
  transition: color 0.2s;
}

/* Bestsellers: small product cards, as in the catalog */

.ags-search .ags-search__cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ags-search__cards li {
  margin: 0;
  list-style: none;
}

.ags-search .ags-search__card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  color: var(--ink);
  text-decoration: none;
}

.ags-search__tile {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.ags-search__tile img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
  transition: transform 0.6s var(--ease);
}

.ags-search__card .ags-search__price {
  margin-top: auto;
  padding-top: 6px;
  text-align: left;
}

/* Suggestions: rows with a photo tile, name, price and an arrow */

.ags-search .ags-search__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -12px;
  padding: 0;
  list-style: none;
}

.ags-search__list li {
  margin: 0;
  list-style: none;
}

.ags-search .ags-search__item {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 18px;
  padding: 8px 14px 8px 8px;
  border-radius: 16px;
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.2s;
}

.ags-search .ags-search__item[aria-selected="true"] {
  background: var(--porcelain-soft);
}

.ags-search__media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.ags-search__media img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
}

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

.ags-search__name {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0.03em;
}

.ags-search__meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ags-search__price {
  color: var(--ink);
  font-size: 17px;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.ags-search__price del {
  margin-right: 6px;
  color: var(--muted);
  font-size: 13px;
}

.ags-search__item .ags-search__price del {
  display: block;
  margin: 0 0 2px;
}

.ags-search__price ins {
  background: none;
  text-decoration: none;
}

.ags-search__go {
  display: grid;
  place-items: center;
  color: var(--gold-dark);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s, transform 0.3s var(--ease);
}

.ags-search__go .ags-search-icon {
  width: 18px;
  height: 18px;
}

.ags-search__item[aria-selected="true"] .ags-search__go {
  opacity: 1;
  transform: none;
}

.ags-search__results {
  transition: opacity 0.2s;
}

.ags-search.is-loading .ags-search__results {
  opacity: 0.55;
  transition-delay: 0.15s;
}

/* Results appear softly: each block or row rises a few pixels, one after another (js/search.js). */
.ags-search__rise {
  animation: ags-search-rise 0.45s var(--ease) backwards;
  animation-delay: calc(var(--order, 0) * 40ms);
}

@keyframes ags-search-rise {
  from { opacity: 0; transform: translateY(10px); }
}

/* "Показати всі товари": the site's gold button */

.ags-search .ags-search__all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin: 28px 0 0;
  padding: 15px 28px;
  border: 0;
  border-radius: 8px;
  background: var(--gold);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s;
}

.ags-search .ags-search__all .ags-search-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.3s var(--ease);
}

/* Nothing found */

.ags-search__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px 8px;
  text-align: center;
}

.ags-search__empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--porcelain);
  color: var(--ink);
}

.ags-search .ags-search__empty-icon .ags-search-icon {
  width: 26px;
  height: 26px;
}

.ags-search .ags-search__empty-title {
  max-width: 28em;
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.ags-search .ags-search__empty-text {
  max-width: 30em;
  margin: 0;
  color: var(--muted);
}

.ags-search__empty .ags-search__block {
  margin: 10px 0 6px;
}

.ags-search__empty .ags-search__chips {
  justify-content: center;
}

@media (hover: hover) {
  .ags-search .ags-search__item:hover {
    background: var(--porcelain-soft);
  }

  .ags-search .ags-search__item:hover .ags-search__go {
    opacity: 1;
    transform: none;
  }

  .ags-search .ags-search__chip:hover {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
  }

  .ags-search .ags-search__chip:hover .ags-search-icon {
    color: var(--gold);
  }

  .ags-search .ags-search__card:hover .ags-search__tile img {
    transform: scale(1.04);
  }

  .ags-search .ags-search__close:hover {
    border-color: var(--ink);
    background: var(--ink);
    color: #fff;
  }

  .ags-search .ags-search__close:hover .ags-search-icon {
    transform: rotate(90deg);
  }

  .ags-search .ags-search__clear:hover {
    background: var(--border);
    color: var(--ink);
  }

  .ags-search .ags-search__all:hover {
    background: var(--gold-dark);
  }

  .ags-search .ags-search__all:hover .ags-search-icon {
    transform: translateX(4px);
  }

  .ags-search .ags-search__text-button:hover {
    text-decoration-color: currentColor;
  }
}

/* Phones: the whole screen; bestsellers scroll sideways as on the home page */

@media (max-width: 767px) {
  .ags-search {
    --pad: 16px;
    --field: 52px;
    width: 100%;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .ags-search[open] {
    animation-name: ags-search-fade;
  }

  .ags-search__head {
    gap: 10px;
    padding: var(--pad) var(--pad) 4px;
  }

  .ags-search__form {
    padding-left: 7px;
  }

  .ags-search .ags-search__field {
    font-size: 18px;
  }

  .ags-search__body {
    padding-top: 18px;
  }

  .ags-search .ags-search__title {
    font-size: 16px;
  }

  .ags-search .ags-search__cards {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 42%;
    gap: 12px;
    margin: 0 calc(-1 * var(--pad));
    padding: 0 var(--pad);
    scroll-padding: 0 var(--pad);
  }

  .ags-search__card .ags-search__name {
    font-size: 14px;
  }

  .ags-search .ags-search__list {
    margin: 0 -8px;
  }

  .ags-search .ags-search__item {
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 4px 14px;
    padding: 8px;
    border-radius: 14px;
  }

  .ags-search__media {
    grid-row: span 2;
    width: 60px;
    height: 60px;
  }

  .ags-search__item .ags-search__price {
    grid-column: 2;
    font-size: 15px;
    text-align: left;
  }

  .ags-search__item .ags-search__price del {
    display: inline;
    margin: 0 6px 0 0;
  }

  .ags-search__go {
    display: none;
  }
}

/*
 * Opening from a field that looks like this one (the phone menu's, js/search.js): the screen
 * turns white as the field travels up from where it was tapped; the close button and the body
 * rise in behind it. Set until the dialog closes, so nothing replays.
 * The white is the backdrop's and it fades in by opacity: a fading background colour would be
 * repainted across the whole screen on every frame, which stutters on iPhones.
 */
.ags-search.is-morphed[open] {
  background: transparent;
  animation: none;
}

.ags-search.is-morphed::backdrop {
  background: #fff;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  animation: ags-search-fade 0.4s ease-out both;
}

.ags-search.is-morphed .ags-search__close,
.ags-search.is-morphed .ags-search__body {
  animation: ags-search-follow 0.5s var(--ease) 0.18s both;
}

@keyframes ags-search-follow {
  from { opacity: 0; transform: translateY(14px); }
}

/*
 * Closing (js/search.js): the opening backwards, on the closing tokens (css/pages.css). The panel
 * lifts and fades over the clearing backdrop; on phones, where the dialog is the whole screen, it
 * fades as it came. After the opening rules above (the morphed opening included) so that it wins.
 */
.ags-search.is-closing[open] {
  animation: ags-search-out var(--ags-close, 0.3s) var(--ags-ease-close, ease) both;
}

.ags-search.is-closing::backdrop {
  animation: ags-search-fade-out var(--ags-close, 0.3s) var(--ags-ease-close, ease) both;
}

@keyframes ags-search-out {
  to { opacity: 0; transform: translateY(-12px) scale(0.985); }
}

@keyframes ags-search-fade-out {
  to { opacity: 0; }
}

@media (max-width: 767px) {
  .ags-search.is-closing[open] {
    animation-name: ags-search-fade-out;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ags-search[open],
  .ags-search::backdrop,
  .ags-search__rise,
  .ags-search.is-loading .ags-search__progress::before {
    animation: none;
  }

  .ags-search * {
    transition: none !important;
  }
}

/* Header button that opens the dialog: looks like a search field */

.ags-search-trigger {
  display: flex;
  flex: 0 1 590px;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 40px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #6F6A63;
  font-family: "Open Sans", sans-serif;
  font-size: 14px;
  line-height: 1;
  text-align: left;
  cursor: pointer;
}

.ags-search-trigger .ags-search-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: #201600;
}

.ags-search-trigger span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ags-search-trigger:focus-visible {
  outline: 2px solid #C49564;
  outline-offset: 2px;
}

@media (max-width: 740px) {
  .ags-search-trigger {
    flex: 1 1 auto;
  }
}
