/* Modern Products Page Specific Styles */

html {
  scroll-behavior: smooth;
}

/* Updated page header with geometric pattern on dark background */
.page-header-products {
  background: #0a0a0a;
  padding: 100px 0 60px;
  text-align: center;
  border-bottom: 3px solid #dc2626;
  position: relative;
  overflow: hidden;
}

.page-header-products::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: linear-gradient(30deg, #1a1a1a 12%, transparent 12.5%, transparent 87%, #1a1a1a 87.5%, #1a1a1a),
    linear-gradient(150deg, #1a1a1a 12%, transparent 12.5%, transparent 87%, #1a1a1a 87.5%, #1a1a1a),
    linear-gradient(30deg, #1a1a1a 12%, transparent 12.5%, transparent 87%, #1a1a1a 87.5%, #1a1a1a),
    linear-gradient(150deg, #1a1a1a 12%, transparent 12.5%, transparent 87%, #1a1a1a 87.5%, #1a1a1a),
    linear-gradient(60deg, #252525 25%, transparent 25.5%, transparent 75%, #252525 75%, #252525),
    linear-gradient(60deg, #252525 25%, transparent 25.5%, transparent 75%, #252525 75%, #252525);
  background-size: 80px 140px;
  background-position: 0 0, 0 0, 40px 70px, 40px 70px, 0 0, 40px 70px;
  opacity: 0.4;
  pointer-events: none;
}

.page-header-products::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 50% 50%, rgba(220, 38, 38, 0.1) 0%, transparent 60%);
  pointer-events: none;
}

.page-header-products h1 {
  font-size: 3rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  position: relative;
  z-index: 1;
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
}

.header-underline {
  width: 100px;
  height: 4px;
  background: #dc2626;
  margin: 0 auto 1rem;
  border-radius: 2px;
  position: relative;
  z-index: 1;
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.6);
}

.page-header-products p {
  font-size: 1.125rem;
  color: #e0e0e0;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

/* New fancy category showcase section */
.products-section-modern {
  padding: 80px 0;
  background: linear-gradient(180deg, #f9f9f9 0%, #ffffff 100%);
}

.category-showcase {
  margin-bottom: 4rem;
}

/* Equal desktop columns share the product grid's full width. */
.category-nav-modern {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 3rem;
  align-items: stretch;
}

.category-card-modern {
  box-sizing: border-box;
  min-width: 0;
  min-height: 90px;                 /* was 70px */
  background: #ffffff;
  border: 2px solid #e5e5e5;
  border-radius: 12px;
  padding: 8px 4px;                 /* was 10px 4px */
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
  text-align: center;
  display: flex;                    /* was grid */
  flex-direction: column;           /* new */
  justify-content: center;          /* new: vertical centring */
  align-items: center;              /* horizontal centring */
  gap: 2px;                         /* new */
}

.category-card-modern::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(220, 38, 38, 0.05), transparent);
  transition: left 0.6s ease;
  pointer-events: none;
}

.category-card-modern:hover::before {
  left: 100%;
}

.category-card-modern:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
  border-color: var(--category-color, #dc2626);
}

.category-card-modern.active {
  background: var(--category-color, #dc2626);
  border-color: var(--category-color, #dc2626);
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.category-icon {
  font-size: 1.25rem;
  line-height: 1.5;
  margin: 0;
  transition: transform 0.3s ease;
  color: #000000;
}

.category-card-modern.active .category-icon {
  color: #ffffff;
}

.category-card-modern:hover .category-icon,
.category-card-modern.active .category-icon {
  transform: scale(1.15) rotate(5deg);
}

.category-card-modern h3 {
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 20px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: #000000;
  transition: color 0.3s ease;
  margin: 0;
  white-space: nowrap;
}

.category-card-modern.active h3 {
  color: #ffffff;
}

.category-card-modern p {
  font-size: 0.75rem;
  line-height: 16px;
  color: #4b4b4b;
  font-weight: 500;
  transition: color 0.3s ease;
  margin: 0;
}

.category-card-modern.active p {
  color: rgba(255, 255, 255, 0.9);
}

.category-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--category-color, #dc2626);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.category-card-modern.active .category-indicator {
  transform: scaleX(1);
}

/* Preserve the legacy four/three/two/one-column product breakpoints. */
.products-grid-modern {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2rem;
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.product-card-modern {
  min-width: 0;
  background: #3b3b3b25;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  transition: opacity 0.35s ease, transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
  border: 2px solid transparent;
  display: none;
  flex-direction: column;
  cursor: pointer;
}

.product-card-modern.show {
  display: flex;
}

.product-card-modern.show:not(.scroll-visible) {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.product-card-modern.show.scroll-visible {
  opacity: 1;
  transform: translateY(0);
}

.product-card-modern.show.scroll-visible:hover {
  transform: translateY(-5px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
  border-color: #dc2626;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .product-card-modern {
    transition: none;
  }

  .product-card-modern.show:not(.scroll-visible) {
    transform: none;
  }
}

/* Transparent product artwork stays fully visible on square neutral stages. */
.product-image-modern {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  background: #E4E8ED;
  overflow: hidden;
}

.product-image-modern img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transition: opacity 0.2s ease;
}

.product-overlay,
.quick-view-btn-modern {
  display: none;
}

.product-info-modern {
  padding: 1.1rem;
  min-height: 5.35rem;
  text-align: center;
  background: #ffffff;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-info-modern h3 {
  font-size: 1.125rem;
  margin: 0;
  color: #000000;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.product-subtitle {
  font-size: 0.875rem;
  color: #dc2626;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* One scrolling surface with a sticky close control. Scoped rules win over
   the shared legacy modal styles without changing any other page. */
#productModal {
  display: none;
  position: fixed;
  z-index: 2500;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 16px;
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0.7);
  animation: fadeIn 0.3s ease;
}

#productModal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

#productModal .modal-content {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 760px;
  height: auto;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  position: relative;
  animation: slideUp 0.3s ease;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

#productModal .modal-close {
  position: sticky;
  top: 12px;
  right: auto;
  /* Keep the sticky close button without reserving an extra header row. */
  margin: 12px 12px -56px auto;
  background: #dc2626;
  color: #ffffff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background-color 0.3s ease;
}

#productModal .modal-close:hover {
  background: #991b1b;
  transform: none;
}

#productModal .modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 1.25rem;
  padding: 1.25rem;
  overflow: visible;
  align-items: center;
  min-height: 0;
}

#productModal .modal-image {
  width: 100%;
  height: auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #E4E8ED;
}

#productModal .modal-image-square {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0.75rem;
  box-sizing: border-box;
  background: #E4E8ED;
  border-radius: 8px;
  overflow: hidden;
}

#productModal .modal-image-square img {
  position: absolute;
  inset: 0.75rem;
  width: calc(100% - 1.5rem);
  height: calc(100% - 1.5rem);
  object-fit: contain;
  object-position: center;
  display: block;
}

#productModal .slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.55);
  border: none;
  border-radius: 50%;
  color: #ffffff;
  font-size: 1.1rem;
  cursor: pointer;
  width: 40px;
  height: 40px;
  padding: 6px;
  z-index: 5;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#productModal .slider-btn:hover { background: #dc2626; }
#productModal .prev-btn { left: 8px; }
#productModal .next-btn { right: 8px; }

#productModal .modal-details {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: visible;
  max-height: none;
  padding: 0;
  align-self: center;
  overflow-wrap: anywhere;
}

#productModal .product-category {
  display: inline-block;
  color: #dc2626;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

#productModal .modal-details h2 {
  font-size: 1.5rem;
  color: #000000;
  font-weight: 800;
  margin: 0;
  line-height: 1.2;
}

#productModal .modal-details p {
  font-size: 0.9rem;
  color: #4b4b4b;
  line-height: 1.5;
  margin: 0;
}

#productModal .product-features {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

#productModal .product-features li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #e5e5e5;
  color: #2b2b2b;
  font-size: 0.875rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

#productModal .product-features li::before {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: #dc2626;
  font-size: 0.875rem;
  flex-shrink: 0;
}

#productModal .product-features li:last-child { border-bottom: none; }

#productModal .filled-image-toggle {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 6;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.92);
  color: #ffffff;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  transition: background-color 0.2s ease, transform 0.2s ease;
}

#productModal .filled-image-toggle:hover {
  background: #b91c1c;
  transform: translateY(-1px);
}

#productModal .filled-image-toggle:focus-visible {
  outline: 3px solid #991b1b;
  outline-offset: 3px;
}

#productModal .filled-image-status {
  min-height: 1.25rem;
  color: #991b1b;
  font-size: 0.8rem;
}

.category-card-modern:focus-visible,
.product-card-modern:focus-visible,
#productModal button:focus-visible {
  outline: 3px solid #991b1b;
  outline-offset: 3px;
}

/* Keep long category names readable rather than squeezing desktop columns. */
@media (max-width: 1200px) {
  .products-grid-modern {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
  }

  .category-nav-modern {
    grid-template-columns: repeat(5, minmax(219px, 1fr));
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    padding: 6px 0 12px;
  }

  .category-card-modern:focus-visible { outline-offset: -5px; }
}

@media (max-width: 968px) {
  .products-grid-modern {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-nav-modern { gap: 0.75rem; }
}

@media (max-width: 640px) {
  .products-section-modern { padding: 40px 0; }

  .products-grid-modern { gap: 0.75rem; }

  .category-nav-modern {
    gap: 0.5rem;
    margin-bottom: 1.5rem;
  }

  .product-info-modern {
    padding: 0.75rem;
    min-height: 4rem;
  }

  .product-info-modern h3 { font-size: 0.85rem; }

  .page-header-products h1 { font-size: 2rem; }

  .page-header-products p {
    font-size: 1rem;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
  }
}

/* Modal responsive rules deliberately follow every modal base rule. */
@media (max-width: 600px) {
  #productModal { padding: 12px; }

  #productModal .modal-content {
    max-height: 80vh;
    max-height: 80dvh;
  }

  /* On narrow screens keep the close control clear of the full-width image. */
  #productModal .modal-close {
    margin-bottom: 0;
  }

  #productModal .modal-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    padding: 0.75rem 1rem 1rem;
    align-items: start;
  }

  #productModal .modal-image-square {
    padding: 0.5rem;
    width: 75%;
    margin: 0 auto;
  }

  #productModal .modal-image-square img {
    inset: 0.5rem;
    width: calc(100% - 1rem);
    height: calc(100% - 1rem);
    transform: scale(1.15);
  }

  #productModal .filled-image-toggle {
    right: 0.75rem;
    bottom: 0.75rem;
  }

  #productModal .modal-details h2 { font-size: 1.25rem; }
}

@media (max-width: 400px) {
  .products-grid-modern { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .products-grid-modern,
  .product-card-modern,
  .product-image-modern img,
  .category-card-modern,
  .category-card-modern::before,
  .category-card-modern h3,
  .category-card-modern p,
  .category-icon,
  .category-indicator,
  #productModal,
  #productModal .modal-content,
  #productModal button {
    animation: none;
    transition: none;
  }

  .product-card-modern.show:not(.scroll-visible) {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .product-card-modern.show.scroll-visible:hover,
  .category-card-modern:hover .category-icon,
  .category-card-modern.active .category-icon {
    transform: none;
  }
}
