/* ============ COVER — bìa tạp chí trong cổng vòm hoa ============ */
#cover {
  container-type: inline-size;
  --mast-top: 8.5%;
  --mast-fs: 27cqw;                 /* cỡ masthead */
  --cv-ch: min(56%, 112cqw);         /* chiều cao cặp đôi (QA2: nhỏ lại để chân không chạm kicker/tên) */
  --cv-head: .17;                   /* tỉ lệ đầu cặp đôi đè lên chân masthead */
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 640px;
  max-height: 1100px;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 70% at 50% 30%, #FFFDF8 0%, rgba(255,253,248,0) 60%),
    linear-gradient(180deg, #F4ECDD 0%, #FBF7F0 45%, #EEE3CF 100%);
}

#cover .cv-stage, #cover .cv-layer, #cover .cv-depth, #cover .cv-in { position: absolute; inset: 0; }
#cover .cv-layer { will-change: transform; pointer-events: none; }
/* .cv-depth: lớp trung gian cho FX (data-depth → dịch theo con trỏ/con quay). JS FX chỉ đặt transform lên chính phần tử này. */
#cover .cv-depth { will-change: transform; }

/* Khung chỉ vàng kiểu bìa tạp chí in (đè lên ảnh, dưới lớp chữ) */
#cover .cv-frame {
  position: absolute; z-index: 7; pointer-events: none;
  inset: calc(env(safe-area-inset-top, 0px) + 10px) 10px calc(env(safe-area-inset-bottom, 0px) + 10px);
  border: 1px solid rgba(184,137,59,.55);
  box-shadow: inset 0 0 0 3px rgba(255,253,248,.35), inset 0 0 0 4px rgba(184,137,59,.28);
  opacity: 0; transition: opacity 1.2s var(--ease-out) .3s;
}
#cover.is-played .cv-frame { opacity: 1; }
#cover .cv-layer.is-missing { display: none; }
#cover img { max-width: none; }

/* --- Cảnh nền --- */
#cover .cv-scenery { z-index: 0; inset: -4% 0 -12% 0; }
#cover .cv-scenery img {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 40%;
  animation: cv-kenburns 28s var(--ease-in-out) infinite alternate;
  transform-origin: 50% 45%;
}
@keyframes cv-kenburns {
  from { transform: scale(1.1) translate3d(-1.2%, -.8%, 0); }
  to   { transform: scale(1.02) translate3d(1%, .8%, 0); }
}

/* --- Masthead (sau đầu cặp đôi) --- */
#cover .cv-mast { z-index: 2; }
#cover .cv-mast-txt {
  position: absolute; left: 0; right: 0; top: var(--mast-top);
  margin: 0; text-align: center;
  font-family: var(--font-display); font-weight: 700;
  font-size: var(--mast-fs); line-height: .8;
  letter-spacing: .06em; text-indent: .06em;     /* bù khoảng chữ cuối để cân giữa */
  text-transform: uppercase;
  padding: .06em 0 .04em;
  /* foil gradient that stays dark at both ends — the pale midtone used to wash the last letter into the pale sky */
  /* foil gradient that stays dark at both ends — the pale midtone used to wash the last letter into the pale sky */
  background: linear-gradient(100deg, #8A6224 0%, #B8893B 22%, #E3C47F 46%, #C99A4B 64%, #8A6224 100%);
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 2px 6px rgba(138, 98, 36, .22));
}
/* Sương kem phía trên: làm dịu cụm hoa/lưới vàng sau masthead + dòng số báo cho bìa đỡ rối */
#cover .cv-veil {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(251,247,240,.82) 0%, rgba(251,247,240,.5) 6%, rgba(251,247,240,0) 13%),
    radial-gradient(70% 16% at 50% 15%, rgba(255,253,248,.78) 0%, rgba(255,253,248,.45) 55%, rgba(255,253,248,0) 100%);
  opacity: 0; transition: opacity .9s var(--ease-out) .1s;
}
#cover.is-played .cv-veil { opacity: 1; }

/* --- Cặp đôi --- */
#cover .cv-couple { z-index: 3; }
#cover .cv-couple-img {
  position: absolute; left: 50%;
  top: calc(var(--mast-top) + var(--mast-fs) * .8 - var(--cv-ch) * var(--cv-head));
  height: var(--cv-ch); width: auto; max-width: 104cqw;
  transform: translateX(-50%);
  object-fit: contain; object-position: 50% 0;
  filter: drop-shadow(0 14px 22px rgba(74, 59, 53, .16));
}
/* Chibi (đầu to, thân ngắn, hình rộng ngang): nhỏ hơn minh hoạ cũ; đỉnh đầu ở ~13% khung SVG
   → --cv-head .19 = đầu đè ~6% chiều cao hình lên chân chữ masthead. Nét vẽ lệch phải ~4.75% khung → bù -3%. */
#cover.cv--chibi { --cv-ch: min(48.5%, 94cqw); --cv-head: .19; }
#cover.cv--chibi .cv-couple-img { transform: translateX(-53%); filter: drop-shadow(0 12px 18px rgba(74, 59, 53, .14)); }
/* coverline lùi sát mép để không đè mặt/thân chibi */
#cover.cv--chibi .cv-lines { gap: 10px; }
#cover.cv--chibi .cv-lines--l { left: 3.5cqw; width: 25.5cqw; top: 51.5%; }
#cover.cv--chibi .cv-lines--r { right: 4.5cqw; width: 25cqw; top: 30%; }
#cover.cv--chibi .cv-lines--l::before { inset: -14px -10px; }
#cover.cv--chibi .cv-cl { font-size: 13.5px; }
#cover.cv--chibi .cv-lines--l .cv-cl { font-size: 13px; }

/* --- Cổng vòm --- */
/* Khung vòm nằm SAU masthead + cặp đôi (kiểu bìa tạp chí: masthead đè lên mọi thứ trừ đầu "cover star") */
#cover .cv-arch { z-index: 1; }
#cover .cv-arch img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; }
#cover .cv-arch-fb { display: none; }
#cover.cv--no-arch .cv-arch.is-missing { display: block; }
#cover.cv--no-arch .cv-arch img { display: none; }
#cover.cv--no-arch .cv-arch-fb {
  display: block; position: absolute; inset: 3.5cqw;
  border: 1px solid var(--gold-light);
  border-radius: 46cqw 46cqw 4px 4px;
  box-shadow: inset 0 0 0 5px rgba(255,253,248,.35), inset 0 0 0 6px rgba(217,182,110,.55);
}

/* --- Chim công --- */
#cover .cv-peacock { z-index: 5; inset: auto auto 0 auto; width: 34cqw; height: 34cqw; bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); }
#cover .cv-peacock img { width: 100%; height: 100%; object-fit: contain; }
#cover .cv-peacock--l { left: -10cqw; }
#cover .cv-peacock--r { right: -10cqw; }
#cover .cv-peacock--r img { transform: scaleX(-1); }

/* --- Chim ruồi --- */
#cover .cv-bird { z-index: 6; inset: auto; }
#cover .cv-bird img { width: 100%; height: auto; }
#cover .cv-bird--a { left: 9%; top: 23%; width: 15cqw; height: 13cqw; }
#cover .cv-bird--b { right: 7%; top: 21.5%; width: 11.5cqw; height: 10cqw; } /* dưới chân masthead, không đè chữ E */
#cover .cv-bird--a img { animation: cv-flutter 3.4s ease-in-out infinite; }
#cover .cv-bird--b img { animation: cv-flutter-m 3s ease-in-out -1.2s infinite; }
@keyframes cv-flutter {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-3deg); }
  25% { transform: translate3d(3px, -7px, 0) rotate(2deg); }
  50% { transform: translate3d(-2px, -3px, 0) rotate(-1deg); }
  75% { transform: translate3d(2px, -9px, 0) rotate(3deg); }
}
@keyframes cv-flutter-m {
  0%, 100% { transform: scaleX(-1) translate3d(0, 0, 0) rotate(-3deg); }
  30% { transform: scaleX(-1) translate3d(3px, -8px, 0) rotate(2deg); }
  60% { transform: scaleX(-1) translate3d(-2px, -3px, 0) rotate(-2deg); }
}

/* ================= Lớp chữ ================= */
#cover .cv-text { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
#cover .cv-text p { margin: 0; }

#cover .cv-issue {
  position: absolute; left: 0; right: 0;
  top: calc(env(safe-area-inset-top, 0px) + 3%);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 0 22px;
  text-align: center;
  font-family: var(--font-sans); font-weight: 500;
  font-size: 10.5px; letter-spacing: .3em; text-transform: uppercase;
  color: var(--gold-deep);
  text-shadow: 0 0 6px rgba(255,253,248,.95), 0 0 2px rgba(255,253,248,.9);
}

#cover .cv-issue::before, #cover .cv-issue::after {
  content: ""; flex: 0 1 28px; min-width: 8px; height: 1px;
  background: linear-gradient(90deg, rgba(184,137,59,0), var(--gold));
}
#cover .cv-issue::after { background: linear-gradient(90deg, var(--gold), rgba(184,137,59,0)); }
#cover .cv-issue span { flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 400px) { #cover .cv-issue { font-size: 9.5px; letter-spacing: .2em; gap: 8px; padding: 0 18px; } }

/* Coverlines 2 mép */
#cover .cv-lines { position: absolute; width: 29cqw; max-width: 132px; display: flex; flex-direction: column; gap: 14px; }
#cover .cv-lines::before { /* màn sương kem sau coverline để đọc rõ trên nền hoa/lưới */
  content: ""; position: absolute; z-index: -1; inset: -20px -22px;
  background: radial-gradient(closest-side, rgba(255,253,248,.95) 0%, rgba(255,253,248,.85) 55%, rgba(255,253,248,0) 100%);
  opacity: 0; transition: opacity .9s var(--ease-out) .8s;
}
#cover.is-played .cv-lines::before { opacity: 1; }
#cover .cv-lines--l { left: max(9cqw, 34px); top: 32%; text-align: left; }
#cover .cv-lines--r { right: max(8cqw, 26px); top: 27%; text-align: right; align-items: flex-end; }
#cover .cv-cl {
  font-family: var(--font-serif); font-style: italic; font-weight: 500;
  font-size: 15px; line-height: 1.24; color: var(--ink);
  text-shadow: 0 0 8px rgba(255,253,248,1), 0 0 3px rgba(255,253,248,1), 0 0 14px rgba(255,253,248,.9);
}
#cover .cv-cl::before {
  content: ""; display: block; width: 22px; height: 2px; margin-bottom: 6px;
  background: var(--red);
}
#cover .cv-lines--r .cv-cl::before { margin-left: auto; }
#cover .cv-cl-kick {
  display: block; margin-bottom: 2px;
  font-family: var(--font-display); font-style: normal; font-weight: 700;
  font-size: 11px; line-height: 1.3; letter-spacing: .16em; text-transform: uppercase;
  white-space: nowrap;
  color: var(--gold-deep);
}
#cover .cv-cl-txt { display: block; }

/* Barcode trang trí */
#cover .cv-barcode {
  width: 26cqw; min-width: 100px; max-width: 116px;
  padding: 5px 6px 4px; background: rgba(255,253,248,.92);
  border: 1px solid rgba(184,137,59,.35);
  box-shadow: 0 4px 14px rgba(59,51,43,.08);
  text-align: center;
}
#cover .cv-bc-top {
  display: flex; justify-content: space-between;
  font-family: var(--font-sans); font-size: 8px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); line-height: 1.4;
}
#cover .cv-bc-bars { display: flex; justify-content: center; height: 24px; overflow: hidden; margin: 2px 0 3px; }
#cover .cv-bc-bars i { flex: none; height: 100%; background: var(--ink); }
#cover .cv-bc-tag {
  font-family: var(--font-sans); font-size: 9px; font-weight: 500; letter-spacing: 0;
  color: var(--ink); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Tên + ngày */
#cover .cv-title {
  position: absolute; left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);   /* chừa chỗ thanh điều hướng nổi (chrome) */
  text-align: center;
}
#cover .cv-title::before {
  content: ""; position: absolute; z-index: -1;
  left: 4%; right: 4%; top: -6%; bottom: -10%;
  background: radial-gradient(closest-side, rgba(255,253,248,.9) 0%, rgba(255,253,248,.72) 55%, rgba(255,253,248,0) 100%);
  opacity: 0; transition: opacity 1s var(--ease-out) .5s;
}
#cover .cv-kicker {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: 17px; letter-spacing: .04em; color: var(--gold-deep);
  margin-bottom: 2px !important;
}
#cover .cv-kicker::before, #cover .cv-kicker::after {
  content: ""; display: inline-block; vertical-align: middle;
  width: 26px; height: 1px; margin: 0 10px; background: var(--gold-light);
}
#cover .cv-names { margin: 0; font-weight: 400; line-height: 1; word-spacing: .14em; }
#cover .cv-write {
  display: inline-block;
  padding: .14em .34em .2em;          /* chừa chỗ nét lượn + dấu tiếng Việt cho nền vàng */
  margin: -.14em -.34em -.2em;
}
#cover .cv-name { font-size: 16cqw; line-height: 1.02; display: block; width: fit-content; margin-left: auto; margin-right: auto; }
#cover .cv-amp  { font-size: 10cqw; line-height: .8; display: block; width: fit-content; margin: -.06em auto -.04em; }
#cover .cv-name.script-fb { font-family: "Dancing Script", cursive; font-weight: 500; font-size: 13.5cqw; }
#cover .cv-date {
  margin-top: 6px !important;
  font-family: var(--font-display); font-weight: 500;
  font-size: 15px; letter-spacing: .3em; text-indent: .3em; color: var(--ink);
}
#cover .cv-date i { font-style: normal; color: var(--red); margin: 0 .25em; }

/* Gợi ý cuộn */
/* Gợi ý cuộn: chữ dọc ở mép phải (kiểu gáy tạp chí) — tránh thanh điều hướng nổi ở đáy */
#cover .cv-cue {
  position: absolute; right: 2.5cqw; top: 56%;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: auto; text-decoration: none;
  font-family: var(--font-sans); font-size: 11px; font-weight: 500; letter-spacing: .24em; text-transform: uppercase;
  color: var(--gold-deep);
  padding: 8px 6px;
  text-shadow: 0 0 6px rgba(255,253,248,1), 0 0 12px rgba(255,253,248,.95);
}
#cover .cv-cue span { writing-mode: vertical-rl; }
#cover .cv-cue b {
  display: block; width: 1px; height: 40px; position: relative; overflow: hidden;
  background: rgba(184,137,59,.3);
}
#cover .cv-cue b::after {
  content: ""; position: absolute; left: 0; top: 0; width: 1px; height: 14px; background: var(--gold-deep);
  animation: cv-cue 1.8s var(--ease-in-out) infinite;
}
@keyframes cv-cue { from { transform: translateY(-14px); } to { transform: translateY(40px); } }

/* ================= Entrance ================= */
/* Toàn bộ bìa hiện xong trong ~2.5s (trước đây ~4.4s) */
#cover .cv-scenery .cv-in { opacity: 0; transition: opacity 1.1s var(--ease-out); }
#cover .cv-mast .cv-in { opacity: 0; transform: translateY(-14px); transition: opacity 1s var(--ease-out) .25s, transform 1.2s var(--ease-out) .25s; }
#cover .cv-couple .cv-in { opacity: 0; transform: translateY(22px) scale(.98); transform-origin: 50% 100%; transition: opacity 1s var(--ease-out) .4s, transform 1.3s var(--ease-out) .4s; }
#cover .cv-arch .cv-in { opacity: 0; transform: scale(1.06); transition: opacity .9s var(--ease-out) .05s, transform 1.6s var(--ease-out) .05s; }
#cover .cv-peacock .cv-in { opacity: 0; transform: translateY(18px); transition: opacity .9s var(--ease-out) .6s, transform 1.2s var(--ease-out) .6s; }
#cover .cv-bird--a .cv-in { opacity: 0; transform: translate3d(-45cqw, 14cqw, 0) rotate(-8deg); transition: opacity .7s var(--ease-out) .7s, transform 1.7s var(--ease-out) .7s; }
#cover .cv-bird--b .cv-in { opacity: 0; transform: translate3d(40cqw, 12cqw, 0) rotate(8deg); transition: opacity .7s var(--ease-out) .85s, transform 1.7s var(--ease-out) .85s; }

#cover .cv-fx { opacity: 0; transition: opacity .8s var(--ease-out) var(--d, .3s), transform 1s var(--ease-out) var(--d, .3s); }
#cover .cv-fx--slide-l { transform: translateX(-24px); }
#cover .cv-fx--slide-r { transform: translateX(24px); }
#cover .cv-cue.cv-fx { transform: translateY(10px); }

#cover .cv-write {
  -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0);
  transition: -webkit-clip-path 1.1s var(--ease-in-out) var(--d, 1s), clip-path 1.1s var(--ease-in-out) var(--d, 1s);
}

#cover.is-played .cv-in { opacity: 1; transform: none; }
#cover.is-played .cv-fx { opacity: 1; transform: none; }
#cover.is-played .cv-write { -webkit-clip-path: inset(0 0 0 0); clip-path: inset(0 0 0 0); }
#cover.is-played .cv-title::before { opacity: 1; }

#cover.is-off .cv-scenery img, #cover.is-off .cv-bird img, #cover.is-off .cv-cue b::after { animation-play-state: paused; }

/* Màn thấp: thu nhỏ tên & coverline một chút */
@media (max-height: 760px) {
  #cover { --cv-ch: min(52%, 106cqw); }  /* cặp đôi thấp hơn → tên không đè quá sâu lên chân */
  #cover .cv-name { font-size: 13.5cqw; }
  #cover .cv-amp { font-size: 8.5cqw; }
  #cover .cv-kicker { font-size: 15px; }
  #cover .cv-lines { gap: 8px; }
  #cover .cv-lines--l { top: 29%; }
  #cover .cv-lines--r { top: 25%; }
  #cover .cv-cl { font-size: 14px; }
  #cover .cv-cl-kick { font-size: 10.5px; }
  #cover .cv-cue { top: 50%; }
}

/* Máy rất thấp (360×640…): cặp đôi nhỏ thêm để chân không chạm "Lễ Thành Hôn"; chim ruồi tránh coverline */
@media (max-height: 700px) {
  #cover { --cv-ch: min(47%, 100cqw); --cv-head: .24; }
  #cover .cv-bird--a { top: 16.5%; width: 12cqw; }
  #cover .cv-bird--b { top: 17%; }
  #cover .cv-lines--l { top: 30%; }
}

/* Chibi theo chiều cao màn (đầu đè chân "LOVE", chân cách "Lễ Thành Hôn" ≥ 10px) */
@media (max-height: 760px) {
  #cover.cv--chibi { --cv-ch: min(45.5%, 90cqw); --cv-head: .187; }
  #cover.cv--chibi .cv-lines--l { top: 46%; }
  #cover.cv--chibi .cv-lines--r { top: 29%; }
  #cover.cv--chibi .cv-cl, #cover.cv--chibi .cv-lines--l .cv-cl { font-size: 12.5px; }
}
@media (max-height: 700px) {
  #cover.cv--chibi { --cv-ch: min(43%, 86cqw); --cv-head: .185; }
  #cover.cv--chibi .cv-lines--l { top: 38%; left: 3.5cqw; width: 25.5cqw; }
  #cover.cv--chibi .cv-lines--r { top: 29%; }
}

/* ===== Chibi: KHÔNG chữ nào nằm trên hình (đo bằng pixel ở 360/390/430/460/480) =====
   - Chibi tối đa 80cqw (trước 94cqw) và tự thu nhỏ (--cv-fit) để chân luôn cách "Lễ Thành Hôn" ≥ 16px
     (--cv-title-h ≈ chiều cao khối tên + ngày, tỉ lệ theo cqw).
   - Coverline neo theo chính hình chibi (--cv-imgtop + tỉ lệ chiều cao), không theo % màn hình:
     cột phải nằm ở đoạn thân hẹp (≤ 66% chiều cao hình, mép phải hình ≤ 66.2cqw),
     cột trái (rộng theo chibi) nằm ở đoạn chân (≥ 79%, mép trái hình ≥ 30cqw). */
#cover.cv--chibi {
  --cv-ch: min(48.5%, 80cqw);
  --cv-title-h: calc(75px + 40.6cqw);
  --cv-lcol: 115px;                  /* chỗ dành cho cột coverline trái + khoảng thở */
  --cv-fit: calc((100% - var(--mast-top) - var(--mast-fs) * .8 - 84px - env(safe-area-inset-bottom, 0px) - var(--cv-title-h) - 16px) / (.99 - var(--cv-head)));
  /* cột coverline trái (~105px) nằm dưới mốc 79% hình và phải kết thúc ≥ 10px trên kicker */
  --cv-fit2: calc((100% - var(--mast-top) - var(--mast-fs) * .8 - 84px - env(safe-area-inset-bottom, 0px) - var(--cv-title-h) - var(--cv-lcol)) / (.79 - var(--cv-head)));
  --cv-chx: min(var(--cv-ch), var(--cv-fit), var(--cv-fit2));
  --cv-imgtop: calc(var(--mast-top) + var(--mast-fs) * .8 - var(--cv-chx) * var(--cv-head));
}
#cover.cv--chibi .cv-couple-img { height: var(--cv-chx); top: var(--cv-imgtop); }
#cover.cv--chibi .cv-lines--r {
  top: calc(var(--cv-imgtop) + var(--cv-chx) * .28);
  left: calc(66.5cqw + 12px); right: 3.5cqw; width: auto; max-width: none;
}
#cover.cv--chibi .cv-lines--l { top: calc(var(--cv-imgtop) + var(--cv-chx) * .79); left: 3cqw;
  width: calc(25cqw - 12px); } /* ≈ mép trái phần chân chibi (50cqw − .2475 × 80cqw) − 3cqw − 12px, trừ thêm 2.2cqw cho giày */
@media (max-height: 700px) { #cover.cv--chibi .cv-lines--l { width: 25cqw; } } /* chibi nhỏ hơn → cột rộng hơn, thấp hơn */
#cover.cv--chibi .cv-barcode { width: 100%; min-width: 0; max-width: 116px; }
#cover.cv--chibi .cv-bird--b { top: calc(var(--cv-imgtop) + var(--cv-chx) * .70); }
/* màn thấp: tên nhỏ hơn (13.5cqw) → khối tên thấp hơn */
@media (max-height: 760px) { #cover.cv--chibi { --cv-title-h: calc(70px + 34.3cqw); --cv-lcol: 96px; } }

@media (prefers-reduced-motion: reduce) {
  #cover .cv-scenery img, #cover .cv-bird img { animation: none; }
  #cover .cv-bird--b img { transform: scaleX(-1); }
  #cover .cv-cue b::after { animation: none; }
}
