@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600;8..60,700&family=Source+Sans+3:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --color-bg: #f4f7fb;
  --color-surface: #ffffff;
  --color-text: #1e293b;
  --color-text-soft: #475569;
  --color-text-light: #94a3b8;

  --color-primary: #0f3b5e;
  --color-primary-light: #2a5f8a;
  --color-primary-soft: #e2edf7;
  --color-primary-dark: #072338;
  --color-secondary: #b9733b;
  --color-secondary-soft: #fcf1e7;
  --color-accent: #1f8a70;
  --color-accent-soft: #e3f4ef;

  --color-border: #dce2ec;
  --color-border-light: #eef2f6;
  --color-shadow: rgba(15, 59, 94, 0.08);
  --color-shadow-hover: rgba(15, 59, 94, 0.15);

  --font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-body: 'Source Sans 3', 'Inter', -apple-system, Segoe UI, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;

  --container-width: 780px;
  --container-wide: 960px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow-card: 0 4px 12px var(--color-shadow);
  --shadow-hover: 0 12px 32px var(--color-shadow-hover);
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.75;
  font-size: 17px;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
  transition: all 0.25s ease;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--color-border-light);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--color-primary-light);
  border-radius: 10px;
  border: 2px solid var(--color-border-light);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 28px;
}
.wide {
  max-width: var(--container-wide);
}

/* ===== THANH TIẾN TRÌNH ===== */
.mobile-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--color-border-light);
  z-index: 1100;
}
.mobile-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary-light), var(--color-secondary));
  transition: width 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== TOP NAV ===== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 1050;
  background: rgba(7, 35, 56, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  color: #e2e8f0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.topnav .brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: -0.01em;
}
.topnav .brand em {
  font-style: normal;
  color: #d4c09b;
  font-weight: 400;
}
.menu-toggle {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  padding: 8px 18px;
  border-radius: 40px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-transform: uppercase;
}
.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
  transform: scale(1.02);
}

/* ===== MENU MOBILE ===== */
.chapter-menu {
  position: fixed;
  inset: 0 0 auto 0;
  top: 64px;
  background: rgba(7, 35, 56, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1040;
  display: none;
  flex-direction: column;
  padding: 12px 28px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.chapter-menu.open {
  display: flex;
}
.chapter-menu a {
  color: #cbd5e1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}
.chapter-menu a:last-child {
  border-bottom: none;
}
.chapter-menu a:hover {
  color: #fff;
  padding-left: 12px;
  background: rgba(255, 255, 255, 0.04);
}

/* ===== RAIL DESKTOP (ĐÃ TẮT MẶC ĐỊNH) ===== */
.rail {
  display: none;
}

/* ===== HERO ===== */
.hero {
  background: linear-gradient(145deg, #072338 0%, #13436a 100%);
  color: #f1f5f9;
  padding: 100px 24px 40px;
  position: relative;
  overflow: hidden;
  border-bottom: 4px solid var(--color-secondary);
}
.hero::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(185, 115, 59, 0.12) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.hero-inner {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 48px;
  position: relative;
  z-index: 2;
}
.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #a0b8cc;
  margin-bottom: 24px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 18px;
  border-radius: 40px;
  backdrop-filter: blur(4px);
  background: rgba(255, 255, 255, 0.03);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  line-height: 1.15;
  margin-bottom: 24px;
  max-width: 660px;
  letter-spacing: -0.01em;
}
.hero h1 .highlight {
  color: #f6d9b1;
  font-style: normal;
  font-weight: 700;
  background: linear-gradient(120deg, #f6d9b1 0%, #e4b87a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  border-bottom: 3px solid rgba(246, 217, 177, 0.3);
}
.hero p.lede {
  font-size: 1.12rem;
  color: #cbdde8;
  max-width: 580px;
  margin-bottom: 36px;
  line-height: 1.8;
  opacity: 0.9;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 36px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #94b0c7;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 24px;
  letter-spacing: 0.02em;
}
.hero-meta strong {
  color: #ffffff;
  font-weight: 600;
}

/* ===== SECTIONS ===== */
section.chapter {
  padding: 72px 0 56px;
  background: var(--color-surface);
  transition: background 0.3s ease;
  position: relative;
}
section.chapter.deep {
  background: var(--color-bg);
  border-top: 1px solid var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
}

/* ===== EYEBROW & TITLE ===== */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-primary-light);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--color-border-light);
}
.eyebrow .ghost-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #fff;
  background: var(--color-primary);
  font-weight: 700;
  line-height: 1;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
}

h2.title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.8rem, 3.2vw, 2.3rem);
  color: var(--color-primary-dark);
  margin-bottom: 16px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  border-left: 6px solid var(--color-secondary);
  padding-left: 20px;
}

.lede {
  font-size: 1.1rem;
  color: var(--color-text-soft);
  max-width: 680px;
  margin-bottom: 28px;
  line-height: 1.8;
}

h3.sub {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--color-primary-dark);
  margin: 48px 0 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border-light);
}
h3.sub .chip {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
  border-radius: 40px;
  padding: 3px 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

h4.micro {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-primary-dark);
  margin: 28px 0 6px;
  display: inline-block;
  border-bottom: 2px solid var(--color-secondary-soft);
  padding-bottom: 2px;
}

p {
  color: var(--color-text);
}
p + p {
  margin-top: 16px;
}
.prose {
  max-width: 680px;
}
.prose strong {
  color: var(--color-primary-dark);
  font-weight: 700;
}

/* ===== STAT ROW ===== */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  margin: 32px 0 28px;
  background: var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.stat {
  border-left: 4px solid var(--color-primary);
  padding: 18px 20px;
  background: var(--color-surface);
  transition: all 0.25s ease;
}
.stat:hover {
  background: var(--color-primary-soft);
  transform: translateY(-2px);
}
.stat .num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.8rem;
  color: var(--color-primary-dark);
  display: block;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat .cap {
  font-size: 0.82rem;
  color: var(--color-text-soft);
  margin-top: 6px;
  display: block;
}

/* ===== CALLOUT ===== */
blockquote.callout {
  border-left: 6px solid var(--color-secondary);
  background: var(--color-secondary-soft);
  padding: 20px 28px;
  margin: 32px 0;
  max-width: 680px;
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow-card);
  transition: all 0.3s ease;
}
blockquote.callout:hover {
  box-shadow: var(--shadow-hover);
  transform: translateX(4px);
}
blockquote.callout.warn {
  border-left-color: var(--color-accent);
  background: var(--color-accent-soft);
}
blockquote.callout p {
  font-size: 0.98rem;
  color: var(--color-text);
}
blockquote.callout .callout-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-secondary);
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}
blockquote.callout.warn .callout-label {
  color: var(--color-accent);
}

/* ===== COMPARE ===== */
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 32px 0;
  max-width: 720px;
  box-shadow: var(--shadow-card);
}
.compare-item {
  background: var(--color-surface);
  padding: 24px 28px;
  transition: all 0.3s ease;
}
.compare-item:hover {
  background: var(--color-bg);
}
.compare-item h4 {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--color-primary-dark);
  font-size: 1rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.compare-item p {
  font-size: 0.94rem;
  color: var(--color-text-soft);
}

/* ===== CARD GRID ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin: 28px 0;
}

.card {
  background: var(--color-surface);
  padding: 28px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--color-primary);
  transition: width 0.3s ease;
}
.card:hover::before {
  width: 6px;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  background: #ffffff;
  z-index: 2;
}

.card h4 {
  font-weight: 700;
  color: var(--color-primary-dark);
  font-size: 1.05rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.card h4 .tag-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: #ffffff;
  background: var(--color-primary);
  padding: 4px 12px;
  border-radius: 40px;
  display: inline-block;
  min-width: 56px;
  text-align: center;
  line-height: 1.4;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(15, 59, 94, 0.2);
}

.card p {
  font-size: 0.94rem;
  color: var(--color-text-soft);
  margin: 0;
  line-height: 1.7;
}

/* ===== FIGURES - ĐÃ SỬA HIỆU ỨNG HOVER GIỐNG CARD ===== */
.figure {
  margin: 36px 0;
  max-width: 680px;
}
.figure.wide {
  max-width: 100%;
}
.figure-frame {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.figure-frame:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px); /* Nổi lên như card */
  border-color: var(--color-primary-light); /* Viền đổi màu sáng */
}
.figure-frame img {
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  display: block;
  width: 100%;
  height: auto;
}
.figure-frame:hover img {
  transform: scale(1.04); /* Phóng nhẹ ảnh bên trong */
}
.figure-placeholder {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 220px;
  padding: 36px 20px;
  background: var(--color-bg);
  border: 2px dashed var(--color-border);
  color: var(--color-text-soft);
  text-align: center;
}
.figure-frame.is-empty .figure-placeholder {
  display: flex;
}
.figure-frame.is-empty img {
  display: none;
}
.figure-placeholder .ph-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--color-text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-light);
}
.figure-placeholder .ph-text {
  font-size: 0.9rem;
  max-width: 360px;
}
.figure-placeholder code {
  font-family: var(--font-mono);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 2px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--color-text);
}

figcaption {
  font-size: 0.88rem;
  color: var(--color-text-soft);
  margin-top: 12px;
  padding-left: 4px;
  line-height: 1.6;
  font-style: italic;
}
figcaption strong {
  color: var(--color-primary-dark);
  font-family: var(--font-body);
  font-weight: 700;
  font-style: normal;
}

.figure-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  max-width: 100%;
}

/* ===== CHART ===== */
.chart-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px 24px 20px;
  margin: 32px 0;
  box-shadow: var(--shadow-card);
  transition: all 0.3s ease;
}
.chart-wrap:hover {
  box-shadow: var(--shadow-hover);
}
.chart-wrap h4 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-soft);
  margin-bottom: 16px;
  font-weight: 700;
}
.chart-wrap .chart-caption {
  font-size: 0.84rem;
  color: var(--color-text-soft);
  margin-top: 14px;
  font-style: italic;
}
canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-height: 300px;
  background: transparent;
}

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin: 24px 0;
  box-shadow: var(--shadow-card);
  transition: all 0.3s ease;
}
.table-wrap:hover {
  box-shadow: var(--shadow-hover);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 480px;
}
th,
td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid var(--color-border-light);
}
th {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--color-border);
}
tr:last-child td {
  border-bottom: none;
}
tbody tr {
  transition: background 0.2s ease;
}
tbody tr:hover {
  background: var(--color-primary-soft);
}
tbody tr:nth-child(even) {
  background: var(--color-bg);
}
tbody tr:nth-child(even):hover {
  background: var(--color-primary-soft);
}

/* ===== FOOTER ===== */
footer {
  background: var(--color-primary-dark);
  color: #b6c8d9;
  padding: 48px 24px 32px;
  margin-top: 0;
  border-top: 4px solid var(--color-secondary);
}
footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
footer .brand {
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: 1.2rem;
  letter-spacing: 0;
}
footer .brand em {
  font-style: normal;
  color: #d4c09b;
  font-weight: 400;
}
.footer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 32px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #94aec7;
}
.team-list {
  font-size: 0.9rem;
  max-width: 760px;
  line-height: 2;
  color: #dee7ef;
  background: rgba(255, 255, 255, 0.04);
  padding: 14px 24px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
}
footer small {
  opacity: 0.5;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 720px) {
  .hero {
    padding: 64px 16px 0;
  }
  .compare {
    grid-template-columns: 1fr;
  }
  .figure-pair {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  section.chapter {
    padding: 48px 0 32px;
  }
  .stat-row {
    grid-template-columns: 1fr;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
  .hero-meta {
    gap: 6px 16px;
    font-size: 0.65rem;
  }
  .topnav {
    padding: 10px 16px;
  }
  .container {
    padding: 0 16px;
  }
  h2.title {
    border-left-width: 4px;
    padding-left: 14px;
  }
}

/* ===== UTILITY ===== */
.mt-8 {
  margin-top: 8px;
}
.mt-16 {
  margin-top: 16px;
}
.mt-24 {
  margin-top: 24px;
}
.mt-40 {
  margin-top: 40px;
}

/* ===== FADE-IN ANIMATION ===== */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}
.delay-1 {
  transition-delay: 0.08s;
}
.delay-2 {
  transition-delay: 0.16s;
}
.delay-3 {
  transition-delay: 0.24s;
}
.delay-4 {
  transition-delay: 0.32s;
}

/* ===== MÀU SẮC THEO CHƯƠNG ===== */
#gioi-thieu {
  --color-primary: #0f3b5e;
  --color-primary-soft: #e2edf7;
}
#nguyen-nhan {
  --color-primary: #1a5a7a;
  --color-primary-soft: #e3eef5;
}
#tac-dong {
  --color-primary: #9e4a3a;
  --color-primary-soft: #f6ece9;
}
#ung-pho {
  --color-primary: #7a6a2e;
  --color-primary-soft: #f4f0e3;
}
#ket-luan {
  --color-primary: #0f3b5e;
  --color-primary-soft: #e2edf7;
}

#tac-dong .card::before {
  background: #9e4a3a;
}
#tac-dong .card h4 .tag-num {
  background: #9e4a3a;
  box-shadow: 0 2px 8px rgba(158, 74, 58, 0.3);
}

#ung-pho .card::before {
  background: #7a6a2e;
}
#ung-pho .card h4 .tag-num {
  background: #7a6a2e;
  box-shadow: 0 2px 8px rgba(122, 106, 46, 0.3);
}

#gioi-thieu .card::before,
#nguyen-nhan .card::before,
#ket-luan .card::before {
  background: #0f3b5e;
}
#gioi-thieu .card h4 .tag-num,
#nguyen-nhan .card h4 .tag-num,
#ket-luan .card h4 .tag-num {
  background: #0f3b5e;
  box-shadow: 0 2px 8px rgba(15, 59, 94, 0.3);
}

.prose a {
  color: var(--color-primary-light);
  border-bottom: 1px dotted var(--color-primary-light);
}
.prose a:hover {
  color: var(--color-secondary);
  border-bottom-color: var(--color-secondary);
}