/* ================================================
   CAMO MATRIX IG-STYLE LAYOUT
   Optimized & cleaned for clarity and performance
   ================================================ */

/* ================================================
   MODAL (ENHANCED STRUCTURE FOR IG-STYLE)
   ================================================ */
/* ============================================================
   FILTER STRIP (Pattern Count + Filter Buttons)
   ============================================================ */
.filter-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem auto 1.5rem;
  padding: 0.75rem 1rem;
  background: #111;
  border: 1px solid #222;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  color: #ddd;
  max-width: 1100px;
}

.filter-heading {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.filter-buttons {
  display: flex;
  gap: 0.5rem;
}

.filter-btn {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #ddd;
  background: #1b1b1b;
  border: 1px solid #333;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background: #2b2b2b;
  color: #fff;
  border-color: #444;
}

.filter-btn.active {
  background: #006400;
  color: #fff;
  border-color: #009900;
  font-weight: 600;
}

@media (max-width: 600px) {
  .filter-strip {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    text-align: left;
  }

  .filter-buttons {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .filter-btn {
    flex: 1;
    text-align: center;
  }
}

/* ----- Base Modal Layer ----- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal, .sale-promo-overlay, .modal-bg-layer img, .modal-pattern-layer img {
  will-change: opacity, transform;
}
body.modal-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}
.modal:not(.hidden) {
  visibility: visible;
  opacity: 1;
  pointer-events: all;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(3px);
  z-index: 1;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .modal-content, .sale-promo-box {
    background: #111;
    color: #fff;
  }
}

/* ----- Modal Box ----- */
.modal-content {
  position: relative;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 95%;
  max-width: 480px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
  color: #fff;
  font-family: 'Roboto', sans-serif;
}

/* ----- Close Button ----- */
.modal-close,
.close-sale-promo {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 1.6rem;
  color: #fff;
  background: rgba(0,0,0,0.4);
  border: none;
  cursor: pointer;
  z-index: 3;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  line-height: 30px;
  text-align: center;
  transition: background 0.2s ease;
  touch-action: manipulation;
}
.modal-close:hover,
.close-sale-promo:hover {
  background: rgba(255,255,255,0.2);
}

/* ----- Visual Area (Pattern + Background) ----- */
.modal-visual-area {
  position: relative;
  height: 280px;
  background: #000;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}
.modal-bg-layer img,
.modal-pattern-layer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.modal-bg-layer { z-index: 1; }
.modal-pattern-layer {
  z-index: 2;
  pointer-events: none;
}
.modal-bg-layer,
.modal-pattern-layer {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ----- Loader Spinner ----- */
.modal-loader {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.3);
  z-index: 5;
}
.modal-loader.hidden { display: none; }
.modal-loader .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top: 4px solid #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ----- Background Controls ----- */
#modalBgImg {
  transition: opacity 0.4s ease;
}
#modalBgImg.fading { opacity: 0; }

.modal-bg-controls {
  position: absolute;
  bottom: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  z-index: 4;
}
.modal-bg-controls button {
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
.modal-bg-controls button:hover {
  background: rgba(255,255,255,0.2);
}
.bg-label {
  font-size: 0.9rem;
  color: #fff;
  text-shadow: 0 0 4px #000;
}

/* ----- Modal Info Section ----- */
.modal-info {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #1a1a1a;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  text-align: center;
}
.modal-sale {
  color: #ff6464;
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

/* ----- Buttons ----- */
.modal-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0.8rem;
}
.modal-btn {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  background: #333;
  color: #fff;
  transition: background 0.2s ease;
}
.modal-btn:hover { background: #555; }
.sale-btn { background: #c00; }
.sale-btn:hover { background: #e22; }

/* ----- Toggles ----- */
.modal-toggles {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}
.toggle-btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  border: none;
  border-radius: 6px;
  background: #444;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-btn:hover { background: #666; }

/* ----- Promo Banner ----- */
.modal-promo {
  width: 100%;
  text-align: center;
  margin-top: 0.8rem;
}
.modal-promo img {
  width: 100%;
  border-radius: 8px;
  max-height: 120px;
  object-fit: cover;
  transition: opacity 0.3s ease;
}
.modal-promo.hidden { display: none; }

/* ----- Mobile Responsiveness ----- */
@media (max-width: 480px) {
  .modal-content {
    width: 92%;
    max-width: 360px;
    border-radius: 10px;
  }
  .modal-visual-area { height: 220px; }
  .modal-actions .modal-btn {
    font-size: 0.75rem;
    padding: 5px 10px;
  }
  .modal-bg-controls button {
    font-size: 1rem;
    padding: 4px 8px;
  }
  .bg-label { font-size: 0.8rem; }
}

/* ================================================
   GRID + CARD SYSTEM
   ================================================ */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  justify-content: center;
  max-width: 900px;
  margin: 0 auto;
}

.pattern-card {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.pattern-card:hover { transform: scale(1.03); }
.pattern-card img {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}

/* ---------- BRAND OVERLAY ---------- */
.pattern-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 6px 8px;
  border-radius: 0 0 8px 8px;
  opacity: 0.95;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.75) 0%,
    rgba(0, 0, 0, 0.35) 60%,
    rgba(0, 0, 0, 0.0) 100%
  );
  transition: opacity 0.25s ease-in-out;
}
.pattern-card:hover .pattern-overlay { opacity: 1; }

.overlay-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  margin-bottom: 4px;
}
.overlay-text {
  font-size: 0.7rem;
  color: #fff;
  font-weight: 600;
  text-shadow: 0 0 3px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.overlay-text-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: 4px;
  line-height: 1.2;
}
.overlay-pattern { font-weight: 600; font-size: 0.9em; color: #fff; }
.overlay-brand { font-size: 0.8em; color: #ccc; opacity: 0.9; }

/* ---------- BADGES ---------- */
.sale-badge, .promo-badge {
  position: absolute;
  top: 6px;
  font-size: 0.65rem;
  color: #fff;
  padding: 3px 5px;
  border-radius: 3px;
  text-align: center;
  line-height: 1.1;
}
.sale-badge { right: 6px; background: rgba(220, 20, 60, 0.85); }
.sale-badge.dual {
  background: linear-gradient(90deg, #c00 0%, #0077cc 100%);
}
.promo-badge {
  left: 6px;
  background-color: #0077cc;
  font-weight: bold;
  text-transform: uppercase;
}

/* ---------- TIER RIBBONS ---------- */
.tier-ribbon {
  position: absolute;
  top: 10px;
  left: -30px;
  width: 120px;
  text-align: center;
  font-size: 0.65rem;
  font-weight: bold;
  color: #fff;
  padding: 3px 0;
  transform: rotate(-45deg);
  transform-origin: left top;
  z-index: 2;
  text-shadow: 0 0 2px rgba(0,0,0,0.5);
}
.tier-ribbon.sponsored {
  background: linear-gradient(90deg, #c00, #ff4444);
}
.tier-ribbon.featured {
  background: linear-gradient(90deg, #f7b500, #ffdf80);
  color: #222;
}

/* ---------- TITLES ---------- */
.tier-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #ccc;
  margin: 16px 0 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* ---------- BRAND + BANNER CARDS ---------- */
.card--brand {
  background: #000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 8px;
}
.card--brand img.brand-logo {
  width: 80%;
  max-width: 120px;
  margin-bottom: 6px;
}
.card--banner {
  overflow: hidden;
  background: #111;
}
.card--banner img {
  border-radius: 8px;
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* Banner spans */
.pattern-grid > .card--banner.double-span {
  grid-column: span 2;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}
.card--banner.double-span .banner-inner {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.card--banner.double-span .responsive-banner {
  max-width: none !important;
  width: 100% !important;
}
.card--banner.double-span img {
  width: 100% !important;
  height: auto !important;
  border-radius: 8px;
  object-fit: cover;
}

/* ---------- SALE / PROMO OVERLAY ---------- */
.sale-promo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(2px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.sale-promo-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.sale-promo-box {
  background: #222;
  border-radius: 10px;
  padding: 1.2rem;
  max-width: 340px;
  width: 90%;
  color: #fff;
  text-align: center;
  box-shadow: 0 0 20px rgba(0,0,0,0.6);
}
.sale-promo-box h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}
.sale-promo-box p {
  font-size: 0.9rem;
  color: #ccc;
  margin-bottom: 1rem;
}
.sale-promo-box .shop-now {
  background: #c00;
}
.promo-code-box {
  margin-top: 0.8rem;
  background: #333;
  border-radius: 6px;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 0.9rem;
}
.promo-code-box span {
  font-weight: bold;
  color: #ffda6a;
}
.copy-code {
  background: #555;
  border: none;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}
.copy-code:hover { background: #777; }
.valid-thru {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #aaa;
  font-style: italic;
}

/* ---------- GLOBAL UTILITIES ---------- */
img {
  image-rendering: auto;
  backface-visibility: hidden;
}
.hidden,
.modal-btn.hidden,
.sale-btn.hidden,
.promo-btn.hidden,
.modal-promo.hidden {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}
.sale-promo-overlay.hidden {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
}
.modal.hidden {
  display: flex !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ---------- RESPONSIVE ADJUSTMENTS ---------- */
@media (max-width: 768px) {
  .pattern-grid { grid-template-columns: repeat(6, 1fr); }
  .pattern-grid > .card--banner.double-span { grid-column: span 3 !important; }
}
@media (max-width: 480px) {
  .pattern-grid { grid-template-columns: repeat(4, 1fr); }
  .pattern-grid > .card--banner.double-span { grid-column: span 2 !important; }

  .tier-ribbon {
    font-size: 0.45rem;
    padding: 3px 8px;
    left: -10px;
  }
  .sale-badge, .promo-badge {
    font-size: 0.55rem;
    padding: 2px 4px;
    border-radius: 2px;
  }
  .overlay-logo { width: 22px; height: 22px; }
  .overlay-text { font-size: 0.6rem; }
}
