/* GIỎ DÙNG CHUNG (gio.js) — thanh giỏ dính đáy, bảng giỏ trượt từ đáy, nút + / − của thẻ món.
   Dùng ở cả trang chủ (/) và trang gọi món (/dat-mon): cùng màu, cùng font với web thương hiệu Bé Nếp.
   Biến riêng tiền tố --g- để không giẫm biến của từng trang. Không gradient, không kính mờ, không emoji. */
:root {
  --g-la: #3A9A3F;
  --g-la-dam: #26762B;
  --g-la-sau: #1D5A26;
  --g-la-nhat: #DDF0D2;
  --g-nep: #FFF7E3;
  --g-nep-trang: #FFFCF3;
  --g-nep-dam: #FBE8B5;
  --g-vang: #F6B92B;
  --g-do: #D2412F;
  --g-do-chu: #B23624;
  --g-muc: #2D2A1E;
  --g-muc-nhat: #5C5643;
  --g-vien: #E6D8B4;
  --g-chu-to: "Baloo 2", "Nunito", system-ui, sans-serif;
  --g-chu: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }
body.khoa-cuon { overflow: hidden; }
/* chừa chỗ cho thanh giỏ để nội dung cuối trang không bị che */
body.co-thanh-gio { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

.chi-doc { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; }

.bt {
  display: block;
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- nút + tròn; đã chọn thì thành "− 2 +" ---------- */
.so-luong { display: flex; align-items: center; gap: 4px; flex: none; }
.nut-tron {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2.5px solid var(--g-muc);
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  font: inherit;
}
.nut-tron::after { content: ""; position: absolute; inset: -6px; }   /* vùng chạm ≥ 44px */
.nut-tron .bt { width: 18px; height: 18px; stroke-width: 2.8; }
.nut-tron.them { background: var(--g-la-dam); color: #FFFFFF; box-shadow: 0 2px 0 var(--g-muc); }
.nut-tron.them:active { transform: translateY(2px); box-shadow: none; }
.nut-tron.them:disabled { opacity: .35; cursor: default; transform: none; box-shadow: none; }
.nut-tron.bot { background: var(--g-nep-trang); color: var(--g-la-dam); }
.nut-tron.bot:active { background: var(--g-la-nhat); }
.so-luong .so {
  min-width: 28px;
  text-align: center;
  font: 800 17px/1 var(--g-chu);
  color: var(--g-muc);
  font-variant-numeric: tabular-nums;
}
.so-luong.rong .bot, .so-luong.rong .so { display: none; }
.nhan-het { display: none; }
.so-luong.het .them { display: none; }
.so-luong.het .nhan-het {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #E7E2D3;
  color: #5C5643;
  font: 800 13px/1.2 var(--g-chu);
}
.nut-combo.vua-them { animation: g-nay .45s cubic-bezier(.34, 1.56, .64, 1) 1; }
@keyframes g-nay { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* ---------- thanh giỏ dính đáy ---------- */
.thanh-gio {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.nut-gio {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 536px;
  min-height: 58px;
  margin: 0 auto;
  padding: 0 16px;
  border: 3px solid var(--g-muc);
  border-radius: 18px;
  background: var(--g-la-dam);
  color: #FFFFFF;
  box-shadow: 0 5px 0 var(--g-muc);
  font: 700 15px/1.2 var(--g-chu);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nut-gio:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--g-muc); }
.gio-trai { display: flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; }
.gio-tong { flex: 1; text-align: center; font: 800 19px/1 var(--g-chu-to); white-space: nowrap; padding-top: 2px; }
.gio-phai { display: flex; align-items: center; gap: 2px; font: 800 16px/1 var(--g-chu-to); white-space: nowrap; padding-top: 2px; }
.gio-phai .bt { width: 18px; height: 18px; }

/* ---------- bảng giỏ trượt từ đáy ---------- */
.man-che { position: fixed; inset: 0; z-index: 70; background: rgba(45, 42, 30, .5); }
.bang-gio {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 71;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  max-height: 88vh;
  max-height: 88dvh;
  margin: 0 auto;
  background: var(--g-nep-trang);
  color: var(--g-muc);
  border: 3px solid var(--g-muc);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  font: 600 16px/1.45 var(--g-chu);
  animation: g-len .22s ease-out;
}
@keyframes g-len { from { transform: translateY(100%); } to { transform: translateY(0); } }
.bang-gio p, .bang-gio h2, .bang-gio ul { margin: 0; }
.bang-dau {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 8px 8px 18px;
  border-bottom: 2px dashed var(--g-vien);
}
.tay-cam {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 40px;
  height: 5px;
  margin-left: -20px;
  border-radius: 3px;
  background: var(--g-vien);
}
.bang-dau h2 { font: 800 22px/1.1 var(--g-chu-to); color: var(--g-la-sau); padding-top: 2px; }
.bang-dau h2:focus { outline: none; }
.nut-dong {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--g-muc-nhat);
  cursor: pointer;
}
.bang-than { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 18px 16px; }
.bang-chan {
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 2px dashed var(--g-vien);
  background: var(--g-nep-trang);
}

.ds-gio { list-style: none; padding: 0; }
.dong-gio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--g-vien);
}
.gio-anh {
  display: block;
  flex: none;
  width: 52px;
  height: 52px;
  border: 2px solid var(--g-muc);
  border-radius: 12px;
  object-fit: cover;
  background: var(--g-nep-dam);
}
.dong-gio-giua { flex: 1; min-width: 0; }
.dong-gio-ten { font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.dong-gio-tien { margin-top: 2px; color: var(--g-do-chu); font-weight: 800; font-variant-numeric: tabular-nums; }

/* tóm tắt tiền */
.gio-tom { margin-top: 12px; padding: 10px 14px; border: 2px solid var(--g-muc); border-radius: 16px; background: var(--g-nep); }
.gio-dong { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-variant-numeric: tabular-nums; }
.gio-dong span:last-child { flex: none; font-weight: 800; }
.gio-dong-giam span:last-child { color: var(--g-la-dam); }
.gio-dong-tang span:last-child { color: var(--g-la-dam); }
.gio-dong-tong { margin-top: 4px; padding-top: 6px; border-top: 2px dashed var(--g-vien); font: 800 19px/1.3 var(--g-chu-to); }
.gio-dong-tong span:last-child { color: var(--g-do-chu); }
.gio-goi-ghep { margin-top: 6px !important; color: var(--g-la-sau); font-size: 14px; font-weight: 800; }

.gio-nhan { display: block; margin: 16px 0 6px; font-size: 15px; font-weight: 800; }
.gio-o {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 2px solid var(--g-muc);
  border-radius: 12px;
  background: #FFFFFF;
  color: var(--g-muc);
  font: 600 16px/1.3 var(--g-chu);   /* ≥ 16px: iPhone không tự phóng to */
}
.gio-o::placeholder { color: #8F8873; }
.gio-o:focus { outline: none; border-color: var(--g-la-dam); box-shadow: 0 0 0 3px var(--g-la-nhat); }
.gio-o[aria-invalid="true"] { border-color: var(--g-do-chu); }

.gio-khach { margin-top: 14px; border-top: 1px solid var(--g-vien); }
.gio-gap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--g-muc);
  text-align: left;
  font: 800 16px/1.3 var(--g-chu);
  cursor: pointer;
}
.gio-phu { color: var(--g-muc-nhat); font-weight: 600; font-size: 14px; }
.gio-gap .bt { color: var(--g-muc-nhat); transition: transform .15s; }
.gio-gap[aria-expanded="true"] .bt { transform: rotate(180deg); }
.gio-gon { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
.gio-gon span { font-weight: 800; min-width: 0; overflow-wrap: anywhere; }
.gio-khach-nhap .gio-nhan:first-child { margin-top: 2px; }
.gio-nut-chu {
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: none;
  color: var(--g-la-dam);
  font: 800 16px/1 var(--g-chu);
  cursor: pointer;
}
/* Đợt 2: ô đồng ý lưu SĐT để tích hạt nếp */
.gio-dong-y { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; min-height: 44px; font-size: 15px; font-weight: 800; line-height: 1.35; cursor: pointer; }
.gio-dong-y input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--g-la-dam); cursor: pointer; }
.gio-link-cs { display: inline-block; margin: 2px 0 0 34px; padding: 6px 0; color: var(--g-la-sau); font-size: 14px; font-weight: 800; }
.gio-bao-nho { margin-top: 6px !important; padding: 8px 10px; border-radius: 10px; background: #FFF0C2; color: #5C4A12; font-size: 14px; font-weight: 700; }
.gio-loi { margin-top: 6px !important; color: var(--g-do-chu); font-size: 14px; font-weight: 800; }
#loi-chung { margin-top: 12px !important; }
.gio-bao {
  margin-top: 12px !important;
  padding: 10px 12px;
  border-radius: 12px;
  background: #FFF0C2;
  color: #5C4A12;
  font-size: 14px;
  font-weight: 700;
}

.gio-nut-dat {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  padding: 10px 16px;
  border: 3px solid var(--g-muc);
  border-radius: 16px;
  background: var(--g-la-dam);
  color: #FFFFFF;
  box-shadow: 0 5px 0 var(--g-muc);
  font: 800 18px/1.1 var(--g-chu-to);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gio-nut-dat:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--g-muc); }
.gio-nut-dat.tat { opacity: .55; }

@media (prefers-reduced-motion: reduce) {
  .bang-gio, .nut-combo.vua-them { animation: none; }
  .gio-gap .bt { transition: none; }
}
