/* =============================================
   WEBSASUK - หน้าแรก (โทนเขียว-ขาว กระจก + โหมดกลางคืน)
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:       #0b7a3e;
  --green-dark:  #064d29;
  --green-soft:  #e7f4ec;
  --bg:          #f4f8f5;
  --surface:     #ffffff;
  --border:      #e0e9e3;
  --text:        #17241d;
  --muted:       #4d5c54;
  --chip-bg:     #ffffff;
  --chip-border: #d5e2da;
  --nav-bg:      rgba(255,255,255,0.82);
  --shadow:      0 10px 28px rgba(11,60,35,0.12);
  --hero-from:   #0d8a47;
  --hero-to:     #065a30;
  --glow-a:      #4fd18b;
  --glow-b:      #b6f0cf;
  --glow-c:      #1aa35c;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --green:       #34c47a;
  --green-dark:  #0a2a1a;
  --green-soft:  rgba(52,196,122,0.14);
  --bg:          #0c1511;
  --surface:     #13201a;
  --border:      #22352b;
  --text:        #e4efe8;
  --muted:       #9fb3a8;
  --chip-bg:     #13201a;
  --chip-border: #2a4135;
  --nav-bg:      rgba(12,21,17,0.82);
  --shadow:      0 10px 28px rgba(0,0,0,0.45);
  --hero-from:   #0b4a2a;
  --hero-to:     #06261a;
  --glow-a:      #1f9d5c;
  --glow-b:      #2f7a55;
  --glow-c:      #0f6b3e;
  color-scheme: dark;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .3s, color .3s;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Navbar ---- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.nav-brand { display: flex; flex-direction: column; line-height: 1.15; text-decoration: none; }
.nav-title { font-family: 'Prompt', sans-serif; font-weight: 600; font-size: 21px; color: var(--green); }
.nav-sub { font-size: 13px; color: var(--muted); }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-link {
  min-height: 44px; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; border-radius: 10px; text-decoration: none;
  color: var(--muted); font-weight: 600; font-size: 15px; transition: background .2s, color .2s;
}
.nav-link:hover { background: var(--green-soft); color: var(--green); }
.nav-link.active { background: var(--green-soft); color: var(--green); }
.nav-admin { border: 1px solid var(--chip-border); }
.btn-icon {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--chip-border);
  background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: background .2s, color .2s;
}
.btn-icon:hover { background: var(--green-soft); color: var(--green); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---- Hero (กระจกโทนเขียว) ---- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  padding: clamp(36px, 7vw, 72px) 20px clamp(40px, 7vw, 76px);
}
.hero-glow { position: absolute; inset: 0; pointer-events: none; }
.glow { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.g1 { width: 380px; height: 380px; background: var(--glow-a); top: -120px; left: 6%; }
.g2 { width: 300px; height: 300px; background: var(--glow-b); bottom: -140px; right: 10%; opacity: .45; }
.g3 { width: 240px; height: 240px; background: var(--glow-c); top: 30%; right: 38%; opacity: .5; }
.hero-glass {
  position: relative; max-width: 820px; margin: 0 auto; text-align: center;
  padding: clamp(28px, 5vw, 44px) clamp(18px, 4vw, 40px);
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 24px;
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 20px 50px rgba(0,40,20,0.25), inset 0 1px 0 rgba(255,255,255,0.35);
}
:root[data-theme="dark"] .hero-glass {
  background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.14);
  box-shadow: 0 20px 50px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.12);
}
.hero-title {
  font-family: 'Prompt', sans-serif; font-weight: 700;
  font-size: clamp(40px, 9vw, 76px); line-height: 1.05; letter-spacing: 0.02em;
  color: #ffffff; text-shadow: 0 4px 24px rgba(0,40,20,0.35);
}
.hero-desc { margin-top: 10px; font-size: clamp(16px, 2.6vw, 20px); color: rgba(255,255,255,0.88); }

.search-box {
  margin: 26px auto 0; max-width: 640px; min-height: 58px;
  display: flex; align-items: center; gap: 10px; padding: 0 8px 0 18px;
  background: rgba(255,255,255,0.92); color: var(--green);
  border: 1px solid rgba(255,255,255,0.7); border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,40,20,0.2);
  transition: box-shadow .2s;
}
:root[data-theme="dark"] .search-box { background: rgba(12,21,17,0.75); border-color: rgba(255,255,255,0.16); color: var(--green); }
.search-box:focus-within { box-shadow: 0 0 0 4px rgba(182,240,207,0.55), 0 10px 30px rgba(0,40,20,0.2); }
.search-box input {
  flex: 1; min-width: 0; min-height: 54px; border: 0; outline: none; background: transparent;
  font: inherit; font-size: 17px; color: var(--text);
}
.search-box input::placeholder { color: #6b7a72; }
:root[data-theme="dark"] .search-box input::placeholder { color: #8ea398; }
.search-box input::-webkit-search-cancel-button { display: none; }
.btn-clear {
  width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent;
  color: var(--muted); font-size: 16px; cursor: pointer;
}
.btn-clear:hover { background: var(--green-soft); color: var(--green); }

/* ---- Main ---- */
.main-content { max-width: 1200px; margin: 0 auto; padding: 26px 20px 56px; }

.category-bar { display: flex; flex-wrap: wrap; gap: 10px; }
.cat-btn {
  min-height: 44px; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--chip-border); background: var(--chip-bg); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; transition: background .2s, border-color .2s, color .2s;
}
.cat-btn:hover { border-color: var(--green); color: var(--green); }
.cat-btn .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.cat-btn .num { font-weight: 400; opacity: .75; }
.cat-btn.active { background: var(--green); border-color: var(--green); color: #ffffff; }
:root[data-theme="dark"] .cat-btn.active { color: #06261a; }
.cat-btn.active .dot { background: currentColor !important; }

.result-count { margin: 18px 0 14px; font-size: 15px; color: var(--muted); }

/* ---- Cards ---- */
.sites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.site-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  text-decoration: none; color: var(--text);
  transition: box-shadow .2s, transform .2s, border-color .2s;
  animation: fadeUp .4s ease both;
}
.site-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--green); }
.site-card:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.card-thumb { aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; background: #ffffff; border-bottom: 1px solid var(--border); }
.card-thumb-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-thumb-emoji { font-size: 48px; }
:root[data-theme="dark"] .card-thumb { background: #eef3f0; }
.card-body { padding: 14px 18px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-name { font-family: 'Prompt', sans-serif; font-weight: 600; font-size: 18px; line-height: 1.3; }
.card-desc { font-size: 15px; line-height: 1.5; color: var(--muted); }
.card-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 18px; border-top: 1px solid var(--border); font-size: 14px;
}
.card-badge { padding: 3px 10px; border-radius: 999px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-open { display: inline-flex; align-items: center; gap: 4px; color: var(--green); font-weight: 600; white-space: nowrap; }
.card-open svg { width: 14px; height: 14px; }

.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); font-size: 17px; }
.btn-reset {
  margin-top: 12px; min-height: 44px; padding: 0 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--green); background: transparent; color: var(--green); font: inherit; font-weight: 600;
}

/* ---- Footer ---- */
.footer { background: var(--green-dark); color: #d6efe0; text-align: center; font-size: 14px; padding: 22px 20px; }
.footer-copy { opacity: .9; }

/* ---- สถิติผู้เข้าชม ---- */
.visit-stats { max-width: 380px; margin: 0 auto 14px; }
.visit-stats[hidden] { display: none; }
.visit-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Prompt', sans-serif; font-size: 14px; font-weight: 600; color: #ffffff; margin-bottom: 8px;
}
.visit-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.visit-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 4px; border-radius: 10px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}
.visit-today { background: rgba(79,209,139,0.18); border-color: rgba(79,209,139,0.45); }
.visit-num {
  font-family: 'Prompt', sans-serif; font-size: 16px; font-weight: 700; line-height: 1.2;
  color: #ffffff; font-variant-numeric: tabular-nums;
}
.visit-label { font-size: 12px; color: #bfe6cf; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Mobile ---- */
@media (max-width: 640px) {
  .nav-sub { display: none; }
  .nav-link { padding: 0 10px; }
  .nav-link.active { display: none; }
  .sites-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 14px; }
  .category-bar { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .cat-btn { flex: none; }
}

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