/* ==========================================================
   Các triều đại Việt Nam
   Thiết kế gốc Full HD 1920px (1rem = 10px tại 1920px).
   Breakpoint: PC > 1024px | Tablet 601-1024px | Mobile <= 600px
   ========================================================== */

@view-transition { navigation: auto; }

:root {
  --c-bg: #970a0b;
  --c-item: #ca0008;
  --c-gold: #e9ee74;
  --c-gold-light: #fffbb0;
  --ff-body: "Nunito Sans", Arial, sans-serif;
  --ff-script: "Dancing Script", "Nunito Sans", cursive;

  /* Kích thước theo thiết kế 1920px */
  --scroll-w: 82rem;
  --list-w: 81.5rem;
  --item-h: 9.4rem;
  --item-gap: 1.6rem;
  --item-fs: 2.8rem;
  --copy-fs: 2.4rem;
  --hero-top: 2.9rem;
  --hero-gap: 2.8rem;
  --copy-mt: 8.3rem;
  --border-h: 5.1rem;
  --border-bottom: 3.4rem;
  --copy-to-border: 8.4rem;

  --ease: cubic-bezier(.22, .8, .24, 1);
}

html {
  font-size: min(calc(100vw / 192), 10px);
  -webkit-text-size-adjust: 100%;
}

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

body {
  margin: 0;
  background-color: var(--c-bg);
  background-image: url("../assets/bgr-trong-dong.png");
  background-position: center center;
  background-size: cover;
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--c-gold);
  font-family: var(--ff-body);
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
ul { margin: 0; padding: 0; list-style: none; }

/* ---------- Page ---------- */
.page {
  position: relative;
  max-width: 192rem;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
}

/* ---------- Hero ---------- */
.hero {
  display: flex;
  justify-content: center;
  padding-top: var(--hero-top);
}

.hero__scroll {
  position: relative;
  width: var(--scroll-w);
  aspect-ratio: 820 / 510;
}

/* Ảnh cuộn gốc là ảnh dọc (510x820), xoay -90° như trong Figma */
.hero__scroll-img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 62.195%;
  height: 160.784%;
  max-width: none;
  transform: translate(-50%, -50%) rotate(-90deg);
  box-shadow: 0 2rem 3rem rgba(0, 0, 0, .2);
  animation: scroll-unroll 1.4s var(--ease) both;
}

.hero__title {
  position: absolute;
  inset: 0;
  margin: 0;
  font-weight: 700;
}

.hero__script {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--ff-script);
  font-size: calc(var(--scroll-w) * .0854);
  line-height: 1.03;
  white-space: nowrap;
  color: var(--c-gold);
  animation: title-focus 1.2s .9s var(--ease) both;
}

.hero__name {
  position: absolute;
  top: 42.93%;
  left: 50%;
  width: 47.68%;
  transform: translateX(-50%);
  animation: name-rise 1s 1.2s var(--ease) both;
}

/* ---------- Danh sách triều đại ---------- */
.main { padding-top: var(--hero-gap); }

.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--item-gap);
  width: var(--list-w);
  max-width: 100%;
  margin: 0 auto;
}

.timeline__item {
  opacity: 0;
  transform: translateY(2.4rem);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  transition-delay: calc(var(--i, 0) * 60ms);
}

.timeline__item.is-visible {
  opacity: 1;
  transform: none;
}

.timeline__link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--item-h);
  padding: 0 4%;
  overflow: hidden;
  border-radius: .5rem;
  background: var(--c-item);
  box-shadow: .2rem .5rem 1rem rgba(0, 0, 0, .3);
  color: var(--c-gold);
  text-decoration: none;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), color .35s;
}

.timeline__frame {
  position: absolute;
  top: 12.77%;
  left: 1.47%;
  width: 97.03%;
  height: 73.41%;
  max-width: none;
  transition: filter .35s;
}

/* Vệt sáng quét qua khi hover */
.timeline__link::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 30%;
  background: linear-gradient(100deg, transparent, rgba(255, 251, 176, .28), transparent);
  transform: skewX(-20deg);
  opacity: 0;
}

.timeline__label {
  position: relative;
  z-index: 1;
  font-size: var(--item-fs);
  font-weight: 700;
  line-height: 1.36;
  text-align: center;
  transition: letter-spacing .35s var(--ease);
}

.timeline__link:hover,
.timeline__link:focus-visible {
  transform: translateY(-.4rem) scale(1.012);
  box-shadow: .2rem 1.2rem 2rem rgba(0, 0, 0, .4), 0 0 2.4rem rgba(233, 238, 116, .25);
  color: var(--c-gold-light);
}

.timeline__link:hover .timeline__frame,
.timeline__link:focus-visible .timeline__frame {
  filter: drop-shadow(0 0 .6rem rgba(233, 238, 116, .7));
}

.timeline__link:hover .timeline__label,
.timeline__link:focus-visible .timeline__label { letter-spacing: .04em; }

.timeline__link:hover::after,
.timeline__link:focus-visible::after { animation: sheen .9s var(--ease); }

.timeline__link:active { transform: translateY(0) scale(.99); }

.timeline__link:focus-visible {
  outline: .3rem solid var(--c-gold);
  outline-offset: .3rem;
}

/* ---------- Footer ---------- */
.footer {
  position: relative;
  padding-top: var(--copy-mt);
  padding-bottom: calc(var(--border-h) + var(--border-bottom) + var(--copy-to-border) - 3.3rem);
}

.footer__copy {
  margin: 0;
  font-size: var(--copy-fs);
  line-height: 1.375;
  text-align: center;
}

.footer__author {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: .2em;
  transition: color .2s, text-decoration-color .2s;
}

.footer__author:hover,
.footer__author:focus-visible {
  color: var(--c-gold-light);
  text-decoration-color: currentColor;
}

.footer__author:focus-visible {
  outline: .2rem solid var(--c-gold);
  outline-offset: .3rem;
}

.author-dialog {
  position: fixed;
  width: min(128rem, calc(100vw - 3.2rem));
  max-width: none;
  max-height: 90vh;
  max-height: min(90dvh, 72rem);
  padding: 1.8rem 2.6rem 1.2rem;
  overflow: auto;
  border: .4rem solid #b75b37;
  border-radius: 2.4rem;
  background: var(--c-bg);
  color: var(--c-gold);
  box-shadow: 0 2rem 7rem rgba(0, 0, 0, .55);
}

.author-dialog::backdrop { background: rgba(24, 5, 5, .76); backdrop-filter: blur(.4rem); }

.author-dialog[open] { animation: dialog-in .25s var(--ease) both; }

.author-dialog__content {
  padding: 3rem clamp(1.8rem, 6vw, 4rem) 3.6rem;
  border-radius: 1.2rem;
  background: #fff;
  color: #111;
  text-align: center;
}

.author-dialog__title {
  margin: 0;
  color: #a20b11;
  font-family: var(--ff-body);
  font-size: clamp(2.4rem, 3vw, 3.4rem);
  font-weight: 800;
  line-height: 1.25;
}

.author-dialog__thanks {
  max-width: 90rem;
  margin: 1.6rem auto 0;
  font-size: clamp(1.6rem, 1.8vw, 2.2rem);
  line-height: 1.45;
}

.author-dialog__contacts {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.2rem 3.6rem;
  margin-top: 2rem;
}

.author-dialog__contact {
  margin: 0;
  font-size: clamp(1.6rem, 2.2vw, 2.8rem);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.author-dialog__contact a {
  color: inherit;
  text-decoration-thickness: .1rem;
  text-underline-offset: .15em;
}

.author-dialog__dismiss {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  z-index: 1;
  min-width: 23.5rem;
  min-height: 6.3rem;
  padding: .8rem 2rem;
  transform: translateX(-50%);
  border: .2rem solid var(--c-gold);
  border-radius: .6rem;
  background: #970a0b;
  color: var(--c-gold);
  font-family: "MTD Whittier", "Segoe Script", cursive;
  font-size: 2.6rem;
  line-height: 1.1;
  cursor: pointer;
}

.author-dialog__footer {
  position: relative;
  height: 6.8rem;
  margin-top: .8rem;
}

.author-dialog__ornament {
  position: absolute;
  right: 1.2rem;
  bottom: .7rem;
  left: 1.2rem;
  width: calc(100% - 2.4rem);
  height: 3.2rem;
  max-width: none;
}

.author-dialog__dismiss:hover { color: var(--c-gold-light); background-color: #76040a; }

.author-dialog__dismiss:focus-visible { outline: .3rem solid var(--c-gold-light); outline-offset: .3rem; }

.footer__border {
  position: absolute;
  left: -.47%;
  bottom: var(--border-bottom);
  width: 100.89%;
  max-width: none;
  height: var(--border-h);
  transform: scaleX(-1);
}

/* ---------- Animation ---------- */
@keyframes scroll-unroll {
  from { clip-path: inset(0 50% 0 50%); opacity: 0; }
  to   { clip-path: inset(0); opacity: 1; }
}

@keyframes title-focus {
  from { opacity: 0; filter: blur(.8rem); letter-spacing: .3em; }
  to   { opacity: 1; filter: blur(0); letter-spacing: 0; }
}

@keyframes name-rise {
  from { opacity: 0; transform: translate(-50%, 1.6rem); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes sheen {
  from { left: -40%; opacity: 1; }
  to   { left: 120%; opacity: 1; }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(1rem) scale(.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .timeline__item { opacity: 1; transform: none; }
}

@media (max-width: 600px) {
  .author-dialog { padding: 1rem 1rem .8rem; border-radius: 1.6rem; }
  .author-dialog__content { padding: 2.4rem 1.4rem 2.6rem; }
  .author-dialog__thanks { margin-top: 1.2rem; }
  .author-dialog__contacts { flex-direction: column; gap: 1.2rem; margin-top: 2rem; }
  .author-dialog__contact { max-width: 100%; }
  .author-dialog__footer { height: 5.6rem; }
  .author-dialog__ornament { right: .2rem; left: .2rem; width: calc(100% - .4rem); height: 2.4rem; }
  .author-dialog__dismiss { min-width: 14rem; min-height: 4.8rem; bottom: .7rem; font-size: 2rem; }
}

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
  html { font-size: 10px; }

  :root {
    --scroll-w: min(82rem, 92vw);
    --list-w: min(72rem, 90vw);
    --item-h: 8rem;
    --item-fs: 2.4rem;
    --copy-fs: 2rem;
    --copy-mt: 6rem;
    --hero-top: 2.4rem;
    }

  .footer__copy { padding: 0 2rem; }
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  :root {
    --scroll-w: 96vw;
    --list-w: 92vw;
    --item-h: 6.4rem;
    --item-gap: 1.2rem;
    --item-fs: 1.6rem;
    --copy-fs: 1.4rem;
    --hero-top: 1.6rem;
    --hero-gap: 2rem;
    --copy-mt: 4rem;
    --border-h: 3.2rem;
    --border-bottom: 2rem;
    --copy-to-border: 4rem;
  }

  .timeline__link { padding: 1rem 6%; }
  .timeline__label { line-height: 1.3; }
}
