/* Tienda — layout mobile-first. DESIGN.md §6. */

.h3 { font-size: var(--fs-lg); display: flex; align-items: center; gap: var(--s-2); }

/* ------------------------------------------------------------ encabezado */
/* Móvil: logo + íconos en una fila; debajo, el bloque de entrega en 2 líneas.
   Escritorio (≥ 1024px): logo · entrega · navegación en una sola fila. */
.shop-header { background: var(--surface); border-bottom: 1px solid var(--border); }
@media (min-width: 720px) {
  .shop-header { position: sticky; top: 0; z-index: 20; }
  html { scroll-padding-top: calc(var(--header-h) + 72px); } /* el foco no queda bajo encabezado + buscador fijos */
}
.header-inner { max-width: 1280px; margin: 0 auto; padding: 6px var(--s-4) 8px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand nav" "delivery delivery"; align-items: center; column-gap: var(--s-3); }
.header-inner .brand-lockup { grid-area: brand; }
.shop-header .brand-lockup img { height: 40px; }
.shop-header .brand-lockup .brand-name { font-size: 1rem; }
.shop-header .brand-lockup .brand-name small { font-size: 0.75rem; }

.shop-nav { grid-area: nav; display: flex; gap: 2px; margin-right: -6px; }
.shop-nav a {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; height: 44px; padding: 0 var(--s-2);
  border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: var(--fs-sm);
}
.shop-nav a:hover { background: var(--surface-2); color: var(--ink); }
.shop-nav a[aria-current="page"] { color: var(--primary); background: var(--primary-tint); }
.shop-nav svg { width: 22px; height: 22px; flex: none; }
.nav-count { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--primary); color: var(--on-primary); font-size: 0.6875rem; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }

.delivery { grid-area: delivery; display: grid; gap: 0; margin-top: 4px; padding: 4px 10px; border-radius: var(--r-sm); background: var(--surface-2); min-width: 0; }
.delivery-line {
  display: flex; align-items: center; gap: 6px; width: 100%; min-height: 32px; margin: 0; padding: 0;
  border: 0; background: none; text-align: left; font-size: var(--fs-sm); line-height: 1.3; color: var(--ink); min-width: 0;
}
/* La dirección se recorta con …; el estado del despacho puede pasar a 2 líneas (no se pierde información). */
.delivery-line > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delivery-line.cycle-status { align-items: flex-start; padding: 6px 0; }
.delivery-line.cycle-status svg:first-child { margin-top: 1px; }
.delivery-line.cycle-status > span { white-space: normal; text-wrap: pretty; }
button.delivery-line { cursor: pointer; border-radius: 8px; }
button.delivery-line:hover > span { text-decoration: underline; text-underline-offset: 3px; }
.delivery-line svg { width: 16px; height: 16px; flex: none; color: var(--primary); }
.delivery-line svg:last-child:not(:first-child) { margin-left: auto; color: var(--ink-2); }
.cycle-status { font-weight: 600; }
.cycle-status.tone-ok, .cycle-status.tone-ok svg { color: var(--primary); }
.cycle-status.tone-warn, .cycle-status.tone-warn svg { color: var(--approx); }
.cycle-status.tone-info, .cycle-status.tone-info svg { color: var(--info); }
.cycle-status.tone-danger, .cycle-status.tone-danger svg { color: var(--danger); }

/* Solo íconos en móvil y en escritorio angosto (1024–1279px), donde la entrega comparte la fila. */
@media (max-width: 719px), (min-width: 1024px) and (max-width: 1279px) {
  .shop-nav span:not(.nav-count) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .shop-nav a { padding: 0; }
}
@media (min-width: 1024px) {
  .header-inner { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "brand delivery nav"; padding: 8px var(--s-4); column-gap: var(--s-5); }
  .shop-header .brand-lockup img { height: 48px; }
  .shop-header .brand-lockup .brand-name { font-size: 1.125rem; }
  .delivery { margin-top: 0; grid-auto-flow: column; justify-content: start; column-gap: var(--s-5); padding: 4px 14px; background: transparent; border-left: 1px solid var(--border); border-radius: 0; }
  .delivery-line { width: auto; }
  .delivery-line svg:last-child:not(:first-child) { margin-left: 0; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  .delivery { grid-auto-flow: row; }
  .delivery-line { min-height: 26px; }
  .delivery-line.cycle-status { padding: 2px 0; }
}

/* ----------------------------------------------------------------- layout */
.shop-layout { max-width: 1280px; margin: 0 auto; padding: var(--s-3) var(--s-4) var(--s-7); display: grid; gap: var(--s-5); }
main { min-width: 0; outline: none; }
.cart-aside { display: none; }
@media (min-width: 1024px) {
  body[data-route="/"] .shop-layout { grid-template-columns: minmax(0, 1fr) 320px; }
  body[data-route="/"] .cart-aside { display: block; }
  .aside-card { position: sticky; top: calc(var(--header-h) + var(--s-4)); max-height: calc(100dvh - var(--header-h) - 32px); overflow-y: auto; }
}
.page-narrow { max-width: 760px; margin: 0 auto; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 700; text-decoration: none; }
.back svg { width: 18px; height: 18px; }
.bullets { padding-left: 1.2em; }

/* --------------------------------------------------------------- catálogo */
.catalog-intro { display: grid; gap: var(--s-2); }
.catalog-intro:has(.notice) { margin-bottom: var(--s-3); }
.catalog-tools { background: var(--bg); padding: 0 0 var(--s-2); margin-bottom: var(--s-2); display: grid; gap: var(--s-2); }
/* Chips a todo el ancho en móvil; el relleno vertical deja ver el anillo de foco. */
.catalog-tools .chips { margin: -4px calc(var(--s-4) * -1) 0; padding: 4px var(--s-4); scroll-padding-inline: var(--s-4); }
@media (min-width: 720px) { .catalog-tools { position: sticky; top: var(--header-h); z-index: 10; padding-top: var(--s-2); } }
@media (min-width: 1024px) {
  .catalog-tools { grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); align-items: center; gap: var(--s-3); }
  .catalog-tools .chips { margin: -4px 0 0; padding: 4px 2px; }
}
.search { position: relative; display: block; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 44px; }
.category { margin-top: var(--s-5); }
.featured + .category, #catalog-results > .category:first-child { margin-top: var(--s-4); }
.category-title { font-size: var(--fs-xl); margin-bottom: var(--s-3); }
.results-count { margin-bottom: var(--s-2); }

/* Tarjeta de producto: foto 1:1 arriba, luego nombre, presentación, precio y acción.
   Referencia: referencias/tarjeta-objetivo.png. DESIGN.md §6. */
.section-head { margin-bottom: var(--s-3); }
.section-head .category-title { margin-bottom: 0; }
@media (max-width: 599px) { .category-title { font-size: 1.25rem; } }
.link-btn { min-height: 44px; padding: 0 var(--s-1); border: 0; background: none; color: var(--primary); font-weight: 600; font-size: var(--fs-sm);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; white-space: nowrap; }
.link-btn:hover { color: var(--primary-hover); }

.product-grid { display: grid; gap: var(--s-3) 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 600px) { .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4) var(--s-3); } }
@media (min-width: 1280px) { .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.product { display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  scroll-margin-top: calc(var(--header-h) + 120px); }
.product-media { position: relative; }
.product-img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; background: var(--surface-2); }

.product-flags { position: absolute; top: 8px; left: 8px; right: 52px; display: flex; flex-wrap: wrap; gap: 4px; pointer-events: none; }
.product-flags .badge, .badge-frequent { font-size: 0.75rem; padding: 1px 8px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.product-flags .badge svg { width: 12px; height: 12px; }
.badge-frequent { position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis;
  background: var(--surface); color: var(--ink); pointer-events: none; }
.fav { position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer; touch-action: manipulation; }
.fav::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16); }
.fav svg { position: relative; width: 18px; height: 18px; }
.fav:hover { color: var(--ink); }
.fav[aria-pressed="true"] { color: var(--danger); }

.product-body { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 12px; min-width: 0; }
.product-name { font-size: 1rem; font-weight: 700; line-height: 1.25; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pres-label { font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.4; overflow-wrap: anywhere; }
.pres-select { display: block; margin: 2px 0; }
.pres-select .select { height: 36px; min-height: 36px; padding: 0 28px 0 8px; border-width: 1px; border-color: var(--border-strong);
  border-radius: 8px; font-size: var(--fs-sm); color: var(--ink-2); text-overflow: ellipsis; }

.price-inline { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 4px; line-height: 1.2; }
.price-inline .amount { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.25rem; color: var(--ink); }
.price-inline .prefix { font-size: var(--fs-xs); font-weight: 700; color: var(--approx); }
.price-inline .basis { flex-basis: 100%; font-size: 0.75rem; color: var(--approx); }

.product-action { margin-top: auto; padding-top: var(--s-2); }
.btn-add { width: 100%; min-height: 44px; padding: 0 var(--s-2); font-size: var(--fs-sm); }
.btn-add svg { width: 18px; height: 18px; }
.stepper-block { display: flex; width: 100%; justify-content: space-between; }
.stepper-block button { width: 44px; height: 40px; }

/* ------------------------------------------------------------ carrito bar */
.cart-bar {
  position: fixed; left: var(--s-3); right: var(--s-3); bottom: calc(var(--s-3) + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: 0 var(--s-4);
  background: var(--primary); color: var(--on-primary); border-radius: var(--r-md); text-decoration: none; box-shadow: var(--shadow);
}
.cart-bar:hover { background: var(--primary-hover); color: var(--on-primary); }
.cart-bar svg { width: 24px; height: 24px; flex: none; }
.cart-bar .num { font-weight: 700; font-size: var(--fs-lg); white-space: nowrap; }
body.has-cart-bar .shop-layout { padding-bottom: 104px; }
@media (min-width: 1024px) { body[data-route="/"] .cart-bar { display: none; } body[data-route="/"].has-cart-bar .shop-layout { padding-bottom: var(--s-7); } }

.aside-lines { list-style: none; display: grid; gap: 6px; max-height: 40vh; overflow-y: auto; font-size: var(--fs-sm); }
.aside-lines li { display: flex; gap: var(--s-2); }

/* ---------------------------------------------------------------- carrito */
.cart-lines { list-style: none; display: grid; gap: var(--s-3); }
.cart-line { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--s-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3); }
.cart-line img { border-radius: var(--r-sm); background: var(--surface-2); }
.cart-line-body { display: grid; gap: var(--s-2); min-width: 0; }
.cart-line-controls { align-items: center; }
.line-amount { font-weight: 700; white-space: nowrap; }

.summary-lines { list-style: none; display: grid; gap: 6px; }
.summary-lines li { display: flex; gap: var(--s-3); justify-content: space-between; border-bottom: 1px dashed var(--border); padding-bottom: 6px; }
.summary-lines .num { white-space: nowrap; }

.option-card { display: grid; gap: 4px; width: 100%; text-align: left; padding: var(--s-3) var(--s-4); min-height: var(--tap);
  border: 2px solid var(--border); border-radius: var(--r-md); background: var(--surface); cursor: pointer; }
.option-card:hover { border-color: var(--border-strong); }
.option-card[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-tint); }

/* ---------------------------------------------------------------- pedidos */
.repeat-grid { list-style: none; display: grid; gap: var(--s-3); }
@media (min-width: 720px) { .repeat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.order-list { list-style: none; display: grid; gap: var(--s-2); }
.order-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-3) var(--s-4); min-height: var(--tap);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--ink); text-decoration: none; }
.order-row:hover { border-color: var(--border-strong); color: var(--ink); }
.order-row svg { width: 20px; height: 20px; color: var(--ink-3); }
.order-items { list-style: none; display: grid; gap: var(--s-2); }
.order-item { display: grid; gap: 4px; padding-bottom: var(--s-2); border-bottom: 1px dashed var(--border); }
.order-item .num { white-space: nowrap; }
.order-item > .row-between, .cart-line-body > .row-between { flex-wrap: nowrap; align-items: flex-start; }

.rebase-list { list-style: none; display: grid; gap: var(--s-3); }
.rebase-row { display: grid; gap: var(--s-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); }
.rebase-row.is-off { background: var(--surface-2); }
.rebase-row .check span { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }

@media print {
  .demo-bar, .shop-header, .cart-bar, .cart-aside { display: none !important; }
}
