/* ==========================================================================
   NHẤT TÂM TÂY PHƯƠNG - HỆ THỐNG GIAO DIỆN CHUẨN (DESIGN SYSTEM CSS)
   ========================================================================== */

/* --- 0. KHAI BÁO PHÔNG CHỮ TIÊU ĐỀ: BEAUTIQUE DISPLAY --- */
@font-face {
  font-family: 'Beautique Display';
  src: url('../font/BeautiqueDisplay-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Beautique Display';
  src: url('../font/BeautiqueDisplay-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Beautique Display';
  src: url('../font/BeautiqueDisplay-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
/* Bí danh cho các lớp cũ vẫn sử dụng tên FzThuPhapTieuTu */
@font-face {
  font-family: 'FzThuPhapTieuTu';
  src: url('../font/BeautiqueDisplay-Regular.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'FzThuPhapTieuTu';
  src: url('../font/BeautiqueDisplay-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --- 1. BIẾN MÀU SẮC & CẤU HÌNH GIAO DIỆN SÁNG / TỐI --- */
:root {
  --font-scale: 1;

  /* Chế độ Sáng (Giấy dó, Chu sa, Mực nho cổ kính) */
  --bg-body: #f8f4ec;
  --bg-surface: #ffffff;
  --bg-surface-alt: #f1ebd8;
  --border-color: #dfd5c2;
  --border-light: #ece3d3;
  
  --primary-accent: #8b3a2b;       /* Đỏ chu sa */
  --primary-hover: #702e22;
  --text-main: #231c16;            /* Đen mực nho */
  --text-muted: #5e5245;           /* Nâu xám */
  --text-dim: #8b7d6b;
  
  --gold-accent: #b38838;
  --shadow-sm: 0 2px 4px rgba(35, 28, 22, 0.05);
  --shadow-md: 0 4px 12px rgba(35, 28, 22, 0.08);

  --font-title: 'Beautique Display', 'Lora', Georgia, serif;
  --font-serif: "Merriweather", "Noto Serif", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Chế độ Tối (Đêm thanh tịnh, mực mờ dịu mắt) */
[data-theme="dark"] {
  --bg-body: #161514;
  --bg-surface: #201e1c;
  --bg-surface-alt: #2a2724;
  --border-color: #383430;
  --border-light: #2c2825;

  --primary-accent: #d97757;
  --primary-hover: #e68d70;
  --text-main: #ede7de;
  --text-muted: #b5aba0;
  --text-dim: #7f776e;

  --gold-accent: #cfa85b;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* --- 2. THIẾT LẬP NỀN TẢNG & CHỐNG TRÀN MÀN HÌNH --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: var(--font-serif);
  font-size: calc(1rem * var(--font-scale));
  line-height: 1.8;
  transition: background-color 0.3s ease, color 0.3s ease, font-size 0.2s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

img, svg, video, audio, iframe {
  max-width: 100%;
  height: auto;
}

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

/* --- 3. THANH ĐIỀU HƯỚNG CHÍNH (HEADER KHÔNG GÃY DÒNG) --- */
.site-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 72px;
  gap: 20px;
}

/* Logo kèm vạch phân cách đứng */
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--primary-accent);
  font-weight: 700;
  font-size: 1.25rem;
  white-space: nowrap;
  padding-right: 24px;
  border-right: 1px solid var(--border-color); /* Vạch đứng chia cách */
  flex-shrink: 0;
}

.brand-logo {
  font-size: 1.5rem;
}

.site-nav {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Giữ menu trên 1 dòng duy nhất, không rớt chữ */
.nav-list {
  display: flex;
  list-style: none;
  gap: 18px;
  margin: 0;
  padding: 0;
  white-space: nowrap;
}

.nav-list li a {
  text-decoration: none;
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 2px;
  display: inline-block;
  white-space: nowrap;
  position: relative;
  transition: color 0.2s ease;
}

.nav-list li a:hover,
.nav-list li a.active {
  color: var(--primary-accent);
}

.nav-list li a.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--primary-accent);
}

/* --- 4. CỤM NÚT CỠ CHỮ & SÁNG / TỐI --- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.font-scaler-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2px 4px;
}

.font-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border-radius: 14px;
  transition: all 0.2s ease;
}

.font-btn:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.05);
}

.font-btn.active {
  background: var(--primary-accent);
  color: #ffffff;
}

.theme-toggle-btn {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--primary-accent);
}

/* --- 5. NỘI DUNG ĐỌC VÀ KHỐI BÀI VIẾT --- */
main {
  flex: 1;
  padding: 36px 0;
}

p, .book-content, .article-content, .reading-area, .summary-text {
  font-size: calc(1.05rem * var(--font-scale));
  line-height: 1.9;
  margin-bottom: 1.25rem;
  text-align: justify;
}

/* Phông chữ cho toàn bộ tiêu đề trên trang: Beautique Display */
h1, h2, h3, h4, h5, h6,
.font-calligraphy,
.brand-title,
.site-brand,
.hero-title,
.section-title,
.cat-name,
.cat-banner-title,
.guide-banner-title,
.detail-title,
.book-cover-title,
.mission-banner h3,
.footer-col h4 {
  font-family: var(--font-title);
  color: var(--text-main);
  line-height: 1.35;
  margin-bottom: 1rem;
  letter-spacing: 0.3px;
}

h1 { font-size: calc(1.8rem * var(--font-scale)); }
h2 { font-size: calc(1.5rem * var(--font-scale)); }
h3 { font-size: calc(1.25rem * var(--font-scale)); }

blockquote, .quote-box {
  background-color: var(--bg-surface-alt);
  border-left: 4px solid var(--primary-accent);
  padding: 16px 20px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

/* --- 6. CHÂN TRANG (FOOTER) --- */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 32px 0 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: auto;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-links {
  display: flex;
  gap: 16px;
  list-style: none;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--primary-accent);
}

/* ========================================================
   NÚT BẬT/TẮT NHẠC NỀN NIỆM PHẬT (BGM TOGGLE)
   ======================================================== */
.bgm-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-alt, #f3ece2);
  border: 1px solid var(--border-color, #d5c8b5);
  color: var(--text-main);
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  margin-right: 8px;
  transition: all 0.25s ease;
  user-select: none;
}
.bgm-toggle-btn:hover {
  background: rgba(139, 58, 43, 0.1);
  border-color: var(--primary-accent, #8b3a2b);
}
.bgm-toggle-btn.active {
  background: var(--primary-accent, #8b3a2b);
  border-color: var(--primary-accent, #8b3a2b);
  color: #ffffff;
}
.bgm-toggle-btn.muted {
  opacity: 0.6;
  text-decoration: line-through;
  background: transparent;
  color: var(--text-muted);
}

/* ========================================================
   ĐIỀU HƯỚNG DI ĐỘNG & BẢO VỆ CHỐNG TRÀN MÀN HÌNH
   ======================================================== */
.sub-nav-mobile {
  display: none;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sub-nav-mobile::-webkit-scrollbar {
  display: none;
}
.sub-nav-inner {
  display: flex;
  gap: 10px;
  padding: 8px 16px;
  white-space: nowrap;
}
.sub-nav-inner a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.sub-nav-inner a.active, .sub-nav-inner a:hover {
  color: #ffffff;
  background: var(--primary-accent, #8b3a2b);
  border-color: var(--primary-accent, #8b3a2b);
}

@media (max-width: 1024px) {
  .site-nav, nav.desktop-nav, .header-divider {
    display: none !important;
  }
  .sub-nav-mobile {
    display: block;
  }
}

@media (max-width: 768px) {
  .lang-btn {
    display: none !important;
  }
  .theme-text {
    display: none !important;
  }
}

@media (max-width: 580px) {
  .bgm-toggle-btn .bgm-label {
    display: none !important;
  }
  .bgm-toggle-btn {
    padding: 4px 8px;
    margin-right: 0;
  }
  .font-scaler-group {
    padding: 2px 2px;
  }
  .font-btn {
    padding: 3px 6px;
    font-size: 0.78rem;
  }
}