/* ==========================================================================
   ST GOLD — mobile-first polish layer (loaded last)
   Fixes mobile nav, touch targets, spacing, and the shop gap.
   ========================================================================== */

/* Prevent any horizontal overflow site-wide */
html, body { max-width: 100%; overflow-x: hidden; }
* { -webkit-tap-highlight-color: rgba(31,42,68,.12); }

/* ------------------------------------------------------ tablet & below */
@media (max-width: 900px) {
  /* MOBILE NAV — anchored dropdown, fully hidden until opened.
     Fixes the stray link peeking above the header. */
  .nav-links {
    position: absolute;
    top: 100%;                 /* drop from the header's own bottom edge */
    left: 0; right: 0;
    background: var(--ivory);
    flex-direction: column;
    gap: 0;
    padding: 8px 20px 16px;
    box-shadow: var(--shadow-md);
    border-top: 1px solid var(--beige-deep);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;        /* truly gone when closed — no peeking */
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease, visibility .22s;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .nav-links a {
    padding: 15px 4px;         /* >=44px touch target */
    border-bottom: 1px solid var(--beige);
    font-size: 1.05rem;
  }
  .nav-links li:last-child a { border-bottom: none; }
  header.site-header { position: sticky; }
  .nav { position: relative; }
  .hamburger { display: grid; }

  /* Single-column structural stacks */
  .hero-grid, .pd-grid, .footer-grid, .cart-layout, .shop-layout,
  .dash-grid, .inquiry-grid { grid-template-columns: 1fr !important; }
}

/* -------------------------------------------------------- phones (<=640) */
@media (max-width: 640px) {
  .container { padding: 0 18px; }
  .section { padding: 44px 0; }

  /* Topbar: keep it short on tiny screens */
  .topbar { font-size: .68rem; padding: 7px 12px; line-height: 1.3; }

  /* Header sizing */
  .nav { padding: 12px 16px; gap: 10px; }
  .logo-mark { width: 40px; height: 40px; font-size: 1.1rem; }
  .logo-text b { font-size: 1.2rem; }
  .logo-text small { font-size: .55rem; letter-spacing: 3px; }
  .icon-btn { width: 44px; height: 44px; }   /* proper touch target */

  /* HERO — tighter, punchier */
  .hero { padding: 40px 0 54px; }
  .hero-copy h1 { font-size: 2.3rem; line-height: 1.1; }
  .hero-copy p { font-size: 1rem; }
  .hero-cta { gap: 12px; }
  .hero-cta .btn { flex: 1; justify-content: center; min-width: 0; }
  .hero-stats { gap: 22px; margin-top: 34px; flex-wrap: wrap; }
  .hero-stats .num { font-size: 1.6rem; }
  .hero-visual { margin-top: 30px; }
  .hero-card .ph { height: 260px; }
  .hero-badge { left: 0; bottom: -16px; padding: 12px 16px; }

  /* Buttons: comfortable tap size */
  .btn { padding: 14px 24px; min-height: 48px; }
  .btn-sm { padding: 10px 16px; min-height: 40px; }

  /* Section titles */
  .section-title { font-size: 1.7rem; }
  .section-sub { font-size: .95rem; margin-bottom: 28px; }
  .page-head { padding: 40px 0; }
  .page-head h1 { font-size: 2.1rem; }

  /* PRODUCT GRID — 2-up with tighter gap */
  .product-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .product-card .ph { height: 165px; }
  .product-name { font-size: 1rem; line-height: 1.25; }
  .product-body { padding: 14px 13px 16px; }
  .price { font-size: 1.15rem; }
  .add-btn { width: 42px; height: 42px; }   /* tap-friendly */

  /* CATEGORY GRID — 2-up */
  .cat-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .cat-card .ph { height: 130px; }
  .cat-card h3 { font-size: 1.05rem; }
  .cat-card .cat-body { padding: 14px 14px; }

  /* SHOP toolbar — stack cleanly, kill the empty gap */
  .shop-layout { gap: 20px; }
  .filters { position: static !important; padding: 16px 18px; }
  .filters h4 { margin: 14px 0 8px; }
  /* Filters as chips on phone */
  #catFilters { display: flex; flex-wrap: wrap; gap: 8px; }
  #catFilters .filter-opt {
    padding: 9px 14px; margin: 0;
    background: var(--beige); border-radius: 999px; font-size: .85rem;
  }
  #catFilters .filter-opt input { display: none; }
  #catFilters .filter-opt:has(input:checked) { background: var(--green); color: var(--ivory); }
  .shop-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .search-box { min-width: 0; width: 100%; }
  .select-sort { width: 100%; }
  #shopCount { order: 3; text-align: center; }

  /* PRODUCT DETAIL */
  .pd-gallery .ph { height: 320px; }
  .pd-info h1 { font-size: 1.9rem; }
  .pd-price { font-size: 1.6rem; }
  .pd-actions { flex-wrap: wrap; gap: 12px; }
  .pd-actions .btn { flex: 1; justify-content: center; }
  .pd-thumbs .ph { height: 66px; width: 66px; }

  /* CART */
  .cart-item { grid-template-columns: 72px 1fr; gap: 12px; }
  .cart-item .ph { height: 72px; width: 72px; }
  .cart-item > div:last-child { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
  .cart-summary { position: static; }

  /* BENEFITS — 2x2 grid, not cramped row */
  .benefits-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; text-align: left; }
  .benefit { justify-content: flex-start; }
  .benefit b { font-size: .95rem; }
  .benefit span { font-size: .72rem; }

  /* REVIEWS / CTA */
  .review-grid { gap: 16px; }
  .review-card { padding: 22px; }
  .cta-band { padding: 36px 20px; }
  .cta-band h2 { font-size: 1.8rem; }
  .subscribe { flex-direction: column; }
  .subscribe input, .subscribe .btn { width: 100%; }

  /* SLIDER — snappy card size */
  .slider > * { flex: 0 0 220px; }
  .slider-nav { display: none; }   /* swipe instead of arrows on touch */

  /* FORMS */
  .field-row { grid-template-columns: 1fr; }
  .form-card { padding: 22px; }

  /* FOOTER */
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .footer-about { grid-column: 1 / -1; }

  /* ADMIN / DASHBOARD — mobile usable */
  .admin-main { padding: 20px 16px; }
  .admin-head { flex-direction: column; align-items: flex-start; }
  .admin-head h1 { font-size: 1.6rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-card .s-val { font-size: 1.6rem; }
  .dash-grid { grid-template-columns: 1fr !important; }
  /* Make wide tables scroll instead of squashing */
  .panel { overflow-x: auto; }
  table.data { min-width: 520px; }
  .login-card { padding: 28px 22px; }
}

/* -------------------------------------------------- very small (<=380) */
@media (max-width: 380px) {
  .product-grid { gap: 12px; }
  .hero-copy h1 { font-size: 2rem; }
  .hero-stats { gap: 16px; }
  .hero-stats .num { font-size: 1.4rem; }
}

/* --------------------------------------- touch devices: calm the motion */
@media (hover: none) and (pointer: coarse) {
  .hero-card { transform: none !important; }         /* no cursor tilt on touch */
  .product-card:hover { transform: none; }
  .product-media::after { display: none; }           /* no cursor spotlight */
  .product-card:active { transform: scale(.985); }   /* tactile press instead */
}
