:root {
  /* Paleta tomada del logo: crema + tinta oscura, sin verde. */
  --green-900: #211f1b; /* tinta (encabezados, texto fuerte) */
  --green-700: #211f1b; /* botones primarios */
  --green-600: #3a352e; /* hover de botones primarios */
  --green-100: #efe3cd; /* relleno suave (chips, franjas) */
  --cream: #f9f1e8; /* fondo, igual al fondo del logo */
  --cream-dark: #e6d9c3;
  --terracotta: #211f1b; /* botón flotante del carrito */
  --terracotta-dark: #211f1b; /* precios */
  --whatsapp: #25d366; /* verde oficial de WhatsApp: única excepción a la paleta monocroma */
  --whatsapp-dark: #1eb857;
  --ink: #211f1b;
  --muted: #7a7265;
  --radius: 14px;
  --shadow: 0 4px 16px rgba(33, 31, 27, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  background: var(--cream);
  color: var(--ink);
  border-bottom: 1px solid var(--cream-dark);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header .wrap {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding-top: 8px;
  padding-bottom: 8px;
  gap: 12px;
}
.header-spacer { grid-column: 1; }
.brand { grid-column: 2; justify-self: center; display: flex; align-items: center; gap: 10px; }
.cart-btn { grid-column: 3; justify-self: end; }
.brand-mark { font-size: 28px; }
.brand h1 { font-size: 20px; margin: 0; line-height: 1.1; }
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
/* El logo ya viene recortado y sin fondo (PNG transparente), así que se puede
   mostrar más chico en alto de header sin perder legibilidad. */
.brand-logo {
  width: auto;
  height: 76px;
  max-height: 76px;
  object-fit: contain;
}
@media (max-width: 480px) {
  .brand-logo { height: 64px; max-height: 64px; }
}
.brand.has-logo h1,
.brand.has-logo .tagline { display: none; }

.cart-btn {
  background: var(--green-700);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.cart-btn:hover { background: var(--green-600); }

.info-banner {
  background: var(--green-100);
  color: var(--green-900);
  font-size: 13px;
  padding: 8px 0;
  text-align: center;
}

/* Category tabs */
.sticky-bar {
  position: sticky;
  top: var(--header-height, 61px);
  background: var(--cream);
  z-index: 15;
  border-bottom: 1px solid var(--cream-dark);
}
.search-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px 0;
}
.search-input {
  width: 100%;
  font-family: inherit;
  font-size: 16px; /* 16px evita que iPhone haga zoom al tocar el campo */
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--cream-dark);
  background: white;
  color: var(--ink);
}
.search-input:focus { outline: 2px solid var(--green-600); outline-offset: 1px; }
.no-results {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}
.cat-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px;
  scrollbar-width: none;
}
.cat-tabs::-webkit-scrollbar { display: none; }
/* Cuando las categorías no entran en una fila, "justify-content: center" con
   scroll horizontal deja el contenido que se desborda a la izquierda
   inalcanzable (bug conocido de flexbox). En ese caso se alinea a la
   izquierda para que el scroll funcione normal y no tape ninguna categoría. */
.cat-tabs.scrollable { justify-content: flex-start; }
.cat-tab {
  flex: none;
  border: 1px solid var(--cream-dark);
  background: white;
  color: var(--green-900);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.cat-tab.active {
  background: var(--green-700);
  border-color: var(--green-700);
  color: white;
}

/* Catalog */
.category-section h2 {
  margin: 20px 0 2px;
  font-size: 20px;
  color: var(--green-900);
}
.category-section .cat-tagline {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.product-card {
  position: relative;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}
.product-emoji { font-size: 30px; line-height: 1; }
.loading-msg {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
}
.cart-item-image {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 6px;
}
.product-name { font-weight: 700; font-size: 15px; }
.product-unit { color: var(--ink); font-size: 12px; }
.product-note { color: var(--ink); font-size: 11px; font-style: italic; }
.product-contents {
  font-size: 12px;
  color: var(--green-700);
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
}
.product-bottom {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.product-price { font-weight: 700; color: var(--terracotta-dark); font-size: 15px; }

/* Producto agotado: atenuado, sin botón de agregar, con etiqueta. */
.product-card.sold-out > *:not(.product-bottom) { opacity: 0.55; }
.product-card.sold-out .product-price { opacity: 0.55; }
.product-card.sold-out.has-image > *:not(.product-bottom),
.product-card.sold-out.has-image .product-price { opacity: 0.8; }
.sold-out-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: #b3261e;
  color: white;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Tarjeta con foto de fondo: la imagen llena la tarjeta, un degradado oscuro
   abajo mantiene el texto legible, y el texto pasa a blanco. */
.product-card.has-image {
  min-height: 210px;
  justify-content: flex-end;
  background-size: cover;
  background-position: center;
}
.product-card.has-image::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(20, 17, 13, 0.88) 0%, rgba(20, 17, 13, 0.45) 45%, rgba(20, 17, 13, 0) 75%);
}
.product-card.sold-out.has-image::before {
  background: linear-gradient(to top, rgba(20, 17, 13, 0.9) 0%, rgba(20, 17, 13, 0.6) 100%);
}
.product-card.has-image > * {
  position: relative;
  z-index: 1;
}
.product-card.has-image .product-name,
.product-card.has-image .product-price { color: white; }
.product-card.has-image .product-unit,
.product-card.has-image .product-note { color: rgba(255, 255, 255, 0.85); }
.product-card.has-image .product-contents {
  color: white;
  text-decoration-color: rgba(255, 255, 255, 0.6);
}
.product-card.has-image .product-bottom { margin-top: 0; }
.product-card.has-image .add-btn { background: white; color: var(--ink); }
.product-card.has-image .add-btn:hover { background: #f0e9dc; }
.product-card.has-image .qty-controls { background: rgba(255, 255, 255, 0.9); }
.product-card.has-image .qty-controls .qty-value { color: var(--ink); }

.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-100);
  border-radius: 999px;
  padding: 4px;
}
.qty-controls button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--green-700);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qty-controls button:disabled { background: #ddd2bf; cursor: default; }
.qty-controls .qty-value { min-width: 18px; text-align: center; font-weight: 700; font-size: 14px; }

.add-btn {
  background: var(--green-700);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 6px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.add-btn:hover { background: var(--green-600); }

/* Floating cart button */
.fab-cart {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 25;
  background: var(--terracotta);
  color: white;
  border: none;
  border-radius: 50%;
  width: 58px;
  height: 58px;
  font-size: 24px;
  box-shadow: 0 6px 20px rgba(33, 31, 27, 0.3);
  cursor: pointer;
  display: none;
}
.fab-cart.visible { display: block; }
.fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--green-900);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 6px;
  min-width: 18px;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(33, 31, 27, 0.45);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.overlay.visible { opacity: 1; pointer-events: auto; }

/* Drawer */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 92vw);
  background: var(--cream);
  z-index: 31;
  transform: translateX(100%);
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
  display: flex;
  flex-direction: column;
  visibility: hidden;
}
.drawer.open { transform: translateX(0); visibility: visible; transition: transform 0.25s ease; }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--cream-dark);
}
.drawer-header h2 { margin: 0; font-size: 18px; color: var(--green-900); }
.icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}
.drawer-body { flex: 1; overflow-y: auto; padding: 12px 16px; }
.empty-cart { color: var(--muted); text-align: center; margin-top: 40px; }

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--cream-dark);
}
.cart-item-emoji { font-size: 22px; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 600; font-size: 14px; }
.cart-item-unit { font-size: 11px; color: var(--muted); }
.cart-item-line-total { font-size: 13px; color: var(--terracotta-dark); font-weight: 700; }
.cart-item-remove {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

.drawer-footer {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--cream-dark);
  background: white;
}
.free-shipping-note {
  font-size: 12px;
  color: var(--green-700);
  margin-bottom: 10px;
  text-align: center;
}
.box-return {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px dashed var(--cream-dark);
  border-radius: 12px;
  background: var(--cream);
  cursor: pointer;
}
.box-return[hidden] { display: none; }
.box-return input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex: none;
  accent-color: var(--ink);
  cursor: pointer;
}
.box-return strong { display: block; font-size: 14px; color: var(--ink); }
.box-return small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.discount-row { color: #2e7d32; }
.discount-row[hidden] { display: none; }
.totals-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--ink);
}
.totals-row.total {
  font-weight: 700;
  font-size: 17px;
  margin-top: 8px;
  color: var(--green-900);
}

.btn-primary {
  width: 100%;
  background: var(--green-700);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
}
.btn-primary:hover { background: var(--green-600); }
.btn-primary:disabled { background: #ddd2bf; cursor: default; }
.btn-whatsapp { background: var(--whatsapp); margin-top: 6px; }
.btn-whatsapp:hover { background: var(--whatsapp-dark); }
.btn-link {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 11px;
  background: white;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn-link:hover { background: var(--cream); }
.btn-link.armed { background: #b3261e; border-color: #b3261e; color: white; }
.btn-link[hidden] { display: none; }

/* Checkout modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 32;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0s linear 0.25s;
}
.modal.open { pointer-events: auto; visibility: visible; transition: none; }
.modal-card {
  background: var(--cream);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.modal.open .modal-card { transform: translateY(0); }

@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 18px; max-height: 85vh; }
}

#checkoutForm { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
#checkoutForm label {
  font-size: 13px;
  font-weight: 600;
  color: var(--green-900);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#checkoutForm input,
#checkoutForm select,
#checkoutForm textarea {
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d8cfbe;
  background: white;
  color: var(--ink);
}
#checkoutForm input:focus,
#checkoutForm select:focus,
#checkoutForm textarea:focus {
  outline: 2px solid var(--green-600);
}
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }

.site-footer {
  margin-top: 30px;
  padding: 20px 0 90px;
  text-align: center;
  color: var(--green-900);
}
.site-footer p { margin: 2px 0; }

/* Modal contents popup (canasta) */
.contents-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(33, 31, 27, 0.45);
  padding: 20px;
}
.contents-modal.visible { display: flex; }
.contents-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  max-width: 360px;
  max-height: 80vh;
  overflow-y: auto;
}
.contents-card h3 { margin-top: 0; color: var(--green-900); }
.contents-card ul { padding-left: 18px; margin: 10px 0; font-size: 14px; }
.contents-card button { margin-top: 10px; }
