:root {
  --green: #2f6b45;
  --green-dark: #1f4a30;
  --bg: #f7f9f5;
  --card-bg: #ffffff;
  --border: #e0e6dc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: #223;
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: auto 1fr;
}

.site-header {
  grid-column: 1 / -1;
  background: var(--green-dark);
  color: #fff;
  padding: 20px 24px;
}
.site-header h1 { margin: 0; font-size: 1.6rem; }
.tagline { margin: 4px 0 0; opacity: 0.85; font-size: 0.9rem; }

main { padding: 20px; }

/* Column count is fixed per breakpoint, independent of image dimensions: 4 desktop / 2 tablet / 1 mobile. */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.product-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.product-image { width: 100%; height: 160px; object-fit: cover; border-radius: 8px; background: #eef2ea; }

/* Master image format is 1080x1920 (9:16 portrait); box matches that ratio so contain never letterboxes unexpectedly. */
.product-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #eef2ea;
  border-radius: 8px;
}
.product-image-wrap .product-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 0;
  transform: scale(1);
  transform-origin: center;
  transition: transform 0.45s ease;
}

/* Only zoom on hover-capable pointers (desktop); touch devices always show the complete image. */
@media (hover: hover) and (pointer: fine) {
  .product-image-wrap:hover .product-image { transform: scale(1.4); }
}

.product-name { margin: 0; font-size: 1.05rem; color: var(--green-dark); }
.product-sku { margin: 0; font-size: 0.75rem; color: #888; }
.product-price { margin: 0; font-weight: 600; color: var(--green); }
.product-stock { margin: 0; font-size: 0.8rem; }
.product-stock.low { color: #b3541e; }
.product-stock.out { color: #b3261e; font-weight: 600; }
.product-description { margin: 4px 0; font-size: 0.85rem; color: #444; flex-grow: 1; }
.product-care summary { cursor: pointer; font-size: 0.8rem; color: var(--green); }
.care-text { font-size: 0.8rem; color: #555; }

.qty-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.qty-input { width: 60px; padding: 4px; }

.add-btn, .checkout-btn {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
}
.add-btn:hover, .checkout-btn:hover:not(:disabled) { background: var(--green-dark); }
.checkout-btn:disabled { background: #aab; cursor: not-allowed; }

.cart-panel {
  border-left: 1px solid var(--border);
  padding: 20px;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cart-items { list-style: none; margin: 0; padding: 0; }
.cart-items li {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.85rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.cart-items li.empty { color: #888; border-bottom: none; }
.cart-total { font-weight: 600; }

.delivery-fields { display: flex; flex-direction: column; gap: 4px; }
.delivery-fields label { font-size: 0.8rem; color: #555; margin-top: 6px; }
.delivery-fields input, .delivery-fields select {
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.checkout-message { font-size: 0.85rem; }
.checkout-message.error { color: #b3261e; }
.checkout-message.success { color: var(--green); }

@media (max-width: 1024px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 800px) {
  body { grid-template-columns: 1fr; }
  .cart-panel { border-left: none; border-top: 1px solid var(--border); }
}

@media (max-width: 640px) {
  .product-grid { grid-template-columns: repeat(1, 1fr); }
}
