/* ============================================================
   QDP Brands Mega-Menu Popup
   ============================================================ */

/* ---- Prevent body scroll when popup is open ---- */
body.qdp-popup-open {
  overflow: hidden;
}

/* ---- Backdrop ---- */
.qdp-brands-popup__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99998;
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* ---- Popup wrapper (hidden state) ---- */
.qdp-brands-popup {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  /* align-items: flex-start; */
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.qdp-brands-popup[hidden] {
  display: none;
}

/* ---- Visible state (JS adds .is-open) ---- */
.qdp-brands-popup.is-open {
  pointer-events: auto;
}

.qdp-brands-popup.is-open .qdp-brands-popup__backdrop {
  opacity: 1;
}

.qdp-brands-popup.is-open .qdp-brands-popup__panel {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Panel (fixed height so category switches don’t resize the modal) ---- */
.qdp-brands-popup__panel {
  position: relative;
  z-index: 100000;
  background: #ffffff;
  width: 100%;
  max-width: 1100px;
  height: min(780px, 85vh);
  max-height: 90vh;
  position: fixed;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-16px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  border-radius: 8px;
  border: 1px solid #2d2d2d;
}

/* ---- Close button ---- */
.qdp-brands-popup__close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  color: #555;
  padding: 4px 8px;
  z-index: 1;
  transition: color 0.15s;
}

.qdp-brands-popup__close:hover,
.qdp-brands-popup__close:focus {
  color: #000;
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* ---- Inner layout: sidebar + brand area ---- */
.qdp-brands-popup__inner {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* ---- Category sidebar ---- */
.qdp-brands-popup__cats {
  flex: 0 0 230px;
  background: #f5f5f5;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  padding: 32px 0 24px;
}

.qdp-brands-popup__cats ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.qdp-brands-popup__cats li {
  margin: 0;
  padding: 0;
}

.qdp-brands-popup__cat-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 13px 24px;
  font-size: 14px;
  font-weight: 500;
  color: #444;
  letter-spacing: 0.02em;
  border-radius: 0 !important;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.qdp-brands-popup__cat-btn:hover {
  background: #d9d9d9;
  color: #111;
  /* border-left: 3px solid #c8a96e; */
}

.qdp-brands-popup__cat-btn.is-active {
  background: #d9d9d9;
  color: #111;
  font-weight: 700;
  /* border-left: 3px solid #c8a96e; */
}

/* ---- Brand grid area ---- */
.qdp-brands-popup__brands-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 32px 36px 36px;
}

/* Each category's brand grid — hidden by default */
.qdp-brands-popup__brand-group {
  display: none;
}

.qdp-brands-popup__brand-group.is-active {
  display: block;
}

.qdp-brands-popup__empty {
  color: #888;
  font-style: italic;
  margin: 0;
}

/* ---- Brand grid ---- */
.qdp-brands-popup__brand-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

.qdp-brands-popup__brand-item {
  margin: 0;
  min-width: 0;
}

/* ---- Brand card: square above, name below ---- */
.qdp-brands-popup__brand-link {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  text-decoration: none;
  color: #333;
  gap: 12px;
  transition: transform 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.qdp-brands-popup__brand-link:hover,
.qdp-brands-popup__brand-link:focus {
  outline: none;
}

.qdp-brands-popup__brand-link:hover .qdp-brands-popup__brand-static,
.qdp-brands-popup__brand-link:focus-visible .qdp-brands-popup__brand-static,
.qdp-brands-popup__brand-link:hover .qdp-brands-popup__brand-flip-inner,
.qdp-brands-popup__brand-link:focus-visible .qdp-brands-popup__brand-flip-inner {
  border-color: #c8a96e;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.qdp-brands-popup__brand-link:hover,
.qdp-brands-popup__brand-link:focus-visible {
  transform: translateY(-2px);
}

/* ---- Static square (single image) ---- */
.qdp-brands-popup__brand-static {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
  padding: 14px;
  box-sizing: border-box;
  border: 1px solid #e8e8e8;
  border-radius: 14px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.qdp-brands-popup__brand-static img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* ---- Flip square: featured img fades to reveal hover image as full-bleed background ---- */
.qdp-brands-popup__brand-flip {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
}

.qdp-brands-popup__brand-flip-inner {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 1px solid #e8e8e8;
  border-radius: 14px;
  background-color: #fff;
  background-image: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-sizing: border-box;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.qdp-brands-popup__brand-link--flip:hover .qdp-brands-popup__brand-flip-inner,
.qdp-brands-popup__brand-link--flip:focus-visible .qdp-brands-popup__brand-flip-inner {
  background-image: var(--qdp-brand-hover-bg);
}

.qdp-brands-popup__brand-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  box-sizing: border-box;
  border-radius: 13px;
  transition: opacity 0.45s ease;
}

.qdp-brands-popup__brand-face--front {
  z-index: 1;
  opacity: 1;
}

.qdp-brands-popup__brand-link--flip:hover .qdp-brands-popup__brand-face--front,
.qdp-brands-popup__brand-link--flip:focus-visible .qdp-brands-popup__brand-face--front {
  opacity: 0;
}

.qdp-brands-popup__brand-face img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
  .qdp-brands-popup__brand-face {
    transition: opacity 0.15s ease;
  }
}

/* ---- Brand name (below square) ---- */
.qdp-brands-popup__brand-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  line-height: 1.35;
  letter-spacing: 0.01em;
  padding: 0 2px;
}

/* ============================================================
   Responsive
   ============================================================ */

/* Tablet */
@media (max-width: 900px) {
  .qdp-brands-popup__panel {
    max-width: 100%;
    margin-top: 60px;
    border-radius: 0;
    height: min(720px, calc(100vh - 60px));
    max-height: calc(100vh - 60px);
  }

  .qdp-brands-popup__cats {
    flex: 0 0 180px;
  }

  .qdp-brands-popup__brands-wrap {
    padding: 24px 20px 28px;
  }

  .qdp-brands-popup__brand-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
  }
}

/* Mobile — stack sidebar on top */
@media (max-width: 600px) {
  .qdp-brands-popup__panel {
    margin-top: 0;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .qdp-brands-popup__inner {
    flex-direction: column;
  }

  .qdp-brands-popup__cats {
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
    padding: 12px 0;
    overflow-x: auto;
    overflow-y: visible;
    white-space: nowrap;
  }

  .qdp-brands-popup__cats ul {
    display: inline-flex;
    flex-wrap: nowrap;
  }

  .qdp-brands-popup__cat-btn {
    padding: 10px 18px;
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    font-size: 13px;
  }

  .qdp-brands-popup__cat-btn.is-active {
    background: none;
    border-bottom-color: #c8a96e;
  }

  .qdp-brands-popup__brands-wrap {
    padding: 20px 16px 24px;
    overflow-y: auto;
    flex: 1;
  }

  .qdp-brands-popup__brand-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
  }
}
