/* ==========================================================================
   ROUNDBOX — 丸筒  ·  ระบบดีไซน์
   วาชิ (生成) · หมึกซูมิ (墨) · คราฟท์ · แดงชาด (朱) ใช้เฉพาะจุดเน้น
   ========================================================================== */
:root {
  --washi: #f2ede3;
  --washi-2: #e9e2d4;
  --paper: #faf7f1;
  --sumi: #191815;
  --sumi-2: #24221e;
  --sumi-3: #2f2c27;
  --ink: #191815;
  --ink-soft: #55504a;
  --ink-mute: #8a847a;
  --line: rgba(25, 24, 21, 0.13);
  --line-strong: rgba(25, 24, 21, 0.28);
  --line-inv: rgba(242, 237, 227, 0.14);
  --kraft: #b8946b;
  --kraft-light: #d8c09d;
  --kraft-deep: #86663f;
  --shu: #b0361f;
  --shu-soft: rgba(176, 54, 31, 0.08);
  --ok: #4d6b3c;
  --warn: #a8741a;

  --font-display: 'Noto Serif Thai', 'Shippori Mincho', Georgia, serif;
  --font-body: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --font-jp: 'Shippori Mincho', 'Noto Serif Thai', serif;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.77, 0, 0.18, 1);
  --gutter: clamp(16px, 4vw, 56px);
  --maxw: 1360px;
  --radius: 2px;
  --header-h: 72px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  margin: 0;
  background: var(--washi);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
body.is-locked { overflow: hidden; }

img, svg, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--sumi); color: var(--washi); }
:focus-visible { outline: 1.5px solid var(--shu); outline-offset: 3px; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 400; line-height: 1.25; margin: 0; letter-spacing: -0.005em; }
p { margin: 0; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.mono { font-family: var(--font-mono); font-feature-settings: 'tnum' 1; letter-spacing: 0.02em; }
.jp { font-family: var(--font-jp); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.eyebrow::before { content: ''; width: 28px; height: 1px; background: currentColor; opacity: 0.6; }
.muted { color: var(--ink-mute); }
.num { font-family: var(--font-mono); font-feature-settings: 'tnum' 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* กระดาษ — เกรนบางๆ ทั้งหน้า */
.grain {
  position: fixed; inset: -50%; z-index: 90; pointer-events: none; opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.09 0 0 0 0 0.08 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); }
  80% { transform: translate(3%, 3%); }
}

/* ---------- ตราประทับ (hanko) ---------- */
.hanko {
  --s: 30px;
  width: var(--s); height: var(--s);
  display: inline-grid; place-items: center;
  background: var(--shu); color: #f6e9e2;
  font-family: var(--font-jp); font-weight: 700; font-size: calc(var(--s) * 0.56); line-height: 1;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.12);
}
.hanko--round { border-radius: 50%; }

/* ---------- ปุ่ม ---------- */
.btn {
  --bg: var(--sumi); --fg: var(--washi);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 14px;
  height: 54px; padding: 0 30px;
  background: var(--bg); color: var(--fg);
  font-size: 15px; font-weight: 500; letter-spacing: 0.02em;
  border-radius: 999px; overflow: hidden; isolation: isolate;
  transition: transform 0.5s var(--ease), color 0.4s var(--ease);
  white-space: nowrap;
}
.btn::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--shu);
  transform: translateY(101%); border-radius: 50% 50% 0 0;
  transition: transform 0.6s var(--ease), border-radius 0.6s var(--ease);
}
.btn:hover::before { transform: translateY(0); border-radius: 0; }
.btn .arrow { width: 18px; height: 18px; transition: transform 0.5s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }
.btn--ghost { --bg: transparent; --fg: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn--ghost:hover { color: var(--washi); }
.btn--ghost::before { background: var(--sumi); }
.btn--light { --bg: var(--washi); --fg: var(--sumi); }
.btn--light:hover { color: var(--washi); }
.btn--sm { height: 42px; padding: 0 20px; font-size: 14px; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: 0.5; pointer-events: none; }
.btn.is-loading::after {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  font-weight: 500;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat;
  transition: background-size 0.5s var(--ease);
}
.link:hover { background-size: 0 1px; background-position: 100% 100%; }

/* ---------- ฟอร์ม ---------- */
.field { display: grid; gap: 6px; }
.field > span, .label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; height: 50px; padding: 0 16px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color 0.3s, box-shadow 0.3s;
  outline: none;
}
.textarea { height: auto; min-height: 96px; padding: 12px 16px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--sumi); box-shadow: 0 0 0 3px rgba(25, 24, 21, 0.06); }
.input[readonly] { background: var(--washi-2); color: var(--ink-soft); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: calc(100% - 20px) 22px, calc(100% - 15px) 22px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 40px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--sumi); }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-error { color: var(--shu); font-size: 14px; min-height: 1em; }

/* ---------- Header ---------- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: var(--header-h);
  transition: transform 0.6s var(--ease), background-color 0.4s, backdrop-filter 0.4s, box-shadow 0.4s;
}
.site-header.is-scrolled { background: rgba(242, 237, 227, 0.78); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); box-shadow: 0 1px 0 var(--line); }
.site-header.is-hidden { transform: translateY(-100%); }
.site-header.is-dark:not(.is-scrolled) { color: var(--washi); }
.site-header .wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand__word { font-family: var(--font-display); font-size: 17px; letter-spacing: 0.32em; font-weight: 500; }
.brand__sub { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.2em; opacity: 0.55; display: block; margin-top: -4px; }
.nav { display: flex; gap: 34px; font-size: 14px; }
.nav a { position: relative; padding: 6px 0; opacity: 0.8; transition: opacity 0.3s; }
.nav a::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: right; transition: transform 0.5s var(--ease); }
.nav a:hover { opacity: 1; }
.nav a:hover::after { transform: scaleX(1); transform-origin: left; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; transition: background-color 0.3s; position: relative; }
.icon-btn:hover { background: rgba(25, 24, 21, 0.06); }
.is-dark:not(.is-scrolled) .icon-btn:hover { background: rgba(242, 237, 227, 0.1); }
.icon-btn svg { width: 20px; height: 20px; }
.cart-count {
  position: absolute; top: 5px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center; border-radius: 9px;
  background: var(--shu); color: #fff; font-family: var(--font-mono); font-size: 10.5px; line-height: 1;
  transform: scale(0); transition: transform 0.5s var(--ease);
}
.cart-count.is-on { transform: scale(1); }
.cart-count.bump { animation: bump 0.6s var(--ease); }
@keyframes bump { 30% { transform: scale(1.45); } }
.account-chip { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 6px; border-radius: 20px; font-size: 13.5px; box-shadow: inset 0 0 0 1px var(--line); }
.account-chip .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--sumi); color: var(--washi); display: grid; place-items: center; font-size: 12px; }
.menu-btn { display: none; }
@media (max-width: 900px) {
  .nav { display: none; }
  .menu-btn { display: grid; }
  .account-chip span:not(.avatar) { display: none; }
  .account-chip { padding: 0 6px; }
}

/* เมนูมือถือ */
.mobile-nav {
  position: fixed; inset: 0; z-index: 70; background: var(--sumi); color: var(--washi);
  display: flex; flex-direction: column; justify-content: center; padding: var(--gutter);
  clip-path: inset(0 0 100% 0); transition: clip-path 0.8s var(--ease-io); visibility: hidden;
}
.mobile-nav.is-open { clip-path: inset(0 0 0 0); visibility: visible; }
.mobile-nav a { font-family: var(--font-display); font-size: clamp(32px, 9vw, 52px); line-height: 1.5; display: flex; align-items: baseline; gap: 16px; }
.mobile-nav a small { font-family: var(--font-mono); font-size: 12px; opacity: 0.5; }
.mobile-nav .close { position: absolute; top: 14px; right: var(--gutter); }

/* ---------- Drawer (ตะกร้า) ---------- */
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(25, 24, 21, 0.4); opacity: 0; visibility: hidden; transition: opacity 0.5s var(--ease), visibility 0.5s; }
.scrim.is-open { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 81;
  width: min(480px, 100vw); background: var(--paper);
  display: flex; flex-direction: column;
  transform: translateX(102%); transition: transform 0.7s var(--ease);
  box-shadow: -30px 0 80px rgba(25, 24, 21, 0.12);
}
.drawer.is-open { transform: none; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: 22px 28px; border-bottom: 1px solid var(--line); }
.drawer__head h3 { font-size: 22px; display: flex; align-items: baseline; gap: 12px; }
.drawer__head h3 .jp { font-size: 14px; color: var(--ink-mute); }
.drawer__body { flex: 1; overflow-y: auto; padding: 8px 28px; overscroll-behavior: contain; }
.drawer__foot { padding: 22px 28px 28px; border-top: 1px solid var(--line); display: grid; gap: 14px; background: var(--washi); }
.cart-line { display: grid; grid-template-columns: 64px 1fr auto; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--line); align-items: center; }
.cart-line__thumb { width: 64px; height: 64px; background: var(--washi); display: grid; place-items: center; border-radius: var(--radius); }
.cart-line__title { font-size: 14.5px; font-weight: 500; line-height: 1.4; }
.cart-line__meta { font-size: 12.5px; color: var(--ink-mute); margin-top: 2px; }
.cart-line__hint { font-size: 12px; color: var(--shu); margin-top: 4px; }
.cart-line__price { text-align: right; font-family: var(--font-mono); font-size: 14px; }
.cart-line__remove { font-size: 12px; color: var(--ink-mute); margin-top: 6px; }
.cart-line__remove:hover { color: var(--shu); }
.cart-empty { padding: 72px 0; text-align: center; color: var(--ink-mute); display: grid; gap: 18px; justify-items: center; }
.cart-empty .jp { font-size: 64px; color: var(--line-strong); line-height: 1; }
.sum-row { display: flex; justify-content: space-between; font-size: 14.5px; }
.sum-row.total { font-size: 18px; font-weight: 500; padding-top: 10px; border-top: 1px solid var(--line); }
.sum-row .num { font-size: 0.95em; }

.qty { display: inline-flex; align-items: center; height: 36px; border: 1px solid var(--line); border-radius: 18px; }
.qty button { width: 34px; height: 34px; display: grid; place-items: center; font-size: 16px; color: var(--ink-soft); }
.qty button:hover { color: var(--ink); }
.qty input { width: 56px; height: 34px; border: 0; background: none; text-align: center; font-family: var(--font-mono); font-size: 13.5px; outline: none; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 16px; visibility: hidden; }
.modal.is-open { visibility: visible; }
.modal__card {
  position: relative; width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--paper); padding: 40px 36px 34px; border-radius: 4px;
  opacity: 0; transform: translateY(24px) scale(0.98); transition: opacity 0.5s var(--ease), transform 0.6s var(--ease);
  box-shadow: 0 40px 120px rgba(25, 24, 21, 0.25);
}
.modal.is-open .modal__card { opacity: 1; transform: none; }
.modal__close { position: absolute; top: 12px; right: 12px; }
.modal h3 { font-size: 28px; margin-bottom: 6px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--washi); border-radius: 999px; margin: 20px 0 24px; }
.tabs button { flex: 1; height: 40px; border-radius: 999px; font-size: 14px; color: var(--ink-soft); transition: background-color 0.3s, color 0.3s; }
.tabs button.is-active { background: var(--sumi); color: var(--washi); }

/* ---------- Toast ---------- */
.toasts { position: fixed; left: 50%; bottom: 24px; z-index: 95; display: grid; gap: 8px; transform: translateX(-50%); width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 4px;
  background: var(--sumi); color: var(--washi); font-size: 14px; pointer-events: auto;
  box-shadow: 0 16px 40px rgba(25, 24, 21, 0.25);
  animation: toast-in 0.6s var(--ease);
}
.toast.is-error { background: var(--shu); }
.toast.is-out { animation: toast-out 0.4s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Footer ---------- */
.site-footer { background: var(--sumi); color: var(--washi); padding: 110px 0 36px; position: relative; overflow: hidden; }
.footer-grid { display: grid; grid-template-columns: 1.3fr 1fr 1.1fr 1fr 1fr; gap: 40px; }
.nav .nav__main { opacity: 0.55; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; padding-left: 26px; border-left: 1px solid var(--line); }
@media (max-width: 1180px) { .nav .nav__main { display: none; } }
.footer-grid h4 { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; opacity: 0.5; margin-bottom: 18px; font-weight: 400; }
.footer-grid p, .footer-grid li { font-size: 14.5px; line-height: 1.9; opacity: 0.85; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid a:hover { color: var(--kraft-light); }
.footer-mark {
  margin-top: 96px; font-family: var(--font-display); font-weight: 300;
  font-size: clamp(64px, 17vw, 260px); line-height: 0.82; letter-spacing: 0.04em;
  color: transparent; -webkit-text-stroke: 1px rgba(242, 237, 227, 0.22);
  white-space: nowrap; user-select: none;
}
.footer-base { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line-inv); font-size: 12.5px; opacity: 0.55; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer-links a:hover { color: var(--kraft-light); }
@media (max-width: 1100px) { .footer-grid { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .footer-grid { grid-template-columns: 1fr; } }

/* ---------- Cursor (เฉพาะเมาส์) ---------- */
.cursor { position: fixed; top: 0; left: 0; z-index: 100; pointer-events: none; mix-blend-mode: difference; opacity: 0; transition: opacity 0.4s; }
.cursor.is-active { opacity: 1; }
.cursor__dot { position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; }
.cursor__ring {
  position: absolute; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  display: grid; place-items: center;
  transition: width 0.45s var(--ease), height 0.45s var(--ease), margin 0.45s var(--ease), background-color 0.45s, border-color 0.45s;
}
.cursor__label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.15em; color: #000; opacity: 0; transition: opacity 0.3s; text-transform: uppercase; }
.cursor.is-hover .cursor__ring { width: 64px; height: 64px; margin: -32px 0 0 -32px; border-color: transparent; background: rgba(255, 255, 255, 0.92); }
.cursor.is-label .cursor__ring { width: 84px; height: 84px; margin: -42px 0 0 -42px; background: #fff; border-color: transparent; }
.cursor.is-label .cursor__label { opacity: 1; }
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

/* ---------- Reveal ---------- */
.split-line { display: block; }
.split-mask { display: inline-block; overflow: hidden; vertical-align: top; padding: 0.42em 0.02em 0.2em; margin: -0.42em -0.02em -0.2em; }
.split-word { display: inline-block; will-change: transform; }
[data-reveal] { opacity: 0; transform: translateY(26px); transition: opacity 1.1s var(--ease), transform 1.1s var(--ease); }
[data-reveal].is-in { opacity: 1; transform: none; }
.no-js [data-reveal], .reduced [data-reveal] { opacity: 1; transform: none; }

/* ---------- ทั่วไป ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border-radius: 13px; font-size: 12.5px; font-weight: 500; background: var(--washi-2); color: var(--ink-soft); white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.pill--pending_payment { background: #f3e6c9; color: #7c5a12; }
.pill--verifying { background: #f1dfd2; color: #9a4a22; }
.pill--paid { background: #dfe6d5; color: #3f5a2e; }
.pill--ready_pickup, .pill--shipped { background: #dbe2e6; color: #2f4d5e; }
.pill--delivered, .pill--completed { background: #d9e3d3; color: #2d4a22; }
.pill--cancelled { background: #e7e1db; color: #7b7067; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.skeleton { background: linear-gradient(90deg, var(--washi-2), var(--washi), var(--washi-2)); background-size: 200% 100%; animation: sk 1.4s infinite; border-radius: 3px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .grain { animation: none; }
}
