/* =====================================================================
   TELOLOAPAN MEAT MARKET — Catálogo y carrito (prototipo)
   Depende de style.css: reutiliza sus tokens, botones, chips y campos.
   Sólo se animan `transform` y `opacity`.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. CABECERA DE LA TIENDA
   --------------------------------------------------------------------- */
.tienda-actions { display: flex; align-items: center; gap: var(--sp-3); flex: none; }

.cart-btn { position: relative; padding-right: 2.9rem; }
.cart-btn__count {
  position: absolute; right: .55rem; top: 50%;
  transform: translateY(-50%);
  min-width: 26px; height: 26px; padding: 0 .35rem;
  display: grid; place-items: center;
  background: #fff; color: var(--tmm-red);
  border-radius: var(--r-pill);
  font-size: .78rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: transform .3s var(--ease-out);
}
.cart-btn.is-bump .cart-btn__count { animation: bump .45s var(--ease-out); }
@keyframes bump {
  0%   { transform: translateY(-50%) scale(1); }
  40%  { transform: translateY(-50%) scale(1.35); }
  100% { transform: translateY(-50%) scale(1); }
}

/* ---------------------------------------------------------------------
   2. INTRO
   --------------------------------------------------------------------- */
.tienda-intro {
  background: var(--surface-2);
  padding-block: clamp(2.25rem, 1.5rem + 3vw, 4rem);
  border-bottom: 1px solid var(--line);
}
.tienda-intro__title {
  font-size: clamp(2rem, 1.3rem + 3vw, 3.5rem);
  letter-spacing: -.035em; line-height: 1.02;
}
.tienda-intro__title em {
  display: block; font-style: normal;
  font-family: var(--font-serif); font-weight: 600;
  font-variation-settings: "SOFT" 60, "WONK" 1;
  color: var(--tmm-red); letter-spacing: -.025em;
}
.tienda-intro__text {
  font-size: var(--fs-lead); color: var(--ink-2);
  margin-top: var(--sp-4); max-width: 58ch; line-height: 1.6;
}

.aviso-demo {
  display: flex; align-items: flex-start; gap: .65rem;
  margin-top: var(--sp-5);
  padding: .85rem 1.1rem;
  background: rgba(232,163,61,.13);
  border: 1px solid rgba(201,134,42,.35);
  border-radius: var(--r-md);
  font-size: var(--fs-sm); line-height: 1.55;
  color: var(--ink); max-width: 68ch;
}
.aviso-demo svg { width: 19px; height: 19px; flex: none; color: var(--tmm-amber-600); margin-top: .1rem; }
.aviso-demo strong { font-weight: 700; }

/* ---------------------------------------------------------------------
   3. HERRAMIENTAS DEL CATÁLOGO
   --------------------------------------------------------------------- */
.tienda-tools { display: grid; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.tienda-conteo {
  font-size: var(--fs-2xs); color: var(--ink-3);
  letter-spacing: .1em; text-transform: uppercase; font-weight: 600;
  margin-bottom: var(--sp-4);
}

/* ---------------------------------------------------------------------
   4. REJILLA DE PRODUCTOS
   --------------------------------------------------------------------- */
.productos {
  display: grid; gap: clamp(.75rem, .4rem + 1vw, 1.25rem);
  grid-template-columns: repeat(2, 1fr);
}
.producto {
  display: flex; flex-direction: column;
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out),
              border-color .3s var(--ease);
}
.producto:hover { transform: translateY(-5px); box-shadow: var(--sh-3); border-color: transparent; }
.producto.is-hidden { display: none; }
.producto.en-carrito { border-color: var(--tmm-green); }

.producto__media { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--surface-3); }
.producto__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .7s var(--ease-out); }
.producto:hover .producto__media img { transform: scale(1.07); }

.producto__cat {
  position: absolute; top: .6rem; left: .6rem;
  font-family: var(--font-display); font-size: .62rem; font-weight: 800;
  letter-spacing: .14em; text-transform: uppercase;
  padding: .3rem .6rem; border-radius: var(--r-pill);
  background: rgba(255,255,255,.94); color: var(--ink-2);
}
.producto__cat--fruta { color: var(--tmm-red); }
.producto__cat--verdura { color: var(--tmm-green-600); }

.producto__body {
  padding: clamp(.75rem, .6rem + .5vw, 1.1rem);
  display: flex; flex-direction: column; gap: .3rem; flex: 1;
}
.producto__nombre {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1rem; line-height: 1.2; letter-spacing: -.018em;
}
.producto__unidad { font-size: var(--fs-2xs); color: var(--ink-3); }
.producto__precio {
  font-family: var(--font-display); font-weight: 800;
  font-size: 1.45rem; line-height: 1; color: var(--tmm-red);
  letter-spacing: -.04em; font-variant-numeric: tabular-nums;
  margin-top: .35rem;
}

.producto__accion { margin-top: auto; padding-top: .7rem; }
.producto__add {
  width: 100%; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border-radius: var(--r-pill);
  background: var(--tmm-green); color: #fff;
  font-family: var(--font-display); font-weight: 700;
  font-size: .8rem; letter-spacing: .05em; text-transform: uppercase;
  transition: background-color .25s var(--ease), transform .2s var(--ease);
}
.producto__add:hover { background: var(--tmm-green-600); }
.producto__add:active { transform: scale(.97); }
.producto__add svg { width: 16px; height: 16px; }

/* Selector de cantidad dentro de la tarjeta */
.stepper {
  display: flex; align-items: center; justify-content: space-between;
  gap: .4rem; min-height: 44px;
  border: 2px solid var(--tmm-green);
  border-radius: var(--r-pill);
  padding: 0 .3rem;
}
.stepper__btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; color: var(--tmm-green-600);
  transition: background-color .2s var(--ease);
}
.stepper__btn:hover { background: rgba(30,131,67,.12); }
.stepper__btn svg { width: 15px; height: 15px; }
.stepper__valor {
  font-family: var(--font-display); font-weight: 800;
  font-size: 1rem; font-variant-numeric: tabular-nums;
  min-width: 2ch; text-align: center;
}

.productos__vacio {
  display: none; text-align: center;
  padding: var(--sp-8) var(--sp-4);
  color: var(--ink-2);
  background: var(--surface-card);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
}
.productos__vacio.is-visible { display: block; }

/* ---------------------------------------------------------------------
   5. CARRITO
   --------------------------------------------------------------------- */
.cart-backdrop {
  position: fixed; inset: 0; z-index: 940;
  background: rgba(12,9,8,.5);
  opacity: 0; transition: opacity .35s var(--ease);
}
.cart-backdrop.is-visible { opacity: 1; }

.cart {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 950;
  width: min(430px, 100%);
  display: flex; flex-direction: column;
  background: var(--surface);
  box-shadow: -10px 0 40px rgba(40,26,18,.22);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .4s var(--ease-out), visibility .4s;
}
.cart.is-open { transform: translateX(0); visibility: visible; }

.cart__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.cart__title { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; letter-spacing: -.028em; }
.cart__close {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2);
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
.cart__close:hover { background: var(--surface-3); color: var(--ink); }
.cart__close svg { width: 19px; height: 19px; }

.cart__body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--sp-5);
  padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom, 0px));
}

.cart__vacio {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-4);
  text-align: center; color: var(--ink-2);
  padding: var(--sp-8) var(--sp-3);
  font-size: var(--fs-sm); line-height: 1.6;
}
.cart__vacio svg { width: 46px; height: 46px; color: var(--line-strong); }
.cart__vacio[hidden] { display: none; }

.cart__list { display: grid; gap: .6rem; }

.cart-item {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: .75rem; align-items: center;
  padding: .6rem;
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.cart-item__img {
  width: 62px; height: 62px; border-radius: var(--r-sm);
  object-fit: cover; background: var(--surface-3);
}
.cart-item__body { min-width: 0; }
.cart-item__nombre {
  font-family: var(--font-display); font-weight: 700;
  font-size: .92rem; line-height: 1.2; letter-spacing: -.015em;
}
.cart-item__unidad { font-size: var(--fs-2xs); color: var(--ink-3); margin-top: .1rem; }
.cart-item__precio {
  font-size: var(--fs-2xs); color: var(--ink-2); margin-top: .2rem;
  font-variant-numeric: tabular-nums;
}
.cart-item__der { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }
.cart-item__total {
  font-family: var(--font-display); font-weight: 800;
  font-size: 1rem; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.cart-item__stepper {
  display: flex; align-items: center; gap: .15rem;
  border: 1px solid var(--line-2); border-radius: var(--r-pill);
  padding: .1rem;
}
.cart-item__stepper button {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 50%; color: var(--ink-2);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.cart-item__stepper button:hover { background: var(--surface-2); color: var(--tmm-red); }
.cart-item__stepper svg { width: 13px; height: 13px; }
.cart-item__stepper span {
  min-width: 2ch; text-align: center;
  font-family: var(--font-display); font-weight: 700; font-size: .85rem;
  font-variant-numeric: tabular-nums;
}

/* Resumen */
.cart__resumen {
  margin-top: var(--sp-5); padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}
.cart__linea {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-4); font-size: var(--fs-sm); color: var(--ink-2);
  padding-block: .2rem;
}
.cart__linea--total {
  margin-top: .4rem; padding-top: .6rem;
  border-top: 1px dashed var(--line-2);
  font-family: var(--font-display); font-weight: 800;
  font-size: 1.2rem; color: var(--ink); letter-spacing: -.02em;
}
.cart__linea--total span:last-child { color: var(--tmm-red); font-variant-numeric: tabular-nums; }
.cart__nota { font-size: var(--fs-2xs); color: var(--ink-3); margin-top: .5rem; line-height: 1.5; }

/* Formulario */
.cart__form { margin-top: var(--sp-6); display: grid; gap: var(--sp-4); }
.cart__subtitulo {
  font-family: var(--font-display); font-size: var(--fs-2xs); font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3);
}
.cart__form select {
  width: 100%; padding: .9rem 1.1rem; min-height: 52px;
  background: var(--surface-card);
  border: 2px solid var(--line-2);
  border-radius: var(--r-md);
  font-size: .95rem;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}
.cart__form select:focus {
  outline: none; border-color: var(--tmm-green);
  box-shadow: 0 0 0 4px rgba(30,131,67,.14);
}
.cart__legal { font-size: var(--fs-2xs); color: var(--ink-3); text-align: center; line-height: 1.5; }

/* Confirmación */
.cart__ok { text-align: center; padding-top: var(--sp-5); }
.cart__ok-icono {
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; margin: 0 auto var(--sp-4);
  background: rgba(30,131,67,.14); color: var(--tmm-green);
}
.cart__ok-icono svg { width: 28px; height: 28px; }
.cart__ok h3 { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em; }
.cart__ok p { font-size: var(--fs-sm); color: var(--ink-2); margin-top: .6rem; line-height: 1.6; }
.cart__aviso-largo {
  margin-top: .6rem !important;
  padding: .75rem 1rem;
  background: rgba(232,163,61,.15);
  border: 1px solid rgba(201,134,42,.4);
  border-radius: var(--r-md);
  color: var(--ink) !important;
  font-size: var(--fs-sm); line-height: 1.55;
}
.cart__aviso-largo[hidden] { display: none; }

.cart__ok textarea {
  width: 100%; margin-top: var(--sp-4);
  padding: .85rem 1rem;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--surface-card);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .76rem; line-height: 1.5; resize: vertical;
}
.cart__ok-acciones { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); }
.cart__ok-acciones .btn { flex: 1; }

/* ---------------------------------------------------------------------
   6. BARRA INFERIOR (móvil)
   --------------------------------------------------------------------- */
.cart-bar {
  position: fixed; left: 0; right: 0; z-index: 830;
  bottom: 0;
  display: none; align-items: center; justify-content: space-between;
  gap: var(--sp-4);
  padding: .9rem clamp(1rem, .6rem + 2vw, 1.5rem);
  padding-bottom: calc(.9rem + env(safe-area-inset-bottom, 0px));
  background: var(--tmm-green); color: #fff;
  font-family: var(--font-display); font-weight: 700;
  font-size: .9rem; letter-spacing: .03em;
  box-shadow: 0 -6px 24px rgba(40,26,18,.22);
  transform: translateY(100%);
  transition: transform .35s var(--ease-out);
}
.cart-bar.is-visible { transform: translateY(0); }
.cart-bar__izq, .cart-bar__der { display: inline-flex; align-items: center; gap: .5rem; }
.cart-bar svg { width: 19px; height: 19px; }
.cart-bar__der { font-variant-numeric: tabular-nums; font-size: 1.05rem; }

/* ---------------------------------------------------------------------
   7. RESPONSIVE
   --------------------------------------------------------------------- */
@media (max-width: 767px) {
  /* El botón del header se reduce a icono para dejar sitio */
  .cart-btn span[data-en="Cart"] { display: none; }
  .cart-btn { padding: .62rem .8rem; padding-right: 2.4rem; }
  .tienda-actions .btn--outline span { display: none; }
  .tienda-actions .btn--outline { padding: .62rem .8rem; }

  .cart-bar { display: flex; }
  /* Sitio para la barra inferior */
  body { padding-bottom: 72px; }
  .cart { width: 100%; }
}

@media (min-width: 560px) {
  .productos { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
  .tienda-tools { grid-template-columns: minmax(260px, 400px) 1fr; align-items: center; }
  .productos { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .productos { grid-template-columns: repeat(4, 1fr); }
  .cart__body { padding: var(--sp-6); }
}
@media (min-width: 1280px) {
  .productos { grid-template-columns: repeat(5, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .cart, .cart-backdrop, .cart-bar, .producto, .producto__media img { transition: none; }
  .cart-btn.is-bump .cart-btn__count { animation: none; }
}
