/* Bảng màu hoài cổ: giấy dó ngả vàng, son triện, lam chàm, ngọc bích, thổ hoàng */
.mgz-root {
  --paper: #f1e5ca;
  --paper-deep: #e4d0a6;
  --ivory: #f8f0dd;
  --ink: #2a1e16;
  --ink-soft: #5c4736;
  --cinnabar: #a3322a;
  --cinnabar-deep: #7c261f;
  --ochre: #b8873a;
  --gold: #e2c07a;
  --jade: #3d6354;
  --indigo: #23314a;
  --umber: #5a3c21;
  --display: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --text: Georgia, "Times New Roman", serif;
  position: relative;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(255, 248, 230, 0.6), rgba(255, 248, 230, 0) 60%), repeating-linear-gradient(0deg, rgba(90, 60, 33, 0.025) 0 1px, rgba(0, 0, 0, 0) 1px 3px);
  font-family: var(--text);
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

.mgz-root figure { margin: 0; }
.mgz-root picture { display: block; }
.mgz-root img { display: block; max-width: 100%; height: auto; }
.mgz-root h2 { margin: 0; }
.mgz-root a:focus-visible { outline: 3px solid var(--ochre); outline-offset: 3px; }

/* Cột chữ chuẩn */
.mgz-root .mgz-col { box-sizing: content-box; max-width: 44rem; margin-left: auto; margin-right: auto; padding-left: 20px; padding-right: 20px; }

/* Cảnh mở đầu — điện thoại: ảnh trọn khung, chữ nằm dưới ảnh */
.mgz-hero { position: relative; background: var(--indigo); color: var(--ivory); }
.mgz-hero-media img { width: 100%; height: auto; filter: sepia(0.18) saturate(1.05); }
.mgz-hero-text {
  box-sizing: border-box;
  padding: 30px 20px 40px;
  background: linear-gradient(180deg, var(--indigo), #18223a);
}
.mgz-hero-text::before {
  content: "\2756";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  margin-bottom: 22px;
  background: var(--cinnabar);
  color: var(--ivory);
  font-size: 22px;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 4px var(--cinnabar);
}
.mgz-hero-title { font-family: var(--display); font-weight: 700; line-height: 1.08; color: var(--ivory); }
.mgz-hero-pre {
  display: block;
  font-size: clamp(1rem, 0.85rem + 0.7vw, 1.45rem);
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.02em;
  color: var(--gold);
  margin-bottom: 0.5em;
}
.mgz-hero-main { display: block; font-size: clamp(2.1rem, 1.2rem + 4vw, 5rem); letter-spacing: -0.01em; text-wrap: balance; }
.mgz-hero-sapo {
  margin: 1.2em 0 0;
  max-width: 40rem;
  font-size: clamp(1.05rem, 0.98rem + 0.35vw, 1.25rem);
  line-height: 1.65;
  color: rgba(248, 240, 221, 0.9);
}
.mgz-hero-cap {
  margin: 26px 0 0;
  padding-top: 12px;
  max-width: 34rem;
  border-top: 1px solid rgba(226, 192, 122, 0.45);
  font-size: 0.92rem;
  font-style: italic;
  line-height: 1.5;
  color: rgba(248, 240, 221, 0.72);
}

@keyframes mgz-rise {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: none; }
}
.mgz-root.mgz-js .mgz-hero-text { animation: mgz-rise 1.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

/* Cảnh mở đầu — màn rộng: ảnh phủ màn hình, chữ đè, thị sai */
@media (min-width: 768px) {
  .mgz-hero { display: flex; align-items: flex-end; min-height: 100svh; overflow: hidden; background: var(--ink); }
  .mgz-hero-media { position: absolute; top: 0; left: 0; right: 0; height: 100%; will-change: transform; }
  .mgz-hero-media picture { width: 100%; height: 100%; }
  .mgz-hero-media img { width: 100%; height: 100%; object-fit: cover; object-position: center 40%; }
  .mgz-hero::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(24, 18, 14, 0.2) 0%, rgba(24, 18, 14, 0.15) 35%, rgba(24, 18, 14, 0.9) 100%), linear-gradient(90deg, rgba(35, 49, 74, 0.55) 0%, rgba(35, 49, 74, 0) 60%);
    pointer-events: none;
  }
  .mgz-hero-text {
    position: relative;
    z-index: 2;
    max-width: 60rem;
    padding: 0 clamp(28px, 6vw, 96px) clamp(48px, 10svh, 110px);
    background: none;
  }
  .mgz-hero-text::before { width: 58px; height: 58px; font-size: 26px; }
}

/* Thân bài */
.mgz-prologue { padding: clamp(56px, 11svh, 130px) 0 clamp(24px, 4svh, 48px); }
.mgz-body { padding-top: 4px; padding-bottom: clamp(16px, 3svh, 36px); }
.mgz-body p {
  margin: 0 0 1.55em;
  font-size: clamp(1.08rem, 0.98rem + 0.4vw, 1.24rem);
  line-height: 1.88;
  color: var(--ink);
  text-wrap: pretty;
}
.mgz-body .mgz-dropcap::first-letter {
  float: left;
  font-family: var(--display);
  font-size: 4.4em;
  line-height: 0.82;
  padding: 0.08em 0.12em 0 0;
  color: var(--cinnabar);
  font-weight: 700;
}
.mgz-body .mgz-note {
  padding: 1.1em 1.3em;
  border-left: 4px solid var(--cinnabar);
  background: linear-gradient(90deg, rgba(184, 135, 58, 0.18), rgba(184, 135, 58, 0.04));
  color: var(--ink-soft);
  font-style: italic;
}
.mgz-body .mgz-lede {
  margin: 2em 0;
  padding: 1.1em 0;
  border-top: 1px solid rgba(42, 30, 22, 0.25);
  border-bottom: 1px solid rgba(42, 30, 22, 0.25);
  font-family: var(--display);
  font-size: clamp(1.3rem, 1.05rem + 1vw, 1.75rem);
  line-height: 1.5;
  text-align: center;
  color: var(--cinnabar-deep);
  text-wrap: balance;
}
.mgz-body .mgz-finale { font-family: var(--display); font-size: clamp(1.15rem, 1rem + 0.6vw, 1.4rem); color: var(--umber); }
.mgz-hl { font-weight: 700; background: linear-gradient(180deg, rgba(0, 0, 0, 0) 60%, rgba(184, 135, 58, 0.38) 60%); }
.mgz-leadin { font-family: var(--display); font-weight: 700; color: var(--jade); }

/* Dải mở chương: như tấm vải thêu có hoa văn mắt cáo */
.mgz-band {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 62svh;
  margin-bottom: clamp(48px, 8svh, 96px);
  padding: clamp(64px, 12svh, 140px) 0;
  overflow: hidden;
  color: var(--ivory);
  background-color: var(--jade);
  background-image: radial-gradient(ellipse at 15% 0%, rgba(255, 240, 200, 0.14), rgba(255, 240, 200, 0) 60%), repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.04) 0 2px, rgba(0, 0, 0, 0) 2px 20px), repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.06) 0 2px, rgba(0, 0, 0, 0) 2px 20px);
  box-sizing: border-box;
}
.mgz-band::before {
  content: "\2756";
  position: absolute;
  right: 5%;
  bottom: -0.18em;
  font-size: clamp(10rem, 22vw, 20rem);
  line-height: 1;
  color: rgba(226, 192, 122, 0.1);
  pointer-events: none;
}
.mgz-band::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 10px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 14px, rgba(0, 0, 0, 0) 14px 20px);
  opacity: 0.55;
}
.mgz-band--jade { background-color: var(--jade); }
.mgz-band--indigo { background-color: var(--indigo); }
.mgz-band--cinnabar { background-color: var(--cinnabar-deep); }
.mgz-band--umber { background-color: var(--umber); }
.mgz-band-wrap { position: relative; z-index: 1; width: 100%; }
.mgz-chap-num {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.32em;
  color: var(--gold);
}
.mgz-chap-num::after { content: ""; flex: 0 0 64px; height: 1px; background: currentColor; }
.mgz-chap-title {
  font-family: var(--display);
  font-size: clamp(1.9rem, 1.25rem + 2.7vw, 3.5rem);
  font-weight: 700;
  line-height: 1.14;
  color: var(--ivory);
  text-wrap: balance;
}
.mgz-chapter { padding-bottom: clamp(24px, 4svh, 48px); }

/* Ảnh bồi khung như ảnh xưa dán album */
.mgz-root .mgz-plate {
  box-sizing: border-box;
  max-width: 68rem;
  margin: clamp(48px, 9svh, 110px) auto;
  padding: 0 20px;
}
.mgz-plate-mount {
  padding: 12px;
  background: var(--ivory);
  border: 1px solid rgba(90, 60, 33, 0.2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 26px 50px -28px rgba(42, 30, 22, 0.55);
}
.mgz-plate-mount img { width: 100%; filter: sepia(0.14) saturate(1.04); }
.mgz-root .mgz-cap {
  max-width: 40rem;
  margin: 18px auto 0;
  padding: 0 20px;
  font-size: 0.95rem;
  font-style: italic;
  line-height: 1.55;
  text-align: center;
  color: var(--ink-soft);
}
.mgz-cap::before { content: "\2756"; display: block; margin-bottom: 6px; font-style: normal; font-size: 0.85rem; color: var(--cinnabar); }

/* Bộ ảnh */
.mgz-root .mgz-gallery {
  box-sizing: border-box;
  max-width: 76rem;
  margin: clamp(48px, 9svh, 110px) auto;
  padding: 0 20px;
}
.mgz-gal-grid { display: grid; gap: 10px; }
.mgz-gal-grid--tri { grid-template-columns: 1.55fr 1fr; grid-template-rows: 1fr 1fr; height: clamp(380px, 44vw, 640px); }
.mgz-gal-grid--duo { grid-template-columns: 1fr 1fr; }
.mgz-gal-item { overflow: hidden; background: var(--paper-deep); border: 6px solid var(--ivory); box-shadow: 0 18px 36px -24px rgba(42, 30, 22, 0.6); }
.mgz-gal-grid--duo .mgz-gal-item { aspect-ratio: 3 / 2; }
.mgz-gal-item--lead { grid-row: 1 / 3; }
.mgz-gal-item picture { width: 100%; height: 100%; }
.mgz-gal-item img { width: 100%; height: 100%; object-fit: cover; filter: sepia(0.14); transition: transform 1.4s ease; }
.mgz-gal-item:hover img { transform: scale(1.03); }

/* Đường tuyến nét đứt như bản đồ xưa */
.mgz-route { position: relative; display: flex; justify-content: space-between; height: 18px; margin: 2.2em 0 1.4em; }
.mgz-route::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 7px;
  right: 7px;
  border-top: 2px dashed var(--cinnabar);
  transform-origin: left center;
  transition: transform 1.6s ease 0.2s;
}
.mgz-route-dot { position: relative; z-index: 1; width: 14px; height: 14px; border-radius: 50%; background: var(--ivory); border: 3px solid var(--cinnabar); box-sizing: border-box; }
.mgz-root.mgz-js .mgz-route::before { transform: scaleX(0); }
.mgz-root.mgz-js .mgz-route.mgz-visible::before { transform: scaleX(1); }

/* Trích dẫn lớn: dải son triện */
.mgz-root .mgz-proverb {
  margin: clamp(48px, 9svh, 110px) 0;
  padding: clamp(64px, 12svh, 140px) 20px;
  background-color: var(--cinnabar-deep);
  background-image: radial-gradient(circle, rgba(226, 192, 122, 0.2) 0 1px, rgba(0, 0, 0, 0) 1.5px);
  background-size: 22px 22px;
  color: var(--ivory);
  text-align: center;
}
.mgz-proverb-inner { max-width: 52rem; margin: 0 auto; }
.mgz-proverb-inner::before {
  content: "\2756";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 28px;
  border: 2px solid var(--gold);
  color: var(--gold);
  font-size: 24px;
}
.mgz-proverb p { margin: 0; font-size: clamp(1.02rem, 0.95rem + 0.3vw, 1.18rem); line-height: 1.7; color: rgba(248, 240, 221, 0.86); }
.mgz-proverb-han {
  display: block;
  margin: 0.45em 0 0.35em;
  font-family: var(--display);
  font-size: clamp(1.9rem, 1.15rem + 3.2vw, 3.7rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--gold);
  text-wrap: balance;
}
.mgz-proverb-vi { display: block; margin-bottom: 0.9em; font-style: italic; font-size: clamp(1.15rem, 1rem + 0.6vw, 1.45rem); color: var(--ivory); }

/* Ảnh tràn lề nghỉ mắt, thị sai nhẹ trên màn rộng */
.mgz-root .mgz-interlude { position: relative; height: 78svh; margin: clamp(56px, 10svh, 120px) 0; overflow: hidden; background: var(--ink); }
.mgz-root .mgz-interlude--end { height: 64svh; margin-bottom: 0; }
.mgz-drift { position: absolute; left: 0; right: 0; top: -12%; height: 124%; }
.mgz-drift picture { width: 100%; height: 100%; }
.mgz-drift img { width: 100%; height: 100%; object-fit: cover; filter: sepia(0.22) saturate(1.05); }
.mgz-interlude::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  box-shadow: inset 0 0 140px rgba(42, 30, 22, 0.55);
  pointer-events: none;
}

/* Kết: con dấu son */
.mgz-coda { display: flex; justify-content: center; padding: clamp(48px, 9svh, 100px) 20px; }
.mgz-coda::before {
  content: "\2756";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  background: var(--cinnabar);
  color: var(--ivory);
  font-size: 26px;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 5px var(--cinnabar);
  transform: rotate(-4deg);
}

/* Hiện dần khi cuộn (chỉ khi JS chạy) */
.mgz-root.mgz-js .mgz-reveal,
.mgz-root.mgz-js .mgz-body > p {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.9s ease, transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.mgz-root.mgz-js .mgz-reveal.mgz-visible,
.mgz-root.mgz-js .mgz-body > p.mgz-visible { opacity: 1; transform: none; }

/* Điện thoại */
@media (max-width: 760px) {
  .mgz-band { min-height: 44svh; }
  .mgz-chap-num { margin-bottom: 14px; }
  .mgz-gal-grid--tri { grid-template-columns: 1fr; grid-template-rows: none; height: auto; }
  .mgz-gal-grid--tri .mgz-gal-item { aspect-ratio: 3 / 2; }
  .mgz-gal-item--lead { grid-row: auto; }
  .mgz-gal-grid--duo { grid-template-columns: 1fr; }
  .mgz-gal-item { border-width: 4px; }
  .mgz-plate-mount { padding: 6px; }
  .mgz-root .mgz-interlude { height: auto; margin: 48px 0; }
  .mgz-root .mgz-interlude--end { height: auto; margin-bottom: 0; }
  .mgz-drift { position: static; height: auto; }
  .mgz-drift img { height: auto; }
  .mgz-interlude::after { box-shadow: inset 0 0 60px rgba(42, 30, 22, 0.45); }
  .mgz-body .mgz-note { padding: 0.9em 1em; }
}

/* Người đọc giảm chuyển động */
@media (prefers-reduced-motion: reduce) {
  .mgz-root.mgz-js .mgz-reveal,
  .mgz-root.mgz-js .mgz-body > p { opacity: 1; transform: none; transition: none; }
  .mgz-root.mgz-js .mgz-hero-text { animation: none; }
  .mgz-root.mgz-js .mgz-route::before { transform: none; transition: none; }
  .mgz-gal-item img { transition: none; }
  .mgz-gal-item:hover img { transform: none; }
  .mgz-hero-media { will-change: auto; }
}

/* Bản in */
@media print {
  .mgz-root { background: #fff; color: #000; }
  .mgz-root.mgz-js .mgz-reveal,
  .mgz-root.mgz-js .mgz-body > p { opacity: 1; transform: none; }
  .mgz-band { min-height: 0; background: #fff; color: #000; }
  .mgz-chap-title { color: #000; }
  .mgz-root .mgz-proverb { background: #fff; color: #000; }
  .mgz-proverb p { color: #000; }
  .mgz-proverb-han { color: #000; }
  .mgz-proverb-vi { color: #000; }
}