/* ============================================================
   SHARED COMPONENTS — used by every month page + home
   Polaroid base, music button, cursor trail, photo lightbox,
   reduced-motion guard, handwriting reveal primitives.
   ============================================================ */

/* ── Polaroid / Scrapbook Photo ─────────────────────────────── */
.polaroid {
  background: white;
  padding: 10px 10px 36px 10px;
  box-shadow:
    2px 4px 12px rgba(0, 0, 0, 0.1),
    0 1px 3px rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  max-width: 280px;
  display: inline-block;
  position: relative;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              box-shadow 0.4s ease;
  visibility: hidden; /* GSAP reveals */
}

.polaroid.reveal-now { visibility: visible; }

.polaroid:hover {
  box-shadow:
    4px 8px 24px rgba(0, 0, 0, 0.15),
    0 2px 6px rgba(0, 0, 0, 0.08);
  transform: scale(1.03);
}

.polaroid img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 1px;
}

.polaroid-caption {
  padding-top: 4px;
  line-height: 1.4;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--caption);
  text-align: center;
}

/* Tape effect */
.polaroid.taped::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 60px;
  height: 22px;
  background: rgba(255, 248, 220, 0.7);
  border: 1px solid rgba(200, 180, 120, 0.2);
  border-radius: 2px;
  z-index: 2;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Tilt classes */
.tilt-left  { transform: rotate(-3deg); }
.tilt-right { transform: rotate(3deg); }
.tilt-slight { transform: rotate(1.5deg); }

/* ── GIF / Memory Frame (gold gradient) ─────────────────────── */
.gif-frame {
  max-width: 380px;
  padding: 8px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold-accent), var(--gold-soft), var(--gold-accent));
  background-size: 300% 300%;
  animation: shimmer-gold 4s ease-in-out infinite;
  box-shadow:
    0 4px 20px rgba(202, 138, 4, 0.2),
    0 0 40px rgba(246, 224, 94, 0.1);
  visibility: hidden;
}

.gif-frame img { display: block; border-radius: 4px; }

@keyframes shimmer-gold {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* ── Glowing Heart ──────────────────────────────────────────── */
.glowing-heart {
  animation: heartbeat 2s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgba(219, 39, 119, 0.4));
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 8px rgba(219, 39, 119, 0.4)); }
  15%      { transform: scale(1.1);  filter: drop-shadow(0 0 20px rgba(244, 114, 182, 0.6)); }
  30%      { transform: scale(1);    filter: drop-shadow(0 0 8px rgba(219, 39, 119, 0.4)); }
  45%      { transform: scale(1.06); filter: drop-shadow(0 0 16px rgba(244, 114, 182, 0.5)); }
}

/* ── Music Button ───────────────────────────────────────────── */
.music-btn {
  border: 2px solid rgba(244, 114, 182, 0.2);
}

.music-btn.playing {
  animation: music-pulse 2s ease-in-out infinite;
  border-color: rgba(219, 39, 119, 0.3);
}

@keyframes music-pulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 0 0 0 rgba(219, 39, 119, 0); }
  50%      { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 0 20px 4px rgba(219, 39, 119, 0.15); }
}

/* ── Cursor Trail (defaults to small heart, page may override) */
.trail-particle {
  position: fixed;
  pointer-events: none;
  z-index: var(--z-cursor);
  font-size: 14px;
  color: var(--rose-soft);
  user-select: none;
}

/* ── Handwriting / writing cursor ───────────────────────────── */
.writing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: currentColor;
  margin-left: 2px;
  animation: cursor-blink 0.8s ease-in-out infinite;
  vertical-align: text-bottom;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

.hw-char { opacity: 0; }

/* ── Photo Lightbox Overlay ─────────────────────────────────── */
#photo-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  pointer-events: none;
  transition: background 0.4s ease, backdrop-filter 0.4s ease;
}

#photo-overlay.active {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  pointer-events: all;
  cursor: pointer;
}

.expanded-photo-clone {
  position: absolute;
  background: white;
  padding: 10px 10px 40px 10px;
  border-radius: 3px;
  box-shadow: 0 0 30px rgba(219, 39, 119, 0.12), 0 12px 40px rgba(0, 0, 0, 0.25);
  visibility: visible !important;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.expanded-photo-clone:not(.scattered) {
  max-width: 85vw;
  padding: 12px 12px 44px 12px;
}

.expanded-photo-clone.scattered { max-width: 40vw; }

.expanded-photo-clone img {
  max-width: 100%;
  max-height: 65vh;
  width: auto;
  height: auto;
  display: block;
  border-radius: 2px;
  pointer-events: none;
}

.expanded-photo-clone.scattered img { max-height: 50vh; }

.expanded-photo-clone .polaroid-caption {
  text-align: center;
  padding-top: 6px;
  font-size: 0.85rem;
  color: var(--caption);
  font-family: var(--font-ui);
  pointer-events: none;
}

.expanded-photo-clone:active {
  box-shadow: 0 0 40px rgba(219, 39, 119, 0.2), 0 24px 60px rgba(0, 0, 0, 0.35) !important;
}

@media (max-width: 768px) {
  .expanded-photo-clone.scattered     { max-width: 52vw; padding: 6px 6px 28px 6px; }
  .expanded-photo-clone.scattered img { max-height: 35vh; }
  .expanded-photo-clone:not(.scattered)     { max-width: 90vw; padding: 8px 8px 36px 8px; }
  .expanded-photo-clone:not(.scattered) img { max-height: 60vh; }
}

.overlay-close-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.1em;
  opacity: 0;
  transition: opacity 0.5s ease 0.5s;
  pointer-events: auto;
  z-index: 1;
}

#photo-overlay.active .overlay-close-hint { opacity: 1; }

body.photo-expanded { overflow: hidden; }

.gif-frame:hover { transform: scale(1.03); transition: transform 0.2s ease; }

/* ── Reduced Motion Guard ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .polaroid, .gif-frame, .hw-char, .letter-paragraph,
  #closing-text, .close-char {
    visibility: visible !important;
    opacity: 1 !important;
  }

  .glowing-heart {
    animation: none;
    filter: drop-shadow(0 0 8px rgba(219, 39, 119, 0.4));
  }

  html { scroll-behavior: auto; }
}
