/* =========================================================
   ZHR GLOBAL — BASE / RESET / TYPOGRAPHY
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  background: var(--c-paper);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  font-optical-sizing: auto;
  letter-spacing: -0.012em;
  line-height: var(--leading-snug);
  color: var(--c-ink);
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: var(--text-h1); line-height: var(--leading-tight); letter-spacing: -0.022em; font-weight: 500; }
h2 { font-size: var(--text-h2); line-height: 1.08; letter-spacing: -0.018em; font-weight: 500; }
h3 { font-size: var(--text-h3); font-weight: 600; letter-spacing: -0.01em; }
h4 { font-size: var(--text-h4); font-weight: 600; letter-spacing: -0.006em; }

p { margin: 0 0 var(--space-4); }
p:last-child { margin-bottom: 0; }

a { color: inherit; text-decoration: none; }

ul, ol { margin: 0; padding: 0; list-style: none; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: var(--c-accent); color: #fff; }

/* --- Layout primitives ---------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.wrap--narrow { max-width: var(--wrap-narrow); }

.section { padding-block: var(--space-section); position: relative; }
.section--tight { padding-block: clamp(3rem, 2rem + 3.5vw, 5.5rem); }
.section--paper2 { background: var(--c-paper-2); }
.section--dark { background: var(--c-ink); color: var(--c-on-dark); }
.section--dark h1, .section--dark h2, .section--dark h3, .section--dark h4 { color: var(--c-on-dark); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--c-ink); color: #fff; padding: 12px 18px; border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

/* --- Text utilities ------------------------------------- */
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: var(--text-label);
  font-weight: 600;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--c-accent-deep);
  margin-bottom: var(--space-4);
}
.eyebrow::before {
  content: ""; width: 26px; height: 1px; background: currentColor; opacity: 0.7;
}
.section--dark .eyebrow { color: var(--c-accent-bright); }

.lead { font-size: var(--text-lead); color: var(--c-text-muted); max-width: 62ch; }
.section--dark .lead { color: var(--c-on-dark-muted); }

.muted { color: var(--c-text-muted); }
.section--dark .muted { color: var(--c-on-dark-muted); }

.accent-word { color: var(--c-accent-deep); }
.section--dark .accent-word { color: var(--c-accent-bright); }

/* Header nhóm: tiêu đề trái, mô tả phải — nhịp editorial */
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(1.25rem, 4vw, 4rem);
  align-items: end;
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-7);
  border-bottom: 1px solid var(--c-line);
}
.section--dark .section-head { border-bottom-color: var(--c-on-dark-line); }
.section-head--center { grid-template-columns: 1fr; text-align: center; justify-items: center; }

@media (max-width: 860px) {
  .section-head { grid-template-columns: 1fr; align-items: start; gap: var(--space-4); }
}

/* --- Reveal on scroll ----------------------------------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}
[data-reveal].is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
}

/* =========================================================
   GLOBAL ENTERPRISE POLISH
   Film grain, reading progress, back-to-top
   ========================================================= */

/* Hạt nhiễu cực nhẹ toàn trang — chiều sâu "in ấn cao cấp" */
body::after {
  content: "";
  position: fixed; inset: 0;
  z-index: 9990;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  opacity: 0.04;
  mix-blend-mode: multiply;
}

/* Thanh tiến trình đọc trang — mảnh, chạy dọc mép trên */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  z-index: 9999;
  pointer-events: none;
  background: linear-gradient(90deg, var(--c-accent), var(--c-accent-bright));
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
}

/* Nút cuộn về đầu trang */
.back-top {
  position: fixed;
  left: clamp(16px, 2.4vw, 32px);
  bottom: clamp(16px, 2.4vw, 32px);
  z-index: 80;
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  box-shadow: 0 12px 32px -14px rgba(7, 26, 43, 0.28), 0 2px 6px rgba(7, 26, 43, 0.06);
  color: var(--c-ink);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease),
              border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.back-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.back-top:hover { border-color: var(--c-accent); color: var(--c-accent-deep); transform: translateY(-2px); }
.back-top svg { width: 18px; height: 18px; }
