/* =========================================================================================
 * 5. VƯỜN HOA LÚC HOÀNG HÔN: trời, mây, đồi xa, hồ; thảm hoa hai lớp; vòng ảnh; bảng tên
 * Thứ tự lớp (z-index): trời 0 → cánh đồng hoa xa 10 → ảnh 20–30 → thảm hoa gần 40
 *                       → cánh hoa bay, bướm, đốm sáng 45 → chữ, nút 50–60 → màn trời tối 100
 * ========================================================================================= */
body[data-current="garden"] {
  background: #f6c9d6;
}

.garden-scene {
  position: relative;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------------------------------------------------------------- Trời hoàng hôn */
.g-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, #e9b9d6 0%, #f6c6d6 22%, #fdd7d3 44%, #ffe2cf 54%, #f8cbd6 62%, #f3bfd0 100%);
}

.g-sun {
  position: absolute;
  left: 50%;
  bottom: 40dvh;
  width: 70vmin;
  height: 70vmin;
  margin-left: -35vmin;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 246, 228, 0.95) 0%, rgba(255, 228, 206, 0.7) 18%, rgba(255, 214, 214, 0.25) 45%, transparent 70%);
  animation: gSun 6s ease-in-out infinite;
}

@keyframes gSun {
  50% {
    transform: scale(1.06);
    opacity: 0.9;
  }
}

.g-clouds {
  position: absolute;
  left: 0;
  width: calc(100% + var(--cloud-w, 1200px));
  background-repeat: repeat-x;
  will-change: transform;
}

.g-clouds.near {
  top: 12dvh;
  height: 24dvh;
  opacity: 0.95;
}

.g-clouds.far {
  top: 24dvh;
  height: 16dvh;
  opacity: 0.6;
}

.g-hills {
  position: absolute;
  left: 0;
  bottom: 44dvh;
  width: 100%;
  height: 15dvh;
}

/* Mặt hồ phản chiếu ánh hoàng hôn, vài vệt sáng lấp lánh */
.g-lake {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 40dvh;
  height: 5dvh;
  background: linear-gradient(180deg, #f4c4d8, #fbd9dc 50%, #f2c0d2);
}

.g-lake i {
  position: absolute;
  left: 50%;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.85);
  animation: gGlint 3.2s ease-in-out infinite;
}

.g-lake i:nth-child(1) {
  top: 22%;
  width: 70px;
  margin-left: -35px;
}

.g-lake i:nth-child(2) {
  top: 48%;
  width: 120px;
  margin-left: -50px;
  animation-delay: 1s;
}

.g-lake i:nth-child(3) {
  top: 72%;
  width: 46px;
  margin-left: -10px;
  animation-delay: 2s;
}

@keyframes gGlint {
  50% {
    opacity: 0.2;
    transform: scaleX(0.6);
  }
}

/* Nền cỏ dưới cánh đồng hoa xa, để khe giữa các bông ở lớp gần không lộ màu trời */
.g-ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 24dvh;
  z-index: 10;
  background: linear-gradient(180deg, #78b05f, #4f8f42);
}

/* ---------------------------------------------------------------- Thảm hoa
 * .g-sway: lớp bọc đung đưa theo gió (nghiêng nhẹ quanh mép dưới) · .g-hedge: dải hoa trôi ngang (JS) */
.g-sway {
  position: absolute;
  left: -4%;
  right: -4%;
  pointer-events: none;
  transform-origin: 50% 100%;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.garden-scene.ready .g-sway {
  opacity: 1;
}

.g-sway.back {
  bottom: 22dvh;
  height: 24dvh;
  z-index: 10;
  animation: gWind 5.5s ease-in-out infinite alternate;
}

.g-sway.front {
  bottom: -1dvh;
  height: 38dvh;
  z-index: 40;
  animation: gWind 4.2s ease-in-out -1.3s infinite alternate;
}

@keyframes gWind {
  from {
    transform: skewX(-1.6deg);
  }
  to {
    transform: skewX(1.6deg) scaleY(1.015);
  }
}

.g-hedge {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background-repeat: repeat-x;
  background-position: 0 100%;
  will-change: transform;
}

.g-hedge.back {
  width: calc(100% + var(--back-w, 1200px));
}

.g-hedge.front {
  width: calc(100% + var(--front-w, 1400px));
}

/* ---------------------------------------------------------------- Hàng ảnh đứng trong vườn */
.g-row {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.g-photo {
  position: absolute;
  left: 0;
  bottom: 15dvh;
  height: min(46dvh, 540px);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transform-origin: 50% 100%;
  will-change: transform;
}

.g-photo img {
  display: block;
  height: 100%;
  width: auto;
  pointer-events: none;
  /* Viền sáng mảnh quanh người + bóng hồng mềm, như ảnh được ánh hoàng hôn chiếu ngược */
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.95)) drop-shadow(0 8px 16px rgba(160, 60, 100, 0.25));
}

/* Tấm đang đi qua giữa màn hình thì sáng hơn một chút */
.g-photo img {
  transition: filter 0.6s ease;
}

.g-photo.center img {
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 14px rgba(255, 236, 214, 0.9)) drop-shadow(0 10px 18px rgba(160, 60, 100, 0.28));
}

.g-photo:focus-visible {
  outline: none;
}

.g-photo:focus-visible img {
  filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 10px #ff8fb3);
}

/* Tim nhỏ bay lên khi chạm ảnh */
.g-heart {
  position: absolute;
  z-index: 46;
  font-size: 18px;
  color: #ff5c8a;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  animation: gHeart 1.5s ease-out both;
}

@keyframes gHeart {
  from {
    opacity: 0;
    transform: translate(0, 0) scale(0.4);
  }
  20% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translate(var(--dx), -120px) scale(1.15);
  }
}

/* ---------------------------------------------------------------- Cánh hoa bay ngang theo gió */
.g-petals {
  position: absolute;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  overflow: hidden;
}

.g-petals i {
  position: absolute;
  left: 104%;
  width: 12px;
  height: 9px;
  border-radius: 80% 10% 80% 10%;
  background: linear-gradient(135deg, #ffd3e2, #f27aa3);
  opacity: 0.9;
  animation: gPetal 9s linear infinite;
}

.g-petals i:nth-child(3n) {
  background: linear-gradient(135deg, #fff, #ffc2d6);
  width: 9px;
  height: 7px;
}

.g-petals i:nth-child(4n) {
  background: linear-gradient(135deg, #ffe6a8, #ffb35c);
}

.g-petals i:nth-child(1) { top: 18%; animation-delay: 0s; }
.g-petals i:nth-child(2) { top: 34%; animation-delay: -1.4s; animation-duration: 11s; }
.g-petals i:nth-child(3) { top: 52%; animation-delay: -2.8s; }
.g-petals i:nth-child(4) { top: 26%; animation-delay: -4.1s; animation-duration: 12s; }
.g-petals i:nth-child(5) { top: 44%; animation-delay: -5.3s; }
.g-petals i:nth-child(6) { top: 62%; animation-delay: -6.6s; animation-duration: 10s; }
.g-petals i:nth-child(7) { top: 12%; animation-delay: -7.7s; animation-duration: 13s; }
.g-petals i:nth-child(8) { top: 40%; animation-delay: -3.5s; animation-duration: 8s; }
.g-petals i:nth-child(9) { top: 70%; animation-delay: -8.4s; }
.g-petals i:nth-child(10) { top: 22%; animation-delay: -2.2s; animation-duration: 10.5s; }
.g-petals i:nth-child(11) { top: 56%; animation-delay: -9.6s; animation-duration: 12.5s; }
.g-petals i:nth-child(12) { top: 32%; animation-delay: -6s; animation-duration: 9.5s; }

@keyframes gPetal {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(-30vw, 4vh) rotate(160deg);
  }
  50% {
    transform: translate(-60vw, -2vh) rotate(320deg);
  }
  75% {
    transform: translate(-90vw, 6vh) rotate(480deg);
  }
  100% {
    transform: translate(-118vw, 10vh) rotate(640deg);
  }
}

/* ---------------------------------------------------------------- Bướm & đốm sáng */
.g-butterfly {
  position: absolute;
  z-index: 45;
  width: 30px;
  pointer-events: none;
  animation: gFly1 16s ease-in-out infinite;
}

.g-butterfly svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.g-butterfly .wl,
.g-butterfly .wr > g {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: gFlap 0.24s ease-in-out infinite alternate;
}

.g-butterfly.b2 {
  width: 24px;
  animation: gFly2 19s ease-in-out -4s infinite;
}

.g-butterfly.b3 {
  width: 20px;
  animation: gFly1 23s ease-in-out -11s infinite;
}

@keyframes gFlap {
  to {
    transform: scaleX(0.2);
  }
}

@keyframes gFly1 {
  0% {
    left: -8%;
    top: 58%;
  }
  25% {
    left: 30%;
    top: 46%;
  }
  50% {
    left: 62%;
    top: 55%;
  }
  75% {
    left: 84%;
    top: 40%;
  }
  100% {
    left: 108%;
    top: 50%;
  }
}

@keyframes gFly2 {
  0% {
    left: 106%;
    top: 36%;
  }
  30% {
    left: 70%;
    top: 48%;
  }
  60% {
    left: 26%;
    top: 38%;
  }
  100% {
    left: -10%;
    top: 52%;
  }
}

.g-motes {
  position: absolute;
  inset: 0;
  z-index: 45;
  pointer-events: none;
}

.g-motes i {
  position: absolute;
  bottom: 20%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fffaf0;
  box-shadow: 0 0 8px 2px rgba(255, 236, 200, 0.8);
  opacity: 0;
  animation: gMote 7s linear infinite;
}

.g-motes i:nth-child(odd) {
  width: 3px;
  height: 3px;
}

.g-motes i:nth-child(1) { left: 6%; animation-delay: 0s; }
.g-motes i:nth-child(2) { left: 14%; animation-delay: 2.1s; }
.g-motes i:nth-child(3) { left: 22%; animation-delay: 4.3s; }
.g-motes i:nth-child(4) { left: 31%; animation-delay: 1.2s; }
.g-motes i:nth-child(5) { left: 39%; animation-delay: 5.5s; }
.g-motes i:nth-child(6) { left: 46%; animation-delay: 3.1s; }
.g-motes i:nth-child(7) { left: 53%; animation-delay: 0.7s; }
.g-motes i:nth-child(8) { left: 61%; animation-delay: 4.9s; }
.g-motes i:nth-child(9) { left: 68%; animation-delay: 2.6s; }
.g-motes i:nth-child(10) { left: 75%; animation-delay: 6.1s; }
.g-motes i:nth-child(11) { left: 82%; animation-delay: 1.7s; }
.g-motes i:nth-child(12) { left: 89%; animation-delay: 3.8s; }
.g-motes i:nth-child(13) { left: 95%; animation-delay: 5.2s; }
.g-motes i:nth-child(14) { left: 50%; animation-delay: 6.6s; }

@keyframes gMote {
  0% {
    opacity: 0;
    transform: translate(0, 0);
  }
  15% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate(18px, -42dvh);
  }
}

/* ---------------------------------------------------------------- Dải băng tiêu đề, bảng tên, nút */
.g-head {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  z-index: 50;
  text-align: center;
  pointer-events: none;
}

.g-banner {
  display: block;
  width: min(92vw, 420px);
  margin: 0 auto;
  filter: drop-shadow(0 6px 10px rgba(170, 60, 100, 0.2));
}

.g-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.g-foot .btn {
  pointer-events: auto;
}

/* Lời nhắn của tấm ảnh đang đi qua giữa màn hình, nằm ngay dưới dải băng tiêu đề */
.g-plate {
  display: inline-block;
  max-width: min(90vw, 400px);
  margin: 2px auto 0;
  padding: 8px 18px;
  border-radius: 18px;
  background: rgba(255, 249, 251, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 20px rgba(150, 50, 90, 0.14), inset 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}

.g-cap {
  display: block;
  font-family: var(--font-hand);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
  color: #b23a63;
}

.g-plate.swap .g-cap {
  animation: gSwap 0.6s ease both;
}

@keyframes gSwap {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Bấm tiếp tục: trời tối dần trước khi sang bầu trời lời chúc */
.g-dusk {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: linear-gradient(180deg, #120818 0%, #2a1238 60%, #3a1640 100%);
  opacity: 0;
  transition: opacity 1.4s ease;
}

.garden-scene.night-falls .g-dusk {
  opacity: 1;
}

/* ---------------------------------------------------------------- Nối với các cảnh trước */
.g-photo[hidden] {
  display: none;
}

/* Bó hoa bạng cắm buổi sáng, đứng giữa vườn cùng hàng ảnh */
.g-bq {
  display: block;
  aspect-ratio: 400 / 520;
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.9)) drop-shadow(0 10px 16px rgba(160, 60, 100, 0.25));
}

.g-bq svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Dây ảnh vừa chụp buổi chiều, giăng trên trời hoàng hôn */
.g-line {
  position: absolute;
  left: 3%;
  right: 3%;
  top: 27dvh;
  height: 8dvh;
  z-index: 15;
  pointer-events: none;
}

.g-line svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.g-minis {
  position: absolute;
  inset: 0;
}

.g-mini {
  position: absolute;
  border: 0;
  cursor: pointer;
  pointer-events: auto;
  width: min(10vw, 46px);
  padding: 3px 3px 8px;
  background: #fffdf8;
  box-shadow: 0 4px 10px rgba(140, 60, 90, 0.22);
  transform: translateX(-50%) rotate(var(--tilt));
  transform-origin: 50% 0;
  animation: gMini 3.2s ease-in-out infinite alternate;
}

.g-mini::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 5px;
  height: 12px;
  margin-left: -2.5px;
  border-radius: 1.5px;
  background: linear-gradient(90deg, #d9a877, #f1cfa2 50%, #c8925f);
}

.g-mini img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

@keyframes gMini {
  from {
    transform: translateX(-50%) rotate(calc(var(--tilt) - 3deg));
  }
  to {
    transform: translateX(-50%) rotate(calc(var(--tilt) + 3deg));
  }
}

.g-head .chapter {
  margin: 0 0 -2px;
  color: #a2466d;
  text-shadow: 0 1px 6px rgba(255, 255, 255, 0.9);
}

/* Ô ảnh trên dây chưa chụp: chỉ còn chiếc kẹp chờ sẵn */
.g-mini.empty {
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.g-mini.empty img {
  visibility: hidden;
}

.g-mini.swing {
  animation: gMiniIn 1.3s ease-out, gMini 3.2s ease-in-out 1.3s infinite alternate;
}

@keyframes gMiniIn {
  0% {
    transform: translateX(-50%) rotate(calc(var(--tilt) + 16deg));
  }
  40% {
    transform: translateX(-50%) rotate(calc(var(--tilt) - 9deg));
  }
  70% {
    transform: translateX(-50%) rotate(calc(var(--tilt) + 4deg));
  }
  100% {
    transform: translateX(-50%) rotate(var(--tilt));
  }
}

/* Máy ảnh ở chân vườn, trên lớp hoa gần */
.g-foot .cam-wrap {
  margin-bottom: -4px;
}
