/*
Theme Name: PromptShop
Theme URI: https://example.com/promptshop
Author: BIS Chiangmai
Description: ธีม WooCommerce แบบ Block theme (FSE) — สร้างใหม่แทน Storefront Ecommerce แก้จุดอ่อนเรื่องโค้ดบวม (customizer 178KB, Bootstrap 193KB, jQuery) ด้วยแนวทาง lean: design tokens ทั้งหมดอยู่ใน theme.json, template เป็น block markup, ไม่มี CSS framework, ไม่มี jQuery ฝั่งธีม
Requires at least: 6.6
Tested up to: 6.9
Requires PHP: 7.4
Version: 0.7.14
License: GNU General Public License v3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Text Domain: promptshop
Tags: e-commerce, block-patterns, full-site-editing, wide-blocks
*/

/* ============================================================
   Design system ตาม UI handoff (ui-brief 2026-07-19)
   สี/ฟอนต์/รัศมี/เงา อ้างจาก theme.json ผ่าน alias ข้างล่างเท่านั้น
   ============================================================ */

:root {
	--blue-50: var(--wp--preset--color--blue-50, #f3f8fc);
	--blue-100: var(--wp--preset--color--blue-100, #e6f0f9);
	--blue-200: var(--wp--preset--color--blue-200, #c7e0f2);
	--blue-300: var(--wp--preset--color--blue-300, #96c5e8);
	--blue-400: var(--wp--preset--color--blue-400, #5da5da);
	--blue-500: var(--wp--preset--color--blue-500, #3788c7);
	--blue-600: var(--wp--preset--color--blue-600, #266cab);
	--blue-700: var(--wp--preset--color--blue-700, #1f568b);
	--blue-800: var(--wp--preset--color--blue-800, #1e4973);
	--blue-900: var(--wp--preset--color--blue-900, #1e3e60);
	--blue-950: var(--wp--preset--color--blue-950, #142940);
	--ink: var(--wp--preset--color--ink, #142940);
	--muted: var(--wp--preset--color--muted, #64819c);
	--bg: var(--wp--preset--color--blue-50, #f3f8fc);
	--card: var(--wp--preset--color--base, #ffffff);
	--border: var(--wp--preset--color--blue-100, #e6f0f9);
	--ok-bg: #e8f6ee; --ok-ink: #14532d;
	--warn-bg: #fff4e0; --warn-ink: #92400e;
	--err-bg: #fdecec; --err-ink: #b3261e;
	--radius: var(--wp--custom--radius--md, 12px);
	--radius-sm: var(--wp--custom--radius--sm, 8px);
	--shadow: var(--wp--custom--shadow--sm, 0 1px 3px rgba(20,41,64,.06), 0 4px 16px rgba(20,41,64,.05));
	--shadow-lg: var(--wp--custom--shadow--lg, 0 8px 32px rgba(20,41,64,.14));
	--ring: rgba(55, 136, 199, .25);
	--font-head: var(--wp--preset--font-family--heading, 'Prompt', sans-serif);
	--font-body: var(--wp--preset--font-family--body, 'Sarabun', sans-serif);
}

/* box-sizing ทั้งหน้า — กันปุ่ม/ช่องกรอกที่กว้าง 100% ล้นกรอบเพราะ padding */
*, *::before, *::after { box-sizing: border-box; }

:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }
button { font: inherit; }
.muted { color: var(--muted); }
.stars { color: #f5a623; letter-spacing: 2px; white-space: nowrap; }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }

/* ── แถบประกาศ + ส่วนหัว ── */
.announce { background: var(--blue-950); color: var(--blue-100); text-align: center; font: 500 14px/1.4 var(--font-head); padding: 10px 16px; margin: 0; }
.site-head { position: sticky; top: 0; z-index: 50; background: var(--card); border-bottom: 1px solid var(--border); }
.site-head .wrap { display: flex; align-items: center; gap: 12px; height: 64px; position: relative; }
.logo { font: 600 22px var(--font-head); color: var(--ink); text-decoration: none; }
.logo:hover { color: var(--ink); }
.logo b { color: var(--blue-600); font-weight: 600; }
.logo.logo-img { display: inline-flex; align-items: center; }
.logo img { max-height: 44px; width: auto; display: block; }
nav.main { display: none; gap: 24px; margin-left: 12px; }
nav.main a { color: var(--ink); font: 500 16px var(--font-head); padding: 4px 0; text-decoration: none; }
nav.main a:hover, nav.main a.on { color: var(--blue-600); }
nav.main.open { display: flex; flex-direction: column; position: absolute; top: 64px; left: 0; right: 0; background: var(--card); border-bottom: 1px solid var(--border); padding: 16px; gap: 4px; box-shadow: var(--shadow-lg); }
nav.main.open a { padding: 12px 8px; border-radius: var(--radius-sm); }
nav.main.open a:hover { background: var(--blue-50); }
.head-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--radius-sm); background: none; border: 0; color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: var(--blue-50); color: var(--blue-600); }
.cart-n { position: absolute; top: 3px; right: 1px; background: var(--blue-600); color: var(--card); font: 600 11px/1 var(--font-head); padding: 3px 6px; border-radius: 999px; }
.cart-n:empty { display: none; }
@media (min-width: 768px) { nav.main { display: flex; } .menu-btn { display: none; } }

/* ── ปุ่ม ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 500 16px var(--font-head); border-radius: var(--radius-sm); padding: 10px 22px; min-height: 44px; border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: background .15s, color .15s, box-shadow .15s; }
.btn-primary { background: var(--blue-600); color: var(--card); }
.btn-primary:hover { background: var(--blue-700); color: var(--card); }
.btn-secondary { background: transparent; border-color: var(--blue-600); color: var(--blue-600); }
.btn-secondary:hover { background: var(--blue-50); color: var(--blue-700); }
.btn-danger { background: transparent; border-color: var(--err-ink); color: var(--err-ink); }
.btn-danger:hover { background: var(--err-bg); }
.btn-inverse { background: var(--card); color: var(--blue-700); }
.btn-inverse:hover { background: var(--blue-100); color: var(--blue-800); }
/* ปุ่ม CTA ชำระเงิน — สีส้มสะดุดตา */
.btn-accent { background: #e8590c; color: #fff; }
.btn-accent:hover { background: #c74b06; color: #fff; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 32px; font-size: 18px; }

/* ── section / การ์ด ── */
.sec { margin-top: 48px; }
.sec > h2 { font-size: 24px; margin-bottom: 16px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.sec-head h2 { margin: 0; }
@media (min-width: 768px) {
	.sec > h2 { font-size: 28px; margin-bottom: 24px; }
	.sec-head { margin-bottom: 24px; }
	.sec-head h2 { margin: 0; }
}
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.crumb { font-size: 14px; color: var(--muted); margin: 16px 0; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--blue-600); }

/* ── การ์ดสินค้า (ใช้ร่วมทุกหน้า) ── */
.pgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 768px) { .pgrid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1140px) { .pgrid { grid-template-columns: repeat(4, 1fr); gap: 24px; } }
.pgrid.cols-3 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) { .pgrid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.pcard { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.pcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.pimg { aspect-ratio: 1/1; background: var(--blue-100); display: flex; align-items: center; justify-content: center; color: var(--blue-400); font: 500 13px var(--font-head); overflow: hidden; }
.pimg img { width: 100%; height: 100%; object-fit: cover; }
.pimg.alt { background: var(--blue-200); color: var(--blue-500); }
.pbody { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.pname { font: 700 16px/1.5 var(--font-body); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.pname a { color: inherit; text-decoration: none; }
.pprice { font: 600 18px var(--font-head); color: var(--blue-600); }
.pprice s { color: var(--muted); font: 400 15px var(--font-body); margin-left: 8px; }
.pcard .btn { margin-top: auto; }
@media (hover: hover) and (min-width: 768px) {
	.pcard .btn { opacity: 0; transform: translateY(4px); transition: .15s; }
	.pcard:hover .btn, .pcard .btn:focus-visible { opacity: 1; transform: none; }
}
.badge { position: absolute; top: 12px; left: 12px; z-index: 1; font: 500 13px var(--font-head); padding: 4px 12px; border-radius: 999px; }
.badge-new { background: var(--blue-600); color: var(--card); }
.badge-sale, .badge-out { background: var(--err-bg); color: var(--err-ink); }
.pcard.out .pimg { opacity: .6; }

/* ── pill สถานะ ── */
.pill { display: inline-flex; align-items: center; font: 500 13px var(--font-head); padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.pill-wait { background: var(--blue-100); color: var(--blue-700); }
.pill-ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill-err { background: var(--err-bg); color: var(--err-ink); }

/* ── ฟอร์ม / notice / qty ── */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.field label { font: 500 15px var(--font-body); }
.field input, .field textarea, .field select { border: 1px solid var(--blue-200); border-radius: var(--radius-sm); padding: 10px 12px; font: 400 16px var(--font-body); color: var(--ink); background: var(--card); min-height: 44px; width: 100%; }
.field textarea { min-height: 96px; line-height: 1.65; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--ring); }
.notice { display: flex; gap: 8px; align-items: flex-start; border-radius: var(--radius-sm); padding: 12px 16px; font-size: 15px; margin: 12px 0; }
.notice svg { flex: none; margin-top: 3px; }
.notice-ok { background: var(--ok-bg); color: var(--ok-ink); }
.notice-err { background: var(--err-bg); color: var(--err-ink); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--blue-200); border-radius: var(--radius-sm); background: var(--card); }
.qty button { width: 44px; height: 44px; background: none; border: 0; font: 600 18px var(--font-head); color: var(--blue-600); cursor: pointer; border-radius: var(--radius-sm); }
.qty button:hover { background: var(--blue-50); }
.qty button:disabled { color: var(--blue-200); cursor: default; background: none; }
.qty output { min-width: 36px; text-align: center; font: 600 16px var(--font-head); }

/* ── Hero หน้าแรก ── */
/* margin-bottom 54 = เว้นจริง 30px (กล่องจุดเด่นถูกดึงขึ้น -24px) */
.hero { position: relative; overflow: hidden; background: var(--blue-700); color: var(--card); padding: 32px 0; margin-bottom: 54px; }
.hero::before { content: ""; position: absolute; top: -120px; right: -120px; width: 420px; height: 420px; border-radius: 999px; background: var(--blue-800); opacity: .55; }
.hero::after { content: ""; position: absolute; bottom: -160px; left: -100px; width: 360px; height: 360px; border-radius: 999px; border: 2px solid var(--blue-600); opacity: .5; }
.hero .wrap { position: relative; z-index: 1; display: grid; gap: 32px; }
.hero-kicker { display: inline-flex; align-items: center; gap: 8px; background: var(--blue-800); color: var(--blue-100); font: 500 13px var(--font-head); padding: 6px 14px; border-radius: 999px; margin-bottom: 16px; }
.hero-kicker::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--blue-300); }
.hero h1 { font-size: 32px; color: var(--card); letter-spacing: -.5px; margin: 0; }
.hero h1 em { font-style: normal; color: var(--blue-300); }
.hero p { color: var(--blue-100); font-size: 17px; margin: 12px 0 24px; max-width: 44ch; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.hero-link { color: var(--blue-100); font: 500 16px var(--font-head); display: inline-flex; align-items: center; gap: 6px; min-height: 44px; text-decoration: none; }
.hero-link:hover { color: var(--card); }
.hero-visual { position: relative; }
.hero-visual::before { content: ""; position: absolute; inset: 24px -12px -12px 24px; border-radius: var(--radius); background: var(--blue-800); opacity: .6; }
.hero-tag { position: absolute; z-index: 2; right: 12px; top: 12px; background: var(--card); color: var(--blue-700); font: 600 14px var(--font-head); padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow-lg); }
.hero-tag small { display: block; font: 400 11px var(--font-body); color: var(--muted); }
.hero-img { position: relative; z-index: 1; background: var(--blue-100); border: 1px solid var(--blue-200); border-radius: var(--radius); aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; color: var(--blue-400); font: 500 14px var(--font-head); box-shadow: var(--shadow-lg); overflow: hidden; }
.hero-img img { width: 100%; height: 100%; object-fit: cover; }
@media (min-width: 768px) {
	.hero { padding: 0; display: flex; align-items: center; }
	.hero .wrap { grid-template-columns: 1.1fr 1fr; align-items: center; gap: 48px; padding-top: 32px; padding-bottom: 32px; }
	.hero h1 { font-size: 44px; }
	/* ตำแหน่งภาพซ้าย (ตั้งจาก Customizer) — สลับคอลัมน์ */
	.hero-img-left .wrap { grid-template-columns: 1fr 1.1fr; }
	.hero-img-left .hero-visual { order: -1; }
}

/* ── Benefits / หมวด / สถิติ / รีวิว ── */
/* กัน margin อัตโนมัติ (block-gap) ของ WP ที่ทำให้กล่องใน grid สูงไม่เท่ากัน */
.benefits > *, .cats > *, .stats > *, .reviews > *, .pgrid > * { margin-block-start: 0 !important; }
.wp-block-group.benefits { margin-block-start: -24px !important; }
.wp-block-group.sec { margin-block-start: 48px !important; }
.sec > .wp-block-group { margin-block-start: 0 !important; }
.benefits { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: -24px; }
@media (min-width: 768px) { .benefits { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.benefit { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.benefit svg { color: var(--blue-600); }
.benefit h3 { font-size: 16px; font-weight: 500; margin: 0 !important; }
.benefit p { font-size: 14px; color: var(--muted); line-height: 1.5; margin: 0 !important; }
.cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 768px) { .cats { grid-template-columns: repeat(4, 1fr); gap: 16px; } }
.cat { display: block; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: box-shadow .15s, transform .15s; text-decoration: none; }
.cat:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.cat .pimg { aspect-ratio: 4/3; }
.cat h3 { font-size: 16px; font-weight: 500; color: var(--ink); padding: 12px 16px; margin: 0; }
.stats { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: 24px 8px; gap: 8px; }
.stats b, .stats strong { display: block; font: 600 28px var(--font-head); color: var(--blue-600); }
@media (min-width: 768px) { .stats b, .stats strong { font-size: 36px; } }
.stats span, .stats p { font-size: 14px; color: var(--muted); margin: 0 !important; }
.reviews { display: grid; gap: 12px; }
@media (min-width: 768px) { .reviews { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
.review { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.review p { font-size: 15px; margin: 0 !important; }
.review footer { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.avatar { width: 40px; height: 40px; border-radius: 999px; background: var(--blue-100); color: var(--blue-700); display: flex; align-items: center; justify-content: center; font: 600 16px var(--font-head); }
.review b { font: 500 15px var(--font-head); }
.review span { display: block; font-size: 13px; color: var(--muted); }

/* ── ส่วนท้าย ── */
.site-foot { background: var(--blue-950); color: var(--blue-200); margin-top: 48px; padding: 48px 0 24px; }
.foot-grid { display: grid; gap: 32px; }
@media (min-width: 768px) { .foot-grid { grid-template-columns: 1.4fr 1fr 1.2fr; } }
.site-foot h3 { color: var(--card); font-size: 18px; margin: 0 0 12px; }
.site-foot p { font-size: 15px; color: var(--blue-300); margin: 0; }
.site-foot nav a { display: block; color: var(--blue-200); padding: 6px 0; font-size: 15px; text-decoration: none; }
.site-foot nav a:hover { color: var(--card); }
.paybadges { display: flex; gap: 8px; flex-wrap: wrap; }
.paybadge { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--blue-800); border-radius: var(--radius-sm); padding: 8px 14px; font: 500 14px var(--font-head); color: var(--blue-100); }
.foot-extra { margin-top: 12px !important; }
.foot-note { border-top: 1px solid var(--blue-900); margin-top: 32px; padding-top: 24px; font-size: 14px; color: var(--blue-400); text-align: center; }
