/* home.css — (Cleaned - Modal CSS removed - Mobile UI Fixed) */

:root {
  --color-primary-dark: #1e1d1a;
  --color-accent-gold: #ffc400;
  --color-text-light: #f5f5f5;
  --color-text-muted: #aaa;
  --color-card-bg: rgba(255, 255, 255, 0.05);
}

body {
  font-family: 'Kanit', Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  background: var(--color-primary-dark) url('picture/back.jpeg') no-repeat center center fixed;
  background-size: cover;
  color: var(--color-text-light);
  padding-bottom: 80px; 
}


/* --- (ออกแบบใหม่) HEADER & NAV --- */
header {
  display: flex;
  /* justify-content: center; */ /* <-- (แก้ไขจากรอบที่แล้ว) */
  align-items: center;
  padding: 0px 40px;
  
  background: transparent;
  border-bottom: 1px solid transparent;
  box-shadow: none;

  position: sticky;
  top: 0;
  z-index: 100;
  
  transition: background-color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}
header::before,
header::after {
  content: none !important;
  display: none !important;
}

header.scrolled {
  background: rgba(0, 0, 0, 0.95);
  border-bottom-color: rgba(255, 196, 0, 0.15);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}


/* LOGO (ใน Banner) */
.logo {
  max-width: 400px;
  width: 100%;
  height: auto;
  font-size: 1.8em;
  color: var(--color-accent-gold);
  font-weight: bold;
}

/* (ออกแบบใหม่) NAVIGATION (คอลัมน์กลาง) */
nav {
  grid-column: 2 / 3;
  justify-self: center;
  
  display: flex;
  gap: 10px;
  padding-left: 0;
  border: none !important;
  box-shadow: none !important;
  background-image: none !important;
}
nav::before,
nav::after {
  content: none !important;
  display: none !important;
}

/* (ออกแบบใหม่) LINK MENU */
nav a {
  color: var(--color-text-light);
  font-weight: 500;
  padding: 18px 14px;
  border-radius: 4px;
  text-decoration: none;
  position: relative;
  transition: color 0.3s ease, background-color 0.3s ease;
  border: none !important;
  box-shadow: none !important;
  background: none !important;
  white-space: nowrap;
}
nav a:hover {
  color: var(--color-accent-gold);
  background-color: rgba(255, 255, 255, 0.05);
}

nav a.nav-active { 
  color: var(--color-accent-gold);
  font-weight: 700;
}
nav a.nav-active::after {
  content: '';
  position: absolute;
  bottom: 12px;
  left: 14px;
  right: 14px;
  height: 2px;
  background-color: var(--color-accent-gold);
}


/* (ออกแบบใหม่) .menu-container (ใช้ Grid 3 คอลัมน์) */
.menu-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  /* max-width: 1400px; */ /* <-- (แก้ไขจากรอบที่แล้ว) */
  border: none !important;
  box-shadow: none !important;
  background: none; /* <--- (แก้ไขจากรอบที่แล้ว) */
}
.menu-container::before,
.menu-container::after {
  content: none !important;
  display: none !important;
}

/* --- (ออกแบบใหม่) LOGIN SECTION (คอลัมน์ขวา) --- */
.login-section {
  grid-column: 3 / 4;
  justify-self: end;
  
  display: flex;
  gap: 10px;
}

.btn-login, .btn-register {
  font-family: 'Kanit', sans-serif;
  font-size: 0.95rem; 
  font-weight: 500;
  padding: 8px 18px; 
  border-radius: 8px; 
  text-decoration: none;
  transition: all 0.3s ease;
  white-space: nowrap; 
}

.btn-login {
  color: var(--color-accent-gold);
  background: transparent;
  border: 1px solid var(--color-accent-gold);
}

.btn-login:hover {
  color: var(--color-primary-dark); 
  background: var(--color-accent-gold); 
  box-shadow: 0 0 8px rgba(255, 196, 0, 0.4);
}

.btn-register {
  color: var(--color-primary-dark); 
  background: var(--color-accent-gold); 
  border: 1px solid var(--color-accent-gold);
}

.btn-register:hover {
  color: var(--color-accent-gold);
  background: transparent; 
  box-shadow: 0 0 8px rgba(255, 196, 0, 0.4);
}

/* --- HAMBURGER STYLES --- */
.hamburger-btn {
  display: none; 
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  z-index: 101; 
}
.hamburger-btn span {
  display: block;
  width: 25px;
  height: 3px;
  background-color: var(--color-text-light);
  margin: 5px 0;
  transition: all 0.3s ease;
}

/* --- BANNER & CTA BUTTONS --- */
.main-banner {
  text-align: center;
  padding: 80px 20px 60px;
  background: transparent;
  border: none !important;
}

.banner-cta {
  margin-top: 30px; 
  display: flex;
  justify-content: center;
  gap: 15px; 
}

.btn-cta-primary, .btn-cta-secondary {
  font-family: 'Kanit', sans-serif;
  font-size: 1.1rem; 
  font-weight: 600;
  padding: 12px 28px; 
  border-radius: 10px; 
  text-decoration: none;
  transition: all 0.3s ease;
  border: 2px solid var(--color-accent-gold); 
  width: 210px;
  text-align: center; 
  box-sizing: border-box; 
}

.btn-cta-primary {
  background: var(--color-accent-gold);
  color: var(--color-primary-dark);
}

.btn-cta-primary:hover {
  background: transparent;
  color: var(--color-accent-gold);
  box-shadow: 0 0 15px rgba(255, 196, 0, 0.6);
}

.btn-cta-primary i {
  margin-right: 8px;
}

.btn-cta-secondary {
  background: transparent;
  color: var(--color-accent-gold);
}

.btn-cta-secondary:hover {
  background: var(--color-accent-gold);
  color: var(--color-primary-dark);
  box-shadow: 0 0 15px rgba(255, 196, 0, 0.6);
}

.btn-cta-secondary i {
  margin-right: 8px;
}


.mobile-cta-bar {
  display: none;
}

/* --- SIDEBAR CONTAINER (ปรับปรุงใหม่) --- */
.sidebar.server-status-wrapper {
  background: var(--color-card-bg);
  border-radius: 8px;
  border: 1px solid rgba(255, 196, 0, 0.2);
  padding: 20px;
  box-sizing: border-box;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* --- Countdown Timer (ปรับปรุงใหม่สำหรับ Sidebar) --- */
.sidebar-countdown-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-accent-gold);
  text-shadow: 0 0 5px rgba(255, 196, 0, 0.4);
  margin-bottom: 25px;
}

.countdown-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 300px;
}

.countdown-box {
  background: rgba(255, 196, 0, 0.1);
  color: var(--color-accent-gold);
  font-size: 1.5rem;
  font-weight: 700;
  padding: 10px 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 196, 0, 0.3);
  text-align: center;
  flex-grow: 1;
  flex-basis: 0;
  min-width: 60px;
  line-height: 1.2;
  text-shadow: 0 0 3px rgba(255, 196, 0, 0.3);
  box-shadow: 0 0 5px rgba(255, 196, 0, 0.2);
}

.countdown-box span {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--color-text-light);
  margin-top: 5px;
  text-shadow: none;
}

.sidebar.server-status-wrapper > .countdown-box[style*="width: auto"] {
  width: auto !important;
  padding: 15px 30px !important;
  font-size: 1.3rem !important;
  background: var(--color-accent-gold) !important;
  color: var(--color-primary-dark) !important;
  text-shadow: none !important;
  box-shadow: 0 0 10px rgba(255, 196, 0, 0.5) !important;
  border-color: var(--color-accent-gold) !important;
}


/* --- (เพิ่ม) สไตล์สำหรับไฟสถานะเซิร์ฟเวอร์ (แดง) --- */
.server-status-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 25px; /* เว้นระยะจากกล่องตัวเลข */
  color: #ffc400; /* ใช้สีทองให้เข้าธีม */
  font-size: 0.95rem;
  font-weight: 500;
  text-shadow: 0 0 5px rgba(255, 196, 0, 0.3);
}

.status-dot-red {
  width: 10px;
  height: 10px;
  background-color: #ff4d4d; /* สีแดงสด */
  border-radius: 50%;
  margin-right: 8px; /* เว้นระยะจากข้อความ */
  border: 1px solid rgba(255, 255, 255, 0.2);
  
  /* Animation ไฟกระพริบ */
  box-shadow: 0 0 8px rgba(255, 77, 77, 0.7);
  animation: pulse-red 2s infinite ease-in-out;
}
/* --- (จบ) สไตล์สำหรับไฟสถานะ --- */


/* --- CONTENT --- */
section.content {
  border: none !important;
  box-shadow: none !important;
  padding-top: 30px;
}

/* --- TABS STYLES --- */
.tabs {
  display: flex;
  justify-content: center;
  gap: 10px; 
  margin-bottom: 25px; 
  border-bottom: none !important;
  border-top: none !important;
  background: none !important;
  box-shadow: none !important;
}

.tab-btn {
  font-family: 'Kanit', sans-serif; 
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted); 
  background: var(--color-card-bg); 
  border: 1px solid rgba(255, 196, 0, 0.2); 
  padding: 10px 20px;
  border-radius: 8px; 
  cursor: pointer;
  transition: all 0.3s ease; 
}

.tab-btn:hover {
  color: var(--color-text-light); 
  background: rgba(255, 196, 0, 0.2); 
  border-color: var(--color-accent-gold); 
}

.tab-btn.active {
  color: var(--color-primary-dark); 
  background: var(--color-accent-gold); 
  border-color: var(--color-accent-gold); 
  box-shadow: 0 0 10px rgba(255, 196, 0, 0.5); 
}

/* --- NEWS LIST STYLES --- */
.news-list {
  max-width: 800px; 
  margin: 20px auto 0 auto; 
  display: grid;
  grid-template-columns: 1fr; 
  gap: 15px; 
  border: none !important;
  box-shadow: none !important;
}

.news-item {
  display: grid;
  grid-template-columns: 160px 1fr; 
  gap: 15px;
  background: var(--color-card-bg); 
  border-radius: 8px;
  overflow: hidden; 
  border: none !important;
  box-shadow: none !important;
  align-items: center; 
}

.news-image {
  width: 100%;
  height: 100%;
  object-fit: cover; 
}

.news-content {
  padding: 15px;
}

.news-countdown {
  font-weight: bold;
  color: var(--color-accent-gold);
  font-size: 0.9em;
  margin-bottom: 5px; 
}

.news-header {
  display: flex;
  gap: 10px;
  font-size: 0.8em;
  color: var(--color-text-muted);
  margin-bottom: 8px; 
}

.news-tab {
  background: var(--color-accent-gold);
  color: var(--color-primary-dark);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.news-title {
  color: var(--color-text-light);
  text-decoration: none;
  font-size: 1.1em;
  font-weight: 600;
  display: block;
}

.news-title:hover {
  color: var(--color-accent-gold);
}

/* +++ START: FOOTER (ส่วนที่แก้ไข) +++ */
footer {
  text-align: center;
  padding: 25px 0;
  color: var(--color-text-muted);
  font-size: 0.9em;
  border-top: none !important;
  box-shadow: none !important;
}

footer a {
  color: var(--color-text-muted);
  text-decoration: none;
}
footer a:hover {
  color: var(--color-accent-gold);
  text-decoration: underline;
}
/* +++ END: FOOTER +++ */


/* +++ START: Animation สำหรับ Scroll (NEW) +++ */
section.content {
  opacity: 0; 
  transform: translateY(20px); 
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

section.content.is-visible {
  opacity: 1; 
  transform: translateY(0); 
}
/* +++ END: Animation สำหรับ Scroll (NEW) +++ */


/* --- REMOVE ANY EXTRA HR OR FAKE LINES --- */
hr, .menu-bar, .topbar, .top-line {
  display: none !important;
  border: none !important;
  background: none !important;
}

/* --- UTILITY FOR ALL ::BEFORE / ::AFTER IN HEADER/NAV --- */
header *::before, header *::after,
nav *::before, nav *::after {
  content: none !important;
  display: none !important;
  border: none !important;
  background: none !important;
}

/* --- (อัปเดตใหม่ทั้งหมด) คอนเทนเนอร์สำหรับ "noho" และคำพูด --- */
.noho-container {
  position: fixed;
  bottom: 0px!important;
  right: 0px!important;
  width: 250px!important;
  z-index: 50!important;
  pointer-events: none;
  
  transform: translateY(100%);
  animation: slideUpNoho 1s ease-out forwards;
}

/* (ปรับปรุง) สไตล์รูปภาพ noho (อยู่ภายใน container) */
.noho-character {
  width: 100%;
  height: auto;
  display: block;
  
  filter: drop-shadow(0px 8px 25px rgba(0, 0, 0, 0.7))
          drop-shadow(0 0 18px rgba(255, 196, 0, 0.3));
}

/* (อัปเดตใหม่ทั้งหมด) สไตล์สำหรับกล่องคำพูด */
.noho-speech-bubble {
  position: absolute;
  bottom: 100%;
  right: 0;
  
  width: 280px;
  max-width: 90vw;

  background: linear-gradient(135deg, rgba(30, 29, 26, 0.95), rgba(10, 10, 10, 0.95));
  border: 1px solid var(--color-accent-gold);
  border-radius: 12px;
  padding: 15px 20px;
  
  color: var(--color-text-light);
  font-family: 'Kanit', sans-serif;
  font-size: 1.1rem;
  text-align: center;
  line-height: 1.5;
  font-weight: 500;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.7), 0 0 15px rgba(255, 196, 0, 0.2);
  
  margin-bottom: 20px;
  
  opacity: 0;
  animation: fadeInBubble 0.5s ease-out forwards;
  animation-delay: 0.8s; 
  
  text-shadow: 0 0 5px rgba(255, 196, 0, 0.2);
}

/* (อัปเดตใหม่ทั้งหมด) หางสามเหลี่ยมของกล่องคำพูด (ชี้ลงมาที่ตัวละคร) */
.noho-speech-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 50px;
  transform: translateX(50%);
  
  border-width: 15px 15px 0 15px;
  border-style: solid;
  border-color: var(--color-accent-gold) transparent transparent transparent;
  
  z-index: 1;
}

.noho-speech-bubble::before { /* หางด้านใน */
  content: '';
  position: absolute;
  top: 100%;
  right: 50px;
  transform: translateX(50%) translateY(-1px);
  
  border-width: 14px 14px 0 14px;
  border-style: solid;
  border-color: rgba(30, 29, 26, 0.95) transparent transparent transparent;
  z-index: 2;
}


/* Keyframes สำหรับ Animation (ตัวละครสไลด์ขึ้น) */
@keyframes slideUpNoho {
  to {
    transform: translateY(0);
  }
}

/* Keyframes สำหรับ Animation (กล่องคำพูด fade in) */
@keyframes fadeInBubble {
  to {
    opacity: 1;
  }
}

/* (เพิ่ม) โค้ดสำหรับเคอร์เซอร์พิมพ์ดีด */
#noho-bubble-text::after {
  content: '█';
  display: inline-block;
  animation: blinkCaret 0.7s infinite;
  margin-left: 2px;
  font-size: 0.9em;
  opacity: 1;
}

/* (เพิ่ม) เมื่อพิมพ์เสร็จ ให้ซ่อนเคอร์เซอร์ */
#noho-bubble-text.typing-finished::after {
  content: '';
  animation: none;
  display: none;
}

/* (เพิ่ม) Keyframes สำหรับเคอร์เซอร์กระพริบ */
@keyframes blinkCaret {
  0% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 1; }
}

/* (เพิ่ม) Keyframes สำหรับไฟกระพริบสีแดง */
@keyframes pulse-red {
  0% {
    transform: scale(1);
    box-shadow: 0 0 5px rgba(255, 77, 77, 0.5);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(255, 77, 77, 1);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 5px rgba(255, 77, 77, 0.5);
  }
}


/* * ============================================
 * --- (รวมโค้ด) RESPONSIVE (จอมือถือ) --- 
 * ============================================
*/
@media (max-width: 900px) {
  
  body {
    padding-bottom: 80px;
  }

  /* (ออกแบบใหม่) HEADER & HAMBURGER สำหรับมือถือ */
  header { 
    padding: 10px 18px; 
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  nav { 
    gap: 8px;
    flex-direction: column;
    align-items: center;
    width: 100%;
    
    /* (เพิ่ม) ล้างค่า grid ของ desktop */
    grid-column: auto;
    justify-self: auto;
  }

  .hamburger-btn {
    display: block;
  }

  /* (ออกแบบใหม่) ซ่อน .menu-container (ที่เป็น grid) บนมือถือ */
  .menu-container {
    display: none; 
    position: absolute;
    top: 55px;
    left: 0;
    right: 0;
    
    background: rgba(0, 0, 0, 0.98); 
    
    grid-template-columns: 1fr;
    width: auto;
    flex-direction: column; 
    align-items: center;
    padding: 20px;
    border-top: 1px solid rgba(255, 196, 0, 0.3); 
  }

  header.scrolled .menu-container {
      top: 57px;
  }

  .menu-container.active {
    display: flex;
  }
  
  
  /* +++ START: (แก้ไข) โค้ดที่แก้ไข UI เมนูมือถือ +++ */
  
  /* 1. จัดการลิงก์เมนูหลัก (จัดอันดับ, อันดับสำนัก ฯลฯ) */
  .menu-container nav {
    padding-bottom: 15px; 
    border-bottom: 1px solid rgba(255, 196, 0, 0.2); 
    margin-bottom: 15px; 
  }

  .menu-container nav a {
    color: var(--color-text-light) !important; /* บังคับให้เป็นสีสว่าง */
    font-size: 1.1rem; 
    padding: 10px 0; 
    width: 100%;
    text-align: center;
    background: none !important; 
    border: none !important; 
    text-decoration: none !important; /* เอาเส้นใต้ออก */
  }
  
  .menu-container nav a:hover {
      color: var(--color-accent-gold) !important; 
      background: rgba(255, 196, 0, 0.1) !important; 
  }
  
  /* 2. จัดการลิงก์ที่ถูกเลือก (หน้าหลัก) */
  .menu-container nav a.nav-active {
    color: var(--color-accent-gold) !important; /* บังคับให้เป็นสีทอง */
    font-weight: 700;
  }

  /* 3. ลบเส้นขีดสีทองใต้ลิงก์ (เพราะเราอยู่ในเมนูมือถือ) */
  .menu-container nav a.nav-active::after {
    display: none !important;
  }
  
  /* 4. (สำคัญ) ทำให้ปุ่มทั้งสองปุ่มมีสีที่ชัดเจนบนพื้นหลังสีเข้ม */
  .menu-container .btn-login,
  .menu-container .btn-register {
    padding: 12px 20px; 
    font-size: 1.1rem;
    text-align: center;
    text-decoration: none !important; /* เอาเส้นใต้ออก */
  }
  
  /* 5. ปุ่มลงชื่อเข้าใช้: เปลี่ยนเป็นสีทองตัวอักษร */
  .menu-container .btn-login {
    color: var(--color-accent-gold) !important;
    background: transparent !important;
    border: 1px solid var(--color-accent-gold) !important;
  }

  /* 6. ปุ่มสมัครสมาชิก: เปลี่ยนเป็นสีทองพื้นหลัง */
  .menu-container .btn-register {
    color: var(--color-primary-dark) !important;
    background: var(--color-accent-gold) !important;
    border: 1px solid var(--color-accent-gold) !important;
  }
        
  /* +++ END: โค้ดที่แก้ไข UI เมนูมือถือ +++ */
  

  .login-section {
    flex-direction: column;
    width: 100%;
    gap: 10px;
    margin-top: 20px;
    
    /* (เพิ่ม) ล้างค่า grid ของ desktop */
    grid-column: auto;
    justify-self: auto;
  }
  .login-section a {
    text-align: center; 
  }

  .banner-cta {
    display: none; 
  }

  .container {
    display: flex;
    flex-direction: column;
    padding: 0 10px;
  }
  .content {
    order: 1;
  }
  .sidebar {
    order: 2;
  }

  /* --- (ดีไซน์ใหม่) Responsive Adjustments สำหรับ Countdown --- */
  .sidebar.server-status-wrapper {
    padding: 20px 15px;
    min-height: 200px;
    margin-top: 20px;
    
    position: relative;
    z-index: 60;
  }

  .sidebar-countdown-title {
    font-size: 1.2rem;
    margin-bottom: 20px;
  }

  .countdown-container {
    gap: 8px;
  }

  .countdown-box {
    font-size: 1.3rem;
    padding: 10px 0;
    min-width: 55px;
  }

  .countdown-box span {
    font-size: 0.7rem;
    margin-top: 4px;
  }

  .sidebar.server-status-wrapper > .countdown-box[style*="width: auto"] {
    padding: 12px 20px !important;
    font-size: 1.1rem !important;
  }


  .mobile-cta-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.98);
    border-top: 1px solid var(--color-accent-gold);
    padding: 10px;
    box-sizing: border-box;
    gap: 10px;
    z-index: 90;
  }

  .mobile-cta-bar .btn-cta-primary,
  .mobile-cta-bar .btn-cta-secondary {
    width: 50%;
    padding: 10px 5px;
    font-size: 1rem;
    width: 50%;
    min-width: 0;
  }

  .news-item {
    grid-template-columns: 1fr; 
  }

  .news-image {
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
    object-fit: cover;
  }

  .tabs {
    justify-content: flex-start; 
    overflow-x: auto; 
    padding: 5px 10px; 
    padding-bottom: 10px;
  }
  .tab-btn {
    white-space: nowrap; 
    padding: 8px 15px; 
  }

  /* (ดีไซน์ใหม่) Responsive สำหรับ noho */
  .noho-container {
    bottom: 90px;
    right: 10px;
    width: 180px;
  }

  .noho-speech-bubble {
    width: 190px;
    font-size: 0.9rem;
    padding: 12px 15px;
    margin-bottom: 15px; 
    right: 0;
  }

  .noho-speech-bubble::after,
  .noho-speech-bubble::before {
    right: 50px;
    transform: translateX(50%) translateY(-1px);
    border-width: 12px 12px 0 12px;
  }
  
}