/* ==========================================================================
   Tienda del cliente · modo "Operar": escaneable, rápida, con el pulgar.
   El color de marca del negocio entra por --accent desde config.js.
   ========================================================================== */

body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

.intro, .cats, .grid, .foot {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Barra superior: material translúcido ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--canvas) 78%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}
.top__in {
  max-width: 1200px;
  margin-inline: auto;
  padding: 10px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand__mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.02em;
}
.brand__name {
  font-weight: 620;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t-ui) var(--ease-out), transform var(--t-ui) var(--ease-out);
}
.top.is-scrolled .brand__name { opacity: 1; transform: none; }

.cart-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--hairline);
  font-weight: 560;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out);
}
.cart-btn i { font-size: 1.25rem; }
.cart-btn:active { transform: scale(0.96); }
.badge {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.75rem;
  font-weight: 650;
}
.badge[hidden] { display: none; }

/* ---------- Introducción ---------- */
.intro { padding-top: clamp(16px, 4vw, 40px); padding-bottom: 8px; }
.intro h1 {
  font-size: clamp(2rem, 6vw, 3.25rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 680;
  max-width: 16ch;
}
.intro__lead { margin: 12px 0 0; color: var(--ink-2); font-size: 1.0625rem; max-width: 52ch; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 20px 0 0; padding: 0; }
.meta li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hairline);
  font-size: 0.8125rem;
  font-weight: 520;
  color: var(--ink-2);
}
.meta i { font-size: 1rem; }
.meta .is-open { color: var(--accent-soft-ink); background: var(--accent-soft); box-shadow: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.meta small { color: var(--ink-3); font-weight: 450; font-size: inherit; }

.search { position: relative; margin-top: 24px; max-width: 560px; }
.search i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 1.2rem; color: var(--ink-3); pointer-events: none; }
.search__input { padding-left: 46px; border-radius: var(--r-pill); min-height: 52px; }
.search__input::-webkit-search-cancel-button { cursor: pointer; }

/* ---------- Categorías ---------- */
.cats {
  position: sticky;
  top: 64px;
  z-index: 15;
  padding-top: 12px;
  padding-bottom: 12px;
  background: color-mix(in srgb, var(--canvas) 78%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}
/* Borde de desplazamiento: una sombra suave solo cuando hay contenido debajo */
.cats::after {
  content: "";
  position: absolute;
  inset: 100% 0 auto;
  height: 16px;
  background: linear-gradient(color-mix(in srgb, var(--canvas) 70%, transparent), transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-ui) ease;
}
.is-scrolled .cats::after, .cats.is-stuck::after { opacity: 1; }
.cats__track {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--gutter);
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
  mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent);
}
.cats__track::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  font-size: 0.9rem;
  font-weight: 540;
  cursor: pointer;
  scroll-snap-align: start;
  box-shadow: inset 0 0 0 1px var(--hairline-strong);
  transition: background-color var(--t-fast) ease, color var(--t-fast) ease, box-shadow var(--t-fast) ease, transform var(--t-press) var(--ease-out);
}
.chip i { font-size: 1.1rem; }
.chip:active { transform: scale(0.96); }
.chip[aria-selected="true"] { background: var(--ink); color: var(--canvas); box-shadow: none; }
.chip .n { font-size: 0.75rem; opacity: 0.6; }
@media (hover: hover) and (pointer: fine) {
  .chip:not([aria-selected="true"]):hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-3); }
}

/* ---------- Productos ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-top: 8px;
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; } }

.section-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 32px 0 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  font-weight: 640;
}
.section-title:first-child { margin-top: 12px; }
.section-title span { font-size: 0.875rem; font-weight: 450; color: var(--ink-3); letter-spacing: 0; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
/* Entrada escalonada al filtrar: corta y sutil (se ve decenas de veces) */
.card.is-entering { animation: card-in var(--t-ui) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms); }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } }

.media {
  position: relative;
  aspect-ratio: 1;
  margin: 6px 6px 0;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  isolation: isolate;
}
/* Esqueleto mientras carga la foto */
.media::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(100deg, #f1f2ef 30%, #e6e8e3 50%, #f1f2ef 70%);
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
.media.is-loaded::before, .media.is-fallback::before { animation: none; opacity: 0; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12%;
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 240ms ease, transform 300ms var(--ease-out);
}
.media.is-loaded img { opacity: 1; transform: none; }
.media__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2.6rem;
  color: var(--ink-3);
  background: var(--surface-2);
}
.card.is-off .media img { filter: grayscale(1); opacity: 0.45; }
.tag {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(13, 15, 12, 0.8);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
}

.card__body { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 14px; flex: 1; }
.card__name { font-size: 0.95rem; font-weight: 560; line-height: 1.3; letter-spacing: -0.01em; }
.card__detail { font-size: 0.8125rem; color: var(--ink-3); }
.card__price { margin-top: auto; padding-top: 10px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card__price b { font-size: 1.125rem; font-weight: 660; letter-spacing: -0.02em; }
.card__price small { font-size: 0.78rem; color: var(--ink-3); }
.card__action { margin-top: 12px; height: 40px; }

.add {
  width: 100%;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 580;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-fast) ease, color var(--t-fast) ease;
}
.add i { font-size: 1.05rem; }
.add:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) { .add:not([disabled]):hover { background: var(--accent); color: var(--accent-ink); } }
.add[disabled] { cursor: not-allowed; color: var(--ink-3); background: transparent; box-shadow: inset 0 0 0 1px var(--hairline); }

.stepper {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  height: 40px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 640;
  text-align: center;
}
.stepper.is-new { animation: morph var(--t-fast) var(--ease-out); }
@keyframes morph { from { opacity: 0.5; transform: scale(0.97); } }
.stepper button {
  height: 40px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-fast) ease;
}
.stepper button:active { transform: scale(0.88); }
@media (hover: hover) and (pointer: fine) { .stepper button:hover { background: rgba(255, 255, 255, 0.16); } }

/* Estado vacío de la búsqueda */
.none { grid-column: 1 / -1; display: grid; justify-items: center; text-align: center; gap: 8px; padding: 56px 16px; color: var(--ink-2); }
.none i { font-size: 2.5rem; color: var(--ink-3); }
.none h3 { font-size: 1.125rem; color: var(--ink); letter-spacing: -0.01em; }
.none p { margin: 0 0 8px; }

.foot { padding-top: 56px; padding-bottom: 24px; display: grid; gap: 4px; font-size: 0.8125rem; color: var(--ink-3); }
.foot p { margin: 0; }
.foot a { font-weight: 600; color: var(--ink-2); }

/* ---------- Dock del pedido (móvil) ---------- */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  pointer-events: none;
  transform: translateY(110%);
  transition: transform var(--t-sheet) var(--ease-drawer);
}
.dock.is-visible { transform: none; }
.dock.is-visible .dock__btn { pointer-events: auto; }
.dock__btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
  height: 60px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--canvas);
  font-weight: 600;
  font-size: 0.975rem;
  box-shadow: var(--shadow-3);
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out);
}
.dock__btn:active { transform: scale(0.98); }
.dock__count { display: grid; place-items: center; min-width: 44px; height: 44px; padding: 0 10px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink); }
.dock__total { margin-left: auto; padding: 0 16px; }
@media (min-width: 900px) { .dock { display: none; } body { padding-bottom: 0; } }

/* ---------- Hoja del pedido ---------- */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 560px;
  max-height: min(92dvh, 900px);
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-3);
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform var(--t-sheet) var(--ease-drawer);
}
.sheet[open] { display: flex; }
.sheet.is-open { transform: translateY(0); }
.sheet.is-dragging { transition: none; }
.sheet::backdrop {
  background: rgba(8, 12, 9, 0.44);
  opacity: 0;
  transition: opacity var(--t-sheet) var(--ease-drawer);
}
.sheet.is-open::backdrop { opacity: 1; }

@media (min-width: 900px) {
  .sheet {
    inset: 0 0 0 auto;
    width: 440px;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 24px 0 0 24px;
    transform: translateX(100%);
  }
  .sheet.is-open { transform: translateX(0); }
  .sheet__handle { display: none; }
}

.sheet__grab { flex: none; padding: 8px 20px 12px; touch-action: none; cursor: grab; user-select: none; }
.sheet.is-dragging .sheet__grab { cursor: grabbing; }
@media (min-width: 900px) { .sheet__grab { cursor: default; padding-top: 20px; } }
.sheet__handle { display: block; width: 40px; height: 5px; margin: 0 auto 12px; border-radius: 99px; background: var(--hairline-strong); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; }
.sheet__head h2 { font-size: 1.375rem; letter-spacing: -0.025em; font-weight: 660; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-3);
  font-size: 1.15rem;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out);
}
.icon-btn:active { transform: scale(0.92); }

.sheet__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 20px 20px; }
.sheet__foot {
  flex: none;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--hairline);
}
.sheet__foot[hidden] { display: none; }

.view[hidden] { display: none; }
.view.is-entering { animation: view-in var(--t-ui) var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

.lines { list-style: none; margin: 0; padding: 0; }
.line { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; }
.line + .line { box-shadow: 0 -1px 0 var(--hairline); }
.line__img { width: 56px; height: 56px; border-radius: 12px; background: #fff; object-fit: contain; padding: 6px; box-shadow: inset 0 0 0 1px var(--hairline); }
.line__img--none { display: grid; place-items: center; background: var(--surface-2); font-size: 1.5rem; color: var(--ink-3); }
.line__name { font-size: 0.925rem; font-weight: 560; line-height: 1.3; }
.line__sub { font-size: 0.8125rem; color: var(--ink-3); }
.line__right { display: grid; justify-items: end; gap: 6px; }
.line__right b { font-size: 0.95rem; font-weight: 620; }
.mini-step { display: inline-grid; grid-template-columns: 32px 24px 32px; align-items: center; height: 32px; border-radius: var(--r-pill); box-shadow: inset 0 0 0 1px var(--hairline-strong); text-align: center; font-size: 0.875rem; font-weight: 600; }
.mini-step button { height: 32px; border: 0; background: transparent; cursor: pointer; border-radius: var(--r-pill); font-size: 0.95rem; transition: transform var(--t-press) var(--ease-out); }
.mini-step button:active { transform: scale(0.85); }

.totals { margin: 8px 0 28px; padding: 16px; border-radius: var(--r-md); background: var(--surface-2); display: grid; gap: 6px; font-size: 0.9rem; }
.totals div { display: flex; justify-content: space-between; color: var(--ink-2); }
.totals .grand { color: var(--ink); font-size: 1.25rem; font-weight: 680; letter-spacing: -0.02em; padding-top: 10px; margin-top: 4px; box-shadow: 0 -1px 0 var(--hairline); }
.totals .bs { color: var(--ink-3); font-size: 0.8125rem; }

.group { border: 0; margin: 0; padding: 0; display: grid; gap: 16px; min-width: 0; }
.group__title { padding: 0; margin-bottom: 4px; font-size: 1rem; font-weight: 640; letter-spacing: -0.01em; }
.opt { font-weight: 450; color: var(--ink-3); }

/* Selector segmentado (delivery / retiro) */
.seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; border-radius: var(--r-pill); background: var(--surface-3); }
.seg[hidden] { display: none; }
.seg__pill { position: absolute; top: 4px; bottom: 4px; left: 4px; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow-1); transition: transform var(--t-ui) var(--ease-in-out); }
.seg label { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 6px; height: 44px; font-size: 0.875rem; font-weight: 560; color: var(--ink-2); cursor: pointer; transition: color var(--t-fast) ease; }
.seg label:has(input:checked) { color: var(--ink); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-pill); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg i { font-size: 1.1rem; }

.link-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 24px; padding: 8px 0; border: 0; background: none; color: var(--ink-3); font-size: 0.875rem; cursor: pointer; transition: color var(--t-fast) ease; }
@media (hover: hover) and (pointer: fine) { .link-btn:hover { color: var(--danger); } }

.btn--wa { min-height: 56px; font-size: 1rem; justify-content: flex-start; padding-left: 20px; }
.btn--wa i { font-size: 1.35rem; }
.btn--wa__total { margin-left: auto; opacity: 0.9; }

.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 32px 8px 16px; }
.empty__icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--surface-2); font-size: 2rem; color: var(--ink-3); margin-bottom: 8px; }
.empty h3 { font-size: 1.25rem; letter-spacing: -0.02em; }
.empty p { margin: 0 0 12px; color: var(--ink-2); max-width: 34ch; }

/* Momento de logro: el check se dibuja una sola vez */
.done__check { width: 72px; height: 72px; margin-bottom: 8px; }
.done__check circle { fill: var(--accent-soft); transform-origin: center; animation: pop 360ms var(--ease-out) both; }
.done__check path { fill: none; stroke: var(--accent-soft-ink); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 36; stroke-dashoffset: 36; animation: draw 420ms var(--ease-out) 160ms forwards; }
@keyframes pop { from { transform: scale(0.9); opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Toasts (entran y salen por abajo) ---------- */
.toaster { position: fixed; left: 0; right: 0; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 60; display: grid; justify-items: center; pointer-events: none; padding-inline: var(--gutter); }
@media (min-width: 900px) { .toaster { bottom: 24px; } }
.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 8px 8px 18px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--canvas);
  font-size: 0.9rem;
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  transition: transform 360ms var(--ease-out), opacity 360ms var(--ease-out);
}
@starting-style { .toast { transform: translateY(100%); opacity: 0; } }
.toast.is-leaving { transform: translateY(100%); opacity: 0; transition-duration: 200ms; }
.toast button { height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-pill); background: color-mix(in srgb, var(--canvas) 18%, transparent); color: inherit; font-weight: 600; cursor: pointer; }

/* ---------- Accesibilidad de movimiento y materiales ---------- */
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .card.is-entering, .view.is-entering, .stepper.is-new { animation-name: fade; }
  .media::before { animation: none; }
  .media img { transform: none; }
  .sheet, .sheet.is-open { transform: none; opacity: 0; transition: opacity var(--t-ui) ease; }
  .sheet.is-open { opacity: 1; }
  .dock, .dock.is-visible { transform: none; opacity: 0; transition: opacity var(--t-ui) ease; }
  .dock.is-visible { opacity: 1; }
  .toast, .toast.is-leaving { transform: none; transition: opacity 200ms ease; }
  .brand__name { transform: none; }
  .seg__pill { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .top, .cats { background: var(--canvas); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* Dentro de un iframe (página de ventas, panel) se oculta la barra de desplazamiento */
.is-embedded { scrollbar-width: none; }
.is-embedded::-webkit-scrollbar { display: none; }

/* Tienda inexistente o pausada */
.is-estado { padding: 0; }
.estado { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 32px var(--gutter); text-align: center; }
.estado__icon { display: grid; place-items: center; width: 80px; height: 80px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-1); font-size: 2.2rem; color: var(--ink-3); margin-bottom: 8px; }
.estado h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); letter-spacing: -0.03em; max-width: 20ch; }
.estado p { margin: 0 0 12px; color: var(--ink-2); max-width: 40ch; }
