/* =============================================================
   GLAZE — Responsive layer (phone + pad)
   Loaded globally after glaze.css / glaze_components_merged.css.

   Breakpoints align with Tailwind defaults used in the design:
     phone : max-width: 767px   (< Tailwind md)
     pad   : 768px – 1023px     (Tailwind md to < lg)
     desktop: 1024px+            (Tailwind lg+)

   Targets component classes that ship with fixed desktop layouts
   so all 17 Glaze page templates collapse correctly on mobile
   and tablet without requiring per-page Tailwind utility edits.
   ============================================================= */

/* =============================================================
   Design-aligned product card (shared across listing / home / wishlist / also-purchased)
   ============================================================= */
.glaze-product-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.glaze-product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}
.gpc-image-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--surface-2);
}
.gpc-image-wrap .gpc-image-link { display: block; width: 100%; height: 100%; }
.gpc-image-wrap .gpc-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.glaze-product-card:hover .gpc-image { transform: scale(1.04); }
.gpc-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #fff;
  z-index: 2;
}
.gpc-badge.new { background: var(--ink); }
.gpc-badge.sale { background: #E53935; }
.gpc-wishlist {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  transition: color .2s ease, background .2s ease, transform .2s ease;
  z-index: 2;
}
.gpc-wishlist:hover { color: var(--brand); transform: scale(1.08); }
.gpc-wishlist.active, .gpc-wishlist.active .gpc-heart-icon { color: var(--brand); fill: var(--brand); }
.gpc-wishlist.gpc-wishlist-remove { color: var(--brand); }
.gpc-wishlist.gpc-wishlist-remove .gpc-heart-icon { fill: var(--brand); stroke: var(--brand); }
.gpc-heart-icon { width: 18px; height: 18px; }
.gpc-body { padding: 12px; }
.gpc-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  margin: 0 0 6px;
}
.gpc-title a { color: inherit; text-decoration: none; transition: color .2s ease; }
.gpc-title a:hover { color: var(--brand); }
.gpc-rating {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 8px;
}
.gpc-star {
  width: 14px;
  height: 14px;
}
.gpc-star.filled { color: #F59E0B; fill: #F59E0B; }
.gpc-star.empty { color: var(--ink-3); fill: none; }
.gpc-rating-count {
  font-size: 12px;
  color: var(--ink-2);
  margin-left: 3px;
}
.gpc-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

/* Compact wishlist preview on account dashboard */
.wishlist-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.wishlist-preview-grid .glaze-product-card {
  border-radius: var(--r-md);
}
.wishlist-preview-grid .gpc-image-wrap {
  aspect-ratio: 1 / 1;
}
.wishlist-preview-grid .gpc-body {
  padding: 8px;
}
.wishlist-preview-grid .gpc-title {
  font-size: 11px;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.wishlist-preview-grid .gpc-rating {
  margin-bottom: 4px;
}
.wishlist-preview-grid .gpc-star {
  width: 10px;
  height: 10px;
}
.wishlist-preview-grid .gpc-price {
  font-size: 12px;
}
.wishlist-preview-grid .gpc-wishlist {
  width: 24px;
  height: 24px;
  top: 6px;
  right: 6px;
}
.wishlist-preview-grid .gpc-heart-icon {
  width: 13px;
  height: 13px;
}
.wishlist-preview-grid .gpc-badge {
  padding: 2px 6px;
  font-size: 8px;
  top: 6px;
  left: 6px;
}

/* =============================================================
   PHONE (< 768px)
   ============================================================= */
@media (max-width: 767px) {
  /* ---------- Containers & spacing ---------- */
  .container-glaze {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Zen Cart legacy page-frame table (#contentMainWrapper) ships with
     table-layout:auto + width:100%, which lets a single content cell grow to
     its min-content and push the document 6px past the viewport on phones
     (seen on Site Map). Pin it fixed-width so the frame can never exceed the
     viewport. Nested data tables keep their own layout. */
  #contentMainWrapper {
    table-layout: fixed;
    width: 100%;
    max-width: 100%;
  }
  #contentMainWrapper > tbody > tr > td { width: 100%; }

  /* Reduce giant top-level padding classes when used without responsive suffix */
  .py-16,
  .py-20 { padding-top: 40px !important; padding-bottom: 40px !important; }
  .pt-16, .pt-20 { padding-top: 40px !important; }
  .pb-16, .pb-20, .pb-24, .pb-28 { padding-bottom: 40px !important; }

  /* ---------- Typography ---------- */
  .font-display.text-\[36px\],
  .font-display.text-\[38px\],
  .font-display.text-\[42px\],
  .font-display.text-\[50px\] { font-size: 28px !important; }

  h1.font-display { font-size: clamp(28px, 8vw, 36px); }

  /* ---------- Auth (login / register) ---------- */
  .auth-card {
    grid-template-columns: 1fr;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    max-width: 100%;
  }
  .auth-visual {
    padding: 32px 24px;
    min-height: auto;
  }
  .auth-visual h2 { font-size: 26px; }
  .auth-form-wrap { padding: 28px 20px; }
  .auth-tabs { gap: 8px; }
  .auth-tab { padding: 10px 14px; font-size: 13px; }

  /* ---------- Account layout ---------- */
  .account-layout {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px 0 40px;
  }
  .account-sidebar { position: static; }
  .sidebar-profile { padding: 16px; }
  .sidebar-profile .avatar { width: 48px; height: 48px; font-size: 20px; }
  .sidebar-link { padding: 10px 16px; }
  .sidebar-logout { padding: 12px 16px; }

  /* Force account page inner 2-col grids to single column */
  .account-content .grid.grid-cols-2,
  .account-content .grid.grid-cols-3,
  .account-content .grid.grid-cols-4 { grid-template-columns: 1fr !important; }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 22px; }

  .orders-table,
  .account-content table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* ---------- Product detail ---------- */
  .product-gallery-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .thumbs-row {
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
  }
  .thumb-item { width: 52px; height: 52px; }

  /* Description / reviews tabs */
  #productMainWrapper .tab-btn { padding: 12px 16px; font-size: 14px; }
  #productMainWrapper .tab-panel { padding-top: 24px; }
  #tab-reviews > div[style*="grid-template-columns:280px 1fr"],
  #tab-reviews > div[style*="grid-template-columns: 280px 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }

  /* ---------- Product grids (category / all / featured / new / also purchased) ---------- */
  .product-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  .product-card .product-name {
    font-size: 13px;
  }
  .product-card .product-price {
    font-size: 14px;
  }
  .wishlist-btn { width: 30px; height: 30px; }

  /* ---------- Category / listing ----------
     Sidebar (aside.glaze-product-filters) uses Tailwind's "hidden lg:block"
     which means display:none below 1024px and display:block at 1024px+.
     When sidebar is HIDDEN we force column layout so sort-bar sits
     ABOVE the product grid (not beside it). */
  .filter-section,
  .sidebar-sort,
  .modern-filter { display: none; }
  /* Mobile filter toggle (if present) becomes visible */
  .mobile-filter-toggle { display: flex; }
  /* Force single-column flow — sort-bar on top, grid below
     !important needed because glaze-modern-filter.css loads after this file
     and may contain competing flex-direction rules. */
  .listing-layout {
    flex-direction: column !important;
    display: flex;
  }
  .listing-layout > aside.glaze-product-filters {
    display: none !important;   /* hide sidebar; !important overrides Tailwind lg:block */
  }
  .listing-layout > .flex-1 {
    width: 100% !important;
    flex: none !important;
    min-width: 0;
  }
  /* Ensure sort-bar is full-width and horizontally stacked on mobile */
  .sort-bar {
    width: 100% !important;
    display: flex !important;
  }
  aside.glaze-product-filters.filters-open {
    display: block !important;
    width: 100%;
    margin-bottom: 24px;
  }
  /* When the sidebar opens on mobile, reveal its hidden children
     (.modern-filter attributes + .filter-section links) that are
     display:none by default at this breakpoint. */
  aside.glaze-product-filters.filters-open .modern-filter,
  aside.glaze-product-filters.filters-open .filter-section {
    display: block !important;
  }
  /* Avoid plugin's fixed mobile drawer fighting the in-flow sidebar */
  aside.glaze-product-filters.filters-open .modern-filter {
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
  }

  /* Sort bar — compact ONLY on true phones (≤639px).
     640-767 (iPad Mini portrait etc.) uses the full sort bar — see block below. */
  .sort-bar {
    padding: 10px 0;
    gap: 10px;
    flex-wrap: wrap;
  }
  .sort-bar-left,
  .sort-bar-right {
    gap: 10px;
  }

  /* ---------- Cart ---------- */
  .cart-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .cart-item {
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
  }
  .cart-item-image { width: 80px; height: 80px; }
  .cart-item-details { width: calc(100% - 96px); }
  .cart-item-price {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
  }
  .cart-footer {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  .cart-footer .continue-shopping,
  .cart-footer .update-cart-btn { width: 100%; justify-content: center; }
  .summary-card { position: static; }

  /* ---------- One-page checkout ---------- */
  .opc-base .grid.grid-cols-1.lg\:grid-cols-\[1\.17fr_1fr\] {
    grid-template-columns: 1fr !important;
  }
  .opc-base .lg\:sticky { position: static !important; }

  /* ---------- Wishlist ---------- */
  .wishlist-toolbar {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  .toolbar-actions { justify-content: flex-start; }
  .wishlist-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  /* ---------- Contact ---------- */
  .contact-page .flex.flex-col.lg\:flex-row,
  .contact-page form .grid {
    grid-template-columns: 1fr !important;
  }
  .info-card { padding: 16px; }

  /* ---------- Site map ---------- */
  .sitemap-grid,
  .site-map-page .grid.grid-cols-2,
  .site-map-page .grid.grid-cols-3,
  .site-map-page .grid.grid-cols-4 { grid-template-columns: 1fr !important; }

  /* ---------- Time out / empty states ---------- */
  .timeout-card,
  .empty-state-card {
    padding: 32px 20px;
  }
  .timeout-card h1,
  .empty-state-card h1 { font-size: 26px; }

  /* ---------- Info pages (shipping/conditions/privacy/gv_faq) ---------- */
  .glaze-content-page .content-grid,
  .glaze-content-page .grid.grid-cols-2,
  .glaze-content-page .grid.grid-cols-3 { grid-template-columns: 1fr !important; }

  /* ---------- Footer ---------- */
  .site-footer .grid.grid-cols-2.md\:grid-cols-4,
  .site-footer .grid.grid-cols-1.md\:grid-cols-2 {
    gap: 32px 16px;
  }
  .site-footer .col-span-2.md\:col-span-1 { grid-column: span 2 / span 2; }

  /* ---------- Tables globally ---------- */
  table.responsive-table,
  .dataTable,
  .orders-table,
  .cart-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* ---------- Forms ---------- */
  .form-row { grid-template-columns: 1fr !important; }
  .account-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .account-actions .actions-right { justify-content: space-between; }
  .account-actions .btn-primary,
  .account-actions .btn-ghost { width: 100%; justify-content: center; }

  /* ---------- Utilities ---------- */
  .hidden-phone { display: none !important; }
}

/* =============================================================
   SMALL PHONE (≤639px) — compact sort bar
   True phones (iPhone SE/14/15/17, Galaxy S/Note, Pixel ≤430px):
   hide result count / view toggle / sort icon, icon-only Filter.
   ============================================================= */
@media (max-width: 639px) {
  .sort-bar {
    padding: 10px 0;
    gap: 10px;
    flex-wrap: wrap;
  }
  .sort-bar-left,
  .sort-bar-right { gap: 10px; }
  /* Hide result count text */
  .result-count { display: none; }
  /* Filter button = icon only (square) */
  .mobile-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    padding: 0;
    border-radius: var(--r-md);
    border: 1px solid var(--input);
    background: var(--surface);
    color: var(--ink-2);
  }
  .filter-text { display: none; }
  /* View toggle stays VISIBLE on phones (base styles are compact enough);
     only shrink slightly. */
  .view-toggle { display: flex; gap: 2px; }
  .view-btn { padding: 4px; }
  /* Hide sort icon prefix */
  .sort-icon { display: none; }
  /* Compact select */
  .sort-select {
    font-size: 13px;
    padding: 8px 28px 8px 10px;
    min-width: 0;
    max-width: 160px;
  }
}

/* =============================================================
   LARGE PHONE / SMALL TABLET (640px – 767px)
   Covers iPad Mini portrait (744px) and similar: room enough for
   the FULL sort bar (result count + Filter text + view toggle + sort icon).
   ============================================================= */
@media (min-width: 640px) and (max-width: 767px) {
  .sort-bar {
    padding: 14px 0;
    gap: 16px;
    flex-wrap: nowrap;
  }
  .sort-bar-left,
  .sort-bar-right { gap: 14px; }
  .result-count { display: inline; font-size: 13px; }
  .mobile-filter-toggle {
    display: flex;
    align-items: center;
    width: auto; height: auto;
    padding: 8px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--input);
    background: transparent;
    color: var(--ink-2);
    gap: 6px;
  }
  .filter-text { display: inline; font-size: 13px; }
  .view-toggle { display: flex; }
  .sort-icon { display: block; }
  .sort-select {
    font-size: 14px;
    padding: 8px 32px 8px 12px;
    max-width: 200px;
  }
}

/* =============================================================
   PAD (768px – 1023px)
   ============================================================= */
@media (min-width: 768px) and (max-width: 1023px) {
  .container-glaze {
    padding-left: 24px;
    padding-right: 24px;
  }

  /* Listing layout — stack vertically on tablet (sidebar hidden, single-column flow) */
  .listing-layout {
    flex-direction: column !important;
    display: flex;
  }
  .listing-layout > aside.glaze-product-filters {
    display: none !important;
  }
  .listing-layout > .flex-1 {
    width: 100% !important;
    flex: none !important;
    min-width: 0;
  }

  /* Auth */
  .auth-card {
    grid-template-columns: 1fr 1fr;
    max-width: 100%;
  }
  .auth-visual { padding: 32px; }
  .auth-form-wrap { padding: 32px; }

  /* Account */
  .account-layout {
    grid-template-columns: 220px 1fr;
    gap: 24px;
  }

  /* Product detail */
  .product-gallery-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }

  /* Product grids */
  .product-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 18px !important;
  }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(4, 1fr); }

  /* Cart */
  .cart-layout { grid-template-columns: 1fr 300px; gap: 24px; }
  .cart-item { padding: 20px; }

  /* OPC */
  .opc-base .grid.grid-cols-1.lg\:grid-cols-\[1\.17fr_1fr\] {
    grid-template-columns: 1fr !important;
  }
  .opc-base .lg\:sticky { position: static !important; }

  /* Category filter */
  .filter-sidebar { width: 220px; }

  /* Sort bar — tablet (768–1023px) */
  .sort-bar {
    padding: 14px 0;
    gap: 16px;
    flex-wrap: nowrap;
  }
  .sort-bar-left,
  .sort-bar-right { gap: 14px; }
  /* Show result count */
  .result-count { display: inline; font-size: 13px; }
  /* Filter button with text label */
  .mobile-filter-toggle {
    display: flex;
    width: auto; height: auto;
    padding: 8px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--input);
    background: transparent;
    color: var(--ink-2);
    gap: 6px;
  }
  .filter-text { display: inline; font-size: 13px; }
  /* Show view toggle */
  .view-toggle { display: flex; }
  /* Show sort icon */
  .sort-icon { display: block; }
  /* Normal select width */
  .sort-select {
    font-size: 14px;
    padding: 8px 32px 8px 12px;
    max-width: 200px;
  }
}

/* =============================================================
   TABLET-LANDSCAPE / SMALL-DESKTOP (1024px – 1279px)
   Sidebar visible (lg:block kicks in at 1024px) but viewport is narrow.
   Keep row layout with sidebar, but use 3-column grid to avoid cramping.
   Covers: iPad Pro 11" landscape (~1194px), iPad 10th landscape,
           Galaxy Tab S9+ landscape, small laptop windows.
   ============================================================= */
@media (min-width: 1024px) and (max-width: 1279px) {
  /* Listing stays row-direction (sidebar visible via lg:block) */
  .listing-layout {
    gap: 20px;
  }
  /* Sidebar narrower on constrained viewports */
  aside.glaze-product-filters {
    width: 200px;
    flex-shrink: 0;
  }

  /* 3 columns (not 4) so cards don't get too tiny */
  .product-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 18px !important;
  }
  .also-purchased-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Sort bar — slightly tighter than full desktop */
  .sort-bar {
    padding: 14px 0;
    gap: 16px;
    flex-wrap: nowrap;
  }
  .sort-bar-left,
  .sort-bar-right { gap: 14px; }
  .result-count { display: inline; font-size: 13px; }
  .mobile-filter-toggle { padding: 8px 14px; }
  .filter-text { display: inline; font-size: 13px; }
  .view-toggle { display: flex; }
  .sort-icon { display: block; }
  .sort-select {
    font-size: 14px;
    padding: 8px 32px 8px 12px;
    max-width: 200px;
  }
}

/* =============================================================
   DESKTOP (1280px+) — full sidebar + 4-column grids
   True desktops / laptops (HiDPI, MDPI, touch).
   ============================================================= */
@media (min-width: 1280px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 24px !important;
  }
  .also-purchased-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  /* Sort bar — desktop (1024px+) */
  .sort-bar {
    padding: 16px 0;
    gap: 20px;
    flex-wrap: nowrap;
  }
  .sort-bar-left,
  .sort-bar-right { gap: 16px; }
  .result-count { display: inline; font-size: 14px; }
  .mobile-filter-toggle {
    display: flex;
    width: auto; height: auto;
    padding: 8px 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--input);
    background: transparent;
    color: var(--ink-2);
    gap: 6px;
  }
  .filter-text { display: inline; font-size: 14px; }
  .view-toggle { display: flex; }
  .sort-icon { display: block; }
  .sort-select {
    font-size: 14px;
    padding: 8px 32px 8px 12px;
    max-width: 220px;
  }
}

/* =============================================================
   Accessibility / reduced motion
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  .mobile-drawer__panel { transition: none; }
}

/* =============================================================
   Rating stars — per Product Detail design mockup
   .star-filled { color:#F59E0B; fill:#F59E0B }  (amber gold solid)
   Loaded last so it wins over any residual inline brand-color override
   and over the older glaze.css #E8B04C token.
   ============================================================= */
.star-filled { color: #F59E0B !important; fill: #F59E0B !important; }
.star-empty  { color: var(--ink-3) !important; fill: none !important; }
