/* ==========================================================================
   Arriba Paleteria — carrinho de pedidos (WhatsApp)
   ========================================================================== */

:root {
  --whats: #1FAF54;
  --whats-dark: #168A41;
  --line: #F0E3D6;
}

/* ---------- Contador ---------- */
.cart-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--yellow); color: var(--ink);
  font: 900 12px/22px var(--f-body); text-align: center; letter-spacing: 0;
}
.cart-count[hidden] { display: none; }
.header__cta { position: relative; border: 0; cursor: pointer; font-family: var(--f-body); }
.fab .cart-count { position: absolute; top: -4px; right: -4px; box-shadow: 0 0 0 3px var(--cream); }

@keyframes cart-bump { 0% { transform: scale(1); } 35% { transform: scale(1.18) rotate(-6deg); } 70% { transform: scale(.95); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: no-preference) {
  .is-bumping { animation: cart-bump .45s var(--ease-spring); }
}

/* No celular o botão do topo mostra só o ícone + contador */
@media (max-width: 420px) {
  .header__cta-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .header__cta { padding: 10px 14px; }
}

/* ---------- Botões "Adicionar" ---------- */
[data-add][hidden] { display: none !important; }
button.btn { font-family: var(--f-body); cursor: pointer; }
.btn--sm svg { width: 14px; height: 14px; }
.btn--sm:hover svg { transform: rotate(90deg); }

.chip-add {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 0; cursor: pointer;
  font: 800 12px/1 var(--f-body); letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--yellow); color: var(--ink);
  transition: transform .25s var(--ease-spring), background-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.chip-add:hover { transform: translateY(-2px); }
.chip-add:active { transform: scale(.95); }
.chip-add svg { width: 14px; height: 14px; transition: transform .3s var(--ease-out); }
.chip-add:hover svg { transform: rotate(90deg); }
.chip-add--light { background: var(--pink-soft); color: var(--pink); flex: none; }

.menu-item__row { align-items: center; }

/* ---------- Stepper (− qtd +) ---------- */
.stepper {
  display: inline-flex; align-items: center; gap: 2px;
  border-radius: 999px; background: var(--ink); color: var(--white); padding: 3px;
  animation: stepper-in .3s var(--ease-spring);
}
.stepper[hidden] { display: none; }
@keyframes stepper-in { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.stepper__btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,0.12); color: inherit; font: 900 20px/1 var(--f-body);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .2s, transform .2s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
.stepper__btn:hover { background: rgba(255,255,255,0.24); }
.stepper__btn:active { transform: scale(.88); }
.stepper__qty { min-width: 28px; text-align: center; font: 400 22px/1 var(--f-display); }
.product .stepper { background: var(--btn); }
.price-chip .stepper { background: var(--yellow); color: var(--ink); align-self: flex-start; }
.price-chip .stepper__btn { background: rgba(42,31,51,0.1); }
.menu-item .stepper { background: var(--pink); flex: none; }
.promo .stepper { background: var(--yellow); color: var(--ink); align-self: flex-start; }
.promo .stepper__btn { background: rgba(42,31,51,0.1); }

/* ---------- Gaveta ---------- */
html.cart-locked { overflow: hidden; }

.cart-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(42,31,51,0.5);
  opacity: 0; transition: opacity .3s ease;
}
.cart-backdrop.is-open { opacity: 1; }

.cart {
  position: fixed; z-index: 100; left: 0; right: 0; bottom: 0;
  max-height: 92dvh; max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--cream); border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 50px rgba(42,31,51,0.25);
  transform: translateY(105%); visibility: hidden;
  transition: transform .45s var(--ease-out), visibility 0s linear .45s;
}
@supports (height: 1dvh) { .cart { max-height: 92dvh; } }
.cart.is-open { transform: none; visibility: visible; transition: transform .45s var(--ease-out), visibility 0s; }
.cart::before {
  content: ''; position: absolute; top: 8px; left: 50%; width: 44px; height: 5px; margin-left: -22px;
  border-radius: 3px; background: rgba(42,31,51,0.18);
}

.cart__head {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 18px 14px; border-bottom: 1px solid var(--line);
}
.cart__eyebrow { font-family: var(--f-script); color: var(--pink); font-size: 16px; line-height: 1.2; }
.cart__title { font: 400 34px/1 var(--f-display); letter-spacing: 0.02em; color: var(--ink); }
.cart__clear {
  margin-left: auto; border: 0; background: none; cursor: pointer; min-height: 44px; padding: 0 8px;
  font: 800 12px/1 var(--f-body); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3);
  text-decoration: underline; text-underline-offset: 3px;
}
.cart__clear:hover { color: var(--pink); }
.cart__clear[hidden] + .cart__close { margin-left: auto; }
.cart__close {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--pink-soft); color: var(--pink);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .3s var(--ease-spring);
}
.cart__close:hover { transform: rotate(90deg); }

.cart__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px 18px; -webkit-overflow-scrolling: touch; }

.cart__empty { text-align: center; padding: 28px 8px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cart__empty[hidden] { display: none; }
.cart__empty-icon {
  width: 72px; height: 72px; border-radius: 50%; background: var(--pink-soft); color: var(--pink);
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 4px;
}
.cart__empty-title { font-weight: 900; font-size: 18px; }
.cart__empty-text { color: var(--ink-3); font-size: 14.5px; line-height: 1.5; max-width: 300px; }
.cart__empty .btn { margin-top: 6px; }

.cart__list { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cart__list[hidden] { display: none; }
.cart-item {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  background: var(--white); border-radius: 14px; padding: 10px 10px 10px 14px;
  box-shadow: 0 4px 12px rgba(42,31,51,0.05);
  animation: item-in .35s var(--ease-out);
}
@keyframes item-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.cart-item__name { font-weight: 800; font-size: 14.5px; line-height: 1.3; }
.cart-item .stepper { animation: none; }
.cart-item .stepper__btn { width: 32px; height: 32px; font-size: 18px; }
.cart-item .stepper__qty { min-width: 24px; font-size: 20px; }
.cart-item__remove {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; background: none; color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center; transition: color .2s, background-color .2s;
}
.cart-item__remove:hover { color: var(--pink); background: var(--pink-soft); }

/* ---------- Formulário ---------- */
.cart__form { display: flex; flex-direction: column; gap: 14px; }
.cart__form[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field[hidden] { display: none; }
.field label, .field legend { font-weight: 800; font-size: 14px; color: var(--ink); padding: 0; }
.field__hint { font-weight: 600; color: var(--ink-3); font-size: 12.5px; }
.field input[type="text"], .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--white); color: var(--ink);
  font: 600 16px/1.4 var(--f-body); /* 16px evita zoom automático no iPhone */
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--purple); box-shadow: 0 0 0 4px rgba(94,43,151,0.15);
}
.field [aria-invalid="true"] { border-color: var(--pink); }
.field__error { color: var(--pink-dark); font-size: 13px; font-weight: 700; }
.field__error[hidden] { display: none; }

.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice label { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px;
  border-radius: 12px; border: 2px solid var(--line); background: var(--white);
  font-weight: 800; font-size: 14px; text-align: center;
  transition: border-color .2s, background-color .2s, color .2s;
}
.choice input:checked + span { border-color: var(--pink); background: var(--pink-soft); color: var(--pink-dark); }
.choice input:focus-visible + span { outline: 3px solid var(--purple); outline-offset: 2px; }

/* ---------- Rodapé da gaveta ---------- */
.cart__foot {
  padding: 12px 18px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--cream);
}
.cart__foot[hidden] { display: none; }
.btn--whats {
  width: 100%; border: 0; cursor: pointer; font-family: var(--f-body);
  background: var(--whats); color: var(--white); box-shadow: 0 8px 20px rgba(31,175,84,0.3);
}
.btn--whats:hover { background: var(--whats-dark); color: var(--white); transform: translateY(-2px); }
.btn--whats:hover svg { transform: none; }
.cart__foot-note { margin-top: 8px; text-align: center; font-size: 12.5px; color: var(--ink-3); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 110; left: 50%; bottom: max(90px, calc(env(safe-area-inset-bottom) + 84px));
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: var(--white); font-weight: 800; font-size: 14px; text-align: center;
  box-shadow: 0 12px 28px rgba(42,31,51,0.3);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  transition: transform .35s var(--ease-spring), opacity .25s;
}
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Desktop: painel lateral ---------- */
@media (min-width: 768px) {
  .prices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cart {
    left: auto; top: 0; width: 440px; max-height: none; height: 100%;
    border-radius: 22px 0 0 22px; transform: translateX(105%);
    box-shadow: -20px 0 50px rgba(42,31,51,0.25);
  }
  .cart::before { display: none; }
  .cart__head { padding: 24px 24px 16px; }
  .cart__body { padding: 18px 24px 22px; }
  .cart__foot { padding: 14px 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .cart, .cart-backdrop, .toast, .stepper, .cart-item { transition: none; animation: none; }
}
