/**
 * Mobile + typography fixes — load last on storefront.
 */

/* Readable text everywhere */
body.pd-layout,
body.page-grocery-kit {
  color: #111827;
  -webkit-font-smoothing: antialiased;
}

body.pd-layout .hp-kit-section-head h2,
body.pd-layout .hp-kit-cat-name,
body.pd-layout .sp-premium-title,
body.pd-layout .sdp-title {
  color: #111827 !important;
}

body.pd-layout .hp-kit-eyebrow,
body.pd-layout .hp-kit-link {
  color: #2E7D32 !important;
}

/* Banner photos — show full 3:2 graphic without cropping */
body.pd-layout .hp-kit-banner--photo .hp-kit-banner-photo {
  max-height: none;
  object-fit: contain;
}

body.pd-layout .hp-kit-banner-body {
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

body.pd-layout .hp-kit-banner-title,
body.pd-layout .hp-kit-banner-sub,
body.pd-layout .hp-kit-banner-features li {
  color: #fff !important;
}

body.pd-layout .hp-poster-tile-text strong,
body.pd-layout .hp-poster-tile-text span {
  color: #fff !important;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

/* Mobile category rail labels */
body.pd-layout .sp-cat-rail-label,
body.pd-layout .pd-cat-ribbon-label {
  color: #1f2937 !important;
  font-weight: 700;
}

/* Shop category grid (products page + mobile) */
.sp-shop-categories {
  margin-bottom: 1.75rem;
  scroll-margin-top: calc(var(--bottom-nav-h, 72px) + 80px);
}

.sp-shop-categories-head h2 {
  font-size: 1.125rem;
  font-weight: 800;
  color: #111827;
  margin: 0 0 4px;
}

.sp-shop-categories-head p {
  margin: 0 0 14px;
  font-size: 0.875rem;
  color: #4b5563;
}

.sp-shop-categories-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sp-shop-cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #e8f0e8;
  text-decoration: none;
  color: #111827;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.04);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.sp-shop-cat-card.is-active,
.sp-shop-cat-card:hover {
  border-color: #66BB6A;
  box-shadow: 0 6px 18px rgba(46, 125, 50, 0.12);
}

.sp-shop-cat-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sp-shop-cat-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sp-shop-cat-name {
  font-size: 0.6875rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.25;
  color: #111827;
}

.sp-shop-cat-count {
  font-size: 0.625rem;
  color: #6b7280;
}

/* Mobile sidebar — always above bottom nav */
@media (max-width: 991px) {
  body.pd-layout .sp-sidebar-overlay.sidebar-overlay {
    z-index: 11050 !important;
  }

  body.pd-layout .sp-mobile-menu.mobile-sidebar {
    z-index: 11060 !important;
    position: fixed !important;
    top: 0 !important;
    left: calc(-1 * var(--sp-menu-w, 320px)) !important;
    transform: none !important;
    visibility: visible !important;
  }

  body.pd-layout .sp-mobile-menu.mobile-sidebar.open {
    left: 0 !important;
    transform: none !important;
  }

  body.pd-layout .sp-menu-cat-name,
  body.pd-layout .sp-menu-section-title,
  body.pd-layout .sp-menu-link span {
    color: #111827 !important;
  }

  body.pd-layout .category-tabs {
    display: none;
  }

  .sp-shop-categories-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }

  .sp-shop-cat-photo {
    width: 58px;
    height: 58px;
  }
}

@media (min-width: 992px) {
  .sp-shop-categories-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
  }

  .sp-shop-cat-photo {
    width: 72px;
    height: 72px;
  }

  .sp-shop-cat-name {
    font-size: 0.75rem;
  }
}

/* Product detail mobile */
@media (max-width: 991px) {
  body.sdp-page .sdp-layout {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  body.sdp-page .sdp-gallery {
    position: static;
  }

  body.sdp-page .sdp-title,
  body.sdp-page .sdp-short-desc,
  body.sdp-page .sdp-price,
  body.sdp-page .sdp-label {
    color: #111827 !important;
  }

  body.sdp-page .sdp-gallery-main img {
    object-fit: contain;
    padding: 12px;
    background: #fff;
  }
}

/* Promo poster scroll on small screens — skip compact offers grid on grocery homepage */
@media (max-width: 575px) {
  body.pd-layout:not(.page-grocery-kit) .hp-kit-promo-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 10px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  body.pd-layout:not(.page-grocery-kit) .hp-kit-promo-grid--compact .hp-poster-tile--photo {
    flex: 0 0 42%;
    min-height: 0;
    scroll-snap-align: start;
  }

  body.pd-layout:not(.page-grocery-kit) .hp-poster-tile--photo {
    flex: 0 0 42%;
    min-height: 0;
    scroll-snap-align: start;
  }

  body.pd-layout:not(.page-grocery-kit) .hp-poster-tile:not(.hp-poster-tile--photo) {
    flex: 0 0 78%;
    scroll-snap-align: start;
    min-height: 130px;
  }
}

#shop-categories {
  scroll-margin-top: calc(var(--bottom-nav-h, 72px) + 88px);
}

@media (max-width: 991px) {
  .sp-mobile-topbar-actions .sp-mob-btn[aria-label="Search"] {
    display: none !important;
  }
  .mobile-search-sheet,
  .mobile-search-backdrop {
    display: none !important;
  }
  .hp-pd-row-wrap::after {
    content: 'Swipe →';
    position: absolute;
    right: 8px;
    top: -22px;
    font-size: 0.625rem;
    font-weight: 700;
    color: #9ca3af;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    pointer-events: none;
  }
}

.pdp-mobile-buy-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--bottom-nav-h, 72px) + env(safe-area-inset-bottom, 0px));
  z-index: 10050;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -8px 24px rgba(17, 24, 39, 0.08);
}

.pdp-mobile-buy-info {
  flex: 1;
  min-width: 0;
}

.pdp-mobile-buy-label {
  display: block;
  font-size: 0.625rem;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
}

.pdp-mobile-buy-info strong {
  font-size: 1.125rem;
  color: #111827;
}

.pdp-mobile-buy-btn {
  border: none;
  border-radius: 12px;
  background: #2E7D32;
  color: #fff;
  font-weight: 800;
  font-size: 0.875rem;
  padding: 12px 18px;
  white-space: nowrap;
  cursor: pointer;
}

.sp-premium-tax {
  color: #6b7280 !important;
  font-weight: 600 !important;
}

/* Cart / checkout — use dedicated checkout bar, hide bottom nav */
body.page-cart .sanju-bottom-nav,
body.page-cart .sp-mock-bottom-nav,
body.page-checkout .sanju-bottom-nav,
body.page-checkout .sp-mock-bottom-nav {
  display: none !important;
}

body.page-cart .mobile-bottom-bar {
  bottom: env(safe-area-inset-bottom, 0px);
}

body.page-cart .page-wrapper,
body.page-checkout .page-wrapper {
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

/* Product page — room for sticky buy bar */
body.pdp-page .page-wrapper {
  padding-bottom: calc(var(--bottom-nav-h, 72px) + 64px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 992px) {
  body.pdp-page .page-wrapper {
    padding-bottom: 2rem;
  }
}

/* Cart uses live AJAX qty — hide legacy update row */
body.page-cart .jc-form-actions {
  display: none !important;
}

/* ── Mini cart drawer ── */
.sp-mini-cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 12000;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sp-mini-cart-overlay:not([hidden]) {
  opacity: 1;
}

.sp-mini-cart {
  position: fixed;
  top: 0;
  right: 0;
  width: min(100%, 400px);
  height: 100%;
  max-height: 100dvh;
  background: #fff;
  z-index: 12001;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(17, 24, 39, 0.15);
  transform: translateX(100%);
  transition: transform 0.28s ease;
}

.sp-mini-cart:not([hidden]) {
  transform: translateX(0);
}

body.sp-mini-cart-open {
  overflow: hidden;
}

.sp-mini-cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #eef0ee;
  flex-shrink: 0;
}

.sp-mini-cart-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #111827;
}

.sp-mini-cart-head h2 i {
  color: #2E7D32;
  margin-right: 6px;
}

.sp-mini-cart-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: #f3f4f6;
  color: #374151;
  cursor: pointer;
}

.sp-mini-cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.sp-mini-cart-loading,
.sp-mini-cart-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #6b7280;
}

.sp-mini-cart-empty i {
  font-size: 2.5rem;
  color: #d1d5db;
  margin-bottom: 12px;
  display: block;
}

.sp-mini-cart-shop-btn {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 18px;
  background: #2E7D32;
  color: #fff;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  font-size: 0.875rem;
}

.sp-mini-cart-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sp-mini-cart-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f3f4f6;
}

.sp-mini-cart-thumb {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: #f9fafb;
  border: 1px solid #eef0ee;
}

.sp-mini-cart-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.sp-mini-cart-info {
  flex: 1;
  min-width: 0;
}

.sp-mini-cart-name {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #111827;
  text-decoration: none;
  line-height: 1.35;
  margin-bottom: 4px;
}

.sp-mini-cart-variant {
  display: block;
  font-size: 0.6875rem;
  color: #6b7280;
  margin-bottom: 4px;
}

.sp-mini-cart-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #4b5563;
}

.sp-mini-cart-meta strong {
  color: #111827;
}

.sp-mini-cart-foot {
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #eef0ee;
  background: #fafafa;
  flex-shrink: 0;
}

.sp-mini-cart-ship {
  font-size: 0.75rem;
  font-weight: 600;
  color: #15803d;
  margin-bottom: 10px;
  text-align: center;
}

.sp-mini-cart-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.875rem;
}

.sp-mini-cart-checkout {
  display: block;
  text-align: center;
  padding: 12px;
  background: #2E7D32;
  color: #fff !important;
  font-weight: 800;
  border-radius: 12px;
  text-decoration: none;
  margin-bottom: 8px;
}

.sp-mini-cart-view {
  display: block;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #2E7D32;
  text-decoration: none;
}

@media (max-width: 991px) {
  body.sp-mini-cart-open .sanju-bottom-nav {
    z-index: 11999;
  }
}
