/* ==========================================
 1. CHỦ ĐỀ MÀU SẮC & THIẾT LẬP HỆ THỐNG (CSS Variables)
 ========================================== */
 :root {
    --bg-cream: #fff5f8;
    --bg-rose: #ffe4ec;
    --bg-paper: #fff8fa;
    --bg-white: #ffffff;
    --color-gold: #f0a1b5;
    --color-bronze: #d46b8a;
    --color-dark: #3d2a32;
    --color-muted: #9a7a85;
  
    --shadow-soft: 0 10px 30px rgba(212, 107, 138, 0.1);
    --shadow-medium: 0 15px 45px rgba(212, 107, 138, 0.14);
    --shadow-hard: 0 25px 60px rgba(212, 107, 138, 0.2);
  
    --font-serif: "Playfair Display", Georgia, serif;
    --font-cursive: "Caveat", cursive;
    --font-sans: "Plus Jakarta Sans", system-ui, sans-serif;
  
    --transition-smooth: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-spring: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  
  /* Reset mặc định */
  #image-birthday,
  #image-birthday *,
  #image-birthday *::before,
  #image-birthday *::after {
    box-sizing: border-box;
  }

  #image-birthday {
    position: fixed;
    inset: 0;
    z-index: 50;
    color: var(--color-dark);
    font-family: var(--font-sans);
    line-height: 1.6;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.65s ease, visibility 0.65s ease;
  }

  #image-birthday.is-active {
    z-index: 90;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* Hiệu ứng hạt bụi cổ kính (Vintage Dust Overlay) */
  #image-birthday::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    opacity: 0.03;
    pointer-events: none;
    z-index: 9999;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  }
  
  /* Thước đo kích thước màn hình thông minh (Fluid Container) */
  #image-birthday .container {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: clamp(1.5rem, 5vw, 4rem) clamp(1rem, 3vw, 2.5rem);
    padding-bottom: calc(clamp(1.5rem, 5vw, 4rem) + 5.5rem + env(safe-area-inset-bottom, 0px));
  }

  /* Nút tiếp tục — kiểu pill giống textBirthday2 */
  #image-birthday .image-actions {
    position: fixed;
    left: 50%;
    bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px));
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    padding: clamp(0.35rem, 1.2vw, 0.55rem) clamp(0.7rem, 2.4vw, 1.1rem);
    border: 2px solid #f9a8d4;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.65) inset,
      0 0 16px rgba(244, 114, 182, 0.45),
      0 0 32px rgba(251, 113, 133, 0.28),
      0 8px 22px rgba(244, 114, 182, 0.18);
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    cursor: pointer;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    animation: image-actions-glow 2.4s ease-in-out infinite;
    transition: opacity 0.35s ease, transform 0.25s ease;
  }

  #image-birthday .image-actions.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  #image-birthday .image-actions:hover {
    transform: translateX(-50%) scale(1.04);
  }

  #image-birthday .image-actions:active {
    transform: translateX(-50%) scale(0.97);
  }

  @keyframes image-actions-glow {
    0%, 100% {
      border-color: #f9a8d4;
      box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.65) inset,
        0 0 14px rgba(244, 114, 182, 0.4),
        0 0 28px rgba(251, 113, 133, 0.22),
        0 8px 22px rgba(244, 114, 182, 0.16);
    }
    50% {
      border-color: #fb7185;
      box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.8) inset,
        0 0 22px rgba(244, 114, 182, 0.7),
        0 0 42px rgba(251, 113, 133, 0.42),
        0 10px 26px rgba(244, 114, 182, 0.24);
    }
  }

  #image-birthday .image-action-icon-wrap {
    display: block;
    opacity: 0;
    transform: translateY(18px) scale(0.86);
  }

  #image-birthday .image-action-icon {
    display: block;
    width: clamp(1.75rem, 5.8vw, 2.5rem);
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(244, 114, 182, 0.2));
    pointer-events: none;
    user-select: none;
  }

  @media (hover: none) {
    #image-birthday .image-actions:hover {
      transform: translateX(-50%);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    #image-birthday .image-actions {
      transition: none;
      animation: none;
    }
  }
  
  .page-banner {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto clamp(1.5rem, 4vw, 3rem);
    padding: clamp(0.35rem, 1.5vw, 1rem) 0 clamp(0.75rem, 2.5vw, 1.5rem);
    min-height: clamp(110px, 22vw, 220px);
    isolation: isolate;
  }
  
  /* Vầng sáng hồng phía sau banner */
  .page-banner::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(96%, 720px);
    height: 75%;
    transform: translate(-50%, -50%);
    background: radial-gradient(
      ellipse at center,
      rgba(255, 182, 203, 0.45) 0%,
      rgba(255, 228, 236, 0.25) 45%,
      transparent 72%
    );
    filter: blur(8px);
    z-index: -1;
    pointer-events: none;
    animation: bannerGlow 4.5s ease-in-out infinite alternate;
  }
  
  /* Đường nhấn trang trí hai bên */
  .page-banner::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    width: min(42%, 220px);
    height: 1px;
    transform: translateX(-50%);
    background: linear-gradient(
      90deg,
      transparent,
      rgba(240, 161, 181, 0.55),
      transparent
    );
    pointer-events: none;
  }
  
  .page-banner__frame {
    position: relative;
    width: min(96%, 680px);
    max-width: 100%;
  }

  #image-birthday.is-active .page-banner__frame {
    animation: bannerEnter 1.1s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  
  .page-banner__frame img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    object-position: center;
    filter: drop-shadow(0 12px 24px rgba(212, 107, 138, 0.22));
    transform-origin: center top;
  }

  #image-birthday.is-active .page-banner__frame img {
    animation: bannerFloat 5s ease-in-out infinite;
  }
  
  @keyframes bannerEnter {
    from {
      opacity: 0;
      transform: translateY(-18px) scale(0.94);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }
  
  @keyframes bannerFloat {
    0%,
    100% {
      transform: translateY(0) rotate(-0.4deg);
    }
    50% {
      transform: translateY(-6px) rotate(0.4deg);
    }
  }
  
  @keyframes bannerGlow {
    from {
      opacity: 0.7;
      transform: translate(-50%, -50%) scale(0.96);
    }
    to {
      opacity: 1;
      transform: translate(-50%, -50%) scale(1.06);
    }
  }
  
  @media (prefers-reduced-motion: reduce) {
    .page-banner__frame,
    .page-banner__frame img,
    .page-banner::before {
      animation: none;
    }
  }
  
  /* ==========================================
   2. BỐ CỤC GALLERY CHÍNH (Artistic Non-Grid Layout)
   ========================================== */
  .gallery-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: clamp(1.5rem, 4vw, 3.5rem);
    align-items: start;
  }
  
  /* Các kiểu khung nghệ thuật */
  .gallery-item {
    position: relative;
    cursor: pointer;
    will-change: transform, opacity;
    /* Hiệu ứng ẩn mặc định cho Intersection Observer */
    opacity: 0;
    transform: translateY(60px) scale(0.95);
    filter: blur(10px);
    transition:
      opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1),
      transform 1.2s cubic-bezier(0.16, 1, 0.3, 1),
      filter 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  }
  
  /* Trạng thái được kích hoạt bởi Observer */
  .gallery-item.revealed {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(var(--rotation, 0deg));
    filter: blur(0);
  }
  
  /* Phân bổ các nhóm/vùng hiển thị bất đối xứng trên desktop */
  /* Polaroid Card Styles */
  .gallery-item.polaroid-style {
    background: linear-gradient(180deg, #ffffff 0%, #fff5f8 100%);
    padding: 16px 16px 40px 16px;
    box-shadow: var(--shadow-medium);
    border-radius: 4px;
    border: 1px solid rgba(240, 161, 181, 0.28);
    display: flex;
    flex-direction: column;
    position: relative;
  }
  
  /* Giấy nhám sần cổ điển cho Polaroid */
  .gallery-item.polaroid-style::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    border-radius: inherit;
    box-shadow: inset 0 0 30px rgba(240, 161, 181, 0.08);
    background-image: radial-gradient(
      rgba(240, 161, 181, 0.08) 1px,
      transparent 1px
    );
    background-size: 4px 4px;
  }
  
  /* Decor Washi tape ngẫu nhiên trên Polaroid */
  .washi-tape {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%) rotate(-3deg);
    width: 100px;
    height: 28px;
    background: rgba(240, 161, 181, 0.35);
    backdrop-filter: blur(1px);
    box-shadow: 0 2px 5px rgba(212, 107, 138, 0.08);
    z-index: 3;
    border-left: 2px dashed rgba(212, 107, 138, 0.25);
    border-right: 2px dashed rgba(212, 107, 138, 0.25);
  }
  
  .gallery-item.polaroid-style:nth-child(even) .washi-tape {
    transform: translateX(-50%) rotate(5deg);
    background: rgba(255, 228, 236, 0.7);
  }
  
  .polaroid-image-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background-color: #eaeaea;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.05);
  }
  
  .polaroid-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: sepia(0.15) contrast(1.02) saturate(1.1);
    transition: var(--transition-smooth);
  }
  
  .polaroid-caption-zone {
    margin-top: 16px;
    text-align: center;
  }
  
  .polaroid-caption {
    font-family: var(--font-cursive);
    font-size: clamp(1.4rem, 2vw, 1.9rem);
    color: var(--color-bronze);
    line-height: 1.1;
    transition: var(--transition-smooth);
  }
  
  /* Photobooth Strip Styles */
  .gallery-item.photobooth-style {
    background: linear-gradient(180deg, #ffffff 0%, #fff0f5 100%);
    padding: clamp(10px, 1.5vw, 16px);
    box-shadow: var(--shadow-hard);
    border-radius: 2px;
    border: 1px solid rgba(240, 161, 181, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    max-width: 260px;
    width: 100%;
    justify-self: center;
    cursor: default;
  }
  
  /* Phủ hiệu ứng nhựa bóng loáng lên photobooth */
  .gallery-item.photobooth-style::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.18) 0%,
      rgba(255, 255, 255, 0) 50%,
      rgba(255, 255, 255, 0.08) 100%
    );
    pointer-events: none;
    z-index: 5;
  }
  
  /* Hiệu ứng lỗ xé giấy răng cưa cổ điển (Perforated Edge) ở hai đầu strip */
  .photobooth-edge-top,
  .photobooth-edge-bottom {
    position: absolute;
    left: 0;
    width: 100%;
    height: 8px;
    background-size: 16px 8px;
    pointer-events: none;
    z-index: 4;
  }
  
  .photobooth-edge-top {
    top: -4px;
    background-image: radial-gradient(
      circle,
      transparent 4px,
      var(--bg-cream) 4px
    );
  }
  
  .photobooth-edge-bottom {
    bottom: -4px;
    background-image: radial-gradient(
      circle,
      transparent 4px,
      var(--bg-cream) 4px
    );
  }
  
  .photobooth-strip {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  
  .photobooth-frame {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: #f0f0f0;
  }
  
  .photobooth-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
  }
  
  .photobooth-brand {
    width: 100%;
    text-align: center;
    margin-top: 12px;
    font-family: var(--font-serif);
    font-size: clamp(0.75rem, 1.2vw, 0.95rem);
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--color-gold);
    position: relative;
  }
  
  .gallery-status {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-muted);
    font-family: var(--font-serif);
    font-style: italic;
  }
  
  /* ==========================================
   4. TỔ CHỨC CÁC BỨC ẢNH KHÔNG ĐỒNG ĐỀU (Asymmetric Layout)
   Sử dụng Grid Column để tạo sự lộn xộn mang tính nghệ thuật cao.
   ========================================== */
  @media (min-width: 1025px) {
    .gallery-item:nth-child(1) {
      grid-column: span 4;
      --rotation: -2deg;
      margin-top: 30px;
    }
    .gallery-item:nth-child(2) {
      grid-column: span 4;
      --rotation: 3deg;
    }
    .gallery-item:nth-child(3) {
      grid-column: span 4;
      --rotation: -1deg;
      margin-top: 60px;
    }
    .gallery-item:nth-child(4) {
      grid-column: span 4;
      --rotation: 1.5deg;
      margin-left: 10%;
    }
    .gallery-item:nth-child(5) {
      grid-column: span 3;
      --rotation: -4deg;
      margin-top: 100px;
    }
    .gallery-item:nth-child(6) {
      grid-column: span 4;
      --rotation: 2deg;
      margin-top: 40px;
    }
    .gallery-item:nth-child(7) {
      grid-column: span 4;
      --rotation: -3deg;
    }
    .gallery-item:nth-child(8) {
      grid-column: span 4;
      --rotation: -1deg;
      margin-right: 10%;
      margin-top: -50px;
    }
    .gallery-item:nth-child(9) {
      grid-column: span 3;
      --rotation: 4deg;
      margin-top: 80px;
    }
  }
  
  @media (min-width: 768px) and (max-width: 1024px) {
    .gallery-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 2rem;
    }
    .gallery-item {
      grid-column: span 1 !important;
      margin-top: 0 !important;
      margin-left: 0 !important;
      margin-right: 0 !important;
      --rotation: 1.5deg;
    }
    .gallery-item:nth-child(even) {
      --rotation: -1.5deg;
    }
  }
  
  @media (max-width: 767px) {
    /* Chuyển thành dạng Masonry / Cuộn dọc đơn tầng cho di động */
    .gallery-grid {
      display: flex;
      flex-direction: column;
      gap: 2.5rem;
      padding: 0 5px;
    }
    .gallery-item {
      width: 100%;
      --rotation: 0deg !important; /* Không quay nghiêng trên mobile để tập trung diện tích */
      transform: translateY(30px) scale(0.98);
    }
    .washi-tape {
      width: 80px;
      height: 22px;
    }
  }
  
  /* ==========================================
   5. HIỆU ỨNG HOVER (Sophisticated Hover Interaction)
   ========================================== */
  @media (hover: hover) {
    .gallery-item {
      transition:
        opacity 1s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.7s cubic-bezier(0.25, 1, 0.5, 1),
        filter 1s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.7s cubic-bezier(0.25, 1, 0.5, 1);
    }
  
    /* Hover Polaroid */
    .gallery-item.polaroid-style:hover {
      transform: translateY(-15px) scale(1.04)
        rotate(calc(var(--rotation, 0deg) * 0.4));
      box-shadow: var(--shadow-hard);
      z-index: 10;
    }
  
    .gallery-item.polaroid-style:hover .polaroid-image-container img {
      transform: scale(1.06);
      filter: sepia(0.05) contrast(1.05) saturate(1.15);
    }
  
    .gallery-item.polaroid-style:hover .polaroid-caption {
      color: var(--color-gold);
      text-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
    }
  
    /* Hover Photobooth */
    .gallery-item.photobooth-style:hover {
      transform: translateY(-15px) scale(1.03)
        rotate(calc(var(--rotation, 0deg) * 0.3));
      box-shadow: 0 35px 80px rgba(212, 107, 138, 0.28);
      z-index: 10;
    }
  
    .gallery-item.photobooth-style:hover .photobooth-frame img {
      transform: scale(1.04);
      filter: brightness(1.03);
    }
  }
  
  /* ==========================================
   6. LIGHTBOX HOÀN CHỈNH (Professional Fullscreen Modal)
   ========================================== */
  .lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(18, 11, 6, 0.95);
    backdrop-filter: blur(15px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  }
  
  .lightbox-overlay.active {
    opacity: 1;
    pointer-events: all;
  }
  
  .lightbox-wrapper {
    position: relative;
    width: 90%;
    max-width: 750px;
    height: 80%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
  }
  
  .lightbox-content-box {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  
  .lightbox-overlay.active .lightbox-content-box {
    transform: scale(1) translateY(0);
  }
  
  /* Lightbox: chỉ hiện ảnh phóng to */
  .lightbox-image-only {
    max-height: 90%;
    max-width: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .lightbox-image-only img {
    max-width: min(90vw, 900px);
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  }
  
  .photobooth-frame.is-clickable {
    cursor: pointer;
  }
  
  /* Điều hướng Lightbox (Nút bấm xịn) */
  .lightbox-btn {
    position: absolute;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: clamp(45px, 6vw, 60px);
    height: clamp(45px, 6vw, 60px);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    z-index: 1010;
  }
  
  .lightbox-btn:hover {
    background: var(--bg-white);
    color: var(--color-dark);
    transform: scale(1.1);
  }
  
  .lightbox-prev {
    left: clamp(-10px, 1vw, 20px);
  }
  
  .lightbox-next {
    right: clamp(-10px, 1vw, 20px);
  }
  
  .lightbox-close {
    top: clamp(-50px, -2vw, -20px);
    right: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
  
  /* Chỉ thị số lượng ảnh ở chân */
  .lightbox-counter {
    position: absolute;
    bottom: -30px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    letter-spacing: 1.5px;
  }
  