
/* - ตัวแปรระบบสีระดับพรีเมียม (CSS Variables) - */
:root {
  --ph-paper: #111111;
  --ph-dim: #444444;
  --ph-gold: #b31b1b;
  --ph-serif: 'Cormorant Garamond', Georgia, serif;
  --ph-thai: 'Sarabun', sans-serif;
  /* Pure black-and-white reading theme (light) */
  --bg-primary: #ffffff;       /* Pure white background */
  --bg-secondary: #f5f5f5;     /* Subtle off-white container */
  --bg-tertiary: #ebebeb;      /* Light gray panel */
  --text-primary: #111111;     /* Near-black primary text */
  --text-secondary: #3f3f3f;   /* Dark gray body text */
  --text-tertiary: #666666;    /* Muted gray */
  --text-quaternary: #888888;
  --border-primary: rgba(0,0,0,0.10);
  --border-secondary: rgba(0,0,0,0.18);
  --accent-color: #b31b1b;     /* Brand Red */
  
  /* ตัวแปรพิเศษสำหรับคอมโพเนนต์ที่ควรเข้มเสมอ (Inverted Components) */
  --inverted-bg: #0a0c10;
  --inverted-text: #e8e0d0;
  --footer-bg: #050403;
  --footer-border: rgba(232,224,208,.14);
  
  /* ตัวแปรสำหรับเงา (Dynamic Shadows) */
  --shadow-color: rgba(0,0,0,0.08);
  --shadow-heavy: rgba(0,0,0,0.15);

  --theme-transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

/* ชุดสีดาร์กโหมดสไตล์วิชาการระดับพรีเมียมเมื่อมีคลาส .dark-mode */
html.dark-mode {
  --ph-paper: #f5f5f5;
  --ph-dim: #b8b8b8;
  --bg-primary: #000000;       /* Pure black background */
  --bg-secondary: #0d0d0d;     /* Near-black container */
  --bg-tertiary: #161616;      /* Dark gray panel */
  --text-primary: #f5f5f5;     /* Near-white primary text */
  --text-secondary: #c4c4c4;   /* Light gray body text */
  --text-tertiary: #9a9a9a;    /* Muted gray */
  --text-quaternary: #777777;
  --border-primary: rgba(255,255,255,0.12);
  --border-secondary: rgba(255,255,255,0.24);
  --accent-color: #d32f2f;     /* Brand Red (brightened for dark) */

  --inverted-bg: #0d0d0d;
  --inverted-text: #e8e0d0;
  --footer-bg: #050403;
  --footer-border: rgba(232,224,208,.14);
  
  --shadow-color: rgba(0,0,0,0.4);
  --shadow-heavy: rgba(0,0,0,0.6);
}

/* - สไตล์พื้นฐานของหน้าเว็บ - */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Sarabun', sans-serif;
  color: var(--text-primary);
  background-color: #ffffff;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: var(--theme-transition);
}
html.dark-mode body {
  background-color: #000000;
}
.article-wrap, .article-layout, .about-wrap {
  background: transparent !important;
}
a { text-decoration: none; color: inherit; transition: color 0.2s ease; }

/* - แอนิเมชันลอยขึ้น (Scroll Reveal) - */
.reveal { opacity: 0; transform: translateY(30px); transition: all 0.8s ease-out; }
.reveal.active { opacity: 1; transform: translateY(0); }

/* - วาทะปราชญ์ประจำวัน (Quote of the Day) - */
.daily-quote-wrapper { max-width: 800px; margin: 60px auto 40px; padding: 0 24px; }
.daily-quote { background: var(--bg-tertiary); border: 1px solid var(--border-primary); border-left: 4px solid var(--text-primary); padding: 32px 32px 32px 64px; text-align: center; position: relative; transition: var(--theme-transition); }
.quote-icon { font-family: 'Inter', sans-serif; font-size: 60px; color: var(--border-primary); line-height: 0; position: absolute; top: 30px; left: 20px; transition: var(--theme-transition); }
.quote-text-ar { font-family: 'Amiri', serif; font-size: 24px; color: var(--text-primary); margin-bottom: 20px; line-height: 2.4; transition: var(--theme-transition); }
.quote-text-th { font-family: 'Sarabun', sans-serif; font-size: 16px; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.8; font-style: italic; transition: var(--theme-transition); }
.quote-author { font-size: 14px; color: var(--text-tertiary); margin-top: 8px; font-weight: 500; transition: var(--theme-transition); }

/* - ส่วนแสดงแอปพลิเคชันหน้า Index - */
.index-tools-wrapper { max-width: 1100px; margin: 0 auto 60px; padding: 0 24px; }
.index-tools-header { font-size: 14px; font-weight: 600; color: var(--text-primary); border-bottom: 2px solid var(--text-primary); padding-bottom: 8px; margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; transition: var(--theme-transition); }
.view-all-tools { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; transition: color 0.2s; }
.view-all-tools:hover { color: var(--text-primary); text-decoration: none; }

.index-tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.index-tool-card { background: var(--inverted-bg); color: var(--inverted-text); border-radius: 8px; padding: 30px; display: flex; align-items: center; gap: 20px; transition: var(--theme-transition); text-decoration: none; }
.index-tool-card:hover { transform: translateY(-5px); box-shadow: 0 15px 30px var(--shadow-heavy); color: var(--inverted-text); }

.index-tool-card.coming-soon { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-primary); }
.index-tool-card.coming-soon:hover { transform: translateY(-5px); box-shadow: 0 10px 20px var(--shadow-color); color: var(--text-primary); }

.index-tool-icon { font-size: 40px; line-height: 1; }
.index-tool-info h3 { font-family: 'Sarabun', sans-serif; font-size: 20px; margin-bottom: 4px; font-weight: 700; transition: var(--theme-transition); }
.index-tool-info p { font-size: 13px; opacity: 0.8; line-height: 1.5; margin-bottom: 0; transition: var(--theme-transition); }
.index-tool-badge { display: inline-block; padding: 2px 8px; font-size: 10px; font-weight: 600; background: rgba(255,255,255,0.2); border-radius: 12px; margin-bottom: 8px; letter-spacing: 1px; transition: var(--theme-transition); }
.index-tool-card.coming-soon .index-tool-badge { background: var(--border-primary); color: var(--text-secondary); }

/* - ส่วนแสดงผลลัพธ์บทความ (Results Grid) - */
.results-container { max-width: 1100px; margin: 0 auto 80px; padding: 0 24px; }
.results-header { font-size: 14px; font-weight: 600; color: var(--text-primary); border-bottom: 2px solid var(--text-primary); padding-bottom: 8px; margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; transition: var(--theme-transition); }

.article-list { display: flex; flex-direction: column; gap: 24px; }
.article-item { border: 1px solid transparent; border-bottom: 1px solid var(--border-primary); padding: 24px; display: flex; flex-direction: column; gap: 8px; border-radius: 8px; transition: var(--theme-transition); position: relative; }
.article-item:hover { border-color: var(--border-secondary); box-shadow: 0 10px 30px var(--shadow-color); transform: translateY(-3px); background: var(--bg-secondary); border-bottom-color: transparent; }
.article-item:last-child { border-bottom: 1px solid transparent; }

.item-cat { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-secondary); transition: var(--theme-transition); }
.item-title { font-family: 'Sarabun', sans-serif; font-size: 24px; font-weight: 700; color: var(--text-primary); line-height: 1.4; transition: color 0.2s; }
.item-title:hover { color: var(--text-secondary); text-decoration: none; }
.item-excerpt { font-size: 15px; color: var(--text-tertiary); line-height: 1.6; transition: var(--theme-transition); }
.item-meta { font-size: 12px; color: var(--text-quaternary); display: flex; justify-content: space-between; align-items: center; transition: var(--theme-transition); }
.read-more-link { font-size: 13px; font-weight: 600; color: var(--text-primary); opacity: 0; transform: translateX(-10px); transition: all 0.3s ease; }
.article-item:hover .read-more-link { opacity: 1; transform: translateX(0); }
.article-link { text-decoration: none; color: inherit; display: block; }

/* ========================================== */
/* CSS สำหรับเมนูและ Footer ที่จะถูกดึงเข้ามา */
/* ========================================== */
.topbar { background: var(--inverted-bg); color: var(--inverted-text); text-align: center; font-size: 11px; letter-spacing: 2px; padding: 8px; font-family: 'Inter', sans-serif; text-transform: uppercase; transition: var(--theme-transition); }
header { padding: 28px 0 0; border-bottom: 2px solid var(--text-primary); position: relative; z-index: 1000; background: var(--bg-primary); transition: var(--theme-transition); }
.header-inner { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--border-primary); transition: var(--theme-transition); }

.date-line { font-size: 14px; color: var(--text-secondary); font-family: 'Sarabun', sans-serif; font-weight: 500; letter-spacing: 0.5px; width: 180px; transition: var(--theme-transition); }
.logo-block { text-align: center; flex: 1; }
.logo-en { font-family: 'Inter', sans-serif; font-size: 38px; font-weight: 300; text-transform: uppercase; letter-spacing: 1px; line-height: 1; color: inherit; }
.logo-ar { font-family: 'Amiri', serif; font-size: 18px; color: var(--text-secondary); direction: rtl; margin-top: 6px; line-height: 1.8; transition: var(--theme-transition); }
.header-right { width: 160px; display: flex; justify-content: flex-end; align-items: center; }
.spacer { width: 100%; }

.menu-toggle { display: none !important; } 

nav { display: flex; justify-content: center; margin-top: 12px; transition: var(--theme-transition); }
.nav-item { font-size: 13px; font-weight: 500; padding: 10px 20px; color: var(--text-secondary); border-right: 1px solid var(--border-primary); cursor: pointer; transition: var(--theme-transition); }
.nav-item:first-child { border-left: 1px solid var(--border-primary); }
.nav-item:hover { color: var(--text-primary); }
.nav-item.active { color: var(--text-primary); border-bottom: 2px solid var(--text-primary); }

footer { background: var(--footer-bg); color: var(--inverted-text); padding: 40px 0 24px; border-top: 1px solid var(--footer-border); transition: var(--theme-transition); }
.footer-inner { max-width: 1100px; margin: 0 auto; padding: 0 24px; text-align: center; }
.footer-logo { font-family: 'Inter', sans-serif; font-size: 28px; font-weight: 300; text-transform: uppercase; margin-bottom: 6px; letter-spacing: 1px; color: var(--inverted-text); transition: var(--theme-transition); }
.footer-ar { font-family: 'Amiri', serif; font-size: 17px; color: var(--text-quaternary); direction: rtl; margin-bottom: 28px; line-height: 2.0; transition: var(--theme-transition); }
.footer-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 24px; margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--footer-border); transition: var(--theme-transition); }
.footer-links a { font-size: 13px; color: #bbbbbb; letter-spacing: .5px; transition: var(--theme-transition); text-decoration: none; }
.footer-links a:hover { color: var(--inverted-text); }
.footer-copy { font-family: 'Inter', sans-serif; font-size: 14px; color: #888888; font-style: normal; letter-spacing: 0.5px; transition: var(--theme-transition); }

/* --- Back to Top Button --- */
#backToTopBtn { display: none; position: fixed; bottom: 24px; right: 24px; z-index: 999; padding: 12px; border: 1px solid var(--border-primary); background: var(--bg-primary); color: var(--text-primary); border-radius: 4px; box-shadow: 0 5px 15px var(--shadow-color); cursor: pointer; transition: var(--theme-transition); }
#backToTopBtn:hover { background: var(--text-primary); color: var(--bg-primary); border-color: var(--text-primary); }

/* โหมดมือถือ */
@media(max-width:768px){
  .logo-en { font-family: 'Inter', sans-serif; font-size: 38px; font-weight: 300; text-transform: uppercase; letter-spacing: 1px; line-height: 1; color: inherit; }
  .logo-ar { font-size: 14px; }
  .date-line { display: none; } 
  .header-right { width: auto; }
  .spacer { display: none; }
  
  .menu-toggle { display: block !important; font-size: 28px; cursor: pointer; color: var(--text-primary); user-select: none; transition: var(--theme-transition); } 
  
  nav { 
    display: none; 
    flex-direction: column; 
    position: absolute; 
    top: 100%; 
    left: 0; 
    width: 100%; 
    background: var(--bg-primary); 
    box-shadow: 0 10px 20px var(--shadow-color); 
    margin-top: 0;
    padding: 10px 0;
    border-bottom: 2px solid var(--text-primary);
    transition: var(--theme-transition);
  }
  nav.mobile-active { display: flex; } 
  .nav-item { border: none !important; border-bottom: 1px solid var(--border-secondary) !important; padding: 16px 24px; font-size: 16px; text-align: left; }
  .nav-item:last-child { border-bottom: none !important; }
  .nav-item.active { background: var(--bg-secondary); border-bottom: 1px solid var(--border-secondary) !important; border-left: 4px solid var(--text-primary) !important; }
  
  .quote-text-ar { font-size: 20px; }
  .daily-quote { padding: 24px; }
  .quote-icon { position: static; display: block; margin-bottom: 10px; }
  .article-item { padding: 16px 0; }
  .article-item:hover { box-shadow: none; transform: none; background: transparent; border-bottom: 1px solid var(--border-primary); }
  .read-more-link { display: none; } 
}


/* ==========================================
   ARTICLE LAYOUT & TYPOGRAPHY
   ========================================== */

/* Typography & Layout Reset */
.article-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: flex;
  align-items: flex-start;
  gap: 40px;
  position: relative;
}

.article-content {
  flex: 1;
  min-width: 0;
}

.article-header {
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border-primary);
  padding-bottom: 32px;
}

.article-category {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-color);
  font-weight: 600;
  margin-bottom: 12px;
  display: inline-block;
}

.article-main-title {
  font-family: 'Sarabun', sans-serif;
  font-size: 42px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.article-meta-info {
  font-size: 14px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.meta-divider {
  color: var(--border-primary);
}

/* Article Body Typography */
.article-body {
  font-size: 18px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.article-body p {
  margin-bottom: 24px;
}

.article-body .lead-text {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 32px;
}

.article-body h2 {
  font-family: 'Sarabun', sans-serif;
  font-size: 28px;
  color: var(--text-primary);
  margin: 48px 0 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-secondary);
  scroll-margin-top: 100px; /* Offset for fixed headers if any */
}

.article-body h3 {
  font-family: 'Sarabun', sans-serif;
  font-size: 22px;
  color: var(--text-primary);
  margin: 32px 0 16px;
  scroll-margin-top: 100px;
}

.article-body code {
  font-family: monospace;
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--text-primary);
}

.arabic-quote {
  font-family: 'Amiri', serif;
  font-size: 28px;
  line-height: 2.4;
  text-align: right;
  direction: rtl;
  color: var(--text-primary);
  padding: 24px 32px;
  margin: 32px 0;
  background: var(--bg-secondary);
  border-right: 4px solid var(--accent-color);
  border-radius: 8px 0 0 8px;
}

.thai-quote {
  font-style: italic;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: -16px;
  margin-bottom: 32px;
  font-size: 16px;
}

/* ==========================================
   1. READING PROGRESS BAR
   ========================================== */
#readingProgressBar {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  background: var(--accent-color);
  width: 0%;
  z-index: 9999;
  transition: width 0.1s ease;
}

/* ==========================================
   2. INTERACTIVE TABLE OF CONTENTS (TOC)
   ========================================== */
.article-sidebar {
  width: 300px;
  flex-shrink: 0;
}

.toc-container {
  position: sticky;
  top: 100px;
  background: var(--bg-secondary);
  padding: 24px;
  border-radius: 8px;
  border: 1px solid var(--border-primary);
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.toc-title {
  font-family: 'Sarabun', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toc-link {
  font-size: 14px;
  color: var(--text-tertiary);
  text-decoration: none;
  line-height: 1.4;
  transition: color 0.2s ease, transform 0.2s ease;
  position: relative;
  padding-left: 12px;
}

.toc-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border-primary);
  transition: background 0.2s ease;
}

.toc-link:hover {
  color: var(--text-primary);
}

.toc-link.toc-active {
  color: var(--accent-color);
  font-weight: 600;
  transform: translateX(4px);
}

.toc-link.toc-active::before {
  background: var(--accent-color);
}

/* Identation for h3 vs h2 in TOC */
.toc-link.toc-h3 {
  padding-left: 24px;
  font-size: 13.5px;
}
.toc-link.toc-h3::before {
  left: 12px;
}

/* ==========================================
   3. SOCIAL SHARE BUTTONS
   ========================================== */
.social-share-container {
  margin-top: 64px;
  padding: 40px 24px;
  background: transparent;
  border-top: 1px solid var(--border-primary);
  border-bottom: 1px solid var(--border-primary);
  border-radius: 0;
  text-align: center;
}

.share-title {
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.share-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
  transition: transform 0.2s ease, opacity 0.2s ease;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.share-btn:hover {
  transform: translateY(-3px);
  opacity: 0.9;
}

.btn-facebook { background: #1877F2; }
.btn-twitter { background: #000000; }
html.dark-mode .btn-twitter { background: #ffffff; color: #000000; } /* For X logo */
.btn-line { background: #06C755; }
.btn-copy { background: var(--text-tertiary); }

.copy-alert {
  display: none;
  font-size: 14px;
  color: var(--accent-color);
  margin-top: 12px;
  font-weight: 500;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   4. RELATED ARTICLES
   ========================================== */
.related-articles-section {
  background: var(--bg-secondary);
  padding: 64px 0;
  border-top: 1px solid var(--border-primary);
}

.related-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

.related-title {
  font-family: 'Sarabun', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 32px;
  text-align: center;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.related-card {
  display: block;
  background: var(--bg-primary);
  padding: 24px;
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  text-decoration: none;
  transition: var(--theme-transition);
  box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

html.dark-mode .related-card {
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.related-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-color);
  box-shadow: 0 10px 20px var(--shadow-color);
}

.related-cat {
  font-size: 12px;
  color: var(--accent-color);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 12px;
  display: block;
}

.related-article-title {
  font-family: 'Sarabun', sans-serif;
  font-size: 18px;
  color: var(--text-primary);
  line-height: 1.5;
  transition: color 0.2s ease;
}

.related-card:hover .related-article-title {
  color: var(--accent-color);
}

/* ==========================================
   MOBILE RESPONSIVENESS
   ========================================== */
@media (max-width: 1024px) {
  .article-sidebar {
    width: 240px;
  }
}

@media (max-width: 768px) {
  .article-layout {
    flex-direction: column;
  }
  
  .article-sidebar {
    width: 100%;
    order: -1; /* Puts TOC above the article on mobile */
  }

  .toc-container {
    position: relative;
    top: 0;
    max-height: none;
    margin-bottom: 24px;
  }
  
  .article-main-title {
    font-size: 32px;
  }
}

/* ==========================================
   5. READING TOOLS & CITATIONS (Global Article Styles)
   ========================================== */
.reading-tools {
  display: inline-flex;
  gap: 16px;
  background: var(--bg-tertiary);
  padding: 8px 16px;
  border-radius: 6px;
  margin-bottom: 32px;
  border: 1px solid var(--border-primary);
}
.tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tool-label {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
}
.btn-tool {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: var(--theme-transition);
}
.btn-tool:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.citation-box {
  background: var(--bg-tertiary);
  padding: 24px 32px;
  border-radius: 4px;
  border: none;
  border-left: 4px solid var(--accent-color);
  margin-top: 40px;
  position: relative;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.citation-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  word-break: break-all;
}
.copy-btn {
  background: var(--accent-color);
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.copy-btn:hover {
  opacity: 0.9;
}

.references { margin-top: 60px; }
.ref-title { font-size: 24px !important; border-bottom: none !important; margin-bottom: 16px !important; }
.ref-list { list-style: none; padding: 0; }
.ref-list li { margin-bottom: 12px; font-size: 16px; color: var(--text-secondary); }


.en-text { font-family: 'Inter', sans-serif; }



/* ==========================================
   LEGACY ARTICLE COMPATIBILITY (BUG FIX)
   ========================================== */
.article-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  background: var(--bg-primary);
}

h1.article-title {
  font-family: 'Sarabun', sans-serif;
  font-size: 42px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
  line-height: 1.3;
}


/* Additional Legacy Classes for articles */
.article-cat {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    font-weight: 600;
    margin-bottom: 12px;
    display: inline-block;
    text-decoration: none;
}
.article-cat:hover {
    color: var(--text-primary);
}

.article-meta {
    font-size: 14px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-primary);
    padding-bottom: 24px;
}
.article-meta span {
    color: var(--text-primary);
    font-weight: 500;
}


/* ==========================================
   REFINEMENTS FOR RELATED ARTICLES (UI FIX)
   ========================================== */
.related-grid {
    gap: 32px !important;
}

.related-card {
    border-radius: 12px !important;
    padding: 24px 20px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04) !important;
    border: 1px solid var(--border-secondary) !important;
    transition: all 0.3s ease !important;
    display: flex;
    flex-direction: column;
}

.related-card:hover {
    transform: translateY(-5px) !important;
    box-shadow: 0 12px 24px rgba(0,0,0,0.08) !important;
    border-color: var(--accent-color) !important;
}

/* Fix for legacy HTML using .related-title inside cards */
.related-card .related-title {
    font-family: 'Sarabun', sans-serif !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    color: var(--text-primary) !important;
    line-height: 1.5 !important;
    display: block !important;
    margin: 8px 0 12px !important;
    transition: color 0.2s ease !important;
}

.related-card:hover .related-title {
    color: var(--accent-color) !important;
}

/* ==========================================
   SPACING & TYPOGRAPHY UTILITIES (Rule 30)
   ========================================== */
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.ml-16 { margin-left: 16px; }
.ml-20 { margin-left: 20px; }
.ml-24 { margin-left: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-24 { margin-bottom: 24px; }
.fs-15 { font-size: 15px; }
.text-center { text-align: center; }
.italic { font-style: italic; }
.editorial-note { font-size: 13px; color: #666; line-height: 1.6; margin-bottom: 16px; }

/* Numbered section layout (concept-of-jism) */
.numbered-section { display: flex; gap: 20px; padding: 20px; border-left: 4px solid var(--accent-color); margin-bottom: 16px; background: var(--bg-secondary); }
.numbered-section-dark { border-left-color: #0a0a0a; }
html.dark-mode .numbered-section-dark { border-left-color: var(--text-primary); }
.numbered-section .num { font-family: 'Inter', sans-serif; font-size: 36px; font-weight: 700; color: var(--text-tertiary); line-height: 1; min-width: 44px; flex-shrink: 0; }

/* Article comparison tables (Rule 30) */
.article-table { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 14px; text-align: left; }
.article-table th, .article-table td { padding: 12px; border: 1px solid #ddd; }
.article-table thead tr { background-color: var(--inverted-bg); color: var(--inverted-text); }
.alt-row { background-color: #f9f9f9; }
html.dark-mode .alt-row { background-color: var(--bg-secondary); }
.col-5  { width: 5%; }
.col-25 { width: 25%; }
.col-30 { width: 30%; }
.col-35 { width: 35%; }
.cell-bold { font-weight: 500; }
.cell-center { text-align: center; }
.cell-section-header { font-weight: 500; vertical-align: top; background-color: #fafafa; }
.cell-section-alt { font-weight: 500; vertical-align: top; background-color: #f5f5f5; }
html.dark-mode .cell-section-header,
html.dark-mode .cell-section-alt { background-color: var(--bg-secondary); }

/* Disabled tool button state (tools.html) */
.btn-disabled { pointer-events: none; background: #ccc; color: #fff; }

/* Click Ripple Effect for Site-wide interactivity */
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(5, 114, 244, 0.15); /* Sleek high-tech blue ripple */
  transform: scale(0);
  animation: ripple-animation 0.65s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
  pointer-events: none;
  z-index: 10;
}
@keyframes ripple-animation {
  to {
    transform: scale(2.5);
    opacity: 0;
  }
}

/* ==========================================================
   Article Data Tables
   ========================================================== */
.article-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
  text-align: left;
}
.article-table th,
.article-table td {
  padding: 12px;
  border: 1px solid #ddd;
}
.article-table thead tr {
  background-color: #0a0a0a;
  color: #fff;
}
.article-table .alt-row { background-color: #f9f9f9; }
.article-table .cell-center { text-align: center; }
.article-table .cell-bold { font-weight: 500; }
.article-table .cell-category {
  font-weight: 500;
  vertical-align: top;
  background-color: #fafafa;
}
.article-table .cell-category-alt {
  font-weight: 500;
  vertical-align: top;
  background-color: #f5f5f5;
}

/* ==========================================================
   Article Utility Spacing & Text Classes
   ========================================================== */
.p-top-sm  { margin-top: 16px; }
.p-top-md  { margin-top: 24px; }
.p-bottom-xs { margin-bottom: 6px; }
.p-bottom-sm { margin-bottom: 8px; }
.p-indent  { margin-left: 16px; }
.p-indent-md { margin-left: 24px; }
.p-indent-bottom     { margin-left: 16px; margin-bottom: 24px; }
.p-indent-md-bottom  { margin-left: 24px; margin-bottom: 24px; }
.p-indent-top        { margin-left: 16px; margin-top: 12px; }
.p-indent-top-bottom { margin-left: 16px; margin-top: 12px; margin-bottom: 24px; }
.p-list-step  { margin-left: 20px; font-size: 15px; }
.p-caption    { font-size: 13px; color: #666; line-height: 1.6; margin-bottom: 16px; }
.li-spaced-xs { margin-bottom: 6px; }
.li-spaced-sm { margin-bottom: 8px; }
.li-spaced    { margin-bottom: 12px; }
.li-spaced-md { margin-bottom: 10px; }
.text-center  { text-align: center; }
.font-italic  { font-style: italic; }

/* .numbered-section dark-border variant */
.numbered-section.ns-dark { border-left-color: #0a0a0a; }

/* Table column width helpers */
.col-5  { width: 5%; }
.col-25 { width: 25%; }
.col-30 { width: 30%; }
.col-35 { width: 35%; }


/* ==========================================================
   ⭐️ THE LIBRARY HERO BANNER (SUBPAGES & ARTICLES) ⭐️
   ========================================================== */
.hero-banner {
  position: relative;
  min-height: 420px;
  padding: 120px 24px 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background-color: #05060a; /* Premium dark ink */
  color: #e8e0d0; /* Warm ivory text */
  overflow: hidden;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  transition: var(--theme-transition);
}
.hero-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 320'><path fill='%23d32f2f' fill-opacity='1' d='M0,192L48,202.7C96,213,192,235,288,234.7C384,235,480,213,576,192C672,171,768,149,864,160C960,171,1056,213,1152,229.3C1248,245,1344,235,1392,229.3L1440,224L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z'></path></svg>");
  background-size: cover;
  background-position: bottom;
  z-index: 1;
}
.hero-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: 
    radial-gradient(50% 50% at 70% 20%, rgba(211,47,47,0.08), transparent 60%),
    radial-gradient(70% 60% at 20% 80%, rgba(211,47,47,0.04), transparent 70%);
  z-index: 0;
}
.hero-banner-inner {
  position: relative;
  z-index: 2;
  max-width: 800px;
  width: 100%;
}
.hero-banner .hero-arabic {
  font-family: 'Amiri', serif;
  font-weight: 400;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.4;
  color: #e8e0d0;
  direction: rtl;
  margin-bottom: 12px;
  text-shadow: 0 0 40px rgba(179,27,27,0.15);
}
.hero-banner .hero-arabic-ref {
  font-family: 'Sarabun', sans-serif;
  font-size: 13px;
  color: rgba(232, 224, 208, 0.65);
  margin-bottom: 24px;
}
.hero-banner .hero-divider {
  width: 60px;
  height: 1px;
  background: rgba(211,47,47,0.4);
  margin: 0 auto 32px;
}
.hero-banner .hero-display {
  font-family: 'Cormorant Garamond', 'EB Garamond', Georgia, serif;
  font-weight: 300;
  font-size: clamp(36px, 5.5vw, 64px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: #e8e0d0;
  margin-bottom: 20px;
}
.hero-banner .hero-display em {
  font-style: italic;
  color: #d32f2f;
  font-weight: 400;
}
.hero-banner .hero-sub {
  font-family: 'Sarabun', sans-serif;
  font-weight: 300;
  font-size: 15px;
  line-height: 1.8;
  color: rgba(240, 236, 228, 0.75);
  max-width: 680px;
  margin: 0 auto;
}

/* Specific styling for article header in banner */
.article-hero-banner {
  min-height: 380px;
  padding: 100px 24px 60px;
}
.article-hero-banner .article-category {
  font-family: 'Sarabun', sans-serif;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #d32f2f;
  font-weight: 600;
  margin-bottom: 12px;
  display: inline-block;
}
.article-hero-banner .article-main-title {
  margin-bottom: 16px;
}
.article-hero-banner .article-meta-info {
  font-family: 'Sarabun', sans-serif;
  font-size: 13px;
  color: rgba(232, 224, 208, 0.65);
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.article-hero-banner .article-meta-info strong {
  color: #e8e0d0;
}
.article-hero-banner .meta-divider {
  color: rgba(232, 224, 208, 0.3);
}

/* Custom Grid Height for Homepage Tools */
.tools-cat-grid {
  grid-auto-rows: 480px !important;
}
@media(max-width:980px){
  .tools-cat-grid {
    grid-auto-rows: 260px !important;
  }
}
@media(max-width:600px){
  .tools-cat-grid {
    grid-auto-rows: 200px !important;
  }
}

/* ─── ARTICLE CATEGORY HERO ──────────────────────────────────────── */
.art-hero {
  min-height: 32vh;
  padding: 80px 0 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.art-hero-inner {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 2;
}
.art-hero-display {
  font-family: var(--ph-serif);
  font-weight: 600;
  font-size: clamp(40px, 9vw, 96px);
  line-height: 1.05;
  letter-spacing: -.02em;
  color: var(--ph-paper, #111111);
}
.art-hero-display em {
  font-style: italic;
  color: var(--ph-gold);
  font-weight: 400;
}
.art-hero-br { display: block; }
.art-hero-meteors {
  position: relative;
  width: 120px;
  height: 64px;
  margin: 20px auto 0;
  overflow: hidden;
}
.art-hero-meteors .meteor {
  position: absolute;
  width: 1px;
  background: linear-gradient(to bottom, transparent 0%, var(--ph-gold) 55%, transparent 100%);
  opacity: 0;
  animation: art-meteor-drop var(--dur) var(--delay) ease-in infinite;
}
@keyframes art-meteor-drop {
  0%   { transform: translateY(-36px); opacity: 0; }
  12%  { opacity: 1; }
  80%  { opacity: .7; }
  100% { transform: translateY(90px); opacity: 0; }
}
.art-hero-meteors .meteor:nth-child(1) { left: 52px; height: 28px; --dur: 1.1s; --delay: 0s; }
.art-hero-meteors .meteor:nth-child(2) { left: 60px; height: 18px; --dur: 1.4s; --delay: .45s; }
.art-hero-meteors .meteor:nth-child(3) { left: 44px; height: 22px; --dur: 1.7s; --delay: .9s; }
.art-hero-meteors .meteor:nth-child(4) { left: 68px; height: 14px; --dur: 1.3s; --delay: 1.4s; }
.art-hero-meteors .meteor:nth-child(5) { left: 36px; height: 16px; --dur: 1.9s; --delay: .25s; }
.art-hero-sep {
  height: 1px;
  background: var(--border-primary);
  max-width: 900px;
  margin: 0 auto 32px;
}
@media (max-width: 640px) {
  .art-hero { min-height: 12vh; padding: 24px 0 16px; }
  .art-hero-display { font-size: clamp(36px, 9vw, 72px); }
}
@media (prefers-reduced-motion: reduce) {
  .art-hero-meteors .meteor { animation: none; }
}


