/* ============================================================
   ARAFA CNC — SPARE PARTS LISTING
   01 — Page layout / header
   02 — Desktop category filter
   03 — Product grid and cards
   04 — Empty state / helpers
   05 — Tablet
   06 — Mobile filter drawer / cards
   07 — Reduced motion
   Clean, single-source styles; no prices or cart actions on cards.
============================================================ */

/* ============================================================
   SECTION 01 — PAGE LAYOUT AND HEADING
============================================================ */
.listing-section {
  background: #fff;
  min-width: 0;
}
.listing-section .listing-shell {
  display: grid;
  grid-template-columns: minmax(255px, 290px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.listing-content { min-width: 0; }
.listing-intro {
  padding: 0;
  margin: 0 0 18px;
  background: transparent;
  border: 0;
  text-align: start;
}
.listing-kicker {
  color: var(--primary, #ff5a12);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
}
.listing-intro h1 {
  margin: 4px 0 8px;
  color: #082339;
  font-size: clamp(27px, 2.6vw, 36px);
  line-height: 1.4;
}
.listing-intro p {
  margin: 0;
  color: #738398;
  font-size: 14px;
  line-height: 1.8;
}
.listing-toolbar {
  display: flex;
  align-items: center;
  margin: 0 0 22px;
  gap: 12px;
}
.listing-toolbar strong { color: #082339; font-size: 18px; }
.listing-toolbar strong b { color: var(--primary, #ff5a12); font-size: 21px; }
.active-filter-note {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: #fff7f2;
  border-inline-start: 3px solid #ff5a12;
  color: #617080;
  font-size: 13px;
}
.active-filter-note[hidden] { display: none !important; }

/* ============================================================
   SECTION 02 — CATEGORY FILTER (DESKTOP)
============================================================ */
.filter-panel {
  display: block;
  position: sticky;
  top: 100px;
  min-width: 0;
  background: #fff;
  border: 1px solid #e3eaf0;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(6,27,43,.07);
  overflow: hidden;
}
.filter-panel__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 74px;
  padding: 15px 20px;
  color: #fff;
  background: #061e2d;
}
.filter-panel__head > i { color: #ff5a12; font-size: 18px; }
.filter-panel__head h2 {
  color: #fff;
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.5;
}
.filter-group { margin: 0; border-bottom: 1px solid #e8edf2; }
.filter-group:last-child { border-bottom: 0; }
.filter-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 59px;
  padding: 14px 18px;
  list-style: none;
  cursor: pointer;
  color: #082339;
  background: #fff;
  font-size: 17px;
  font-weight: 800;
  user-select: none;
}
.filter-group > summary::-webkit-details-marker { display: none; }
.filter-group > summary::marker { content: ''; }
.filter-group[open] > summary { background: #fff8f3; }
.filter-group[open] > summary .filter-group__label { color: #f45b13; }
.filter-group > summary > i { font-size: 13px; transition: transform .2s; }
.filter-group[open] > summary > i { transform: rotate(180deg); }
.filter-group > summary:focus-visible { outline: 2px solid #ff5a12; outline-offset: -3px; }
.filter-group__children {
  display: grid;
  padding: 0 14px 13px;
  background: #fff;
}
.filter-group:not([open]) > .filter-group__children { display: none !important; }
.filter-group__children > a,
.filter-group__children > .filter-category > a {
  display: block;
  width: 100%;
  min-height: 43px;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid #eef1f5;
  border-radius: 5px;
  color: #152b3d;
  background: transparent;
  text-align: start;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.5;
}
.filter-group__children .filter-category { min-width: 0; }
.filter-group__children > :last-child,
.filter-group__children > .filter-category:last-child > a { border-bottom: 0; }
.filter-group__children a:hover,
.filter-group__children a.is-active,
.filter-group__children a[aria-current="page"] {
  color: #f45b13;
  background: #fff3ed;
}

/* ============================================================
   SECTION 03 — PRODUCT GRID: ONLY IMAGE + TITLE
============================================================ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.listing-card {
  display: block;
  position: relative;
  min-width: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e9ef;
  border-radius: 15px;
  box-shadow: 0 6px 22px rgba(8,38,57,.045);
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.listing-card:hover,
.listing-card:focus-within {
  border-color: var(--primary, #ff5a12);
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(8,38,57,.11);
}
.listing-card[hidden] { display: none !important; }
.listing-card__main {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  color: inherit;
  text-decoration: none;
}
.listing-card__main:focus-visible {
  outline: 3px solid #ff5a12;
  outline-offset: -4px;
}
/* Fill the top of the card with the photo, without the former inset frame. */
.listing-card__media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1.22 / 1;
  margin: 0;
  overflow: hidden;
  border-radius: 0;
  background: #fff;
}
/* The original JPGs contain tiny "image38"-style captions near the bottom.
   Cropping the bottom edge helps hide those embedded captions, without
   changing the underlying files or adding separate overlaid text. */
.listing-card__media > img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center top;
  transition: transform .35s ease;
}
/* A subtle white fade hides captions printed along the bottom of some
   legacy source images. The true fix is exporting clean product JPGs. */
.listing-card__media::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  height: 13%;
  background: linear-gradient(to top, #fff 22%, rgba(255,255,255,0));
  pointer-events: none;
}
.listing-card:hover .listing-card__media > img { transform: scale(1.025); }
.listing-card__media .smart-media__placeholder { display: none; }
.listing-card__media.is-missing .smart-media__placeholder,
.listing-card__media img[hidden] ~ .smart-media__placeholder {
  display: grid;
  place-items: center;
  position: absolute;
  inset: 0;
  background: #f4f7f9;
  color: #8290a0;
}
.listing-card__media .smart-media__placeholder small { display: none; }
.listing-card__body {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 72px;
  padding: 14px 12px 16px;
  margin: 0;
  background: #fff;
  text-align: center;
}
.listing-card__body h3 {
  margin: 0;
  color: #082339;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.65;
}
.listing-card:hover .listing-card__body h3 { color: var(--primary, #ff5a12); }

/* ============================================================
   SECTION 04 — EMPTY STATE AND ACCESSIBILITY
============================================================ */
.empty-results { padding: 65px 20px; text-align: center; color: #7b8997; }
.empty-results[hidden] { display: none !important; }
.empty-results i { color: #ff5a12; font-size: 42px; }
.mobile-filter-trigger, .filter-panel__close { display: none; }
.filter-drawer-overlay[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ============================================================
   SECTION 05 — TABLET / SMALL DESKTOP
============================================================ */
@media (min-width: 1550px) {
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1050px) {
  .listing-section .listing-shell { grid-template-columns: minmax(220px,260px) minmax(0,1fr); gap: 18px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
}

/* ============================================================
   SECTION 06 — MOBILE: ONE CARD PER ROW + SLIDE-IN FILTER
============================================================ */
@media (max-width: 760px) {
  .listing-section .listing-shell { display: block; min-width: 0; }
  .listing-content { width: 100%; min-width: 0; }
  .listing-intro { margin-bottom: 15px; }
  .listing-intro h1 { font-size: 30px; }
  .listing-intro p { font-size: 13px; }
  .listing-toolbar { margin-bottom: 17px; }
  .listing-toolbar strong { font-size: 16px; }
  .product-grid { grid-template-columns: minmax(0,1fr); gap: 17px; }
  .listing-card__media { aspect-ratio: 1.27 / 1; }
  .listing-card__body { min-height: 64px; padding: 12px; }
  .listing-card__body h3 { font-size: 17px; }

  .mobile-filter-trigger {
    position: fixed;
    top: 52%;
    right: 0;
    z-index: 2147483001;
    display: grid;
    place-items: center;
    width: 47px;
    height: 55px;
    padding: 0;
    transform: translateY(-50%);
    color: #fff;
    background: #ff5a12;
    border: 0;
    border-radius: 12px 0 0 12px;
    box-shadow: 0 8px 20px rgba(6,30,45,.2);
    font-size: 20px;
    cursor: pointer;
  }
  body.filter-drawer-open .mobile-filter-trigger { visibility: hidden; }
  .mobile-filter-trigger:focus-visible,
  .filter-panel__close:focus-visible { outline: 3px solid #ff5a12; outline-offset: 2px; }
  .filter-drawer-overlay:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 2147483002;
    background: rgba(4,19,32,.59);
    cursor: pointer;
  }
  /* The existing JS moves this same panel to <body> on mobile. */
  .filter-panel,
  body > .filter-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 2147483003;
    display: block;
    width: min(365px, 90vw);
    max-width: 100%;
    height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: -12px 0 32px rgba(4,19,32,.25);
    visibility: hidden;
    pointer-events: none;
    transform: translateX(105%);
    transition: transform .25s ease, visibility .25s ease;
  }
  body.filter-drawer-open .filter-panel,
  body.filter-drawer-open > .filter-panel {
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }
  .filter-panel__head {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 75px;
    padding: 14px 16px;
  }
  .filter-panel__close {
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    margin-inline-start: auto;
    padding: 0;
    color: #061e2d;
    background: #fff;
    border: 1px solid rgba(255,255,255,.5);
    border-radius: 8px;
    font-family: Arial, sans-serif;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
  }
}

/* ============================================================
   SECTION 07 — REDUCED MOTION
============================================================ */
@media (prefers-reduced-motion: reduce) {
  .listing-card,
  .listing-card__media img,
  .filter-panel,
  .filter-group > summary > i { transition: none !important; }
}
