/* =====================================================================
 *  theme.css — โหมดสว่าง / มืด (Light / Dark) สำหรับหน้าแรก
 *  โหลดหลัง style.css เสมอ  —  ไม่แก้ style.css เดิม
 *  สลับด้วย <html data-theme="light|dark">  (ตั้งค่าโดย theme.js)
 * ===================================================================== */

/* ---------- ปุ่มสลับโหมดบน navbar ---------- */
.theme-toggle{
  --tt-size:40px;
  display:inline-flex;align-items:center;justify-content:center;
  width:var(--tt-size);height:var(--tt-size);flex:0 0 auto;
  margin-left:.6rem;padding:0;border-radius:50%;
  border:1px solid rgba(128,128,128,.35);
  background:transparent;color:inherit;cursor:pointer;
  transition:background .2s,border-color .2s,transform .2s;
}
.theme-toggle:hover{background:rgba(128,128,128,.15);transform:rotate(-12deg)}
.theme-toggle:focus-visible{outline:2px solid #c9a24a;outline-offset:2px}
.theme-toggle svg{width:20px;height:20px;display:block}
.theme-toggle .ic-sun{display:none}
.theme-toggle .ic-moon{display:block}
html[data-theme="dark"] .theme-toggle .ic-sun{display:block}
html[data-theme="dark"] .theme-toggle .ic-moon{display:none}

/* เปลี่ยนสีแบบนุ่ม ๆ เฉพาะตอนผู้ใช้กดสลับ (theme.js ใส่คลาสนี้ชั่วคราว) */
html.theme-anim, html.theme-anim *, html.theme-anim *::before, html.theme-anim *::after{
  transition:background-color .35s ease,color .35s ease,border-color .35s ease,box-shadow .35s ease !important;
}
@media (prefers-reduced-motion:reduce){
  html.theme-anim, html.theme-anim *{transition:none !important}
}

/* =====================================================================
 *  DARK MODE
 *  โทน navy / teal / gold ให้เข้ากับหน้าหลักสูตร
 * ===================================================================== */
html[data-theme="dark"]{
  color-scheme:dark;
  --dm-bg:#0b1424;          /* พื้นหลังหลัก */
  --dm-bg-alt:#0f1b30;      /* พื้นหลัง section สลับ */
  --dm-surface:#14233c;     /* การ์ด */
  --dm-surface-2:#1a2d4b;   /* hover / chip */
  --dm-border:rgba(148,170,205,.18);
  --dm-text:#e6ecf5;
  --dm-text-2:#a9b6cb;
  --dm-muted:#7f8ea8;
  --dm-accent:#d4b062;      /* gold */
  --dm-teal:#4fc1b6;
}

html[data-theme="dark"] body{background:var(--dm-bg);color:var(--dm-text)}

/* --- Navbar --- */
html[data-theme="dark"] .navbar,
html[data-theme="dark"] .navbar.scrolled{
  background:rgba(11,20,36,.92);
  border-bottom-color:var(--dm-border);
  box-shadow:0 1px 0 var(--dm-border);
}
html[data-theme="dark"] .nav-link{color:var(--dm-text-2)}
html[data-theme="dark"] .nav-link:hover,
html[data-theme="dark"] .nav-link.active{color:var(--dm-accent)}
html[data-theme="dark"] .nav-toggle span{background:var(--dm-text)}
html[data-theme="dark"] .nav-links{background-color:transparent}
@media (max-width:900px){
  html[data-theme="dark"] .nav-links{background:var(--dm-bg-alt)}
}

/* --- Sections --- */
html[data-theme="dark"] .section,
html[data-theme="dark"] .programs-section,
html[data-theme="dark"] .events-section,
html[data-theme="dark"] .features-section{background:var(--dm-bg)}
html[data-theme="dark"] .announce-section,
html[data-theme="dark"] .research-section{background:var(--dm-bg-alt)}

html[data-theme="dark"] .section-title,
html[data-theme="dark"] .program-name,
html[data-theme="dark"] .feature-card h3,
html[data-theme="dark"] .announce-title,
html[data-theme="dark"] .announce-title a,
html[data-theme="dark"] h1, html[data-theme="dark"] h2,
html[data-theme="dark"] h3, html[data-theme="dark"] h4{color:var(--dm-text)}
html[data-theme="dark"] .section-label{color:var(--dm-accent)}
html[data-theme="dark"] .section-subtitle,
html[data-theme="dark"] .program-desc,
html[data-theme="dark"] .feature-card p,
html[data-theme="dark"] .research-text,
html[data-theme="dark"] .announce-excerpt,
html[data-theme="dark"] .highlight-text{color:var(--dm-text-2)}

/* --- Program tabs & cards --- */
html[data-theme="dark"] .program-tabs{background:var(--dm-surface);border-color:var(--dm-border)}
html[data-theme="dark"] .tab-btn{color:var(--dm-text-2);background:transparent}
html[data-theme="dark"] .tab-btn:hover{color:var(--dm-text)}
html[data-theme="dark"] .tab-btn.active{background:var(--dm-accent);color:#0b1424}

html[data-theme="dark"] .program-card,
html[data-theme="dark"] .feature-card,
html[data-theme="dark"] .highlight-item{
  background:var(--dm-surface);
  border-color:var(--dm-border);
  box-shadow:0 1px 2px rgba(0,0,0,.35);
}
html[data-theme="dark"] .program-card:hover,
html[data-theme="dark"] .feature-card:hover{
  background:var(--dm-surface-2);
  box-shadow:0 10px 30px rgba(0,0,0,.45);
}
html[data-theme="dark"] .program-icon,
html[data-theme="dark"] .feature-icon-wrap{background:rgba(79,193,182,.12);color:var(--dm-teal)}
html[data-theme="dark"] .program-icon.doctoral,
html[data-theme="dark"] .program-icon.certificate{background:rgba(212,176,98,.14);color:var(--dm-accent)}
html[data-theme="dark"] .program-meta{border-color:var(--dm-border)}
html[data-theme="dark"] .meta-item{color:var(--dm-muted);background:transparent}
html[data-theme="dark"] .program-link{color:var(--dm-accent)}
html[data-theme="dark"] .highlight-number{color:var(--dm-accent)}

/* --- Announcements --- */
html[data-theme="dark"] .filter-chip{
  background:var(--dm-surface);color:var(--dm-text-2);border-color:var(--dm-border);
}
html[data-theme="dark"] .filter-chip:hover{background:var(--dm-surface-2);color:var(--dm-text)}
html[data-theme="dark"] .filter-chip.active{background:var(--dm-accent);border-color:var(--dm-accent);color:#0b1424}

html[data-theme="dark"] .announce-feed{border-color:var(--dm-border)}
html[data-theme="dark"] .announce-item{
  background:var(--dm-surface);border-color:var(--dm-border);
}
html[data-theme="dark"] .announce-item:hover{background:var(--dm-surface-2)}
html[data-theme="dark"] .announce-date{
  background:var(--dm-bg);border-color:var(--dm-border);color:var(--dm-text);
}
html[data-theme="dark"] .announce-date .d-mon,
html[data-theme="dark"] .announce-date .d-yr{color:var(--dm-muted)}
html[data-theme="dark"] .announce-link{color:var(--dm-text-2);border-color:var(--dm-border)}
html[data-theme="dark"] .announce-link:hover{color:var(--dm-accent);border-color:var(--dm-accent)}
html[data-theme="dark"] .announce-empty,
html[data-theme="dark"] .ev-empty{color:var(--dm-muted)}

/* --- Events slider --- */
html[data-theme="dark"] .slider-arrow{
  background:var(--dm-surface);color:var(--dm-text);border-color:var(--dm-border);
}
html[data-theme="dark"] .slider-arrow:hover{background:var(--dm-surface-2)}
html[data-theme="dark"] .events-grid > *{
  background-color:var(--dm-surface);border-color:var(--dm-border);color:var(--dm-text);
}

/* --- Buttons --- */
html[data-theme="dark"] .btn-outline{color:var(--dm-text);border-color:var(--dm-border);background:transparent}
html[data-theme="dark"] .btn-outline:hover{border-color:var(--dm-accent);color:var(--dm-accent);background:transparent}

/* --- Footer --- */
html[data-theme="dark"] .site-footer{background:#070e1a;color:var(--dm-text-2);border-top:1px solid var(--dm-border)}
html[data-theme="dark"] .footer-bottom{border-color:var(--dm-border)}
html[data-theme="dark"] .site-footer a{color:var(--dm-text-2)}
html[data-theme="dark"] .site-footer a:hover{color:var(--dm-accent)}
html[data-theme="dark"] .social-btn{border-color:var(--dm-border)}

/* --- Images: ลดความจ้าเล็กน้อยในโหมดมืด (ไม่รวม hero) --- */
html[data-theme="dark"] .research-image{filter:brightness(.88)}

/* --- ปุ่มหลัก: navy กลืนกับพื้นมืด → เปลี่ยนเป็น gold --- */
html[data-theme="dark"] .btn-primary{background:var(--dm-accent);color:#0b1424;border-color:var(--dm-accent)}
html[data-theme="dark"] .btn-primary:hover{background:#e2c27a;border-color:#e2c27a}

/* --- ป้ายหมวดประกาศ: ลดความจ้าในโหมดมืด --- */
html[data-theme="dark"] .announce-tag{background:rgba(79,193,182,.16);color:#7fd6cd}
html[data-theme="dark"] .announce-tag.tag-scholarship{background:rgba(212,176,98,.16);color:#e2c27a}
html[data-theme="dark"] .announce-tag.tag-thesis{background:rgba(150,135,235,.18);color:#b9acf5}
html[data-theme="dark"] .announce-tag.tag-general{background:rgba(148,170,205,.16);color:var(--dm-text-2)}

/* =====================================================================
 *  LIGHT MODE — โทนสว่างแบบถนอมสายตา
 *  ลดสีขาวจัด (#fff) เป็นโทนกระดาษอุ่น ๆ  ลดความคมของตัวอักษรดำ-ขาว
 *  และทำเส้นขอบ/เงาให้นุ่มลง
 * ===================================================================== */
html[data-theme="light"]{
  color-scheme:light;
  --lm-bg:#f7f6f2;          /* พื้นหลังหลัก: off-white อุ่น */
  --lm-bg-alt:#f0eee8;      /* section สลับ */
  --lm-surface:#fdfcf9;     /* การ์ด */
  --lm-surface-2:#f9f7f2;   /* hover */
  --lm-border:#e6e1d6;
  --lm-text:#26344d;        /* navy อ่อนลง ไม่ดำจัด */
  --lm-text-2:#5d6a7e;
  --lm-muted:#868f9e;
  --lm-accent:#a8812f;      /* gold เข้มพอสำหรับตัวอักษรบนพื้นสว่าง */
  --lm-navy:#1f3559;
}

html[data-theme="light"] body{background:var(--lm-bg);color:var(--lm-text)}

/* Navbar */
html[data-theme="light"] .navbar,
html[data-theme="light"] .navbar.scrolled{
  background:rgba(247,246,242,.94);
  border-bottom-color:var(--lm-border);
  box-shadow:none;
}
html[data-theme="light"] .nav-link{color:var(--lm-text-2)}
html[data-theme="light"] .nav-link:hover,
html[data-theme="light"] .nav-link.active{color:var(--lm-navy)}

/* Sections */
html[data-theme="light"] .section,
html[data-theme="light"] .programs-section,
html[data-theme="light"] .events-section,
html[data-theme="light"] .features-section{background:var(--lm-bg)}
html[data-theme="light"] .announce-section,
html[data-theme="light"] .research-section{background:var(--lm-bg-alt)}

html[data-theme="light"] .section-title,
html[data-theme="light"] .program-name,
html[data-theme="light"] .feature-card h3,
html[data-theme="light"] .announce-title,
html[data-theme="light"] .announce-title a,
html[data-theme="light"] .highlight-number{color:var(--lm-navy)}
html[data-theme="light"] .section-label{color:var(--lm-accent)}
html[data-theme="light"] .section-subtitle,
html[data-theme="light"] .program-desc,
html[data-theme="light"] .feature-card p,
html[data-theme="light"] .research-text,
html[data-theme="light"] .announce-excerpt,
html[data-theme="light"] .highlight-text{color:var(--lm-text-2)}

/* Tabs & cards */
html[data-theme="light"] .program-tabs{background:var(--lm-bg-alt);border-color:var(--lm-border)}
html[data-theme="light"] .tab-btn{color:var(--lm-text-2)}
html[data-theme="light"] .tab-btn.active{background:var(--lm-navy);color:#fdfcf9}

html[data-theme="light"] .program-card,
html[data-theme="light"] .feature-card,
html[data-theme="light"] .highlight-item,
html[data-theme="light"] .announce-item,
html[data-theme="light"] .events-grid > *{
  background:var(--lm-surface);
  border-color:var(--lm-border);
  box-shadow:0 1px 2px rgba(60,50,30,.04);
}
html[data-theme="light"] .program-card:hover,
html[data-theme="light"] .feature-card:hover,
html[data-theme="light"] .announce-item:hover{
  background:var(--lm-surface-2);
  box-shadow:0 8px 24px rgba(60,50,30,.07);
}
html[data-theme="light"] .program-icon,
html[data-theme="light"] .feature-icon-wrap{background:#e6efed;color:#2f6e69}
html[data-theme="light"] .program-meta{border-color:var(--lm-border)}
html[data-theme="light"] .meta-item{color:var(--lm-muted)}
html[data-theme="light"] .program-link{color:var(--lm-navy)}

/* Announcements */
html[data-theme="light"] .filter-chip{background:var(--lm-surface);border-color:var(--lm-border);color:var(--lm-text-2)}
html[data-theme="light"] .filter-chip:hover{background:var(--lm-surface-2);color:var(--lm-text)}
html[data-theme="light"] .filter-chip.active{background:var(--lm-navy);border-color:var(--lm-navy);color:#fdfcf9}
html[data-theme="light"] .announce-date{background:var(--lm-bg);border-color:var(--lm-border);color:var(--lm-text)}
html[data-theme="light"] .announce-date .d-mon,
html[data-theme="light"] .announce-date .d-yr{color:var(--lm-muted)}
html[data-theme="light"] .announce-link{border-color:var(--lm-border);color:var(--lm-text-2)}
html[data-theme="light"] .announce-link:hover{border-color:var(--lm-navy);color:var(--lm-navy)}
html[data-theme="light"] .announce-tag{background:#e6efed;color:#2f6e69}
html[data-theme="light"] .announce-tag.tag-scholarship{background:#f4ecda;color:#8a6a25}
html[data-theme="light"] .announce-tag.tag-thesis{background:#ebe8f5;color:#5a4f97}
html[data-theme="light"] .announce-tag.tag-general{background:#ecebe6;color:var(--lm-text-2)}

/* Slider + buttons */
html[data-theme="light"] .slider-arrow{background:var(--lm-surface);border-color:var(--lm-border);color:var(--lm-text)}
html[data-theme="light"] .btn-primary{background:var(--lm-navy);border-color:var(--lm-navy)}
html[data-theme="light"] .btn-outline{border-color:#d6d0c3;color:var(--lm-navy)}
html[data-theme="light"] .btn-outline:hover{border-color:var(--lm-navy)}

/* Footer: navy นุ่มลงเล็กน้อย */
html[data-theme="light"] .site-footer{background:#1c2f4f}
