/*
Theme Name: Store Vault
Theme URI: https://example.com
Author: GG
Description: ธีมร้านค้าเกมสไตล์ Steam-inspired dark UI เขียนด้วย vanilla PHP/CSS/JS ล้วน ไม่พึ่งปลั๊กอินหรือ framework ภายนอกใดๆ เน้นความเร็วในการโหลดสูงสุด
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: storevault
*/

/* ==========================================================================
   0. CSS Variables (Design tokens)
   ========================================================================== */
:root {
  --bg-page: #0e1116;
  --bg-shell: #171b23;
  --bg-sidebar: #12151b;
  --bg-card: #1c212b;
  --bg-card-hover: #232935;
  --bg-input: #1f242e;
  --accent: #ff5b1f;
  --accent-hover: #ff7a42;
  --accent-soft: rgba(255, 91, 31, 0.15);
  --text-primary: #f2f3f5;
  --text-secondary: #a3aab8;
  --text-muted: #6b7280;
  --border-subtle: #262b35;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 220px;
}

/* ==========================================================================
   1. Reset & base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
.screen-reader-text {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(1px,1px,1px,1px); white-space: nowrap;
}

/* ==========================================================================
   2. App shell layout
   ========================================================================== */
.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}
.app-frame {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  background: var(--bg-shell);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 720px;
  box-shadow: var(--shadow-card);
}

/* ==========================================================================
   3. Sidebar
   ========================================================================== */
.sidebar {
  background: var(--bg-sidebar);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  height: 100%;
}
/* พื้นที่เลื่อนได้: โลโก้ + เมนูหลัก + เมนู support + หมวดหมู่ ส่วน friend-chat ด้านล่างอยู่นิ่งเสมอ */
.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-right: 4px;
  margin-right: -4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 3px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: 0.5px; flex-shrink: 0; }
.brand svg { flex-shrink: 0; }
.brand sup { font-size: 9px; color: var(--text-muted); font-weight: 600; }

.nav-primary { display: flex; flex-direction: column; gap: 4px; }
.nav-primary li a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px; font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-primary li a:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.nav-primary li.current-menu-item a,
.nav-primary li a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  position: relative;
}
.nav-primary li.current-menu-item a::before {
  content: "";
  position: absolute; left: -20px; top: 8px; bottom: 8px; width: 3px;
  background: var(--accent); border-radius: 0 4px 4px 0;
}
.nav-primary svg { width: 18px; height: 18px; flex-shrink: 0; }

/* วงสีน้ำเงิน: หมวดหมู่พร้อมจำนวนโพสต์ — แบบ pill badge (ชื่อ + จำนวนในพิลล์มุมขวา) */
.category-section { flex-shrink: 0; }
.sidebar-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 4px; margin: 0 0 10px;
}
.nav-categories { display: flex; flex-direction: column; gap: 2px; }
.nav-categories li a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 600; line-height: 1.3;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-categories li a:hover { background: var(--accent-soft); color: var(--text-primary); }
.cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count {
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 11px; font-weight: 700;
  min-width: 22px; text-align: center;
  padding: 2px 9px; border-radius: 999px;
  flex-shrink: 0;
}
.nav-categories li a:hover .cat-count { background: var(--accent); color: #2a0f04; }

.nav-empty-hint {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.sidebar-bottom { display: flex; flex-direction: column; gap: 16px; flex-shrink: 0; }
.nav-secondary { display: flex; flex-direction: column; gap: 4px; }
.nav-secondary li a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: 14px; font-weight: 600;
}
.nav-secondary li a:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); }
.nav-secondary svg { width: 18px; height: 18px; }

.friend-chat-cta {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
}
.friend-chat-cta .plus-btn {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; border: none; flex-shrink: 0;
}

/* ==========================================================================
   4. Main content area
   ========================================================================== */
.main-content { padding: 24px 32px 40px; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
}
.search-form { flex: 1; max-width: 480px; position: relative; }
.search-form input[type="search"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 10px 16px 10px 40px;
  color: var(--text-primary);
  font-size: 14px;
}
.search-form input[type="search"]::placeholder { color: var(--text-muted); }
.search-form input[type="search"]:focus { outline: none; border-color: var(--accent); }
.search-form svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}

/* Live search dropdown */
.search-results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  max-height: 360px;
  overflow-y: auto;
  z-index: 30;
  padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
  scroll-behavior: smooth;
}
/* display:flex ด้านบนไปเขียนทับพฤติกรรมซ่อนตามธรรมชาติของ attribute [hidden]
   (ปกติเบราว์เซอร์จะ display:none ให้เอง) ต้องประกาศ override กลับมาตรงๆ
   ไม่งั้นกล่องนี้จะค้างโชว์เป็นแถบว่างตลอดเวลาแม้ยังไม่ได้พิมพ์ค้นหาอะไรเลย */
.search-results[hidden] { display: none; }
.search-results::-webkit-scrollbar { width: 6px; }
.search-results::-webkit-scrollbar-track { background: transparent; margin: 6px 0; }
.search-results::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 3px; }
.search-results::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.search-result-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px;
  border-radius: 8px;
  color: var(--text-primary);
  transition: background 0.15s ease;
}
.search-result-item:hover,
.search-result-item.is-active { background: var(--accent-soft); }
.search-result-thumb {
  width: 40px; height: 53px; flex-shrink: 0;
  border-radius: 6px;
  background: var(--bg-input);
  overflow: hidden;
  display: block;
}
.search-result-thumb img { width: 100%; height: 100%; object-fit: cover; }
.search-result-title {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-empty {
  padding: 18px 12px;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.icon-btn {
  position: relative;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-input); border: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--bg-input); }
.user-chip img, .user-chip .avatar-fallback {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  background: linear-gradient(135deg, var(--accent), #ffb199);
}
.user-chip span { font-size: 14px; font-weight: 600; }
.user-chip svg { width: 14px; height: 14px; color: var(--text-muted); }

/* ==========================================================================
   5. Hero section
   ========================================================================== */
.hero-row { display: grid; grid-template-columns: 1fr 300px; gap: 20px; margin-bottom: 32px; }

.hero-banner {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 340px;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 24px;
  background: radial-gradient(circle at 30% 20%, #3a2a1a 0%, transparent 45%),
              linear-gradient(160deg, #7a2e10 0%, #2c1410 55%, #150c0c 100%);
  background-size: cover;
  background-position: center;
  transition: background-image 0.25s ease;
  isolation: isolate;
}
/* สคริมไล่สีเข้มด้านล่างเพื่อให้ตัวอักษรอ่านออกชัดเจนเสมอ ไม่ว่าภาพพื้นหลังจะสว่างแค่ไหน */
.hero-banner::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,8,6,0.1) 0%, rgba(10,8,6,0.55) 60%, rgba(10,8,6,0.92) 100%);
  z-index: 0;
  pointer-events: none;
}
.hero-tags, .hero-title, .hero-dots { position: relative; z-index: 1; }
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: auto; }
.hero-tags .tag {
  background: rgba(20, 22, 26, 0.65);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-primary);
  font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px;
}
.hero-tags .tag.tag-add {
  width: 30px; text-align: center; padding: 6px 0;
  color: var(--text-secondary);
}
.hero-title {
  font-size: clamp(18px, 2vw, 28px);
  font-weight: 800; letter-spacing: 0.5px;
  line-height: 1.2;
  margin: 0 0 12px;
  max-width: 85%;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 4px 24px rgba(0,0,0,0.5);
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.hero-dots { display: flex; gap: 6px; position: absolute; bottom: 20px; right: 24px; z-index: 1; }
.hero-dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.3); }
.hero-dots span.is-active { width: 20px; border-radius: 4px; background: var(--accent); }

.hero-detail {
  background: linear-gradient(160deg, #b5490f 0%, #7a1f0c 60%, #3a1108 100%);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex; flex-direction: column;
}
.hero-detail h3 { font-size: 20px; margin: 0 0 10px; }
.hero-detail p { font-size: 13px; color: rgba(255,255,255,0.85); line-height: 1.6; margin: 0; }
.hero-thumbs { display: flex; gap: 12px; margin-top: 16px; }
.hero-thumbs .thumb {
  flex: 1; height: 64px; border-radius: 10px;
  background-color: rgba(0,0,0,0.25);
  background-size: cover;
  background-position: center;
}

/* ==========================================================================
   6. Special offers grid
   ========================================================================== */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 16px;
}
.section-head h2 { font-size: 20px; margin: 0; }
.section-head a { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.section-head a:hover { color: var(--accent); }

.game-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.game-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.18s ease, background 0.18s ease;
}
.game-card:hover { transform: translateY(-4px); background: var(--bg-card-hover); }
.game-card .art {
  aspect-ratio: 241 / 339;
  background-size: cover;
  background-position: center;
  position: relative;
  display: flex; align-items: flex-end; padding: 14px;
}
.game-card .art::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.75) 100%);
  z-index: 1;
}
.game-card .art span { position: relative; z-index: 2; font-weight: 800; font-size: 15px; color: #fff; line-height: 1.2; }
.game-card .art.art-1 { background-image: linear-gradient(160deg, #2b3a52, #0e1420); }
.game-card .art.art-2 { background-image: linear-gradient(160deg, #3a3f2b, #14150e); }
.game-card .art.art-3 { background-image: linear-gradient(160deg, #1f3a4a, #0e1a20); }
.game-card .art.art-4 { background-image: linear-gradient(160deg, #3a2b3f, #150e18); }
/* ภาพปกจริงจากโพสต์ (featured image) วางเต็มพื้นที่การ์ด อยู่ใต้ gradient overlay */
.game-card .art-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* Pagination ของ Special offers */
.sv-pagination {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 6px;
  margin-top: 28px;
}
.sv-pagination a,
.sv-pagination span {
  display: flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 700;
}
.sv-pagination a:hover { background: var(--accent-soft); color: var(--accent); }
.sv-pagination span.current { background: var(--accent); color: #2a0f04; }
.sv-pagination span.dots { background: transparent; }
.sv-pagination svg { width: 16px; height: 16px; }

/* ==========================================================================
   6.5. หน้าโพสต์เดี่ยว / หน้า Page (single.php, page.php) — เน้นอ่านง่าย SEO-friendly
   ========================================================================== */
.breadcrumbs { margin-bottom: 20px; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0; margin: 0; list-style: none; }
.breadcrumbs li { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.breadcrumbs li:not(:last-child)::after { content: "/"; color: var(--text-muted); margin-left: 6px; }
.breadcrumbs a { color: var(--text-secondary); font-weight: 600; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs li[aria-current="page"] { color: var(--text-primary); font-weight: 600; }

.single-post { max-width: 760px; }
.entry-header { margin-bottom: 20px; }
.entry-title { font-size: 32px; font-weight: 800; line-height: 1.25; margin: 0 0 10px; }
.entry-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.entry-meta-sep { opacity: 0.6; }

.entry-thumb { margin: 0 0 24px; border-radius: var(--radius-md); overflow: hidden; }
.entry-thumb img { width: 100%; height: auto; display: block; }

.entry-content { font-size: 16px; line-height: 1.8; color: var(--text-secondary); }
.entry-content p { margin: 0 0 1.4em; }
.entry-content h2 { font-size: 24px; font-weight: 800; color: var(--text-primary); margin: 1.6em 0 0.6em; }
.entry-content h3 { font-size: 19px; font-weight: 700; color: var(--text-primary); margin: 1.4em 0 0.5em; }
.entry-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.entry-content img { max-width: 100%; height: auto; border-radius: var(--radius-md); }
.entry-content ul, .entry-content ol { margin: 0 0 1.4em; padding-left: 1.4em; }
.entry-content blockquote {
  margin: 1.6em 0; padding: 4px 20px;
  border-left: 3px solid var(--accent);
  color: var(--text-primary); font-style: italic;
}

.entry-taxonomy { margin-top: 32px; display: flex; flex-direction: column; gap: 10px; }
.entry-cats, .entry-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.taxonomy-pill {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 12px; font-weight: 700;
  padding: 6px 14px; border-radius: 999px;
}
.taxonomy-pill:hover { background: var(--accent-soft); color: var(--accent); }
.taxonomy-pill-tag { background: transparent; border: 1px solid var(--border-subtle); }

.related-posts { margin-top: 48px; max-width: 100%; }

/* ==========================================================================
   7. Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app-frame { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; align-items: center; justify-content: space-between;
    padding: 14px 16px; position: sticky; top: 0; z-index: 20;
  }
  .sidebar-scroll { flex-direction: row; align-items: center; gap: 20px; overflow: visible; }
  .nav-primary { flex-direction: row; }
  .nav-primary li a span.label { display: none; }
  .category-section { display: none; } /* ย้ายไปหน้าอื่น/เมนูมือถือแยกในอนาคตได้ */
  .sidebar-bottom { display: none; }
}
@media (max-width: 640px) {
  .app-shell { padding: 0; }
  .app-frame { border-radius: 0; }
  .game-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .hero-title { font-size: 34px; }
  .topbar-actions .user-chip span { display: none; }
  .main-content { padding: 16px; }
}
