/* ==========================================================================
   Mielova — shop components shared by the homepage and the catalogue.

   Two things live here, and they are the two things both pages need to agree
   on: the glass product card, and the catalogue's filter rail.

   These `--mls-*` values are the canonical shop palette. mielova-home.css
   maps its local token names onto them, so a colour is only ever defined once.
   ========================================================================== */

:root {
  --mls-ink: #1b241d;
  --mls-forest: #123f2b;
  --mls-forest-deep: #0e3223;
  --mls-honey: #d9a441;
  --mls-honey-deep: #c08a28;
  --mls-honey-ink: #2e1d06;
  --mls-paper: #f6f5f0;
  --mls-panel: #efefea;
  --mls-line: #d9ddd6;
  --mls-copy: #4d574e;
  --mls-muted: #6e786e;
  --mls-ui: "Tajawal", "Noto Sans Arabic", system-ui, sans-serif;
  --mls-num: "Manrope", "Tajawal", sans-serif;
  --mls-ease: cubic-bezier(.22, .61, .36, 1);

  /* Also redefined by Govix Admin -> Site Settings (SiteTheme.build_css). */
  --mls-on-forest: #f4f1e6;
  --mls-danger: #9a4a37;
  --mls-surface-rgb: 255, 255, 255;
  --mls-heading: var(--mls-ui);
  --mls-radius-card: 18px;
  --mls-radius-panel: 14px;
  --mls-radius-btn: 999px;
  --mls-shadow-card: 0 8px 24px rgba(64, 48, 20, .07);
  --mls-shadow-lift: 0 12px 30px rgba(64, 48, 20, .1);
}

/* ----------------------------------------------------------------- grid */

.mlh-grid { display: grid; gap: clamp(16px, 1.6vw, 22px); }
/* The homepage shows a short, known row and sizes itself to it. */
.mlh-grid[data-count="1"] { grid-template-columns: minmax(0, 320px); }
.mlh-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 700px; }
.mlh-grid[data-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 1060px; }
.mlh-grid[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* The catalogue is open-ended, so it just fills the row. */
.mlh-grid-fluid { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: none; }

/* -------------------------------------------------------- glass product card */
/* Frosted panel: translucent white over the section's ambient, a bright top
   edge for the lit rim, and one soft shadow to lift it off the ground. */

.mlh-card {
  position: relative;         /* anchor for the title's full-card hit area */
  display: flex;
  flex-direction: column;
  padding: 10px;
  color: var(--mls-ink);
  background: linear-gradient(160deg, rgba(var(--mls-surface-rgb), .72), rgba(var(--mls-surface-rgb), .46));
  border: 1px solid rgba(var(--mls-surface-rgb), .8);
  border-radius: var(--mls-radius-card);
  box-shadow: var(--mls-shadow-card);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  font-family: var(--mls-ui);
  transition: border-color .25s var(--mls-ease), box-shadow .25s var(--mls-ease), transform .25s var(--mls-ease);
}
.mlh-card:hover {
  border-color: rgba(var(--mls-surface-rgb), .96);
  box-shadow: var(--mls-shadow-lift);
  transform: translateY(-2px);
}

.mlh-card-visual {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: rgba(var(--mls-surface-rgb), .42);
  border: 1px solid rgba(var(--mls-surface-rgb), .6);
  border-radius: var(--mls-radius-panel);
}
.mlh-card-visual img {
  width: 100%;
  height: 100%;
  padding: 9%;
  object-fit: contain;
  transition: transform .4s var(--mls-ease);
}
.mlh-card:hover .mlh-card-visual img { transform: scale(1.025); }

.mlh-card-badge {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  padding: 5px 10px;
  color: var(--mls-forest-deep);
  background: rgba(var(--mls-surface-rgb), .82);
  border: 1px solid rgba(var(--mls-surface-rgb), .8);
  border-radius: var(--mls-radius-btn);
  font-size: .7rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mlh-card-badge.is-deal { color: #fff; background: #a9691a; border-color: #a9691a; }

.mlh-card-body { display: flex; flex: 1; flex-direction: column; gap: 6px; padding: 14px 6px 6px; }
html[dir] .mlh-card-body h3 {
  margin: 0;
  color: var(--mls-ink);
  font-family: var(--mls-ui);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.5;
}
.mlh-card-body h3 a { color: inherit; text-decoration: none; }
.mlh-card-body h3 a::after { content: ""; position: absolute; inset: 0; }   /* whole card is the link */
.mlh-card-meta { margin: 0; color: var(--mls-muted); font-size: .82rem; }
.mlh-card-price {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin: 2px 0 8px;
  font-family: var(--mls-num);
  font-variant-numeric: tabular-nums;
}
.mlh-card-price strong { color: var(--mls-forest); font-size: 1.06rem; font-weight: 700; }
.mlh-card-price s { color: #98a199; font-size: .86rem; }

/* Two actions: buy now, or go read about it. Gold carries the purchase, deep
   forest carries the detour — above the title overlay so both stay clickable. */
.mlh-card-actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}
.mlh-card-add,
.mlh-card-view {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--mls-radius-btn);
  font-family: var(--mls-ui);
  font-size: .88rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background .25s var(--mls-ease), transform .2s var(--mls-ease);
}
.mlh-card-add > span,
.mlh-card-view > span { transform: translateY(1px); }   /* Arabic baseline sits high */
.mlh-card-add:active,
.mlh-card-view:active { transform: translateY(1px); }

.mlh-card-add {
  flex: 1 1 8rem;
  color: var(--mls-honey-ink) !important;
  background: var(--mls-honey);
  border: 1px solid var(--mls-honey);
}
.mlh-card-add:hover { background: var(--mls-honey-deep); border-color: var(--mls-honey-deep); }
.mlh-card-add .i { flex: 0 0 auto; width: 16px; height: 16px; }
.mlh-card-add[disabled] { opacity: .6; cursor: default; }

.mlh-card-view {
  flex: 1 1 7rem;
  color: var(--mls-on-forest) !important;
  background: var(--mls-forest);
  border: 1px solid var(--mls-forest);
}
.mlh-card-view:hover { background: var(--mls-forest-deep); border-color: var(--mls-forest-deep); }

.mlh-card-out {
  flex: 1 1 100%;
  padding: 12px 0;
  color: var(--mls-muted);
  font-size: .85rem;
  text-align: center;
}

/* ------------------------------------------------------------ filter rail */
/* Replaces the old left sidebar. Everything that used to be a stacked
   fieldset is now one horizontal rail of controls that sits above the grid,
   so the products get the full width of the page. */

.mls-shop { position: relative; background: var(--mls-paper); }
/* Glass needs something to refract; this is the ground the cards sit on. */
.mls-shop::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1100px 620px at 74% 2%, color-mix(in srgb, var(--mls-honey) 11%, transparent), transparent 72%),
    radial-gradient(900px 560px at 6% 88%, color-mix(in srgb, var(--mls-forest) 5%, transparent), transparent 74%);
}
.mls-shop > * { position: relative; z-index: 1; }

.mls-rail-wrap {
  position: sticky;
  top: 84px;
  z-index: 30;
  padding: 14px 0;
}
.mls-rail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(var(--mls-surface-rgb), .74);
  border: 1px solid rgba(var(--mls-surface-rgb), .85);
  border-radius: var(--mls-radius-card);
  box-shadow: var(--mls-shadow-card);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
}
.mls-count {
  margin: 0;
  padding-inline-end: 6px;
  color: var(--mls-muted);
  font-size: .85rem;
  white-space: nowrap;
}
.mls-count b { color: var(--mls-ink); font-family: var(--mls-num); font-size: 1rem; }
.mls-rail-spacer { flex: 1 1 auto; }

/* Each dropdown is a native <details>, so it opens with the keyboard for free. */
.mls-drop { position: relative; }
.mls-drop > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 15px;
  color: var(--mls-ink);
  background: rgba(var(--mls-surface-rgb), .7);
  border: 1px solid var(--mls-line);
  border-radius: var(--mls-radius-btn);
  font-size: .85rem;
  font-weight: 600;
  line-height: 1;
  list-style: none;
  cursor: pointer;
  transition: background .2s var(--mls-ease), border-color .2s var(--mls-ease);
}
.mls-drop > summary::-webkit-details-marker { display: none; }
.mls-drop > summary:hover { background: rgb(var(--mls-surface-rgb)); border-color: #c3cabf; }
.mls-drop > summary > span { transform: translateY(1px); }
.mls-drop > summary .i { width: 14px; height: 14px; transition: transform .2s var(--mls-ease); }
.mls-drop[open] > summary { background: rgb(var(--mls-surface-rgb)); border-color: var(--mls-forest); }
.mls-drop[open] > summary .i { transform: rotate(180deg); }
.mls-drop.is-on > summary { color: var(--mls-on-forest); background: var(--mls-forest); border-color: var(--mls-forest); }

.mls-pop {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  z-index: 5;
  width: max-content;
  min-width: 232px;
  max-width: min(340px, calc(100vw - 40px));
  padding: 14px;
  background: rgba(var(--mls-surface-rgb), .96);
  border: 1px solid var(--mls-line);
  border-radius: var(--mls-radius-panel);
  box-shadow: var(--mls-shadow-lift);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.mls-pop-title { margin: 0 0 10px; color: var(--mls-muted); font-size: .74rem; font-weight: 600; }

.mls-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 9px;
  font-size: .88rem;
  cursor: pointer;
}
.mls-opt:hover { background: var(--mls-panel); }
.mls-opt input { accent-color: var(--mls-forest); width: 16px; height: 16px; }
.mls-opt small { margin-inline-start: auto; color: var(--mls-muted); font-family: var(--mls-num); font-size: .78rem; }

/* Promo / new are single switches, so they are their own pill rather than
   hiding inside a menu. */
.mls-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 15px;
  color: var(--mls-ink);
  background: rgba(var(--mls-surface-rgb), .7);
  border: 1px solid var(--mls-line);
  border-radius: var(--mls-radius-btn);
  font-size: .85rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background .2s var(--mls-ease), color .2s var(--mls-ease), border-color .2s var(--mls-ease);
}
.mls-toggle span { transform: translateY(1px); }
.mls-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.mls-toggle:hover { border-color: #c3cabf; }
.mls-toggle:has(input:checked) {
  color: var(--mls-honey-ink);
  background: var(--mls-honey);
  border-color: var(--mls-honey);
}
.mls-toggle:has(input:focus-visible) { outline: 2px solid var(--mls-forest); outline-offset: 2px; }

/* Price keeps the two-handle range, just inside its own popover. */
.mls-price-out {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--mls-ink);
  font-family: var(--mls-num);
  font-size: .9rem;
  font-weight: 700;
}
.mls-range { position: relative; height: 30px; margin: 0 4px 12px; }
.mls-range::before {
  content: "";
  position: absolute;
  top: 13px;
  inset-inline: 0;
  height: 4px;
  background: var(--mls-line);
  border-radius: var(--mls-radius-btn);
}
.mls-range-fill {
  position: absolute;
  top: 13px;
  right: var(--from, 0%);
  left: calc(100% - var(--to, 100%));
  height: 4px;
  background: var(--mls-honey);
  border-radius: var(--mls-radius-btn);
}
html[dir="ltr"] .mls-range-fill { left: auto; right: auto; margin-inline-start: var(--from, 0%); width: calc(var(--to, 100%) - var(--from, 0%)); }
.mls-range input {
  position: absolute;
  inset-inline: 0;
  top: 0;
  width: 100%;
  height: 30px;
  margin: 0;
  background: none;
  border: 0;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
}
/* The storefront's global form styles give every input a solid background.
   Stacked over the track, that paints the track and the gold fill out of sight,
   so the range inputs and their track parts are forced see-through. */
.mls-range input {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  outline-offset: 4px;
}
.mls-range input::-webkit-slider-runnable-track { background: transparent; border: 0; box-shadow: none; }
.mls-range input::-moz-range-track { background: transparent; border: 0; box-shadow: none; }
.mls-range input::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  background: rgb(var(--mls-surface-rgb));
  border: 2px solid var(--mls-forest);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  appearance: none;
  -webkit-appearance: none;
}
.mls-range input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: rgb(var(--mls-surface-rgb));
  border: 2px solid var(--mls-forest);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
}

.mls-apply {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  color: var(--mls-honey-ink) !important;
  background: var(--mls-honey);
  border: 1px solid var(--mls-honey);
  border-radius: var(--mls-radius-btn);
  font-family: var(--mls-ui);
  font-size: .85rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.mls-apply span { transform: translateY(1px); }
.mls-apply:hover { background: var(--mls-honey-deep); }

/* Sort sits at the far end — it orders results, it does not filter them. */
.mls-sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 6px 0 15px;
  background: rgba(var(--mls-surface-rgb), .7);
  border: 1px solid var(--mls-line);
  border-radius: var(--mls-radius-btn);
  font-size: .85rem;
}
.mls-sort span { color: var(--mls-muted); font-weight: 600; }
.mls-sort select {
  min-height: 38px;
  padding: 0 8px;
  color: var(--mls-ink);
  background: none;
  border: 0;
  font-family: var(--mls-ui);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}

/* What is actually on, spelled out and individually removable. */
.mls-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.mls-active-label { color: var(--mls-muted); font-size: .8rem; }
.mls-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  color: var(--mls-forest-deep);
  background: rgba(var(--mls-surface-rgb), .8);
  border: 1px solid var(--mls-line);
  border-radius: var(--mls-radius-btn);
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
}
.mls-chip:hover { background: rgb(var(--mls-surface-rgb)); border-color: #c3cabf; }
.mls-chip i { font-size: 1rem; font-style: normal; line-height: 1; }
.mls-chip-clear { color: var(--mls-danger); }

.mls-results { padding-bottom: clamp(56px, 7vw, 92px); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1200px) { .mlh-grid-fluid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

@media (max-width: 1100px) {
  .mlh-grid[data-count="4"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 880px) {
  .mlh-grid[data-count="3"],
  .mlh-grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: none; }
  .mlh-grid-fluid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  /* The rail scrolls sideways instead of stacking into a wall of controls. */
  .mls-rail-wrap { top: 70px; }
  .mls-rail {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    border-radius: var(--mls-radius-panel);
  }
  .mls-rail::-webkit-scrollbar { display: none; }
  .mls-rail > * { flex: 0 0 auto; }
  .mls-rail-spacer { display: none; }
  /* backdrop-filter makes an element the containing block for fixed children,
     which would trap the popover inside the scrolling rail — so the phone rail
     trades blur for opacity, and the popover docks above the bottom tab bar. */
  .mls-rail { background: rgba(var(--mls-surface-rgb), .94); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .mls-pop {
    position: fixed;
    inset-inline: 12px;
    top: auto;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    z-index: 80;
    width: auto;
    max-width: none;
    max-height: 60vh;
    overflow-y: auto;
    box-shadow: var(--mls-shadow-lift);
  }
}

@media (max-width: 640px) {
  .mlh-grid { gap: 12px; }
  .mlh-card { padding: 8px; }
  .mlh-card-body { gap: 4px; padding: 12px 4px 4px; }
  html[dir] .mlh-card-body h3 { font-size: .93rem; }
  .mlh-card-price strong { font-size: 1rem; }
  /* Two-up cards are narrow: the label needs the room the icon was taking. */
  .mlh-card-actions { gap: 6px; }
  .mlh-card-add,
  .mlh-card-view { flex-basis: 100%; padding: 0 10px; font-size: .82rem; }
  .mlh-card-add .i { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mlh-card,
  .mlh-card-visual img,
  .mlh-card-add,
  .mlh-card-view,
  .mls-drop > summary .i { transition: none; }
}
