/* ============================================================
   gallery.css — Polaroid Gallery & Full-Screen Viewer
   Appended to the main website styles.
   ============================================================ */

/* ══════════════════════════════════════════
   POLAROID GRID
══════════════════════════════════════════ */
.gallery-section {
  background: linear-gradient(170deg, #fff5f8 0%, #ffe8f2 60%, #fdf0f5 100%);
  /* Override old gallery grid rules — polaroid layout takes over */
}

.polaroid-grid {
  display: grid;
  /* 1 col mobile → 2 col tablet → 3 col desktop → 5 col widescreen */
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 85vw), 1fr));
  gap: 2.4rem 2rem;
  width: 100%;
  max-width: 1200px;
  padding: 1rem 0.5rem 2rem;
}

/* ── Individual Polaroid ── */
.polaroid {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  /* Random slight tilt — overridden by JS per card for variety */
  --tilt: 0deg;
  --float-dur: 5s;
  --float-delay: 0s;
  transform: rotate(var(--tilt));
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.35s ease,
              filter 0.35s ease;
  filter: drop-shadow(0 10px 24px rgba(214, 48, 96, 0.22));
  position: relative;
  animation:
    polaroidReveal 0.65s cubic-bezier(0.34,1.56,0.64,1) both,
    polaroidFloat var(--float-dur) ease-in-out var(--float-delay) infinite;
}

.polaroid:hover {
  animation-play-state: paused;
  transform: rotate(0deg) translateY(-12px) scale(1.05);
  filter: drop-shadow(0 22px 42px rgba(214, 48, 96, 0.38));
  z-index: 10;
}

@keyframes polaroidReveal {
  from { opacity: 0; transform: rotate(var(--tilt)) translateY(30px) scale(0.88); }
  to   { opacity: 1; transform: rotate(var(--tilt)) translateY(0)    scale(1); }
}

@keyframes polaroidFloat {
  0%, 100% { transform: rotate(var(--tilt)) translateY(0px); }
  50%      { transform: rotate(calc(var(--tilt) * 0.6)) translateY(-8px); }
}

/* ── Romantic Pink Polaroid Frame ── */
.polaroid-inner {
  background: linear-gradient(165deg, #fff6f9 0%, #ffe3ee 60%, #ffd2e4 100%);
  border: 1.5px solid rgba(255, 128, 170, 0.55);
  padding: 0.75rem 0.75rem 0.45rem;
  border-radius: 8px;
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 4px 12px rgba(214, 48, 96, 0.12),
    0 8px 24px rgba(214, 48, 96, 0.08);
  width: 100%;
}

/* ── Image Area ── */
.polaroid-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;        /* square photo area */
  overflow: hidden;
  background: var(--blush, #fde8ef);
  border-radius: 2px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.polaroid-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.polaroid:hover .polaroid-img {
  transform: scale(1.07);
}

/* Placeholder icon shown when image fails */
.polaroid-placeholder {
  display: none;
  font-size: 3rem;
  color: var(--pink-200, #ffb3cc);
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
}

.polaroid-img-wrap.no-photo .polaroid-img     { display: none; }
.polaroid-img-wrap.no-photo .polaroid-placeholder {
  display: flex;
}

/* Add a subtle "photo slot" texture to empty frames */
.polaroid-img-wrap.no-photo {
  background: repeating-linear-gradient(
    45deg,
    #fff0f5,
    #fff0f5 8px,
    #ffe8f2 8px,
    #ffe8f2 16px
  );
}

/* ── Decorative Tape Strip ── */
.polaroid-tape {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 50px;
  height: 20px;
  background: rgba(247, 201, 72, 0.55);
  border-radius: 2px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.08);
  backdrop-filter: blur(2px);
}

/* Alternate tape angles for variety — set via JS */
.polaroid:nth-child(even)   .polaroid-tape { transform: translateX(-50%) rotate(2deg);  }
.polaroid:nth-child(3n)     .polaroid-tape { transform: translateX(-50%) rotate(-4deg); }
.polaroid:nth-child(4n)     .polaroid-tape {
  left: 30%;
  transform: rotate(5deg);
  background: rgba(255, 128, 170, 0.5);
}

/* ── Caption below the frame ── */
.polaroid-caption {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  color: var(--rose-700, #9b1942);
  text-align: center;
  padding: 0.65rem 0.5rem 0.1rem;
  line-height: 1.4;
  /* Handwritten look — slight rotation from parent */
  letter-spacing: 0.01em;
}

/* ── Pink heart stamp on hover ── */
.polaroid::after {
  content: '❤️';
  position: absolute;
  bottom: 2.8rem;
  right: 0.5rem;
  font-size: 0.9rem;
  opacity: 0;
  transform: scale(0.5) rotate(20deg);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
  z-index: 2;
}

.polaroid:hover::after {
  opacity: 1;
  transform: scale(1) rotate(-5deg);
}

/* ── Stagger reveal animations ── */
.polaroid:nth-child(1)  { animation-delay: 0.05s; }
.polaroid:nth-child(2)  { animation-delay: 0.10s; }
.polaroid:nth-child(3)  { animation-delay: 0.15s; }
.polaroid:nth-child(4)  { animation-delay: 0.20s; }
.polaroid:nth-child(5)  { animation-delay: 0.25s; }
.polaroid:nth-child(6)  { animation-delay: 0.30s; }
.polaroid:nth-child(7)  { animation-delay: 0.35s; }
.polaroid:nth-child(8)  { animation-delay: 0.40s; }
.polaroid:nth-child(9)  { animation-delay: 0.45s; }
.polaroid:nth-child(10) { animation-delay: 0.50s; }
.polaroid:nth-child(11) { animation-delay: 0.55s; }
.polaroid:nth-child(12) { animation-delay: 0.60s; }
.polaroid:nth-child(13) { animation-delay: 0.65s; }
.polaroid:nth-child(14) { animation-delay: 0.70s; }
.polaroid:nth-child(15) { animation-delay: 0.75s; }

/* ══════════════════════════════════════════
   FULL-SCREEN PHOTO VIEWER
══════════════════════════════════════════ */
.photo-viewer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 8000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.2rem;
}

.photo-viewer.open {
  display: flex;
  animation: viewerFadeIn 0.35s ease both;
}

@keyframes viewerFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Blurred romantic backdrop */
.viewer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 0, 10, 0.88);
  backdrop-filter: blur(10px) saturate(1.4);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  cursor: pointer;
  z-index: 0;
}

/* Main floating panel */
.viewer-panel {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 0 1rem;
  width: 100%;
  max-width: 900px;
}

/* Close button */
.viewer-close {
  position: fixed;
  top: 1.2rem;
  right: 1.5rem;
  z-index: 9;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.9);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.25s, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
  cursor: pointer;
}

.viewer-close:hover {
  background: rgba(255,255,255,0.25);
  transform: scale(1.1) rotate(90deg);
}

/* Prev / Next navigation */
.viewer-nav {
  position: relative;
  z-index: 2;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
  transition: background 0.25s, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
  cursor: pointer;
}

.viewer-nav:hover {
  background: rgba(255,80,120,0.4);
  transform: scale(1.12);
}

/* On narrow screens, overlay prev/next on the image */
@media (max-width: 600px) {
  .viewer-prev { position: fixed; left: 0.5rem; top: 50%; transform: translateY(-50%); }
  .viewer-next { position: fixed; right: 0.5rem; top: 50%; transform: translateY(-50%); }
  .viewer-prev:hover { transform: translateY(-50%) scale(1.1); }
  .viewer-next:hover { transform: translateY(-50%) scale(1.1); }
}

/* Polaroid-style viewer frame */
.viewer-polaroid {
  background: linear-gradient(165deg, #fff6f9 0%, #ffe3ee 65%, #ffd2e4 100%);
  border: 2px solid rgba(255, 128, 170, 0.6);
  padding: 1rem 1rem 0.5rem;
  border-radius: 10px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 20px 60px rgba(0,0,0,0.5),
    0  4px 18px rgba(214,48,96,0.3);
  max-width: min(540px, 85vw);
  width: 100%;
  animation: viewerCardIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
  position: relative;
  flex-shrink: 0;
}

@keyframes viewerCardIn {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* When transitioning between photos */
.viewer-polaroid.slide-out-left  { animation: slideOutLeft  0.25s ease both; }
.viewer-polaroid.slide-in-right  { animation: slideInRight  0.3s  cubic-bezier(0.34,1.56,0.64,1) both; }
.viewer-polaroid.slide-out-right { animation: slideOutRight 0.25s ease both; }
.viewer-polaroid.slide-in-left   { animation: slideInLeft   0.3s  cubic-bezier(0.34,1.56,0.64,1) both; }

@keyframes slideOutLeft  { to   { opacity: 0; transform: translateX(-60px) scale(0.95); } }
@keyframes slideInRight  { from { opacity: 0; transform: translateX(60px)  scale(0.95); } }
@keyframes slideOutRight { to   { opacity: 0; transform: translateX(60px)  scale(0.95); } }
@keyframes slideInLeft   { from { opacity: 0; transform: translateX(-60px) scale(0.95); } }

/* Image inside viewer */
.viewer-img-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--blush, #fde8ef);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#viewer-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.viewer-img-placeholder {
  display: none;
  font-size: 4rem;
  color: var(--pink-200, #ffb3cc);
  position: absolute;
}

.viewer-img-wrap.empty #viewer-img         { display: none; }
.viewer-img-wrap.empty .viewer-img-placeholder { display: flex; }

/* Caption + counter row */
.viewer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 0.2rem 0.4rem;
  gap: 0.5rem;
}

.viewer-caption-text {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.05rem, 3vw, 1.3rem);
  color: var(--rose-700, #9b1942);
  flex: 1;
}

.viewer-counter {
  font-family: 'Lato', sans-serif;
  font-size: 0.8rem;
  color: var(--text-light, #c06080);
  white-space: nowrap;
  opacity: 0.75;
}

/* ── Thumbnail Strip ── */
.viewer-strip {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  max-width: min(540px, 85vw);
  padding: 0.5rem 0.3rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
  -webkit-overflow-scrolling: touch;
}

.viewer-strip::-webkit-scrollbar { height: 4px; }
.viewer-strip::-webkit-scrollbar-track { background: transparent; }
.viewer-strip::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 2px; }

.strip-thumb {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2.5px solid rgba(255,255,255,0.15);
  transition: border-color 0.25s, transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.25s;
  opacity: 0.55;
}

.strip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.strip-thumb.active {
  border-color: var(--gold, #f7c948);
  opacity: 1;
  transform: scale(1.12);
  box-shadow: 0 0 10px rgba(247,201,72,0.5);
}

.strip-thumb:hover:not(.active) {
  opacity: 0.85;
  border-color: rgba(255,255,255,0.4);
}

/* Strip placeholder for missing photos */
.strip-thumb-ph {
  background: var(--blush, #fde8ef);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--pink-200, #ffb3cc);
}

/* ══════════════════════════════════════════
   KEYBOARD HINT BADGE (shown briefly on open)
══════════════════════════════════════════ */
.viewer-keys-hint {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(6px);
  color: rgba(255,255,255,0.75);
  font-size: 0.75rem;
  font-family: 'Lato', sans-serif;
  padding: 0.4rem 1rem;
  border-radius: 50px;
  letter-spacing: 0.05em;
  z-index: 10;
  pointer-events: none;
  animation: hintFadeOut 3.5s ease forwards;
}

@keyframes hintFadeOut {
  0%, 60% { opacity: 1; }
  100%     { opacity: 0; }
}

/* ══════════════════════════════════════════
   RESPONSIVE GRID OVERRIDES
══════════════════════════════════════════ */
@media (max-width: 400px) {
  .polaroid-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem 1rem;
  }
}

@media (min-width: 500px) and (max-width: 767px) {
  .polaroid-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem 1.5rem;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .polaroid-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) and (max-width: 1399px) {
  .polaroid-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1400px) {
  .polaroid-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Touch-friendly tap area on mobile */
@media (hover: none) {
  .polaroid::after { display: none; }
  .polaroid:active {
    transform: rotate(0deg) scale(0.96);
    filter: drop-shadow(0 4px 12px rgba(214, 48, 96, 0.3));
  }
}

/* ══════════════════════════════════════════
   REDUCED MOTION SAFETY
══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .polaroid,
  .polaroid-img,
  .viewer-polaroid { animation: none !important; transition: none !important; }
}
