/* =====================================================================
   BOAH STORE — ธีมหลัก (มือถือก่อน แล้วขยายเป็นแท็บเล็ต/เดสก์ท็อป)
   ===================================================================== */

:root {
  --red-hi: #bb354d;
  --red: #8a2537;
  --red-lo: #5a1824;
  --ink: #761827;            /* ตัวหนังสือแดงเข้มบนพื้นขาว */
  --ink-soft: #a0596a;
  --pink: #e8a6b2;           /* เส้นประ/ขอบชมพู */
  --pink-soft: #f6dde2;
  --white: #fff;
  --bg: #efeeec;
  --grad: linear-gradient(180deg, var(--red-hi) 0%, var(--red) 55%, var(--red-lo) 100%);
  --grad-soft: linear-gradient(180deg, #b9384f 0%, #7d2133 100%);
  --ring: 0 0 0 2px rgba(214, 120, 138, .55);
  --glow: 0 6px 16px rgba(122, 24, 42, .25);
  --inner-hi: inset 0 2px 0 rgba(255, 255, 255, .22), inset 0 -3px 6px rgba(0, 0, 0, .18);
  --radius: 22px;
  --radius-lg: 30px;
  --pad: 14px;
  --font: 'Mitr', 'Noto Sans Thai', 'Leelawadee UI', 'Thonburi', system-ui, sans-serif;
  --fab-size: 72px;
  --ease: cubic-bezier(.2, .9, .3, 1.2);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.no-scroll { overflow: hidden; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico .fill, .ico--fill { fill: currentColor; stroke: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
:focus-visible { outline: 3px solid #f4b6c2; outline-offset: 2px; }

.page-bg {
  position: fixed; inset: 0; z-index: -1;
  background: var(--bg) url(/img/bg-silk.webp) center / cover no-repeat;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* ---------- ปุ่มกด: ยุบนิดๆ ตอนกด ---------- */
.pressable { transition: transform .12s ease, filter .12s ease; }
.pressable:active { transform: scale(.96); filter: brightness(.95); }

/* =====================================================================
   Header
   ===================================================================== */
.site-header { position: relative; padding-top: 14px; }
.site-header__thread {
  position: absolute; left: 0; top: -6px; width: min(100%, 760px); height: auto;
  pointer-events: none; opacity: .9; z-index: -1;
}
.hdr {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 7px 9px 7px 7px;
  border-radius: 999px;
  background: var(--grad);
  border: 3px solid var(--white);
  box-shadow: var(--ring), var(--glow), var(--inner-hi);
  color: var(--white);
}
.hdr__avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  border: 2.5px solid var(--white); overflow: hidden; background: #8e9cf0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  transition: transform .15s ease;
}
.hdr__avatar:active { transform: scale(.92); }
.hdr__avatar img { width: 100%; height: 100%; object-fit: cover; }
.hdr__title { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.1; }
.hdr__title strong {
  font-weight: 600; font-size: clamp(15px, 4.4vw, 24px); letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hdr__title span { font-size: clamp(10px, 2.9vw, 13px); opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr__clock {
  display: flex; align-items: center; gap: 4px; flex: none;
  background: var(--white); color: var(--ink);
  border-radius: 999px; padding: 4px 8px 4px 6px;
  font-weight: 500; font-size: clamp(12px, 3.3vw, 15px);
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08);
}
.hdr__clock .ico { font-size: 1.15em; stroke-width: 2; }
.hdr__btn {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--white); color: var(--ink);
  font-size: 19px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08);
  transition: transform .12s ease;
}
.hdr__btn:active { transform: scale(.9); }
.hdr__btn .ico { stroke-width: 2; }

@media (max-width: 370px) {
  .hdr { gap: 5px; padding-right: 7px; }
  .hdr__avatar { width: 40px; height: 40px; }
  .hdr__btn { width: 30px; height: 30px; font-size: 17px; }
  .hdr__clock { padding: 3px 7px 3px 5px; }
}

/* =====================================================================
   โครงหน้า
   ===================================================================== */
main { flex: 1; padding-top: 18px; padding-bottom: 28px; outline: none; }

.page-title {
  display: flex; align-items: center; gap: 12px;
  margin: 6px 0 0; padding-bottom: 14px;
  font-size: clamp(26px, 7.5vw, 34px); font-weight: 600; color: var(--ink);
}
.page-title img { width: 36px; height: auto; }
.dash { height: 0; border-top: 2.5px dashed var(--pink); margin: 0 6px 18px; opacity: .9; }

.back-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 24px;
  background: var(--white); color: var(--ink);
  border: 2.5px solid var(--red); box-shadow: var(--glow);
}

/* หัวข้อแบบแคปซูลขาว + หัวใจสองข้าง (สินค้ายอดนิยม) */
.section-head { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 26px 0 18px; }
.section-head img { width: 46px; height: auto; filter: drop-shadow(0 3px 4px rgba(120, 20, 40, .25)); }
.section-head h2 {
  margin: 0; padding: 6px 30px; border-radius: 999px;
  background: var(--white); border: 2.5px solid var(--red);
  box-shadow: var(--ring), var(--glow);
  font-size: clamp(18px, 5vw, 22px); font-weight: 600; color: var(--ink);
}

/* =====================================================================
   ปุ่มแดงสไตล์ร้าน (CTA)
   ===================================================================== */
.btn-red {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  color: var(--white); font-weight: 600;
  background: var(--grad);
  border: 3px solid var(--white);
  border-radius: var(--radius);
  box-shadow: var(--ring), var(--glow), var(--inner-hi);
  padding: 12px 18px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.btn-white {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--white); color: var(--ink); font-weight: 600;
  border-radius: 999px; padding: 10px 18px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08), 0 2px 6px rgba(80, 10, 25, .15);
}
.btn-red .star { position: absolute; color: var(--white); font-size: 14px; opacity: .95; }
.btn-red .star--lg { font-size: 30px; }
.btn-red .star--a { left: 12px; top: 8px; }
.btn-red .star--b { left: 26px; bottom: 9px; font-size: 11px; }
.btn-red .star--c { right: 14px; top: 8px; font-size: 12px; }
.btn-red--big .star--a { left: 22px; top: 12px; }
.btn-red--big .star--b { left: 8px; bottom: 12px; font-size: 16px; }
.btn-red--big .star--c { right: 22px; bottom: 10px; top: auto; }
.btn-red > span { position: relative; z-index: 1; }
.btn-red .cream { position: absolute; right: 6px; bottom: 4px; width: 44px; height: auto; pointer-events: none; }

/* =====================================================================
   หน้าแรก
   ===================================================================== */
.hero { display: grid; gap: 14px; }
.hero__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hero__actions .btn-red { min-height: 72px; font-size: clamp(16px, 4.8vw, 21px); line-height: 1.15; padding-right: 44px; }
.hero__actions .btn-red--big { grid-column: 1 / -1; font-size: clamp(20px, 6vw, 27px); padding-right: 18px; min-height: 80px; }

/* ---------- Banner slider (scroll-snap) ---------- */
.banner {
  position: relative; border-radius: var(--radius-lg);
  border: 3px solid var(--white);
  box-shadow: var(--ring), var(--glow);
  overflow: hidden; background: #f3d9de;
  aspect-ratio: 3 / 2;
}
.banner__track {
  display: flex; height: 100%;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.banner__track::-webkit-scrollbar { display: none; }
.banner__slide {
  position: relative; flex: 0 0 100%; height: 100%;
  scroll-snap-align: center; scroll-snap-stop: always; overflow: hidden;
  cursor: zoom-in;
}
.banner__fill { position: absolute; inset: -20px; background: center / cover no-repeat; filter: blur(18px) saturate(1.1); opacity: .7; }
.banner__slide img { position: relative; width: 100%; height: 100%; object-fit: contain; }
.banner__dots {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 4px 8px; border-radius: 999px; background: rgba(255, 255, 255, .35);
}
.banner__dots button { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .9); transition: background .2s, transform .2s; }
.banner__dots button[aria-current="true"] { background: var(--red); transform: scale(1.15); }
.banner__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .9); color: var(--ink); font-size: 22px;
  border: 2px solid var(--red); box-shadow: var(--glow);
}
.banner__nav--prev { left: 10px; }
.banner__nav--next { right: 10px; }
.banner__nav:disabled { opacity: 0; pointer-events: none; }

/* =====================================================================
   หน้าสินค้าทั้งหมด: ค้นหา + ตัวกรอง + หมวดหมู่
   ===================================================================== */
.toolbar { display: flex; gap: 10px; align-items: center; }
.search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .85); border: 2.5px solid var(--red);
  border-radius: 999px; padding: 0 16px; height: 50px;
  box-shadow: var(--glow);
}
.search .ico { font-size: 24px; color: var(--ink); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--ink); }
.search input::placeholder { color: #b78591; }
.icon-circle {
  width: 50px; height: 50px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 24px;
  background: rgba(255, 255, 255, .85); color: var(--ink);
  border: 2.5px solid var(--red); box-shadow: var(--glow);
}
.icon-circle .ico { stroke-width: 2.6; }

.chips {
  display: flex; gap: 10px; margin: 16px -4px 0; padding: 4px 4px 12px;
  overflow-x: auto; scroll-snap-type: x proximity;
  scrollbar-width: thin; scrollbar-color: #dba3ae transparent;
}
.chips::-webkit-scrollbar { height: 6px; }
.chips::-webkit-scrollbar-thumb { background: #dba3ae; border-radius: 99px; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px 0 10px; border-radius: 999px;
  background: var(--white); color: var(--ink); font-weight: 600; font-size: 15px;
  box-shadow: 0 2px 8px rgba(120, 20, 40, .12);
  scroll-snap-align: start; white-space: nowrap;
}
.chip img { width: 26px; height: 26px; object-fit: contain; }
.chip[aria-pressed="true"] { background: var(--grad); color: var(--white); padding-inline: 18px; border: 2px solid var(--white); box-shadow: var(--ring), var(--glow); }
.chip[aria-pressed="true"] img { display: none; }

/* =====================================================================
   การ์ดสินค้า
   ===================================================================== */
.grid { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 10px; }
.card {
  position: relative; display: flex; flex-direction: column; text-align: center;
  background: var(--grad);
  border: 3px solid var(--white); border-radius: 20px;
  box-shadow: var(--ring), var(--glow);
  padding: 7px 7px 6px; color: var(--white);
  transition: transform .15s ease;
}
.card:active { transform: scale(.97); }
.card__bow { position: absolute; left: -10px; top: -10px; width: 66px; height: auto; z-index: 2; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .15)); }
.card__img { background: var(--white); border-radius: 14px; aspect-ratio: 1 / .86; overflow: hidden; display: grid; place-items: center; }
.card__img img { width: 88%; height: 88%; object-fit: contain; }
.card__name {
  margin: 8px 4px 6px; font-size: 15px; font-weight: 500; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.5em;
}
.card__price {
  background: var(--white); color: var(--ink); border-radius: 999px;
  font-weight: 600; font-size: 17px; padding: 3px 6px; letter-spacing: .3px;
}
.card__stock { font-size: 11.5px; margin-top: 3px; opacity: .95; }
.card--off { filter: grayscale(1) opacity(.55); }
.card__stamp {
  position: absolute; z-index: 3; left: 50%; top: 32%;
  transform: translate(-50%, -50%) rotate(-24deg);
  background: var(--white); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 12px;
  padding: 4px 12px; font-weight: 600; font-size: 16px; white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .2);
}
.card-wrap { position: relative; }
.card-wrap--off .card__stamp { filter: none; }

.empty { text-align: center; color: var(--ink-soft); padding: 40px 10px; font-size: 15px; }

/* =====================================================================
   Footer + ปุ่มลอย
   ===================================================================== */
.site-footer { padding-bottom: calc(var(--fab-size) + 26px + env(safe-area-inset-bottom)); text-align: center; color: var(--ink); }
.site-footer__line { border-top: 2.5px dashed var(--pink); margin: 6px calc(var(--fab-size) + 6px) 10px; }
.site-footer p { margin: 0; font-size: 13px; font-weight: 500; }

.fab { position: fixed; z-index: 40; bottom: calc(14px + env(safe-area-inset-bottom)); }
.fab--music { left: 12px; width: var(--fab-size); height: var(--fab-size); filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .22)); }
.fab--music img { width: 100%; height: 100%; }
.fab--cart {
  right: 12px; width: calc(var(--fab-size) + 6px); height: calc(var(--fab-size) + 6px); border-radius: 50%;
  display: grid; place-items: center; font-size: 40px; color: var(--white);
  background: var(--grad); border: 4px solid var(--white);
  box-shadow: var(--ring), 0 8px 20px rgba(110, 20, 38, .35), var(--inner-hi);
  transition: transform .15s var(--ease);
}
.fab--cart:active { transform: scale(.92); }
.fab--cart .ico { stroke-width: 1.8; }
.fab__badge {
  position: absolute; top: -4px; right: -4px; min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 999px; background: var(--white); color: var(--ink);
  font-size: 14px; font-weight: 600; display: grid; place-items: center;
  border: 2px solid var(--red);
}
.fab--bump { animation: bump .45s var(--ease); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* =====================================================================
   Modal (popup) — ใช้ร่วมทุกหน้าต่าง
   ===================================================================== */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 22px 16px; }
.modal__backdrop {
  position: absolute; inset: 0; background: rgba(35, 30, 32, .45);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  animation: fade .2s ease both;
}
.modal__panel {
  position: relative; width: 100%; max-width: 440px; max-height: calc(100dvh - 60px);
  display: flex; flex-direction: column;
  background: var(--grad); color: var(--white);
  border: 3px solid var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--ring), 0 18px 40px rgba(60, 10, 20, .4), var(--inner-hi);
  animation: pop .28s var(--ease) both;
}
.modal__body { overflow-y: auto; overscroll-behavior: contain; padding: 22px 20px 22px; border-radius: inherit; }
.modal__close {
  position: absolute; right: -12px; top: -16px; z-index: 2;
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: var(--white); font-size: 30px;
  border: 3px solid var(--white); box-shadow: var(--ring), 0 4px 10px rgba(0, 0, 0, .3), var(--inner-hi);
}
.modal__close .ico { stroke-width: 3.4; }
.modal__close:active { transform: scale(.9); }
.modal__title { margin: 0; text-align: center; font-size: 22px; font-weight: 600; }
.modal__sub { margin: 4px 0 0; text-align: center; font-size: 13px; opacity: .85; }
.modal__dash { border-top: 1.5px dashed rgba(255, 255, 255, .45); margin: 14px 0; }
.modal--closing .modal__backdrop { animation: fade .16s ease reverse both; }
.modal--closing .modal__panel { animation: pop-out .16s ease both; }

/* รูปภาพเต็มจอ (ดูรูปปก) */
.modal--image .modal__panel { max-width: min(1100px, 96vw); background: transparent; border: 0; box-shadow: none; }
.modal--image .modal__body { padding: 0; overflow: visible; }
.modal--image img { width: 100%; height: auto; max-height: calc(100dvh - 70px); object-fit: contain; border-radius: 18px; border: 3px solid var(--white); background: var(--white); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.94); } }
@keyframes pop-out { to { opacity: 0; transform: translateY(10px) scale(.96); } }

/* Toast */
#toast-root { position: fixed; left: 50%; bottom: calc(var(--fab-size) + 34px); transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; pointer-events: none; }
.toast {
  background: var(--white); color: var(--ink); font-weight: 500; font-size: 15px;
  padding: 10px 18px; border-radius: 999px; border: 2px solid var(--red);
  box-shadow: var(--glow); animation: pop .25s var(--ease) both; white-space: nowrap;
}

/* placeholder ระหว่างพัฒนา */
.soon { text-align: center; padding: 10px 4px 4px; }
.soon p { margin: 8px 0 0; font-size: 14px; opacity: .9; }

/* =====================================================================
   แท็บเล็ต
   ===================================================================== */
@media (min-width: 640px) {
  :root { --pad: 22px; --fab-size: 80px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 16px; }
  .hdr { padding: 10px 14px 10px 10px; gap: 12px; }
  .hdr__avatar { width: 56px; height: 56px; }
  .hdr__btn { width: 42px; height: 42px; font-size: 23px; }
  .card__name { font-size: 16px; }
  .card__price { font-size: 18px; }
  .card__stock { font-size: 12.5px; }
  .hero__actions .btn-red { font-size: 24px; min-height: 88px; padding-right: 64px; }
  .hero__actions .btn-red--big { font-size: 30px; min-height: 96px; }
  .btn-red .cream { width: 54px; right: 10px; bottom: 8px; }
}

/* =====================================================================
   เดสก์ท็อป
   ===================================================================== */
@media (min-width: 1024px) {
  :root { --pad: 28px; --fab-size: 84px; }
  main { padding-top: 26px; }
  .hdr__title strong { font-size: 28px; }
  .hdr__title span { font-size: 14px; }
  .hdr__clock { font-size: 18px; padding: 6px 14px 6px 10px; }

  /* หน้าแรก: แบนเนอร์ซ้าย ปุ่มขวา */
  .hero { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 22px; align-items: stretch; }
  .hero__actions { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr 1.25fr; gap: 16px; }
  .hero__actions .btn-red { font-size: 26px; padding-right: 70px; }
  .hero__actions .btn-red--big { grid-column: auto; font-size: 30px; padding-right: 18px; }
  .btn-red .cream { width: 62px; right: 12px; bottom: 8px; }
  .m-br { display: none; }
  .banner__nav { width: 46px; height: 46px; }

  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 26px 20px; }
  .card__bow { width: 76px; }
  .toolbar { max-width: 760px; }
  .chips { flex-wrap: wrap; overflow: visible; padding-bottom: 4px; }
  .modal__body { padding: 26px 28px; }
}
@media (min-width: 1280px) {
  .grid--products { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* hover เฉพาะอุปกรณ์ที่มีเมาส์ */
@media (hover: hover) {
  .card:hover { transform: translateY(-4px); }
  .btn-red:hover, .fab--cart:hover { filter: brightness(1.08); }
  .chip:hover:not([aria-pressed="true"]) { background: var(--pink-soft); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
