/* ==========================================
   it4x.com — Custom Stylesheet
   Dark Glassmorphism Design
   Font: Kanit (Google Fonts)
   ========================================== */

/* ── Google Fonts ──────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700;800;900&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────────────────── */
:root {
  --bg-gradient:   linear-gradient(135deg, #0a0a1a 0%, #0f1628 25%, #1a1040 50%, #0d1530 75%, #090915 100%);
  --glass-bg:      rgba(15, 25, 50, 0.55);
  --glass-bg-dark: rgba(8, 15, 35, 0.7);
  --glass-border:  rgba(100, 150, 255, 0.12);
  --glass-hover:   rgba(20, 35, 70, 0.75);
  --accent-1:      #00d4ff;   /* Cyan blue */
  --accent-2:      #7c3aed;   /* Purple */
  --accent-3:      #06d6a0;   /* Teal green */
  --accent-glow:   rgba(0, 212, 255, 0.25);
  --text-primary:  #e8f0ff;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;
  --shadow-card:   0 8px 32px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255,255,255,0.05) inset;
  --shadow-hover:  0 16px 48px rgba(0, 0, 0, 0.6), 0 0 24px rgba(0, 212, 255, 0.1);
  --radius-card:   16px;
  --radius-sm:     8px;
  --transition:    all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Kanit', 'Sarabun', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.7;
  overflow-x: hidden;
}

/* Animated background particles */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(0, 212, 255, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(6, 214, 160, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Typography ────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.3; }
a { color: var(--accent-1); text-decoration: none; transition: var(--transition); }
a:hover { color: #fff; }

/* ── Glassmorphism Card ─────────────────────────────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.3), transparent);
}

.glass-card:hover {
  background: var(--glass-hover);
  border-color: rgba(0, 212, 255, 0.2);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.glass-card-dark {
  background: var(--glass-bg-dark);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

/* ══════════════════════════════════════════════════════════
   NAVIGATION — Desktop + Mobile
   ══════════════════════════════════════════════════════════ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;                        /* สูงพอที่จะอยู่เหนือทุก section */
  background: rgba(7, 9, 22, 0.93);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(0, 212, 255, 0.1);
  padding: 0 1.5rem;
}

.navbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 64px;
  gap: 0.5rem;
  position: relative;                   /* anchor สำหรับ dropdown */
}

.navbar-logo {
  font-size: 1.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.navbar-logo:hover { opacity: 0.85; }

/* รายการเมนูหลัก — ต้อง overflow:visible เพื่อให้ dropdown โผล่ออกมาได้ */
.navbar-menu {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex: 1;
  overflow: visible;                    /* ⚠️ critical: ห้าม hidden ไม่งั้น dropdown โดน clip */
  list-style: none;
}

.nav-item {
  display: block;
  color: var(--text-secondary);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
  cursor: pointer;
  user-select: none;
}
.nav-item:hover, .nav-item.active {
  color: var(--accent-1);
  background: rgba(0, 212, 255, 0.09);
}

/* ── Dropdown ─────────────────────────────────────────────
   position: relative บน <li> เพื่อให้ menu ยึดตาม toggle
   ──────────────────────────────────────────────────────── */
.nav-dropdown {
  position: relative;
  list-style: none;
}

.nav-dropdown-menu {
  display: none;                        /* ปิดด้วย display เพื่อความแน่นอน */
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 230px;
  background: rgba(6, 9, 26, 0.98);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 12px;
  box-shadow: 0 24px 56px rgba(0,0,0,0.75), 0 0 0 1px rgba(255,255,255,0.04);
  z-index: 1001;                        /* เหนือ .navbar (1000) */
  padding: 0.45rem;
  list-style: none;
}

/* Bridge pseudo-element ป้องกัน gap ระหว่าง toggle และ menu */
.nav-dropdown-menu::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  height: 8px;
}

/* เปิด dropdown เมื่อ JS เพิ่ม class .open */
.nav-dropdown.open > .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 400;
  color: #a8bcd4;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav-dropdown-item:hover {
  background: rgba(0, 212, 255, 0.1);
  color: var(--accent-1);
}
.nav-dropdown-item .badge-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

/* Search in navbar */
.navbar-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.search-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 0.4rem 1rem;
  color: var(--text-primary);
  font-family: 'Kanit', sans-serif;
  font-size: 0.875rem;
  width: 200px;
  transition: var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-1);
  width: 260px;
  background: rgba(0, 212, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

.search-input::placeholder { color: var(--text-muted); }

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: var(--transition);
}

/* ── Hero Section ────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 1.5rem 4rem;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(0, 212, 255, 0.12) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(124, 58, 237, 0.1) 0%, transparent 60%);
}

.hero-content { position: relative; z-index: 1; max-width: 720px; }

.hero-badge {
  display: inline-block;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 24px;
  padding: 0.3rem 1rem;
  font-size: 0.8rem;
  color: var(--accent-1);
  letter-spacing: 0.05em;
  margin-bottom: 1.25rem;
}

.hero-title {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 900;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-1) 50%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.hero-tagline {
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 2rem;
}

.hero-tagline strong {
  color: var(--accent-3);
  font-weight: 700;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}

.hero-stat-num {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent-1);
  display: block;
  line-height: 1;
}

.hero-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Section Container ───────────────────────────────────────────────────── */
.container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.25rem;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  /* ป้องกัน child ล้นออก */
  overflow-x: clip;
}

.section {
  padding: 3rem 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title::before {
  content: '';
  display: block;
  width: 4px;
  height: 1.4em;
  background: linear-gradient(to bottom, var(--accent-1), var(--accent-2));
  border-radius: 2px;
}

.section-link {
  font-size: 0.875rem;
  color: var(--accent-1);
  font-weight: 500;
}

/* ── Category Carousel ───────────────────────────────────────────────────── */
.cat-carousel-wrap {
  position: relative;
}

.cat-carousel {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 212, 255, 0.3) transparent;
}

.cat-carousel::-webkit-scrollbar { height: 4px; }
.cat-carousel::-webkit-scrollbar-track { background: transparent; }
.cat-carousel::-webkit-scrollbar-thumb { background: rgba(0, 212, 255, 0.3); border-radius: 4px; }

.cat-card {
  flex: 0 0 auto;
  width: 200px;
  scroll-snap-align: start;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: block;
}

.cat-card:hover {
  border-color: rgba(0, 212, 255, 0.35);
  background: rgba(0, 212, 255, 0.07);
  transform: translateY(-3px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 212, 255, 0.1);
}

.cat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
}

.cat-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Topic Card Grid ─────────────────────────────────────────────────────── */
.topics-grid {
  display: grid;
  /* auto-fit: จะขยาย/ย่อตาม viewport ไม่ overflow */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1rem;
}

.topic-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: 1rem 1.1rem;
  transition: var(--transition);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  /* สำคัญมาก: ป้องกัน content ภายในล้น grid cell */
  min-width: 0;
  overflow: hidden;
  word-break: break-word;
}

.topic-card:hover {
  border-color: rgba(0, 212, 255, 0.25);
  background: var(--glass-hover);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.topic-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.topic-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 24px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.2);
  color: var(--accent-1);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.topic-sticky-badge {
  background: rgba(252, 211, 77, 0.1);
  border-color: rgba(252, 211, 77, 0.3);
  color: #fcd34d;
}

.topic-title {
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-excerpt {
  font-size: 0.835rem;
  color: var(--text-secondary);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.topic-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.topic-author {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.avatar-xs {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(0, 212, 255, 0.2);
}

.topic-stats {
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.topic-stat-item {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

/* ── Article Page ────────────────────────────────────────────────────────── */
.article-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 2rem;
  align-items: start;
}

.article-main {}

.article-header {
  margin-bottom: 2rem;
}

.article-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.article-breadcrumb a { color: var(--text-muted); }
.article-breadcrumb a:hover { color: var(--accent-1); }
.article-breadcrumb .sep { color: var(--glass-border); }

.article-title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 800;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
}

.article-byline {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  margin-bottom: 2rem;
}

.article-author-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(0, 212, 255, 0.3);
  flex-shrink: 0;
}

.article-author-info { flex: 1; min-width: 0; }
.article-author-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.article-author-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.article-body {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--text-secondary);
}

/* BBCode rendered content styles */
.article-body strong { color: var(--text-primary); }
.article-body em { color: #c4b5fd; }
.article-body a.bbcode-link {
  color: var(--accent-1);
  border-bottom: 1px dotted rgba(0, 212, 255, 0.4);
}
.article-body a.bbcode-link:hover { border-bottom-style: solid; }

.article-body .bbcode-code {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  color: #a5f3fc;
  margin: 1.25rem 0;
  white-space: pre;
}

.article-body .bbcode-inline-code {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-family: monospace;
  font-size: 0.875em;
  color: #67e8f9;
}

.article-body .bbcode-quote {
  border-left: 3px solid var(--accent-2);
  background: rgba(124, 58, 237, 0.07);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}

.article-body .bbcode-quote-author {
  display: block;
  font-size: 0.82rem;
  color: var(--accent-2);
  margin-bottom: 0.4rem;
  font-style: normal;
}

.article-body .bbcode-img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
}

.article-body .bbcode-figure { margin: 1.25rem 0; }

.article-body .bbcode-video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  margin: 1.25rem 0;
}

.article-body .bbcode-video-wrapper iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.article-body .bbcode-list {
  padding-left: 1.5rem;
  margin: 0.75rem 0;
}

.article-body .bbcode-list li { margin-bottom: 0.3rem; }

.article-body .bbcode-table-wrap { overflow-x: auto; margin: 1rem 0; }

.article-body .bbcode-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.article-body .bbcode-table th,
.article-body .bbcode-table td {
  border: 1px solid var(--glass-border);
  padding: 0.6rem 0.9rem;
  text-align: left;
}

.article-body .bbcode-table th {
  background: rgba(0, 212, 255, 0.08);
  color: var(--accent-1);
  font-weight: 600;
}

.article-body .bbcode-hr {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 1.5rem 0;
}

.article-body .bbcode-glow { text-shadow: 0 0 8px var(--accent-1); }

/* ── Share Buttons ───────────────────────────────────────────────────────── */
.share-section {
  padding: 1.25rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  margin: 2rem 0;
}

.share-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.share-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'Kanit', sans-serif;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.share-btn-fb   { background: #1877f2; color: #fff; }
.share-btn-line { background: #06c755; color: #fff; }
.share-btn-x    { background: #000; border: 1px solid rgba(255,255,255,0.2); color: #fff; }
.share-btn-copy { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: var(--text-secondary); }

.share-btn:hover { opacity: 0.85; transform: translateY(-2px); }

/* ── Tags / Keywords (AEO) ───────────────────────────────────────────────── */
.tags-section { margin: 1.5rem 0; }

.tags-title {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.65rem;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-pill {
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.2);
  color: #c4b5fd;
  padding: 0.25rem 0.75rem;
  border-radius: 24px;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
}

.tag-pill:hover {
  background: rgba(124, 58, 237, 0.2);
  border-color: rgba(124, 58, 237, 0.4);
  color: #ddd6fe;
}

/* ── Replies / Thread ─────────────────────────────────────────────────────── */
.replies-section { margin-top: 3rem; }

.replies-header {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reply-count-badge {
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.2);
  color: var(--accent-1);
  padding: 0.15rem 0.6rem;
  border-radius: 24px;
  font-size: 0.78rem;
  font-weight: 700;
}

.reply-item {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: var(--transition);
}

.reply-item:hover { border-color: rgba(255,255,255,0.1); }

.reply-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.reply-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.reply-author-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.reply-author-posts {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.reply-date {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.reply-body {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.reply-number {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar { position: sticky; top: 80px; }

.sidebar-widget {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.sidebar-widget-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sidebar-topic-item {
  display: block;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: var(--transition);
}

.sidebar-topic-item:last-child { border-bottom: none; }
.sidebar-topic-item:hover { color: var(--accent-1); padding-left: 4px; }

/* ── Topic Compact List (home page rows 4-50) ───────────────────────────── */
.topic-list-compact {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.topic-list-item {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  background: var(--glass-bg);
  border: 1px solid transparent;
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
  min-width: 0;
}

.topic-list-item:hover {
  background: var(--glass-hover);
  border-color: var(--glass-border);
}

.tli-board {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-1);
  background: rgba(0, 212, 255, 0.08);
  border: 1px solid rgba(0, 212, 255, 0.15);
  border-radius: 20px;
  padding: 0.18rem 0.55rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.tli-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.tli-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.tli-stat { color: var(--text-muted); }

/* Featured (top 3) cards - taller excerpt */
.topic-card-featured .topic-excerpt {
  -webkit-line-clamp: 3;
}

/* Mobile: compact list stack vertically */
@media (max-width: 640px) {
  .topic-list-item {
    grid-template-columns: 90px 1fr;
    grid-template-rows: auto auto;
  }
  .tli-meta {
    grid-column: 1 / -1;
    font-size: 0.7rem;
    gap: 0.5rem;
    padding-top: 0.25rem;
    border-top: 1px solid rgba(255,255,255,0.04);
  }
}

/* ── Board Listing ───────────────────────────────────────────────────────── */
.board-list { display: flex; flex-direction: column; gap: 0.75rem; }

.board-item {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}

.board-item:hover {
  border-color: rgba(0, 212, 255, 0.25);
  background: var(--glass-hover);
  transform: translateX(4px);
}

.board-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(0,212,255,0.15), rgba(124,58,237,0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.board-info { flex: 1; min-width: 0; }
.board-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.15rem; }
.board-desc { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.board-stats {
  text-align: right;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.board-stats strong { color: var(--text-secondary); }

/* ── Search ──────────────────────────────────────────────────────────────── */
.search-hero {
  padding: 4rem 1.25rem 3rem;
  text-align: center;
}

.search-form-big {
  max-width: 640px;
  margin: 0 auto;
}

.search-input-big {
  width: 100%;
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  border-radius: 50px;
  padding: 1rem 1.5rem;
  color: var(--text-primary);
  font-family: 'Kanit', sans-serif;
  font-size: 1.05rem;
  outline: none;
  transition: var(--transition);
}

.search-input-big:focus {
  border-color: var(--accent-1);
  background: rgba(0, 212, 255, 0.04);
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.1);
}

.search-result-item {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: var(--transition);
}

.search-result-item:hover {
  border-color: rgba(0, 212, 255, 0.2);
  background: var(--glass-hover);
}

mark {
  background: rgba(0, 212, 255, 0.2);
  color: var(--accent-1);
  border-radius: 2px;
  padding: 0 2px;
}

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination-wrap { margin: 2.5rem 0; display: flex; justify-content: center; }

.pagination {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-family: 'Kanit', sans-serif;
  transition: var(--transition);
  text-decoration: none;
}

.page-btn:hover, .page-btn.active {
  background: rgba(0, 212, 255, 0.1);
  border-color: rgba(0, 212, 255, 0.35);
  color: var(--accent-1);
}

.page-ellipsis { color: var(--text-muted); padding: 0 0.25rem; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  background: rgba(5, 8, 20, 0.9);
  border-top: 1px solid var(--glass-border);
  padding: 3rem 1.25rem 2rem;
  margin-top: 4rem;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2rem;
}

.footer-brand-logo {
  font-size: 1.75rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.footer-tagline {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.footer-col-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 1rem;
}

.footer-links { list-style: none; }
.footer-links li { margin-bottom: 0.5rem; }
.footer-links a { font-size: 0.875rem; color: var(--text-muted); }
.footer-links a:hover { color: var(--accent-1); }

.footer-bottom {
  max-width: 1280px;
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Utility ──────────────────────────────────────────────────────────────── */
.text-accent   { color: var(--accent-1); }
.text-muted    { color: var(--text-muted); }
.text-sm       { font-size: 0.875rem; }
.text-xs       { font-size: 0.78rem; }
.flex-center   { display: flex; align-items: center; }
.gap-1         { gap: 0.25rem; }
.gap-2         { gap: 0.5rem; }
.mt-1          { margin-top: 0.25rem; }
.mt-2          { margin-top: 0.5rem; }
.mt-3          { margin-top: 0.75rem; }
.mb-4          { margin-bottom: 1rem; }

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--glass-bg-dark);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  backdrop-filter: blur(16px);
  font-size: 0.875rem;
  color: var(--text-primary);
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: var(--transition);
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(6, 214, 160, 0.4); }
.toast.error   { border-color: rgba(239, 68, 68, 0.4); }

/* "Back to top" button */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 212, 255, 0.15);
  border: 1px solid rgba(0, 212, 255, 0.3);
  color: var(--accent-1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: var(--transition);
  font-size: 1.1rem;
  z-index: 50;
}

.back-to-top.visible { opacity: 1; }
.back-to-top:hover { background: rgba(0, 212, 255, 0.25); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  /* topics-grid: auto-fill จัดการเองแล้ว ไม่ต้อง override */
  .article-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  /* ── ซ่อนเมนูหลัก + แสดง hamburger ───────────────────── */
  .navbar-menu { display: none; }
  .hamburger   { display: flex; }
  .navbar-search .search-input { width: 130px; }
  .hero { padding: 3rem 1rem 2.5rem; min-height: 360px; }
  .hero-stats { gap: 1rem; }
  .hero-stat-num { font-size: 1.5rem; }
  .footer-inner { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; text-align: center; }

  /* ── Mobile nav drawer (slide down) ───────────────────── */
  .navbar-menu.open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: rgba(6, 9, 26, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 212, 255, 0.15);
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    z-index: 999;
    padding: 0.75rem 0.75rem 1rem;
    gap: 0.15rem;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Mobile nav items */
  .navbar-menu.open .nav-item {
    padding: 0.7rem 1rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
  }

  /* Mobile dropdown: แสดงแบบ inline (ไม่ใช่ absolute) */
  .navbar-menu.open .nav-dropdown {
    position: static;
  }
  .navbar-menu.open .nav-dropdown-menu {
    position: static;
    display: none;
    min-width: auto;
    width: 100%;
    background: rgba(0, 212, 255, 0.04);
    border: 1px solid rgba(0, 212, 255, 0.1);
    border-radius: 10px;
    box-shadow: none;
    padding: 0.35rem;
    margin: 0.3rem 0 0.3rem 0.75rem;
    z-index: auto;
  }
  .navbar-menu.open .nav-dropdown-menu::before { display: none; }
  .navbar-menu.open .nav-dropdown.open > .nav-dropdown-menu {
    display: block;
  }
  .navbar-menu.open .nav-dropdown-item {
    padding: 0.55rem 0.85rem;
    font-size: 0.875rem;
    border-radius: 8px;
    white-space: normal;
  }
}

@media (max-width: 480px) {
  .container { padding: 0 0.9rem; }
  .cat-card { width: 150px; }
  .article-title { font-size: 1.3rem; }
  .hero-title { font-size: 2.5rem; }
  .section { padding: 2rem 0; }
  .topic-card { padding: 0.9rem 1rem; }
}

/* Print styles */
@media print {
  body { background: white; color: black; }
  .navbar, .sidebar, .share-section, .back-to-top { display: none; }
  .article-body { color: black; }
}
