/* ============================================================
   BagIT Dropshop — Design Polish v1
   Fixes: category cards, hero products, image loading, alignment
   Load AFTER style.css, mobile-patch.css, upgrade-additions.css
   ============================================================ */

/* ============================================================
   FIX 1: CATEGORY CARDS (HTML uses .category-card, CSS had .cat-card)
   ============================================================ */
.category-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.category-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  background: rgba(245, 196, 0, 0.04);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.category-icon {
  font-size: 36px;
  display: block;
  line-height: 1;
}
.category-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

/* Categories grid — 5 columns to fit the 10 categories nicely */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

@media (max-width: 1024px) {
  .categories-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
  .categories-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .category-card { padding: 18px 10px; }
  .category-icon { font-size: 28px; }
  .category-name { font-size: 11px; }
}
@media (max-width: 480px) {
  .categories-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   FIX 2: HERO PRODUCT CARDS (were completely unstyled)
   ============================================================ */
.hero-right {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  padding: 30px;
  align-content: center;
}
.hero-product {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}
.hero-product:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
.hero-product img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.hero-product-big {
  grid-row: span 2;
}
.hero-product-big img {
  aspect-ratio: auto;
  height: 100%;
}
.hero-product-info {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
}
.hero-product-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-product-price {
  font-family: 'Space Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

@media (max-width: 768px) {
  .hero-right { display: none; }
}

/* ============================================================
   FIX 3: IMAGE LOADING (remove opacity:0 hack that causes flash)
   ============================================================ */
img[loading="lazy"] {
  opacity: 1 !important;
  animation: none !important;
}

/* ============================================================
   FIX 4: PRODUCT CARD POLISH (consistent heights, alignment)
   ============================================================ */

/* Ensure equal height cards */
.products-grid {
  align-items: stretch;
}
.product-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

/* Title — strict 2-line clamp */
.product-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 8px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 38px;
}

/* Stars */
.product-stars {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 10px;
}
.product-stars span {
  color: var(--muted);
  font-size: 11px;
}

/* Push pricing + button to bottom */
.product-pricing {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.add-to-cart {
  margin-top: auto;
}

/* Category label */
.product-category {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 6px;
  font-weight: 500;
}

/* Image consistent sizing */
.product-card .product-img {
  aspect-ratio: 1;
  width: 100%;
  background: var(--surface2);
  overflow: hidden;
  position: relative;
}
.product-card .product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.product-card:hover .product-img img {
  transform: scale(1.05);
}

/* ============================================================
   FIX 5: SECTION SPACING CONSISTENCY (8px grid system)
   ============================================================ */
section {
  padding: 48px 40px;
}
.section-header {
  margin-bottom: 28px;
}
.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 40px;
  letter-spacing: 1px;
  line-height: 1;
}

@media (max-width: 768px) {
  section { padding: 32px 16px; }
  .section-title { font-size: 28px; }
  .section-header { margin-bottom: 20px; }
}

/* ============================================================
   FIX 6: PRODUCT PAGE — BALANCED LAYOUT
   ============================================================ */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
  margin-bottom: 48px;
}
.product-gallery {
  position: sticky;
  top: 100px;
}
.product-detail-info h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 38px;
  letter-spacing: 0.5px;
  line-height: 1.1;
  margin-bottom: 12px;
}
.product-detail-info .price-current {
  font-size: 30px;
}
.product-detail-info .product-pricing {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

/* Variant selects — consistent styling */
.variant-select {
  width: 100%;
  max-width: 280px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.variant-select:focus {
  border-color: var(--accent);
  outline: none;
}

/* Product actions — CTA prominent */
.product-actions .btn-primary {
  font-size: 16px;
  padding: 16px 32px;
  flex: 1;
}

@media (max-width: 768px) {
  .product-detail { gap: 24px; }
  .product-detail-info h1 { font-size: 26px; }
  .product-detail-info .price-current { font-size: 24px; }
  .product-gallery { position: static; }
}

/* ============================================================
   FIX 7: HEADER — TIGHTER ANCHOR
   ============================================================ */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 32px;
}
.logo {
  font-size: 28px;
  flex-shrink: 0;
}
nav {
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
}
nav a {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
}

@media (max-width: 768px) {
  header { padding: 10px 16px; }
  nav { padding: 0 12px; }
  nav a { padding: 10px 8px; font-size: 12px; }
  .logo { font-size: 24px; }
}

/* ============================================================
   FIX 8: TYPOGRAPHY HIERARCHY
   ============================================================ */

/* Price hierarchy — current price always dominant */
.price-current {
  font-family: 'Space Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.price-original {
  font-size: 13px;
  color: var(--muted);
  text-decoration: line-through;
}
.price-save {
  font-size: 11px;
  background: rgba(245, 196, 0, 0.1);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 50px;
  font-weight: 700;
  white-space: nowrap;
}

/* ============================================================
   FIX 9: FREE SHIPPING SECTION — CONSISTENT WITH REST
   ============================================================ */
section[style*="background:var(--surface)"] {
  border: 1px solid var(--border);
}

/* ============================================================
   FIX 10: VALUE PROPS — TIGHTER GRID
   ============================================================ */

/* ============================================================
   FIX 11: NEWSLETTER — POLISH
   ============================================================ */
.newsletter {
  padding: 48px 32px;
}
.newsletter h2 {
  font-size: 44px;
}

@media (max-width: 768px) {
  .newsletter { padding: 36px 16px; }
  .newsletter h2 { font-size: 28px; }
}

/* ============================================================
   FIX 12: FOOTER — TIGHTER
   ============================================================ */
footer {
  padding: 40px 32px 24px;
}
.footer-grid {
  margin-bottom: 32px;
}

/* ============================================================
   FIX 13: GLOBAL — SMOOTH SCROLLING + CONSISTENT MAX-WIDTH
   ============================================================ */
html {
  scroll-behavior: smooth;
}

/* Constrain all main sections to same max-width */
.hero,
section,
.newsletter {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}
footer {
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

/* Full-width backgrounds handled by body bg */

/* ============================================================
   FIX 14: CART PAGE IMAGES (referrerpolicy already on tags)
   ============================================================ */
.cart-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================================
   FIX 15: CHECKOUT — CONSISTENT FORM STYLING
   ============================================================ */
.checkout-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  outline: none;
}

/* ============================================================
   FIX 16: BADGE ALIGNMENT (prevent jumping on hover)
   ============================================================ */
.badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 50px;
  letter-spacing: 0.5px;
}

/* ============================================================
   FIX 17: GLOBAL — REMOVE UNWANTED OUTLINES + FOCUS VISIBLE
   ============================================================ */
*:focus {
  outline: none;
}
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   MEGA MENU — Desktop dropdown on hover
   ============================================================ */
#main-nav {
  display: flex;
  gap: 0;
  overflow: visible;
  position: relative;
}
/* Mobile scrolling handled by mobile-fix.css */

#main-nav > a,
.nav-item > .nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: block;
}
#main-nav > a:hover,
#main-nav > a.active,
.nav-item > .nav-link:hover,
.nav-item > .nav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.nav-item {
  position: relative;
}

/* Mega menu dropdown */
.mega-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  padding-top: 4px;
}

.nav-item.has-mega:hover .mega-menu {
  display: block;
}

.mega-menu-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  min-width: 320px;
  max-width: 480px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: megaFadeIn 0.15s ease;
}

@keyframes megaFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.mega-menu-header {
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.mega-menu-header a {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.mega-menu-header a:hover {
  text-decoration: underline;
}

.mega-menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}

.mega-menu-item {
  display: block;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
  transition: all 0.15s;
  opacity: 0.8;
}
.mega-menu-item:hover {
  background: var(--surface2);
  color: var(--accent);
  opacity: 1;
}

/* Keep mega-menu open when moving from nav-link to dropdown */
.nav-item.has-mega::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 8px;
}

/* First few and last few items — shift dropdown to avoid overflow */
.nav-item:nth-child(-n+3) .mega-menu {
  left: 0;
  transform: none;
}
.nav-item:nth-last-child(-n+3) .mega-menu {
  left: auto;
  right: 0;
  transform: none;
}

/* Mobile — no mega menu, just links */
@media (max-width: 768px) {
  .mega-menu {
    display: none !important;
  }
  #main-nav {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 10px;
  }
  #main-nav::-webkit-scrollbar {
    display: none;
  }
  .nav-item > .nav-link {
    padding: 10px 8px;
    font-size: 12px;
  }
}
