/* TG Shop · storefront
   Mobile-first shop for small sellers: big photos, one-tap add, bottom sheets.
   Everything is scoped to .tgsm so it does not fight the site's theme. */

.tgsm {
	--tg-accent: #127a5c;
	--tg-accent-ink: #ffffff;
	--tg-ink: #14201b;
	--tg-muted: #65736d;
	--tg-line: #e3e9e6;
	--tg-soft: #f3f6f4;
	--tg-paper: #ffffff;
	--tg-warn: #b4570b;
	--tg-warn-bg: #fff3e4;
	--tg-bad: #b42330;
	--tg-ok: #157a4a;
	--tg-r: 18px;
	--tg-font: "Kantumruy Pro", "Noto Sans Khmer", "Khmer OS Battambang", "Khmer UI", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	font-family: var(--tg-font);
	color: var(--tg-ink);
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
}
.tgsm *, .tgsm *::before, .tgsm *::after { box-sizing: border-box; }
.tgsm [hidden] { display: none !important; }
:where(.tgsm) button { font: inherit; color: inherit; cursor: pointer; text-transform: none; letter-spacing: 0; box-shadow: none; }
.tgsm-shop.alignwide { width: 100%; }
.tgsm img { max-width: 100%; display: block; }
.tgsm svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tgsm :focus-visible { outline: 3px solid color-mix(in srgb, var(--tg-accent) 45%, transparent); outline-offset: 2px; }
.tg-muted { color: var(--tg-muted); }

/* ---------- toolbar ---------- */
.tg-bar { display: flex; flex-direction: column; gap: 12px; margin: 0 0 18px; }
.tg-search { display: flex; align-items: center; gap: 10px; background: var(--tg-soft); border-radius: 999px; padding: 0 16px; height: 48px; color: var(--tg-muted); max-width: 520px; }
.tg-search input { flex: 1; min-width: 0; border: 0 !important; background: transparent !important; outline: 0; font: inherit; font-size: 15px; color: var(--tg-ink); padding: 0 !important; box-shadow: none !important; height: 100%; }
.tg-search:focus-within { box-shadow: 0 0 0 2px var(--tg-accent); }
.tg-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.tg-chips::-webkit-scrollbar { display: none; }
.tg-chips button { flex: none; border: 1px solid var(--tg-line); background: var(--tg-paper); border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.tgsm .tg-chips button.is-on { background: var(--tg-ink); border-color: var(--tg-ink); color: #fff; }

/* ---------- product grid ---------- */
.tg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 14px; }
@media (min-width: 720px) { .tg-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 30px 22px; } }
@media (min-width: 1100px) { .tg-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); } }
.tg-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tg-card-img { position: relative; display: block; width: 100%; aspect-ratio: 4 / 5; border: 0; padding: 0; border-radius: var(--tg-r); overflow: hidden; background: var(--tg-soft); }
.tg-card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.tg-card:hover .tg-card-img img { transform: scale(1.04); }
.tg-ph { display: grid; place-items: center; width: 100%; height: 100%; font-size: 42px; font-weight: 700; color: color-mix(in srgb, var(--tg-accent) 55%, #fff); background: color-mix(in srgb, var(--tg-accent) 10%, #fff); }
.tg-tag { position: absolute; left: 10px; top: 10px; background: var(--tg-warn-bg); color: var(--tg-warn); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.tg-tag-out { background: rgba(20, 32, 27, .82); color: #fff; }
.tg-card.is-out .tg-card-img img { filter: grayscale(.8); opacity: .7; }
.tg-card-body { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; min-width: 0; flex: 1; }
.tg-card-body h3 { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3; letter-spacing: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tg-card-sizes { margin: 0; font-size: 12.5px; color: var(--tg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.tg-price { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tgsm .tg-add, .tg-layer .tg-add { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--tg-accent); color: var(--tg-accent-ink); display: grid; place-items: center; transition: transform .15s; }
.tg-add:active { transform: scale(.9); }
.tg-nomatch, .tg-empty { text-align: center; color: var(--tg-muted); padding: 40px 0; }

/* ---------- buttons, fields ---------- */
.tgsm .tg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; border: 0; border-radius: 14px; background: var(--tg-accent); color: var(--tg-accent-ink); font-size: 16px; font-weight: 600; text-decoration: none; transition: filter .15s, transform .1s; }
.tgsm .tg-btn:hover { filter: brightness(1.06); }
.tgsm .tg-btn:active { transform: translateY(1px); }
.tgsm .tg-btn:disabled { opacity: .55; cursor: default; }
.tgsm .tg-btn-block { width: 100%; }
.tgsm .tg-btn-ghost { background: var(--tg-soft); color: var(--tg-ink); }
.tg-field { display: flex; flex-direction: column; gap: 6px; }
.tg-field > span { font-size: 13px; font-weight: 600; }
.tgsm input:not([type=radio]):not([type=search]), .tgsm select, .tgsm textarea {
	width: 100%; font: inherit; font-size: 16px; color: var(--tg-ink); background: var(--tg-paper);
	border: 1.5px solid var(--tg-line); border-radius: 12px; padding: 12px 14px; min-height: 50px; box-shadow: none; outline: 0; margin: 0;
}
.tgsm textarea { min-height: 76px; resize: vertical; }
.tgsm input:focus, .tgsm select:focus, .tgsm textarea:focus { border-color: var(--tg-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tg-accent) 18%, transparent); }
.tg-field.has-err input, .tg-field.has-err textarea, .tg-field.has-err select { border-color: var(--tg-bad); }
.tg-err { color: var(--tg-bad); font-size: 13px; }

/* ---------- floating cart bar ---------- */
.tg-cartbar { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 99990; width: min(520px, calc(100% - 24px)); transform: translate(-50%, 140%); transition: transform .3s cubic-bezier(.2, .9, .3, 1.2); }
.tg-cartbar.is-on { transform: translate(-50%, 0); }
.tgsm.tg-cartbar button { width: 100%; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 18px; background: var(--tg-ink); color: #fff; padding: 10px 10px 10px 18px; min-height: 60px; box-shadow: 0 12px 32px rgba(20, 32, 27, .28); text-align: left; }
.tg-cartbar .tg-count { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: #fff; color: var(--tg-ink); font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.tg-cartbar .tg-cb-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.tg-cartbar small { opacity: .7; font-size: 12.5px; }
.tg-cartbar b { font-size: 16px; font-variant-numeric: tabular-nums; }
.tg-cartbar .tg-cb-go { background: var(--tg-accent); color: var(--tg-accent-ink); border-radius: 12px; padding: 10px 16px; font-weight: 600; font-size: 15px; white-space: nowrap; }

/* ---------- sheets (product, checkout) ---------- */
html.tg-lock, html.tg-lock body { overflow: hidden !important; }
.tg-layer { position: fixed; inset: 0; z-index: 99995; display: flex; align-items: flex-end; justify-content: center; }
.tg-scrim { position: absolute; inset: 0; background: rgba(13, 22, 18, .5); animation: tg-fade .2s ease; }
.tg-sheet { position: relative; width: 100%; max-height: 94vh; max-height: 94dvh; background: var(--tg-paper); border-radius: 24px 24px 0 0; display: flex; flex-direction: column; animation: tg-up .32s cubic-bezier(.2, .9, .3, 1); overflow: hidden; padding-bottom: env(safe-area-inset-bottom); }
.tg-sheet::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--tg-line); z-index: 2; }
@media (min-width: 760px) {
	.tg-layer { align-items: center; padding: 24px; }
	.tg-sheet { max-width: 880px; max-height: min(720px, 92vh); border-radius: 24px; animation: tg-pop .25s ease; }
	.tg-sheet::before { display: none; }
	.tg-layer.is-side { justify-content: flex-end; padding: 0; }
	.tg-layer.is-side .tg-sheet { max-width: 460px; height: 100%; max-height: none; border-radius: 0; animation: tg-left .3s cubic-bezier(.2, .9, .3, 1); }
}
@keyframes tg-up { from { transform: translateY(100%); } }
@keyframes tg-left { from { transform: translateX(100%); } }
@keyframes tg-pop { from { transform: scale(.96); opacity: 0; } }
@keyframes tg-fade { from { opacity: 0; } }
.tg-x { position: absolute; top: 12px; right: 12px; z-index: 3; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); display: grid; place-items: center; box-shadow: 0 2px 10px rgba(0, 0, 0, .1); }
.tg-sheet-head { display: flex; align-items: center; gap: 10px; padding: 22px 64px 14px 20px; border-bottom: 1px solid var(--tg-line); flex: none; }
.tg-sheet-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: 0; }
.tg-sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 18px; }
.tg-sheet-foot { flex: none; padding: 14px 20px 18px; border-top: 1px solid var(--tg-line); display: flex; gap: 10px; background: var(--tg-paper); }
.tg-sheet-foot .tg-btn { flex: 1; }
.tg-sheet-foot .tg-btn-ghost { flex: 0 0 auto; }

/* product sheet */
.tg-pv { display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 760px) { .tg-pv { display: grid; grid-template-columns: 1.05fr 1fr; overflow: hidden; height: 100%; } .tg-pv-info { overflow-y: auto; } }
.tg-gallery { position: relative; background: var(--tg-soft); }
.tg-slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; aspect-ratio: 4 / 5; max-height: 46vh; width: 100%; }
@media (min-width: 760px) { .tg-slides { height: 100%; max-height: none; aspect-ratio: auto; } }
.tg-slides::-webkit-scrollbar { display: none; }
.tg-slides img, .tg-slides .tg-ph { flex: none; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: center; }
.tg-dots { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.tg-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .6); transition: width .2s, background .2s; }
.tg-dots i.is-on { width: 20px; border-radius: 4px; background: #fff; }
.tg-pv-info { padding: 22px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.tg-pv-info .tg-cat { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tg-accent); }
.tg-pv-info h2 { margin: 0; font-size: 23px; line-height: 1.25; font-weight: 700; letter-spacing: 0; text-wrap: balance; }
.tg-pv-info .tg-price { font-size: 24px; }
.tg-pv-info .tg-desc { margin: 0; color: var(--tg-muted); white-space: pre-line; }
.tg-label { font-size: 13px; font-weight: 600; margin-bottom: 8px; display: block; }
.tg-sizes { display: flex; flex-wrap: wrap; gap: 8px; }
.tg-sizes button { min-width: 52px; height: 46px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--tg-line); background: var(--tg-paper); font-weight: 600; }
.tgsm .tg-sizes button.is-on { border-color: var(--tg-ink); background: var(--tg-ink); color: #fff; }
.tg-sizes.is-shake { animation: tg-shake .35s; }
@keyframes tg-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.tg-buy { display: flex; gap: 10px; align-items: stretch; margin-top: auto; position: sticky; bottom: 0; background: var(--tg-paper); padding: 12px 0 4px; box-shadow: 0 -10px 12px -8px rgba(255,255,255,.95); }
.tg-buy .tg-btn { flex: 1; }
.tg-stepper { display: flex; align-items: center; width: fit-content; flex: none; border: 1.5px solid var(--tg-line); border-radius: 14px; height: 52px; }
.tg-stepper button { width: 44px; height: 100%; border: 0; background: transparent; font-size: 20px; font-weight: 500; }
.tg-stepper button:disabled { opacity: .3; }
.tg-stepper output { min-width: 28px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.tg-stepper.is-sm { height: 38px; border-radius: 10px; }
.tg-stepper.is-sm button { width: 34px; font-size: 17px; }
.tg-left { color: var(--tg-warn); font-size: 13.5px; font-weight: 600; }

/* checkout */
.tg-steps { display: flex; gap: 6px; padding: 0 20px 14px; flex: none; }
.tg-steps li { flex: 1; list-style: none; font-size: 12.5px; font-weight: 600; color: var(--tg-muted); display: flex; flex-direction: column; gap: 6px; }
.tg-steps li::before { content: ""; height: 4px; border-radius: 4px; background: var(--tg-line); transition: background .2s; }
.tg-steps li.is-on { color: var(--tg-ink); }
.tg-steps li.is-on::before { background: var(--tg-accent); }
.tg-steps { margin: 0; border-bottom: 1px solid var(--tg-line); }
.tg-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.tg-lines li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.tg-thumb { width: 64px; height: 76px; border-radius: 12px; overflow: hidden; background: var(--tg-soft); }
.tg-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tg-line-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tg-line-info b { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.tg-line-info small { color: var(--tg-muted); font-size: 13px; }
.tg-line-end { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.tg-line-end b { font-variant-numeric: tabular-nums; }
.tg-link { border: 0; background: none; padding: 0; color: var(--tg-muted); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
.tg-sum { margin: 0; padding: 14px 16px; border-radius: 14px; background: var(--tg-soft); display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-variant-numeric: tabular-nums; }
.tg-sum dt { color: var(--tg-muted); }
.tg-sum dd { margin: 0; text-align: right; font-weight: 500; }
.tg-sum .t { color: var(--tg-ink); font-weight: 700; font-size: 17px; padding-top: 8px; border-top: 1px dashed var(--tg-line); }
.tg-zones, .tg-pays { display: grid; gap: 8px; }
.tg-opt { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px solid var(--tg-line); border-radius: 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.tg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.tg-opt .tg-opt-dot { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--tg-line); display: grid; place-items: center; }
.tg-opt:has(input:checked) { border-color: var(--tg-accent); background: color-mix(in srgb, var(--tg-accent) 6%, #fff); }
.tg-opt:has(input:checked) .tg-opt-dot { border-color: var(--tg-accent); }
.tg-opt:has(input:checked) .tg-opt-dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--tg-accent); }
.tg-opt:has(input:focus-visible) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tg-accent) 30%, transparent); }
.tg-opt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tg-opt-text b { font-weight: 600; }
.tg-opt-text small { color: var(--tg-muted); font-size: 13px; }
.tg-opt-end { font-weight: 600; font-variant-numeric: tabular-nums; }
.tg-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.tg-alert { padding: 12px 14px; border-radius: 12px; background: #fdecee; color: var(--tg-bad); font-size: 14px; }

/* thank you */
.tg-done { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 0; }
.tg-done-icon { width: 64px; height: 64px; border-radius: 50%; background: color-mix(in srgb, var(--tg-accent) 14%, #fff); color: var(--tg-accent); display: grid; place-items: center; animation: tg-pop .4s ease; }
.tg-done-icon svg { width: 32px; height: 32px; stroke-width: 2.5; }
.tg-done h2 { margin: 0; font-size: 22px; letter-spacing: 0; }
.tg-orderno { display: flex; flex-direction: column; align-items: center; padding: 10px 26px; border-radius: 14px; background: var(--tg-soft); }
.tg-orderno small { color: var(--tg-muted); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
.tg-orderno b { font-size: 30px; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.tg-qr { width: 230px; max-width: 80%; border-radius: 16px; border: 1px solid var(--tg-line); padding: 10px; background: #fff; }
.tg-done p { margin: 0; max-width: 40ch; }

/* toast */
.tg-toast { position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top)); z-index: 99999; transform: translate(-50%, -150%); background: var(--tg-ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; display: flex; gap: 8px; align-items: center; transition: transform .3s cubic-bezier(.2, .9, .3, 1.2); box-shadow: 0 8px 24px rgba(0, 0, 0, .2); }
.tg-toast.is-on { transform: translate(-50%, 0); }
.tg-toast svg { width: 18px; height: 18px; color: #7ee2b3; }

/* ---------- tracking ---------- */
.tgsm-track { max-width: 520px; margin: 0 auto; }
.tg-track-card { background: var(--tg-paper); border: 1px solid var(--tg-line); border-radius: 24px; padding: 26px 22px; display: flex; flex-direction: column; gap: 16px; }
.tg-track-card h2 { margin: 0; font-size: 22px; letter-spacing: 0; }
.tg-track-card > p { margin: -8px 0 0; }
.tg-track-form { display: grid; gap: 12px; }
.tg-track-form label { display: flex; flex-direction: column; gap: 6px; }
.tg-track-form label span { font-size: 13px; font-weight: 600; }
.tg-tl { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 0; padding: 0; list-style: none; }
.tg-tl li { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--tg-muted); font-weight: 500; }
.tg-tl li::before { content: ""; height: 6px; border-radius: 6px; background: var(--tg-line); }
.tg-tl li.is-on { color: var(--tg-ink); }
.tg-tl li.is-on::before { background: var(--tg-accent); }
.tg-tl li.is-now { font-weight: 700; }
.tg-track-out { border-top: 1px solid var(--tg-line); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.tg-track-out h3 { margin: 0; font-size: 18px; letter-spacing: 0; display: flex; justify-content: space-between; gap: 10px; }
.tg-track-out p { margin: 0; }
.tg-pill { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--tg-soft); }
.tg-pill.is-ok { background: #e3f4ea; color: var(--tg-ok); }

@media (prefers-reduced-motion: reduce) {
	.tgsm *, .tg-layer *, .tg-cartbar, .tg-toast { animation: none !important; transition: none !important; }
}

/* ---------- Telegram ordering ---------- */
.tgsm .tg-add.is-tg { background: #2aabee; color: #fff; text-decoration: none; }
.tgsm .tg-add.is-tg svg { margin-left: -2px; }
.tgsm .tg-btn-tg, .tg-layer .tg-btn-tg { background: #2aabee; color: #fff; width: 100%; text-decoration: none; }
.tg-layer .tg-done .tg-btn-tg { width: auto; padding: 0 24px; }
.tgsm .tg-btn-tg svg, .tg-layer .tg-btn-tg svg, .tg-alt svg { width: 20px; height: 20px; }
.tg-layer .tg-alt { display: inline-flex; align-items: center; justify-content: center; gap: 8px; align-self: center; color: #1b8fcc; font-weight: 600; font-size: 14.5px; text-decoration: none; padding: 6px 10px; border-radius: 10px; }
.tg-layer .tg-alt:hover { background: #eaf6fd; }
