/* ============================================
   หวย365 — Design System
   Theme: Dark Indigo + Royal Gold (Lottery)
   ============================================ */

/* === CSS Variables === */
:root {
  --color-primary: #0F0F35;
  --color-secondary: #D4A017;
  --color-accent: #FFB300;
  --color-bg: #0A0A28;
  --color-surface: rgba(20, 20, 60, 0.6);
  --color-text: #FFFFFF;

  --bg-footer: #08081E;
  --bg-card-solid: #1A1A4A;
  --bg-card-dark: #0D0D30;
  --bg-heading-block: rgba(15, 15, 53, 0.5);
  --bg-ticker: #12123A;
  --text-heading: #FFE0A0;
  --text-heading-alt: #FFEBC8;
  --text-nav-hover: #FFB300;
  --text-link: #E8C040;
  --text-keyword: #F0D060;
  --text-footer-brand: #FFB300;
  --border-header: rgba(212, 160, 23, 0.35);
  --border-section: rgba(212, 160, 23, 0.4);
  --border-footer: #D4A017;
  --border-faq: rgba(15, 15, 53, 0.7);
  --border-divider: rgba(212, 160, 23, 0.2);

  --gradient-btn-primary: linear-gradient(180deg, #D4A017 0%, #A07A10 100%);
  --gradient-btn-secondary: linear-gradient(180deg, #E8B830 0%, #D4A017 100%);
  --gradient-btn-mobile: linear-gradient(180deg, #D4A017 0%, #A07A10 100%);
  --gradient-provider: linear-gradient(135deg, #1A1A4A 0%, #0F0F35 100%);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 60px;
  --space-3xl: 80px;

  --radius-btn: 25px;
  --radius-card: 10px;
  --radius-faq: 20px;
  --radius-gallery: 7px;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Kanit', sans-serif;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(20, 20, 70, 0.4) 0%, transparent 60%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body:not(.js-ready) .fade-in { opacity: 1 !important; transform: none !important; }

img { max-width: 100%; height: auto; display: block; }

a { color: var(--text-link); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--color-accent); }

h1, h2, h3 { font-family: 'Kanit', sans-serif; color: var(--text-heading); line-height: 1.3; font-weight: 600; }
h1 { font-size: 32px; line-height: 1.2; }
h2 { font-size: 25px; }
h3 { font-size: 20px; color: var(--text-heading-alt); }

ul, ol { padding-left: 1.5em; }
li { margin-bottom: var(--space-sm); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 var(--space-md); }

/* === Header === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--color-primary);
  border-bottom: 1px solid var(--border-header);
  height: 72px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
  height: 100%;
}

.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo img { height: 56px; width: auto; }
.logo-text { font-family: 'Kanit', sans-serif; font-weight: 700; font-size: 1.5rem; color: var(--color-accent); }

.main-nav.desktop-nav { display: flex; align-items: center; gap: var(--space-lg); }
.main-nav a {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  padding: var(--space-sm) var(--space-md);
  transition: color 0.2s ease;
}
.main-nav a:hover, .main-nav a.active { color: var(--text-nav-hover); }

.cta-header.cta-header-nav {
  background: var(--gradient-btn-primary);
  color: #FFF;
  font-weight: 500;
  font-size: 16px;
  padding: 10px 24px;
  border-radius: var(--radius-btn);
  border: none;
  cursor: pointer;
  text-shadow: 0 0 10px rgba(0,0,0,0.3);
  transition: transform 0.2s ease;
  white-space: nowrap;
}
.cta-header.cta-header-nav:hover { transform: scale(0.96); color: #FFF; }

.hamburger {
  display: none;
  background: rgba(15, 15, 53, 0.8);
  border: 1px solid var(--border-section);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  z-index: 1001;
}
.hamburger span { display: block; width: 24px; height: 2px; background: var(--color-text); transition: all 0.3s ease; }

/* === Mobile Nav (OUTSIDE header) === */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 998;
}
.mobile-nav-overlay.active { display: block; }

.mobile-nav {
  display: none;
  position: fixed;
  top: 72px; left: 0; width: 100%;
  background: rgba(8, 8, 30, 0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-section);
  z-index: 999;
  padding: var(--space-lg) 0;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}
.mobile-nav.active { display: flex; }
.mobile-nav a {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  padding: var(--space-sm) var(--space-lg);
}
.mobile-nav a:hover, .mobile-nav a.active { color: var(--text-nav-hover); }

/* === Hero === */
.hero-section {
  padding: var(--space-xl) 0 var(--space-xl);
  text-align: center;
}
.hero-section .container { max-width: 1240px; }
.hero-image {
  width: 100%;
  border-radius: var(--radius-card);
  margin-bottom: var(--space-md);
}
.hero-section h1 { margin-bottom: var(--space-lg); }
.hero-section p { max-width: 800px; margin: 0 auto var(--space-lg); }

/* === CTA Buttons === */
.cta-button, .cta-primary {
  display: inline-block;
  background: var(--gradient-btn-primary);
  color: #FFF;
  font-family: 'Kanit', sans-serif;
  font-weight: 500;
  font-size: 16px;
  padding: 14px 32px;
  border-radius: var(--radius-btn);
  border: none;
  cursor: pointer;
  text-shadow: 0 0 10px rgba(0,0,0,0.3);
  transition: transform 0.2s ease;
  text-align: center;
}
.cta-button:hover, .cta-primary:hover { transform: scale(0.96); color: #FFF; }

.cta-footer {
  background: var(--gradient-btn-secondary);
  color: #FFF;
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: var(--radius-btn);
  padding: 14px 32px;
  font-family: 'Kanit', sans-serif;
  font-weight: 500;
  font-size: 16px;
  display: inline-block;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.cta-footer:hover { transform: scale(0.96); color: #FFF; }

/* === Ticker === */
.ticker-bar {
  background: var(--bg-ticker);
  border-radius: 20px;
  padding: 10px 20px;
  margin: 0 auto var(--space-xl);
  max-width: 1200px;
  overflow: hidden;
  white-space: nowrap;
}
.ticker-bar .ticker-text {
  display: inline-block;
  animation: ticker 20s linear infinite;
  color: var(--color-accent);
  font-weight: 500;
}
@keyframes ticker { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }

/* === TOC (Table of Contents) — Floating === */
.toc-toggle {
  position: fixed;
  bottom: 80px;
  left: 16px;
  z-index: 997;
  background: var(--gradient-btn-primary);
  color: #FFF;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 20px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
  transition: transform 0.2s ease;
}
.toc-toggle:hover { transform: scale(0.96); }
.toc-toggle.visible { display: flex; }

.toc-panel {
  position: fixed;
  bottom: 140px;
  left: 16px;
  z-index: 996;
  background: rgba(10, 10, 40, 0.97);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-section);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  max-width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.toc-panel.active { display: block; }
.toc-panel h3 { font-size: 16px; margin-bottom: var(--space-md); color: var(--color-accent); }
.toc-panel ol { list-style: decimal; padding-left: 1.2em; }
.toc-panel li { margin-bottom: var(--space-sm); }
.toc-panel a { color: var(--color-text); font-size: 14px; font-weight: 400; }
.toc-panel a:hover, .toc-panel a.active { color: var(--color-accent); }

.toc-progress {
  position: fixed;
  top: 72px;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--gradient-btn-primary);
  z-index: 1001;
  transition: width 0.1s linear;
}

/* === Blog TOC (inline) === */
.toc-container {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-section);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  margin: var(--space-lg) 0 var(--space-xl);
}
.toc-container h3 { font-size: 18px; margin-bottom: var(--space-md); color: var(--color-accent); }
.toc-container ol { padding-left: 1.5em; }
.toc-container li { margin-bottom: var(--space-sm); }
.toc-container a { color: var(--text-link); }
.toc-container a:hover { color: var(--color-accent); }

/* === Content Sections === */
.content-section {
  padding: var(--space-xl) 0;
}
.content-section:nth-child(even) { background: rgba(15, 15, 53, 0.3); }

.section-card {
  background: var(--color-surface);
  border: 2px solid var(--border-section);
  border-radius: var(--radius-card);
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.section-card:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(0,0,0,0.2); }

.section-card h2 { margin-bottom: var(--space-md); }
.section-card h3 { margin-bottom: var(--space-sm); background: var(--bg-heading-block); padding: var(--space-sm) var(--space-md); border-radius: 6px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xl); align-items: center; }
.two-col.reverse { direction: rtl; }
.two-col.reverse > * { direction: ltr; }

.section-image { border-radius: var(--radius-card); width: 100%; }

/* === FAQ Section === */
.faq-section {
  background: var(--bg-card-dark);
  border-radius: var(--radius-faq);
  padding: var(--space-xl);
  margin: var(--space-xl) 0;
}
.faq-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-md); }
.faq-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-faq);
  border-radius: var(--radius-faq);
  padding: 35px;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), box-shadow 0.3s ease;
}
.faq-card:hover { transform: translate3d(0,-8px,0) scale(1.02); box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.faq-card strong, .faq-card .faq-q { color: var(--color-accent); font-weight: 600; display: block; margin-bottom: var(--space-sm); }
.faq-card p { color: rgba(255,255,255,0.85); }

/* === Label Bars === */
.label-bar {
  background: var(--gradient-provider);
  border: 1px solid var(--border-section);
  border-radius: var(--radius-gallery);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  display: inline-block;
  font-weight: 600;
  color: var(--color-accent);
}

/* === Promotion Page === */
.promo-image {
  max-width: 600px;
  margin: var(--space-md) auto;
  border-radius: var(--radius-card);
}
.promo-section { margin-bottom: var(--space-xl); }
.promo-steps { padding-left: 1.5em; }
.promo-steps li { margin-bottom: var(--space-sm); }

/* === Login Page === */
.login-form-container {
  max-width: 480px;
  margin: var(--space-xl) auto;
  background: var(--color-surface);
  border: 2px solid var(--border-section);
  border-radius: var(--radius-card);
  padding: var(--space-xl);
}
.login-form h3 { text-align: center; margin-bottom: var(--space-lg); color: var(--color-accent); }
.login-form label { display: block; margin-bottom: var(--space-xs); font-weight: 500; color: rgba(255,255,255,0.8); }
.login-form input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  height: 48px;
  padding: 0 var(--space-md);
  color: #FFF;
  font-family: 'Kanit', sans-serif;
  font-size: 16px;
  margin-bottom: var(--space-md);
  transition: border-color 0.2s ease;
}
.login-form input:focus { outline: none; border-color: var(--color-accent); }
.login-form .cta-button { width: 100%; text-align: center; margin-bottom: var(--space-md); }
.form-links { text-align: center; display: flex; justify-content: space-between; }
.form-links a { font-size: 14px; }

/* === Archive / Blog Cards === */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}
.post-card {
  background: var(--color-surface);
  border: 2px solid var(--border-section);
  border-radius: var(--radius-card);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.post-card:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.post-card-image img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.post-card-content { padding: var(--space-md); }
.post-card-content h2 { font-size: 18px; margin-bottom: var(--space-sm); }
.post-card-content h2 a { color: var(--text-heading); }
.post-card-content h2 a:hover { color: var(--color-accent); }
.post-card-meta { font-size: 13px; color: rgba(255,255,255,0.5); margin-bottom: var(--space-sm); }
.post-card-content p { font-size: 14px; color: rgba(255,255,255,0.75); margin-bottom: var(--space-md); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.read-more { color: var(--color-accent); font-weight: 500; font-size: 14px; }

/* === Blog Post === */
.blog-post { padding: var(--space-xl) 0; }
.blog-post .container { max-width: 860px; }
.blog-post h1 { margin-bottom: var(--space-md); }
.blog-meta { color: rgba(255,255,255,0.5); font-size: 14px; margin-bottom: var(--space-lg); }
.blog-featured-image { width: 100%; border-radius: var(--radius-card); margin-bottom: var(--space-xl); }
.blog-post h2 { margin-top: var(--space-xl); margin-bottom: var(--space-md); padding-bottom: var(--space-sm); border-bottom: 1px solid var(--border-divider); }
.blog-post p { margin-bottom: var(--space-md); }
.blog-post ul, .blog-post ol { margin-bottom: var(--space-md); }

.related-articles {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-section);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  margin: var(--space-xl) 0;
}
.related-articles h3 { margin-bottom: var(--space-md); color: var(--color-accent); }
.related-articles ul { list-style: none; padding: 0; }
.related-articles li { margin-bottom: var(--space-sm); }
.related-articles a { color: var(--text-link); }

/* === Footer === */
.site-footer {
  background: var(--bg-footer);
  border-top: 2px solid var(--border-footer);
  padding: var(--space-xl) 0 var(--space-lg);
}
.footer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-xl); margin-bottom: var(--space-xl); }
.footer-brand { color: var(--text-footer-brand); font-size: 20px; font-weight: 700; margin-bottom: var(--space-md); }
.footer-links a { display: block; color: rgba(255,255,255,0.7); margin-bottom: var(--space-sm); font-size: 15px; }
.footer-links a:hover { color: var(--color-accent); }
.footer-cta { text-align: center; margin-bottom: var(--space-xl); }
.footer-copyright { text-align: center; font-size: 13px; color: rgba(255,255,255,0.4); border-top: 1px solid var(--border-divider); padding-top: var(--space-md); }

/* === Mobile Bottom Nav === */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; width: 100%;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(10px);
  z-index: 1000;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-section);
}
.mobile-bottom-nav-inner { display: flex; justify-content: space-around; align-items: flex-end; max-width: 400px; margin: 0 auto; }
.mobile-bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: rgba(255,255,255,0.7);
  font-size: 11px;
  font-weight: 500;
  gap: 2px;
  text-decoration: none;
  min-width: 60px;
}
.mobile-bottom-nav a:hover { color: var(--color-accent); }
.mobile-bottom-nav .nav-icon { font-size: 20px; }
.mobile-bottom-nav .cta-mobile-nav {
  background: var(--gradient-btn-mobile);
  color: #FFF;
  border-radius: var(--radius-btn);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  transform: translateY(-8px);
  box-shadow: 0 4px 15px rgba(212,160,23,0.3);
}

/* === Scroll Animations === */
.fade-in { opacity: 0; transform: translateY(20px); transition: opacity 0.5s ease-out, transform 0.5s ease-out; }
.fade-in.visible { opacity: 1; transform: translateY(0); }

/* === Responsive: Tablet === */
@media (max-width: 1023px) {
  .cta-header.cta-header-nav { display: none; }
  .main-nav.desktop-nav { display: none; }
  .hamburger { display: flex; }

  h1 { font-size: 25px; }
  h2 { font-size: 21px; }
  h3 { font-size: 19px; }
  body { font-size: 16px; }

  .two-col { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .post-grid { grid-template-columns: repeat(2, 1fr); }

  .hero-section { padding: var(--space-xl) 0 var(--space-lg); }
  .content-section { padding: var(--space-lg) 0; }
}

/* === Responsive: Mobile === */
@media (max-width: 767px) {
  h1 { font-size: 20px; }
  h2 { font-size: 19px; }
  h3 { font-size: 17px; }
  body { font-size: 15px; padding-bottom: 62px; }

  .hero-section { padding: var(--space-lg) 0 var(--space-md); }
  .content-section { padding: var(--space-md) 0; }

  .mobile-bottom-nav { display: block; }

  .cta-button, .cta-primary { width: 100%; padding: 14px; min-height: 48px; }
  .section-card { padding: var(--space-md); }
  .faq-card { padding: var(--space-lg); }

  .footer-grid { grid-template-columns: 1fr; text-align: center; }
  .post-grid { grid-template-columns: 1fr; }

  .toc-panel { left: 8px; right: 8px; max-width: none; bottom: 130px; }
  .toc-toggle { bottom: 72px; }
}
