/* ==========================================================================
   Defacto storefront search — floating desktop panel + full-screen mobile
   sheet. Self-contained; reuses the runtime --color-* theme variables so it
   follows the active brand palette in both LTR and RTL.
   ========================================================================== */
:root {
  --lv-s-radius: 18px;
  --lv-s-shadow: 0 18px 48px -12px rgba(16, 24, 40, .22), 0 4px 12px -6px rgba(16, 24, 40, .12);
  --lv-s-border: var(--color-border, #dfe3e8);
  --lv-s-surface: var(--color-card-bg, #fff);
  --lv-s-ink: var(--color-light-primary-text, #212529);
  --lv-s-muted: var(--color-light-secondary-text, #495057);
  --lv-s-faint: var(--color-light-disabled-text, #919eab);
}

/* ---------- shared bits ---------- */
.lv-s [hidden] { display: none !important; }
.lv-s *, .lv-s *::before, .lv-s *::after { box-sizing: border-box; }

/* Background is locked while the full-screen sheet is open. */
body.lv-s-noscroll { overflow: hidden; }

/* Direction-aware affordances: arrow glyphs mirror in RTL, icons/photos do not. */
[dir="rtl"] .lv-s-arrow { transform: scaleX(-1); }

/* Mobile header field doubles as the sheet trigger. */
.lv-s-mfield { cursor: pointer; }
.lv-s-mfield input[readonly] { cursor: pointer; }

/* The mobile trigger is a real button (it opens a dialog) styled as the field. */
.lv-s-mfield .lv-s__trigger {
  text-align: start;
  color: var(--lv-s-muted);
  font-weight: 400;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
[dir="rtl"] .lv-s-mfield .lv-s__trigger { text-align: right; }

.lv-s__field { position: relative; display: flex; align-items: center; width: 100%; }

.lv-s__icon {
  position: absolute; inset-inline-start: 16px; display: inline-flex;
  color: var(--lv-s-faint); pointer-events: none; line-height: 0;
}
.lv-s__icon .hgi { font-size: 20px; }

.lv-s__input {
  width: 100%; border: 1px solid var(--lv-s-border); background: var(--lv-s-surface);
  color: var(--lv-s-ink); border-radius: 999px; font-size: 15px; line-height: 1.4;
  padding: 12px 46px; outline: none; -webkit-appearance: none; appearance: none;
}
.lv-s__input::placeholder { color: var(--lv-s-faint); }
.lv-s__input:focus-visible { border-color: var(--color-primary, #3d210c); box-shadow: 0 0 0 3px rgba(61,33,12,.14); }

.lv-s__clear {
  position: absolute; inset-inline-end: 12px; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(145,158,171,.16);
  color: var(--lv-s-muted); cursor: pointer; padding: 0; line-height: 0;
}
.lv-s__clear .hgi { font-size: 16px; }
.lv-s__clear:hover { background: rgba(145,158,171,.28); }

/* ---------- desktop floating panel ---------- */
.lv-s-panel {
  position: fixed; z-index: 9990; background: var(--lv-s-surface);
  border: 1px solid var(--lv-s-border); border-radius: var(--lv-s-radius); box-shadow: var(--lv-s-shadow);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(-6px); pointer-events: none; visibility: hidden;
  transition: opacity .16s ease, transform .16s ease;
}
.lv-s-panel[data-open="true"] { opacity: 1; transform: translateY(0); pointer-events: auto; visibility: visible; }
.lv-s-panel__body { overflow-y: auto; overscroll-behavior: contain; padding: 14px; }

/* ---------- mobile full-screen sheet ---------- */
.lv-s-sheet {
  position: fixed; inset: 0; z-index: 9999; background: var(--lv-s-surface);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  transform: translateY(100%); visibility: hidden; transition: transform .26s cubic-bezier(.22,.61,.36,1), visibility .26s;
}
.lv-s-sheet[data-open="true"] { transform: translateY(0); visibility: visible; }

.lv-s-sheet__head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--lv-s-border); background: var(--lv-s-surface); flex: none;
}
.lv-s-sheet__back {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent;
  color: var(--lv-s-ink); cursor: pointer; line-height: 0;
}
.lv-s-sheet__back .hgi { font-size: 24px; }
.lv-s-sheet__title { font-weight: 700; font-size: 1.05rem; margin: 0; color: var(--lv-s-ink); flex: 0 0 auto; }
.lv-s-sheet__body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 14px; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
.lv-s-sheet .lv-s__field { padding-top: 0; }
.lv-s-sheet .lv-s__input { padding-block: 11px; }
.lv-s-sheet__searchrow { padding: 4px 14px 12px; }

/* ---------- sections ---------- */
.lv-s-sec { margin-top: 18px; }
.lv-s-sec:first-child { margin-top: 4px; }
.lv-s-sec__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.lv-s-sec__title { font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--lv-s-faint); margin: 0; }
.lv-s-sec__clear {
  border: 0; background: transparent; color: var(--color-primary, #3d210c); font-size: .8rem; font-weight: 600;
  cursor: pointer; padding: 2px 6px; border-radius: 8px; display: inline-flex; align-items: center; gap: 4px;
}
.lv-s-sec__clear:hover { background: rgba(145,158,171,.12); }
.lv-s-sec__clear .hgi { font-size: 15px; }

/* chips (recent / trending / brands) */
.lv-s-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.lv-s-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--lv-s-border);
  background: var(--lv-s-surface); color: var(--lv-s-ink); font-size: .85rem; text-decoration: none;
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.lv-s-chip:hover, .lv-s-chip:focus-visible { border-color: var(--color-primary, #3d210c); background: rgba(145,158,171,.08); }
.lv-s-chip__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-s-chip__count { color: var(--lv-s-faint); font-size: .78rem; }
.lv-s-chip__x {
  margin-inline-start: 2px; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; background: rgba(145,158,171,.18); color: var(--lv-s-muted);
  border: 0; cursor: pointer; line-height: 0; flex: none;
}
.lv-s-chip__x .hgi { font-size: 11px; }
.lv-s-chip__x:hover { background: var(--color-error, #cb0233); color: #fff; }

/* categories rail */
.lv-s-rail { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; scrollbar-width: thin; }
.lv-s-cat { flex: 0 0 auto; width: 92px; text-decoration: none; color: var(--lv-s-ink); scroll-snap-align: start; text-align: center; }
.lv-s-cat__media {
  width: 92px; height: 92px; border-radius: 16px; overflow: hidden; background: #f4f3f5;
  border: 1px solid var(--lv-s-border); margin-bottom: 7px; display: flex; align-items: center; justify-content: center;
}
.lv-s-cat__media img { width: 100%; height: 100%; object-fit: cover; }
.lv-s-cat__media .lv-s-cat__fallback { font-size: 1.5rem; font-weight: 800; color: var(--color-primary, #3d210c); }
.lv-s-cat:hover .lv-s-cat__media { border-color: var(--color-primary, #3d210c); }
.lv-s-cat__name { font-size: .8rem; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* product rail (popular) */
.lv-s-prail { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; scrollbar-width: thin; }
.lv-s-prod { flex: 0 0 auto; width: 132px; display: flex; flex-direction: column; gap: 6px; scroll-snap-align: start; }
.lv-s-prod__media { width: 132px; height: 132px; border-radius: 12px; overflow: hidden; background: #f4f3f5; border: 1px solid var(--lv-s-border); text-decoration: none; display: block; }
.lv-s-prod__media img { width: 100%; height: 100%; object-fit: cover; }
.lv-s-prod__name { font-size: .82rem; line-height: 1.3; color: var(--lv-s-ink); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lv-s-prod__name:hover { color: var(--color-primary, #3d210c); }
.lv-s-prod__price { font-size: .82rem; font-weight: 700; color: var(--color-primary, #3d210c); }

/* ---------- results list ---------- */
.lv-s-group + .lv-s-group { margin-top: 16px; }
.lv-s-row {
  display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; text-decoration: none; color: var(--lv-s-ink);
}
.lv-s-row:hover, .lv-s-row.is-active { background: rgba(145,158,171,.12); }
.lv-s-row__media { width: 46px; height: 46px; flex: none; border-radius: 10px; overflow: hidden; background: #f4f3f5; display: flex; align-items: center; justify-content: center; }
.lv-s-row__media img { width: 100%; height: 100%; object-fit: cover; }
.lv-s-row__media .hgi { font-size: 22px; color: var(--lv-s-faint); }
.lv-s-row__main { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; }
.lv-s-row__title { font-size: .92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-s-row__meta { font-size: .78rem; color: var(--lv-s-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-s-row__price { font-size: .85rem; font-weight: 700; color: var(--color-primary, #3d210c); flex: none; }
.lv-s-row__tag { flex: none; font-size: .74rem; color: var(--lv-s-faint); }

.lv-s-viewall {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px;
  padding: 11px; border-radius: 12px; background: rgba(145,158,171,.1); color: var(--color-primary, #3d210c);
  font-weight: 700; font-size: .9rem; text-decoration: none;
}
.lv-s-viewall:hover { background: rgba(145,158,171,.18); }
.lv-s-viewall .hgi { font-size: 18px; }

/* ---------- states ---------- */
.lv-s-state { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 26px 12px; color: var(--lv-s-muted); }
.lv-s-state .hgi { font-size: 30px; color: var(--lv-s-faint); }
.lv-s-state p { margin: 0; font-size: .9rem; }
.lv-s-state small { color: var(--lv-s-faint); font-size: .82rem; }
.lv-s-loader { display: flex; align-items: center; gap: 10px; padding: 18px; color: var(--lv-s-faint); font-size: .88rem; }
.lv-s-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(145,158,171,.35); border-top-color: var(--color-primary, #3d210c); animation: lv-s-spin .7s linear infinite; }
@keyframes lv-s-spin { to { transform: rotate(360deg); } }

.lv-s-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* keyboard focus visibility */
.lv-s :focus-visible { outline: 2px solid var(--color-primary, #3d210c); outline-offset: 2px; }
.lv-s-panel .lv-s__input:focus-visible, .lv-s-sheet .lv-s__input:focus-visible { outline: none; }

/* ---------- responsive ---------- */
@media (max-width: 1279px) {
  /* mobile header input doubles as the trigger; it's read-only so hide caret */
  .lv-s-mfield { cursor: pointer; }
  .lv-s-mfield input[readonly] { cursor: pointer; }
  .lv-s-panel { display: none !important; }
}
@media (min-width: 1280px) {
  .lv-s-sheet { display: none !important; }
}

@media (max-width: 420px) {
  .lv-s-cat, .lv-s-cat__media { width: 80px; }
  .lv-s-cat__media { height: 80px; }
}

/* ---------- motion / forced colours ---------- */
@media (prefers-reduced-motion: reduce) {
  .lv-s-panel, .lv-s-sheet, .lv-s-chip, .lv-s-cat__media, .lv-s-prod__name { transition: none !important; }
  .lv-s-spin { animation-duration: 1.4s; }
}

/* ---------- active-filter chips on the results page ---------- */
.lv-fchips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 18px; }
.lv-fchips[hidden] { display: none; }
.lv-fchips__label { font-size: .8rem; font-weight: 700; color: var(--lv-s-faint); text-transform: uppercase; letter-spacing: .04em; margin-inline-end: 2px; }
.lv-fchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 999px;
  border: 1px solid var(--lv-s-border); background: var(--lv-s-surface); color: var(--lv-s-ink); font-size: .82rem;
}
.lv-fchip b { font-weight: 600; }
.lv-fchip button {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%;
  border: 0; background: rgba(145,158,171,.18); color: var(--lv-s-muted); cursor: pointer; line-height: 0; padding: 0;
}
.lv-fchip button .hgi { font-size: 11px; }
.lv-fchip button:hover { background: var(--color-error, #cb0233); color: #fff; }
.lv-fchips__clear {
  border: 0; background: transparent; color: var(--color-error, #cb0233); font-size: .82rem; font-weight: 600;
  cursor: pointer; padding: 5px 8px; border-radius: 999px; margin-inline-start: 2px;
}
.lv-fchips__clear:hover { background: rgba(203,2,51,.08); }
