/* =====================================================================
   Album "polaroid deck" — js/album.js dựng trong #albumMount.
   Chồng ảnh polaroid: kéo/vuốt ngang, tự chạy khi trong khung nhìn, chạm để xem toàn màn hình.
   Dùng lại biến màu của style.css (--wine, --ivory, --gold, --ink…) và có giá trị dự phòng.
   ===================================================================== */
.album-mount { width: 100%; }

.alb {
  /* bề rộng thẻ: điện thoại ≈ 72vw; máy tính theo rem (cỡ chữ gốc co giãn tới 28px) */
  --alb-w: min(72vw, 22rem, calc((100svh - 13rem) / 1.5 + 1rem));
  --alb-pad: 0.5rem;          /* viền trắng hai bên / trên ≈ 8px */
  --alb-foot: 2.375rem;       /* chân polaroid ≈ 38px mang chú thích */
  --alb-h: calc((var(--alb-w) - 2 * var(--alb-pad)) * 1.5 + var(--alb-pad) + var(--alb-foot));
  --alb-gold: var(--gold, #B58B2F);
  --alb-ink: var(--ink, #511419);
  --alb-paper: #FBF8F2;
  --alb-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .33 0 0 0 0 .25 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  position: relative;
  width: 100%;
  margin-top: 1.25rem;
  display: flex; flex-direction: column; align-items: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
@supports not (height: 1svh) {
  .alb { --alb-w: min(72vw, 22rem, calc((100vh - 13rem) / 1.5 + 1rem)); }
}
@media (min-width: 700px) {
  .alb { --alb-w: min(15.5rem, calc((100vh - 9rem) / 1.5 + 1rem)); }
}
.alb:focus-visible .alb-deck { outline: 2px solid var(--alb-gold); outline-offset: 1.25rem; border-radius: 0.25rem; }

/* sân khấu giữ chỗ trước (không nhảy bố cục) — chừa khoảng cho các thẻ nghiêng thò ra */
.alb-stage {
  position: relative;
  width: 100%;
  height: calc(var(--alb-h) + 3.25rem);
  touch-action: pan-y;               /* cuộn dọc vẫn là của trang */
  user-select: none; -webkit-user-select: none;
}
.alb-deck {
  position: absolute; top: 1.5rem; left: 50%;
  width: var(--alb-w); height: var(--alb-h);
  margin-left: calc(var(--alb-w) / -2);
  perspective: 75rem;
}

/* ---------- thẻ polaroid ---------- */
.alb-card {
  position: absolute; inset: 0;
  padding: var(--alb-pad) var(--alb-pad) var(--alb-foot);
  border-radius: 2px;
  background: var(--alb-grain), linear-gradient(172deg, #FFFDF9 0%, var(--alb-paper) 55%, #F3EEE4 100%);
  background-size: 200px 200px, 100% 100%;
  /* bóng đổ nhiều lớp mềm, đậm dần theo --sh (thẻ trên cùng cao nhất) */
  box-shadow:
    0 0 0 1px rgba(81, 20, 25, .05),
    0 1px 1px rgba(40, 12, 14, calc(.06 + var(--sh, .5) * .08)),
    0 0.25rem 0.5rem rgba(40, 12, 14, calc(.05 + var(--sh, .5) * .08)),
    0 0.9rem 1.6rem -0.3rem rgba(40, 12, 14, calc(.06 + var(--sh, .5) * .14));
  transform-origin: 50% 60%;
  will-change: transform;
  cursor: grab;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.alb-card.is-dragging { cursor: grabbing; }
/* bóng "nhấc lên" — độ mờ theo --lift do GSAP điều khiển */
.alb-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  box-shadow: 0 2.2rem 3.2rem -0.6rem rgba(30, 6, 10, .38), 0 0.9rem 1.4rem -0.2rem rgba(30, 6, 10, .22);
  opacity: var(--lift, 0);
}
/* lớp tối nhẹ cho thẻ nằm sâu */
.alb-card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: #2E0910;
  opacity: var(--dim, 0);
}
.alb-photo {
  position: relative;
  width: 100%; aspect-ratio: 2 / 3;
  overflow: hidden;
  background: linear-gradient(160deg, #E9DFD2, #DCCDBB);
  box-shadow: inset 0 0 0 1px rgba(60, 30, 20, .08);
}
.alb-photo img {
  position: absolute; inset: 0;
  display: block; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .6s ease;
  pointer-events: none; -webkit-user-drag: none; user-select: none;
}
.alb-photo img.is-loaded { opacity: 1; }
/* ánh giấy ảnh: vệt sáng rất nhẹ */
.alb-photo::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, .12) 0%, rgba(255, 255, 255, 0) 38%), var(--alb-grain);
  background-size: 100% 100%, 200px 200px;
  mix-blend-mode: soft-light; opacity: .35;
}
.alb-cap {
  position: absolute; left: var(--alb-pad); right: var(--alb-pad); bottom: 0; height: var(--alb-foot);
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0 0.25rem;
  font-family: var(--f-soft, Georgia), serif;
  color: var(--alb-ink);
  pointer-events: none;
}
.alb-cap-t { font-style: italic; font-weight: 500; font-size: 1.0625rem; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alb-cap-n { font-size: 0.75rem; font-weight: 600; letter-spacing: .14em; color: var(--alb-gold); font-variant-numeric: lining-nums tabular-nums; }

/* ---------- đếm + vạch tiến độ + nút ---------- */
.alb-meta {
  display: grid; grid-template-columns: 2.75rem auto 2.75rem; align-items: center; gap: 0.75rem;
  margin-top: 0.25rem;
}
.alb-count {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem; min-width: 7.5rem;
  font-family: var(--f-soft, Georgia), serif;
  font-size: 1rem; font-weight: 600; letter-spacing: .2em;
  font-variant-caps: all-small-caps; font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink-80, rgba(81, 20, 25, .82));
}
.alb-count b { font-weight: 600; color: var(--alb-ink); }
.alb-count .sep { margin: 0 0.35em; color: var(--alb-gold); }
.alb-bar { position: relative; display: block; width: 100%; height: 1px; background: rgba(181, 139, 47, .25); overflow: hidden; }
.alb-bar i { position: absolute; inset: 0; background: var(--alb-gold); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); transition: transform .9s cubic-bezier(.22, 1, .36, 1); }
.alb-btn {
  position: relative; width: 2.75rem; height: 2.75rem; min-width: 44px; min-height: 44px;
  display: grid; place-items: center; padding: 0;
  border: 0; background: none; color: var(--alb-ink); border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.alb-btn::before {
  content: ""; position: absolute; inset: 0.3rem; border-radius: 50%;
  border: 1px solid rgba(181, 139, 47, .55);
  background: rgba(255, 250, 242, .6);
  transition: transform .35s cubic-bezier(.22, 1, .36, 1), background-color .3s, border-color .3s;
}
.alb-btn:hover::before { transform: scale(1.08); background: rgba(255, 250, 242, .95); border-color: var(--alb-gold); }
.alb-btn:active::before { transform: scale(.94); }
.alb-btn svg { position: relative; width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

/* không có GSAP: chuyển cảnh CSS đơn giản */
.alb--css .alb-card { transition: transform .75s cubic-bezier(.22, 1.2, .36, 1), opacity .45s ease; }
.alb--css .alb-card.is-dragging { transition: none; }

/* =====================================================================
   LIGHTBOX
   ===================================================================== */
html.alb-lock, html.alb-lock body { overflow: hidden !important; }
.alb-lb {
  position: fixed; inset: 0; z-index: 1000;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  color: var(--ivory, #ECE4D8);
}
.alb-lb[hidden] { display: none; }
.alb-lb-bg {
  position: absolute; inset: 0;
  background: rgba(46, 9, 16, .92);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  backdrop-filter: blur(14px) saturate(1.1);
}
.alb-lb-frame {
  position: absolute;
  overflow: hidden;
  border-radius: 2px;
  background: #2A0A10;
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, .5), 0 0.4rem 1rem rgba(0, 0, 0, .3);
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  cursor: grab;
}
.alb-lb-kb { position: absolute; inset: 0; transform-origin: 50% 45%; will-change: transform; }
.alb-lb-kb img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  pointer-events: none; -webkit-user-drag: none; user-select: none;
}
.alb-lb-kb img.hi { opacity: 0; transition: opacity .5s ease; }
.alb-lb-kb img.hi.is-loaded { opacity: 1; }
.alb-lb-ui { position: absolute; inset: 0; pointer-events: none; }
.alb-lb-ui > * { pointer-events: auto; }
.alb-lb-btn {
  position: absolute; width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(236, 228, 216, .1);
  box-shadow: inset 0 0 0 1px rgba(236, 228, 216, .28);
  color: var(--ivory, #ECE4D8);
  transition: background-color .3s, transform .35s cubic-bezier(.22, 1, .36, 1);
}
.alb-lb-btn:hover { background: rgba(236, 228, 216, .2); transform: scale(1.06); }
.alb-lb-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.alb-lb-close { top: max(12px, env(safe-area-inset-top)); right: 12px; }
.alb-lb-prev, .alb-lb-next { top: 50%; margin-top: -22px; }
.alb-lb-prev { left: 12px; }
.alb-lb-next { right: 12px; }
@media (max-width: 699px) {
  .alb-lb-prev, .alb-lb-next { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); margin-top: 0; }
  .alb-lb-prev { left: 16px; }
  .alb-lb-next { right: 16px; }
}
.alb-lb-cap {
  position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  margin: 0; white-space: nowrap; text-align: center; pointer-events: none;
  font-family: var(--f-soft, Georgia), serif;
}
.alb-lb-cap .t { font-style: italic; font-size: 1.125rem; color: var(--ivory, #ECE4D8); }
.alb-lb-cap .c { font-size: 0.8125rem; font-weight: 600; letter-spacing: .22em; font-variant-caps: all-small-caps; font-variant-numeric: lining-nums tabular-nums; color: rgba(212, 178, 104, .9); }
.alb-lb--css .alb-lb-bg, .alb-lb--css .alb-lb-ui { transition: opacity .4s ease; }
.alb-lb--css .alb-lb-frame { transition: transform .55s cubic-bezier(.22, 1, .36, 1), opacity .45s ease; }
.alb-lb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@property --tone { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --tint { syntax: "<number>"; inherits: true; initial-value: 0; }

/* =====================================================================
   COVERFLOW (kiểu mặc định) — theo mẫu tham chiếu
   ===================================================================== */
.alb--cf { margin-top: 1.25rem; --acf-h: min(470px, 62svh); }
@supports not (height: 1svh) { .alb--cf { --acf-h: min(470px, 62vh); } }
/* sân khấu tràn hết bề ngang màn hình (thoát khỏi cột nội dung) */
.acf-wrap {
  position: relative;
  width: 100vw; max-width: none; height: var(--acf-h);
  margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw);
  touch-action: pan-y;
  user-select: none; -webkit-user-select: none;
  overflow: hidden; overflow: clip;
}
@media (min-width: 768px) {
  .alb--cf { --acf-h: min(40rem, 80vh); }
  @supports (height: 1svh) { .alb--cf { --acf-h: min(40rem, 80svh); } }
}
.acf {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  perspective: 1000px;
}
.acf-item {
  position: absolute;
  height: 92%; aspect-ratio: 0.666992 / 1;
  border-radius: 16px; overflow: hidden;
  background: linear-gradient(160deg, #E9DFD2, #DCCDBB);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .18), 0 8px 10px -6px rgba(0, 0, 0, .08), 0 0 0 2px rgba(255, 255, 255, .3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* ảnh hai bên cùng một tông ngả sepia nhạt; ảnh giữa giữ màu gốc (--tone 0) */
  --tone: 1; --tint: .14;
  /* --tone 0 (ảnh giữa): brightness 1.04 · contrast 1.03 · saturate 1.05, không sepia; --tone 1 (hai bên): ngả nhạt, tối và nhạt màu hơn */
  filter: sepia(calc(var(--tone) * .2)) saturate(calc(1.05 - var(--tone) * .3)) brightness(calc(1.04 - var(--tone) * .05)) contrast(calc(1.03 - var(--tone) * .07));
  transform-style: flat;
}
.acf-item::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  /* lớp ngà phủ nhẹ (ánh hồng đô rất mờ ở chân) — đậm dần theo độ xa */
  background: linear-gradient(180deg, rgb(247, 240, 230) 0%, rgb(244, 234, 222) 70%, rgb(236, 214, 206) 100%);
  opacity: var(--tint);
}
.acf-item { transition: box-shadow .6s ease; }
.acf-item.is-center {
  cursor: zoom-in;
  box-shadow: 0 24px 48px -12px rgba(46, 9, 16, .45), 0 8px 16px -8px rgba(46, 9, 16, .25), 0 0 0 2px rgba(255, 250, 240, .7);
}
/* không có GSAP: chuyển cảnh CSS như mẫu (biến tông đăng ký để chuyển mượt) */
.acf--css .acf-item { transition: all 1100ms ease-in-out, --tone 1100ms ease-in-out, --tint 1100ms ease-in-out; }
.acf--instant .acf-item { transition: none !important; }
.acf-item img {
  display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%;
  opacity: 0; transition: opacity .6s ease;
  pointer-events: none; -webkit-user-drag: none; user-select: none;
}
.acf-item img.is-loaded { opacity: 1; }
.alb--cf:focus-visible .acf-item.is-center { outline: 2px solid var(--alb-gold); outline-offset: 3px; }

/* ---------- điều hướng: chevron nét mảnh (không nền tròn), vùng chạm 44px ----------
   Hàng điều hướng ngay dưới ảnh giữa, rộng đúng bằng ảnh giữa: chevron thẳng mép trái/phải của ảnh,
   bộ đếm ở giữa — không đè lên ảnh nào (ảnh giữa rộng = cao sân khấu × .92 × .667 ≈ .614 × cao). */
.acf-nav {
  position: relative; z-index: 5;
  display: grid; place-items: center;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0;
  border: 0; border-radius: 50%; background: none; cursor: pointer;
  color: var(--wine, #5A1620);
  -webkit-tap-highlight-color: transparent;
  transition: color .3s ease, opacity .3s ease;
}
.acf-nav svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.25;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform .45s cubic-bezier(.22, 1, .36, 1);
}
.acf-nav:hover { color: #B8925A; }
.acf-prev:hover svg { transform: translateX(-3px); }
.acf-next:hover svg { transform: translateX(3px); }
.acf-nav:active svg { transform: scale(.92); }
.acf-nav:focus-visible { outline: 1px solid #B8925A; outline-offset: -2px; }

/* bộ đếm "03 — 21": chữ hiển thị của bìa, số đều nhau, vàng cổ + đỏ rượu */
.acf-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  width: max(14rem, calc(var(--acf-h) * .614 + 24px)); max-width: calc(100vw - 16px); margin-top: 0.5rem;
}
.acf-count {
  display: inline-flex; align-items: baseline; gap: 0.6em;
  font-family: var(--f-name, "Viaoda Libre"), Georgia, serif;
  font-size: 1.125rem; line-height: 1; letter-spacing: .14em;
  font-variant-caps: all-small-caps; font-variant-numeric: lining-nums tabular-nums;
  color: #B8925A; white-space: nowrap;
}
.acf-count b, .acf-total { display: inline-block; min-width: 2.1ch; text-align: center; }
.acf-count b { font-weight: 400; color: var(--wine, #5A1620); }
.acf-count .sep { color: #B8925A; opacity: .8; letter-spacing: 0; }
.acf-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (min-width: 700px) {
  .acf-nav svg { width: 26px; height: 26px; }
}
/* bóng mềm tạm thời cho hiệu ứng "trang sách" */
.acf-shade { position: absolute; inset: 0; z-index: 2; border-radius: inherit; pointer-events: none; opacity: 0; }
