/* Cartly Mobile Overrides (<= 640px)
   Load with: <link rel="stylesheet" href="/assets/styles.mobile.css" media="(max-width: 640px)">
   Keeps desktop CSS intact; only tweaks for small viewports.
--------------------------------------------------------------------*/

/* --- Layout tokens --- */
:root{
  --bg: #f9fafb;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #16a34a;
}

/* --- Global spacing & typography --- */
body{ background:var(--bg); color:var(--ink); }
.container, .prod-wrap{ padding: 0.75rem; max-width: 100%; }
.search-section h1{ font-size: 1.25rem; margin: .25rem 0 .5rem; }

/* --- Header compaction --- */
.header{ padding: .6rem 0; }
.logo-text .tagline{ display:none !important; }
.nav-links{ gap:.35rem; flex-wrap:wrap; }
.nav-links span[aria-hidden="true"]{ display:none; }

/* Profile/Basket icons become circular with badge */
.dropdown .dropdown-toggle,
.basket-btn{
  width:40px; height:40px; padding:0 !important; border-radius:999px;
  display:inline-flex; align-items:center; justify-content:center;
  border:1px solid var(--line);
}
.basket-btn > span:nth-child(2){ display:none !important; } /* hide label */

/* --- Search controls: stack vertically --- */
.search-controls{ display:grid; grid-template-columns: 1fr; gap:.5rem; }
.search-controls input{ min-height: 44px; font-size: 16px; } /* prevent iOS zoom */
.search-controls button{ min-height: 44px; font-weight: 700; background: var(--brand); color:#fff; }

/* --- Results grid: 1→2 columns depending on width --- */
.results-grid,
#results{
  display:grid;
  gap: .9rem;
  grid-template-columns: 1fr;
}
@media (min-width: 390px) and (max-width: 640px){
  .results-grid,
  #results{ grid-template-columns: 1fr 1fr; }
}

/* --- Product card sizing --- */
.card{ border-radius: 12px; overflow: hidden; }
.card-img{ aspect-ratio: 4 / 3; background:#fff; }
.card-img img{ width:100%; height:100%; object-fit:contain; }
.card-body{ padding: 10px 12px; display:grid; gap:6px; }
.card-title{
  font-weight: 700;
  font-size: .98rem;
  line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow:hidden;
  min-height: 2.4em;
}
.card-meta{ font-size: .85rem; color: var(--muted); }

/* Price + unit neatly together */
.card-price{ color: var(--brand); font-weight: 800; font-size: 1.05rem; }
.card-unit{ color: var(--muted); font-size: .82rem; }

/* Full-width primary action */
.btn.btn-add, .btn-primary{ width:100%; min-height:44px; border-radius:10px; }

/* --- Retailer / popovers: keep on-screen --- */
.retailer-wrap{ position: relative; }
.suggest-popover,
.retailer-menu{
  position: absolute;
  left: 0;
  top: calc(100% + .4rem);
  max-width: 92vw;
  width: max(280px, 60vw);
  z-index: 50;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0,0,0,.12);
}
.suggest-popover .suggest-list{ max-height: 46vh; overflow:auto; }

/* Ensure cards don't clip popovers on mobile */
.card{ overflow: visible; }

/* --- Basket sidebar: convert to block --- */
.results-basket{ grid-template-columns: 1fr !important; }
#basket{ position: static; margin-top: .5rem; }
#basket #checkout-btn{ min-height: 44px; }

/* --- Tables & lists: scroll when needed --- */
.table-wrapper{ overflow:auto; -webkit-overflow-scrolling: touch; }
th, td{ padding: .5rem .4rem; font-size: .92rem; }

/* --- Footer spacing --- */
footer{ padding: 1rem 0; }

