/* GALLERY — "Album" (scoped under #gallery; lightbox under #gallery-lightbox) */
#gallery {
  background:
    radial-gradient(100% 50% at 0% 0%, rgba(233,225,210,.32) 0%, rgba(233,225,210,0) 65%),
    radial-gradient(100% 45% at 100% 100%, rgba(217,195,154,.3) 0%, rgba(217,195,154,0) 70%),
    var(--cream);
  padding-bottom: 84px;
}

/* ---------- Opener ---------- */
#gallery .ga-head { text-align: center; margin-bottom: 34px; }
#gallery .ga-kicker {
  margin: 0;
  font-family: var(--font-sans); font-size: 11px; font-weight: 500;
  letter-spacing: .34em; text-transform: uppercase; color: var(--rose);
}
#gallery .ga-title {
  margin: 0; padding: .08em .15em .16em;
  font-size: clamp(64px, 20vw, 88px); line-height: 1;
}
#gallery .ga-divider { width: min(220px, 64%); height: auto; margin: 4px auto 16px; }
#gallery .ga-deck {
  margin: 0 auto; max-width: 30ch;
  font-style: italic; font-size: 18px; line-height: 1.5; color: var(--ink-soft);
  text-wrap: balance;
}

/* ---------- Editorial grid ---------- */
#gallery .ga-grid {
  --u: clamp(46px, 13.6vw, 66px);
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(12, var(--u));
  gap: 8px;
}
#gallery .ga-frame--1 { grid-column: 1 / 5; grid-row: 1 / 6; }
#gallery .ga-frame--2 { grid-column: 5 / 7; grid-row: 1 / 4; }
#gallery .ga-frame--3 { grid-column: 5 / 7; grid-row: 4 / 7; }
#gallery .ga-frame--4 { grid-column: 1 / 4; grid-row: 6 / 10; }
#gallery .ga-frame--5 { grid-column: 4 / 7; grid-row: 7 / 10; }
#gallery .ga-frame--6 { grid-column: 1 / 7; grid-row: 10 / 13; }
#gallery .ga-orn {
  grid-column: 4 / 5; grid-row: 6 / 7;
  display: grid; place-items: center; pointer-events: none;
}
#gallery .ga-orn img { width: 80%; max-width: 44px; height: auto; opacity: .8; }

/* ----- 4 ảnh dọc (đêm thành phố): bố cục so le kiểu tạp chí — lớn/nhỏ rồi nhỏ/lớn ----- */
#gallery .ga-grid--4 {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: auto auto;
  column-gap: 10px; row-gap: 12px;
}
#gallery .ga-grid--4 .ga-frame { height: auto; aspect-ratio: 2 / 3; }
#gallery .ga-grid--4 .ga-frame--1 { grid-column: 1 / 8;  grid-row: 1; }
#gallery .ga-grid--4 .ga-frame--2 { grid-column: 8 / 13; grid-row: 1; align-self: end; }
#gallery .ga-grid--4 .ga-frame--3 { grid-column: 1 / 6;  grid-row: 2; align-self: start; }
#gallery .ga-grid--4 .ga-frame--4 { grid-column: 6 / 13; grid-row: 2; border-radius: 2px 2px 120px 120px; }
#gallery .ga-grid--4 .ga-frame--4::after { border-radius: 1px 1px 115px 115px; }
#gallery .ga-grid--4 .ga-frame--4 .ga-num { left: 50%; transform: translateX(-50%); bottom: 16px; }
#gallery .ga-grid--4 .ga-orn { grid-column: 8 / 13; grid-row: 1; align-self: start; padding-top: 14px; }
#gallery .ga-grid--4 .ga-orn img { max-width: 52px; }
/* chữ ký monogram lấp khoảng trống dưới ảnh 3 */
#gallery .ga-sign {
  grid-column: 1 / 6; grid-row: 2; align-self: end;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding-bottom: 10px; pointer-events: none;
}
#gallery .ga-sign i { display: block; width: 1px; height: 26px; background: linear-gradient(180deg, rgba(184,137,59,0), var(--gold)); }
#gallery .ga-sign b {
  font-family: var(--font-display); font-style: italic; font-weight: 500;
  font-size: 15px; letter-spacing: .14em; color: var(--gold-deep);
}
@supports not (aspect-ratio: 1) {
  #gallery .ga-grid--4 .ga-frame { height: 0; padding-bottom: 150%; }
}
/* ảnh đêm: nền khung tối để lúc đang tải không loé kem */
#gallery .ga-grid--4 .ga-frame:not(.is-ph) { background: #15120F; }

#gallery .ga-frame {
  position: relative; display: block; overflow: hidden;
  width: 100%; height: 100%; min-width: 0;
  margin: 0; padding: 0; border: 0; border-radius: 2px;
  background: linear-gradient(150deg, var(--blush), var(--peach));
  box-shadow: 0 0 0 1px rgba(184,137,59,.38), 0 14px 28px -20px rgba(59,51,43,.55);
  -webkit-tap-highlight-color: transparent;
  isolation: isolate;
}
#gallery .ga-frame--1 { border-radius: 120px 120px 2px 2px; } /* arched hero frame */
#gallery .ga-frame::after { /* fine inner gold keyline */
  content: ""; position: absolute; inset: 5px; z-index: 2; pointer-events: none;
  border: 1px solid rgba(255,253,248,.7); border-radius: inherit;
}
#gallery .ga-frame--1::after { border-radius: 115px 115px 1px 1px; }
#gallery .ga-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transition: transform 1.2s var(--ease-out);
}
@media (hover: hover) {
  #gallery .ga-frame:hover .ga-img,
  #gallery .ga-frame:hover .ga-ph-couple,
  #gallery .ga-frame:hover .ga-ph-flower { transform: scale(1.05); }
}
#gallery .ga-frame:active { filter: brightness(.97); } /* không dùng transform: FX tilt sở hữu transform của .ga-frame */
#gallery .ga-frame:focus-visible { outline: 2px solid var(--rose); outline-offset: 3px; }
#gallery .ga-num {
  position: absolute; left: 12px; bottom: 9px; z-index: 3;
  font-family: var(--font-display); font-style: italic; font-size: 13px; line-height: 1;
  color: var(--ivory); text-shadow: 0 1px 6px rgba(59,51,43,.45);
}
#gallery .ga-frame.is-ph .ga-num { color: var(--gold-deep); text-shadow: none; }
#gallery .ga-frame--1 .ga-num { left: 50%; transform: translateX(-50%); }

/* ---------- Placeholder (shared by grid + lightbox) ---------- */
#gallery .ga-ph, #gallery-lightbox .ga-ph {
  position: absolute; inset: 0; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
}
.ga-ph--1 { background: linear-gradient(165deg, #FBF5EA 0%, #EFE2C8 100%); }
.ga-ph--2 { background: linear-gradient(170deg, #F3EBDC 0%, #FBF6EE 100%); }
.ga-ph--3 { background: linear-gradient(160deg, #EFE7D7 0%, #FCF8F1 100%); }
.ga-ph--4 { background: linear-gradient(170deg, #F8F0E3 0%, #EEE2CC 100%); }
.ga-ph--5 { background: linear-gradient(165deg, #F2E8D6 0%, #FAF5EB 100%); }
.ga-ph--6 { background: linear-gradient(175deg, #FCF8F0 0%, #F1E6D3 55%, #EDE4D2 100%); }
#gallery .ga-ph::before, #gallery-lightbox .ga-ph::before { /* soft light bloom */
  content: ""; position: absolute; inset: -20%;
  background: radial-gradient(closest-side at 50% 35%, rgba(255,255,255,.7), rgba(255,255,255,0));
}
.ga-ph-flower {
  position: absolute; left: -12%; bottom: -12%; width: 92%; height: auto; opacity: .38;
  transition: transform 1.2s var(--ease-out);
}
.ga-ph--3 .ga-ph-flower, .ga-ph--5 .ga-ph-flower { left: auto; right: -12%; transform: scaleX(-1); }
.ga-ph-couple {
  position: absolute; left: 50%; bottom: -4%; height: 92%; width: auto; max-width: none;
  transform: translateX(-50%); opacity: .22;
  transition: transform 1.2s var(--ease-out);
}
#gallery .ga-frame:hover .ga-ph--3 .ga-ph-flower, #gallery .ga-frame:hover .ga-ph--5 .ga-ph-flower { transform: scaleX(-1) scale(1.05); }
#gallery .ga-frame:hover .ga-ph-couple { transform: translateX(-50%) scale(1.05); }
.ga-ph-mono { /* faint gold diamond motif, visible even if SVGs are missing */
  position: absolute; left: 50%; top: 40%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 1px solid rgba(184,137,59,.55); transform: rotate(45deg);
}
.ga-ph-mono::after { content: ""; position: absolute; inset: 3px; background: rgba(217,182,110,.45); }
.ga-ph-cap {
  position: relative; z-index: 1; display: block;
  margin: 0 8px 26px; text-align: center;
  font-family: var(--font-serif); font-style: italic; font-size: 13px; line-height: 1.25;
  color: var(--ink-soft);
}
#gallery .ga-frame--2 .ga-ph-cap, #gallery .ga-frame--3 .ga-ph-cap { font-size: 12px; margin-bottom: 24px; }
.ga-ph--big .ga-ph-cap { font-size: 17px; margin-bottom: 36px; }
.ga-ph--big .ga-ph-mono { width: 20px; height: 20px; margin: -10px 0 0 -10px; }

/* ---------- Caption key ---------- */
#gallery .ga-key {
  margin: 24px 0 0; padding-top: 14px;
  border-top: 1px solid rgba(184,137,59,.35);
  font-family: var(--font-serif); font-style: italic; font-size: 15px; line-height: 1.6; color: var(--ink-soft);
}
#gallery .ga-key-label {
  display: block; margin-bottom: 4px;
  font-family: var(--font-sans); font-style: normal; font-size: 10px; font-weight: 500;
  letter-spacing: .28em; text-transform: uppercase; color: var(--gold-deep);
}
#gallery .ga-key b {
  font-family: var(--font-display); font-style: normal; font-weight: 500; font-size: 13px; color: var(--gold-deep);
}
#gallery .ga-key-sep { color: var(--gold-light); }

/* ---------- Lightbox ---------- */
#gallery-lightbox {
  position: fixed; inset: 0; z-index: 9000;
  display: grid; grid-template-rows: auto 1fr auto;
  touch-action: none; overscroll-behavior: contain;
  -webkit-user-select: none; user-select: none;
  color: var(--ink);
}
#gallery-lightbox[hidden] { display: none; }
#gallery-lightbox .glb-backdrop {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 70% at 50% 40%, rgba(255,253,248,.96) 0%, rgba(251,247,240,.97) 55%, rgba(243,234,219,.97) 100%);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#gallery-lightbox .glb-top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 12px 8px 20px;
}
#gallery-lightbox .glb-count {
  font-family: var(--font-display); font-style: italic; font-size: 16px; letter-spacing: .08em; color: var(--gold-deep);
}
#gallery-lightbox .glb-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border-radius: 50%;
  background: rgba(255,253,248,.85); color: var(--gold-deep);
  border: 1px solid rgba(184,137,59,.45);
  box-shadow: 0 6px 18px -10px rgba(59,51,43,.5);
  transition: background-color .25s;
}
#gallery-lightbox .glb-btn:hover { background: #fff; }
#gallery-lightbox .glb-btn:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
#gallery-lightbox .glb-stage {
  position: relative; z-index: 1; min-height: 0;
  display: grid; place-items: center;
  touch-action: none;
}
#gallery-lightbox .glb-media {
  position: relative; overflow: hidden;
  border-radius: 3px;
  background: var(--ivory);
  box-shadow: 0 30px 60px -30px rgba(59,51,43,.55), 0 0 0 1px rgba(184,137,59,.3);
  will-change: transform, opacity;
}
#gallery-lightbox .glb-img {
  width: 100%; height: 100%; object-fit: contain; pointer-events: none;
}
#gallery-lightbox .glb-cap {
  position: relative; z-index: 2; margin: 0;
  padding: 10px 64px max(22px, env(safe-area-inset-bottom));
  text-align: center;
  font-family: var(--font-serif); font-style: italic; font-size: 18px; line-height: 1.4; color: var(--ink-soft);
  min-height: 3.2em;
}
#gallery-lightbox .glb-nav {
  position: absolute; z-index: 3; bottom: max(14px, env(safe-area-inset-bottom));
}
#gallery-lightbox .glb-prev { left: 12px; }
#gallery-lightbox .glb-next { right: 12px; }
@media (min-width: 700px) {
  #gallery-lightbox .glb-nav { bottom: auto; top: 50%; margin-top: -22px; }
  #gallery-lightbox .glb-prev { left: 24px; }
  #gallery-lightbox .glb-next { right: 24px; }
  #gallery-lightbox .glb-cap { padding-left: 24px; padding-right: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  #gallery .ga-img, .ga-ph-flower, .ga-ph-couple { transition: none; }
}
