/* ══════════════════════════════════════════════════
   JIMMY — MEMORIAL
   Black & white by default. Colour on hover/focus.
   A personal, emotional, nostalgic archive.
══════════════════════════════════════════════════ */

:root {
  --black:      #0e0c09;
  --near-black: #181410;
  --ink:        #1d1812;
  --ink-mid:    #4a3e30;
  --ink-muted:  #8c7d6c;
  --cream:      #f5f0e8;
  --warm:       #ece6da;
  --paper:      #faf7f1;
  --gold:       #b5915a;
  --gold-light: #d4b986;
  --gold-faint: #ecdec8;
  --white:      #fff;

  --ff-serif: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --ff-sans:  'Lato', 'Helvetica Neue', Arial, sans-serif;

  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--black);
  color: var(--cream);
  font-family: var(--ff-sans);
  font-weight: 300;
  line-height: 1.7;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font: inherit; }

/* ── GRAIN ── */
#grain {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9000;
  opacity: 0.025; width: 100%; height: 100%;
}

/* ══════════════════════════════════════
   MUSIC BUTTON — compact icon
══════════════════════════════════════ */
.music-btn {
  position: fixed; top: 1.2rem; right: 1.2rem; z-index: 1000;
  display: flex; align-items: center; gap: 6px;
  background: rgba(14,12,9,0.65);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(181,145,90,0.18);
  border-radius: 50px; padding: 8px 12px;
  color: var(--gold-light);
  transition: border-color 0.3s, background 0.3s;
}
.music-btn:hover { border-color: rgba(181,145,90,0.5); }
.music-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.music-waves {
  display: flex; align-items: flex-end; gap: 2px; height: 12px;
}
.music-waves span {
  width: 2px; background: var(--gold); border-radius: 2px;
  animation: wave 1.1s ease-in-out infinite; opacity: 0.7;
}
.music-waves span:nth-child(1) { animation-delay: 0s;    height: 5px; }
.music-waves span:nth-child(2) { animation-delay: 0.15s; height: 9px; }
.music-waves span:nth-child(3) { animation-delay: 0.3s;  height: 6px; }
.music-waves span:nth-child(4) { animation-delay: 0.1s;  height: 10px; }
.music-waves.paused span { animation-play-state: paused; opacity: 0.25; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.4); }
  50%       { transform: scaleY(1); }
}

/* ══════════════════════════════════════
   HERO
══════════════════════════════════════ */
.hero {
  position: relative; height: 100svh; min-height: 600px;
  background: var(--black);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.hero-ghost-name {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--ff-serif); font-weight: 400;
  font-size: clamp(100px, 20vw, 220px);
  color: #fff; opacity: 0.022;
  user-select: none; pointer-events: none; white-space: nowrap;
}
.hero-content {
  position: relative; z-index: 2; text-align: center; padding: 2rem;
  display: flex; flex-direction: column; align-items: center;
}
.eyebrow {
  display: flex; align-items: center; gap: 1rem;
  font-size: 10px; font-weight: 300; letter-spacing: 0.3em;
  text-transform: uppercase; color: var(--gold-light);
  margin-bottom: 2rem;
  opacity: 0; transform: translateY(10px);
  animation: fadeup 1s var(--ease-expo) 0.1s forwards;
}
.eline { display: block; width: 32px; height: 1px; background: var(--gold); opacity: 0.5; }
.hero-name {
  font-family: var(--ff-serif); font-size: clamp(80px, 16vw, 160px);
  font-weight: 400; font-style: italic; color: var(--white);
  letter-spacing: -0.015em; line-height: 1; margin-bottom: 1.4rem;
  opacity: 0; transform: translateY(16px);
  animation: fadeup 1.2s var(--ease-expo) 0.3s forwards;
}
.hero-dates {
  font-size: clamp(12px, 2vw, 15px); font-weight: 300;
  letter-spacing: 0.2em; color: rgba(245,240,232,0.4);
  margin-bottom: 1.6rem; opacity: 0;
  animation: fadeup 1s var(--ease-expo) 0.5s forwards;
}
.hero-dot { color: var(--gold); opacity: 0.6; margin: 0 0.4rem; }
.hero-whisper {
  font-family: var(--ff-serif); font-style: italic;
  font-size: clamp(17px, 2.5vw, 22px); color: rgba(245,240,232,0.3);
  margin-bottom: 2.4rem; opacity: 0;
  animation: fadeup 1s var(--ease-expo) 0.65s forwards;
}
.hero-paw {
  width: 44px; color: var(--gold); opacity: 0; margin-bottom: 3rem;
  animation: fadeup 1s var(--ease-expo) 0.8s forwards;
}
.hero-enter {
  display: flex; flex-direction: column; align-items: center; gap: 0.7rem;
  font-size: 10px; font-weight: 300; letter-spacing: 0.28em;
  text-transform: uppercase; color: rgba(245,240,232,0.35);
  opacity: 0; animation: fadeup 1s var(--ease-expo) 1s forwards;
  transition: color 0.3s;
}
.hero-enter:hover { color: rgba(245,240,232,0.7); }
.hero-enter svg { width: 20px; animation: bounceDown 2.6s ease-in-out infinite 1.4s; }
@keyframes bounceDown {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(7px); }
}
.hero-bottom-fade {
  position: absolute; bottom: 0; left: 0; right: 0; height: 160px;
  background: linear-gradient(to bottom, transparent, var(--black));
  pointer-events: none;
}

/* ══════════════════════════════════════
   TRIBUTE
══════════════════════════════════════ */
.tribute {
  background: var(--paper); padding: 7rem 2rem; color: var(--ink);
}
.tribute-inner {
  max-width: 820px; margin: 0 auto;
  display: grid; grid-template-columns: 64px 1fr;
  gap: 2.5rem; align-items: start;
}
.tribute-title {
  font-family: var(--ff-serif); font-size: clamp(26px, 4vw, 42px);
  font-weight: 400; font-style: italic; line-height: 1.22;
  margin-bottom: 1.8rem; color: var(--ink);
}
.t-rule { width: 48px; height: 1px; background: var(--gold); margin-bottom: 1.8rem; }
.tribute-text p {
  font-size: 16px; font-weight: 300; color: var(--ink-mid);
  line-height: 1.9; max-width: 540px; margin-bottom: 1.1rem;
}
.tribute-text em { font-style: italic; color: var(--ink); }
.tribute-sig {
  font-family: var(--ff-serif); font-style: italic;
  font-size: 16px; color: var(--gold); margin-top: 1.8rem;
}

/* Section numbers */
.sec-num {
  font-family: var(--ff-serif); font-style: italic;
  font-size: 64px; font-weight: 400; color: var(--gold-faint);
  line-height: 1; user-select: none; padding-top: 6px;
}

/* ══════════════════════════════════════
   GALLERY
══════════════════════════════════════ */
.gallery-section { background: var(--black); padding: 5rem 0; }
.gallery-header {
  display: flex; align-items: flex-end; gap: 2rem;
  padding: 0 2.5rem 2rem; max-width: 1200px; margin: 0 auto;
  border-bottom: 1px solid rgba(181,145,90,0.12); margin-bottom: 1.4rem;
}
.gallery-title {
  font-family: var(--ff-serif); font-style: italic; font-weight: 400;
  font-size: clamp(26px, 4vw, 40px); color: var(--cream); line-height: 1.1;
}
.gallery-count {
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-muted); padding-bottom: 4px;
}
.bw-hint {
  display: flex; align-items: center; gap: 7px;
  max-width: 1200px; margin: 0 auto 1.8rem; padding: 0 2.5rem;
  font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase;
  color: rgba(245,240,232,0.2);
}
.bw-hint-mobile { display: none; }
@media (hover: none) {
  .bw-hint-desktop { display: none; }
  .bw-hint-mobile { display: inline; }
}


/* ══════════════════════════════════════════════════════
   GRID GALLERY — FULLY REBUILT HOVER SYSTEM
   ─────────────────────────────────────────────────────
   Each card is a GPU-isolated stacking context.
   The grayscale filter is applied via a SEPARATE overlay
   layer, not on the <img> itself. This avoids all
   browser compositing bugs with CSS filter + grid.

   HOVER LOGIC:
     - No hover  → all photos are black & white
     - Hover ONE → ONLY that photo becomes colorful
     - No bleed, no first-card bugs, no row artefacts
══════════════════════════════════════════════════════ */
.masonry {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  padding: 0 2.5rem;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 960px)  { .masonry { grid-template-columns: repeat(2, 1fr); gap: 16px; } }
@media (max-width: 560px)  { .masonry { grid-template-columns: 1fr; padding: 0 1rem; gap: 20px; } }

/* ── PHOTO CARD — polaroid frame ── */
.photo-card {
  /* GPU isolation — CRITICAL for preventing hover bleed */
  isolation: isolate;
  contain: layout style paint;
  will-change: transform;
  transform: translateZ(0);

  position: relative;
  cursor: pointer;
  background: var(--white);
  border-radius: 2px;

  /* Polaroid frame: thick bottom, medium sides/top */
  padding: 10px 10px 36px 10px;

  /* Subtle polaroid shadow */
  box-shadow:
    0 1px 3px rgba(0,0,0,0.25),
    0 4px 12px rgba(0,0,0,0.15),
    0 0 0 1px rgba(255,255,255,0.04);

  /* Slight random rotation for natural feel — JS adds per-card */
  --card-rotate: 0deg;
  transform: rotate(var(--card-rotate)) translateZ(0);
  transition: transform 0.4s var(--ease-expo), box-shadow 0.4s ease;

  /* Fade in */
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.4s var(--ease-expo), box-shadow 0.4s ease;
}
.photo-card.visible { opacity: 1; }

.photo-card:hover {
  transform: rotate(0deg) translateZ(0) scale(1.015);
  box-shadow:
    0 4px 16px rgba(0,0,0,0.35),
    0 12px 40px rgba(0,0,0,0.2),
    0 0 0 1px rgba(255,255,255,0.06);
  z-index: 2;
}

/* ── Image container ── */
.photo-img-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  background: #1a1816;
  /* Own stacking context */
  isolation: isolate;
  transform: translateZ(0);
}

/* ── The actual photo — ALWAYS full colour ── */
.photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* No filter on the img itself — colour lives here always */
}

/* ── B&W overlay — sits ON TOP of the image ──
   This is a pseudo-element with mix-blend-mode that
   desaturates the photo. On hover, it fades out. 
   This approach is immune to the filter compositing bugs. */
.photo-img-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  /* B&W via CSS: saturate(0) on a white overlay with color blend mode */
  background: var(--black);
  mix-blend-mode: saturation;
  opacity: 1;
  transition: opacity 0.55s ease;
  pointer-events: none;
  /* GPU layer */
  will-change: opacity;
  transform: translateZ(0);
}

/* Additional brightness/contrast layer for that classic B&W look */
.photo-img-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(14,12,9,0.15);
  transition: opacity 0.55s ease;
  pointer-events: none;
  will-change: opacity;
  transform: translateZ(0);
}

/* ── HOVER: reveal colour on ONLY the hovered card ── */
.photo-card:hover .photo-img-wrap::after,
.photo-card.in-view .photo-img-wrap::after {
  opacity: 0;
}

.photo-card:hover .photo-img-wrap::before,
.photo-card.in-view .photo-img-wrap::before {
  opacity: 0;
}

/* ── Polaroid caption area (below image, in the white frame) ── */
.photo-polaroid-caption {
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-serif);
  font-style: italic;
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
  margin-top: 2px;
}

/* ── Caption overlay (on top of image, shown on hover) ── */
.photo-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: linear-gradient(to top, rgba(14,12,9,0.7) 0%, transparent 45%);
  opacity: 0;
  transition: opacity 0.4s ease;
  display: flex;
  align-items: flex-end;
  padding: 1rem;
  pointer-events: none;
}
.photo-card:hover .photo-overlay,
.photo-card.in-view .photo-overlay { opacity: 1; }

.overlay-text {
  font-family: var(--ff-serif); font-style: italic;
  font-size: 13px; color: rgba(245,240,232,0.9); line-height: 1.4;
}

/* ── Expand icon ── */
.photo-expand-icon {
  position: absolute; top: 8px; right: 8px;
  z-index: 4;
  width: 26px; height: 26px;
  background: rgba(14,12,9,0.5);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s ease;
  pointer-events: none;
}
.photo-expand-icon svg { width: 12px; height: 12px; color: rgba(245,240,232,0.8); }
.photo-card:hover .photo-expand-icon,
.photo-card.in-view .photo-expand-icon { opacity: 1; }

/* ── Decorative tape on some polaroids (added via JS) ── */
.photo-tape {
  position: absolute;
  z-index: 5;
  width: 40px;
  height: 14px;
  background: rgba(245,240,232,0.22);
  transform: rotate(var(--tape-angle, -3deg));
  pointer-events: none;
  border-radius: 1px;
}
.photo-tape--top-left { top: -4px; left: 12px; }
.photo-tape--top-right { top: -4px; right: 12px; }

/* ── INFINITE SENTINEL ── */
.inf-sentinel {
  display: flex; align-items: center; justify-content: center;
  gap: 7px; padding: 3rem 0;
}
.inf-sentinel span {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--gold); opacity: 0.3;
  animation: pls 1.8s ease-in-out infinite;
}
.inf-sentinel span:nth-child(2) { animation-delay: 0.2s; }
.inf-sentinel span:nth-child(3) { animation-delay: 0.4s; }
.inf-sentinel.done span { display: none; }
@keyframes pls { 0%,100%{opacity:0.15} 50%{opacity:.8} }

/* ══════════════════════════════════════
   QUOTE
══════════════════════════════════════ */
.quote-section {
  background: var(--black); padding: 8rem 2rem; text-align: center;
  border-top: 1px solid rgba(181,145,90,0.08);
}
.quote-inner { max-width: 640px; margin: 0 auto; }
.big-quote {
  font-family: var(--ff-serif); font-size: 100px; line-height: 0.7;
  color: var(--gold); opacity: 0.25; margin-bottom: 1rem;
}
blockquote {
  font-family: var(--ff-serif); font-style: italic; font-weight: 400;
  font-size: clamp(19px, 3vw, 26px); line-height: 1.65;
  color: rgba(245,240,232,0.65); margin-bottom: 1.2rem;
}
cite {
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--gold); opacity: 0.55; font-style: normal;
}

/* ══════════════════════════════════════
   FOOTER
══════════════════════════════════════ */
.site-footer {
  background: var(--black);
  border-top: 1px solid rgba(181,145,90,0.1);
  padding: 3.5rem 2rem 3rem; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.f-paw { width: 38px; color: var(--white); margin-bottom: 0.6rem; }
.f-name { font-family: var(--ff-serif); font-style: italic; font-size: 26px; color: rgba(245,240,232,0.6); }
.f-dates { font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold); opacity: 0.5; }
.f-love { font-size: 13px; font-weight: 300; color: rgba(245,240,232,0.22); margin-top: 0.3rem; }

/* ══════════════════════════════════════
   LIGHTBOX — rebuilt with crossfade
══════════════════════════════════════ */
.lightbox {
  position: fixed; inset: 0; z-index: 5000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
}
.lightbox:not([hidden]) { pointer-events: all; opacity: 1; }
.lightbox[hidden] { display: block !important; }

.lb-bg { position: absolute; inset: 0; background: rgba(8,6,4,0.95); cursor: pointer; }
.lb-x {
  position: fixed; top: 1.4rem; right: 1.6rem;
  width: 40px; height: 40px;
  color: rgba(245,240,232,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.2s; z-index: 2;
}
.lb-x:hover { color: var(--cream); }

.lb-stage {
  position: relative; z-index: 1; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4rem 6rem; pointer-events: none;
}
.lb-stage > * { pointer-events: all; }

/* Crossfade container — holds TWO images stacked */
.lb-img-frame {
  max-width: 760px;
  width: 100%;
  position: relative;
  /* Prevent layout shift */
  min-height: 200px;
}

/* Both images stack in same space */
.lb-img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 2px;
  transition: opacity 0.45s ease;
}

/* The crossfade pair */
.lb-img--current {
  position: relative;
  opacity: 1;
  z-index: 1;
}

.lb-img--next {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  z-index: 0;
}

/* During transition, next fades in and current fades out */
.lb-img-frame.crossfading .lb-img--current {
  opacity: 0;
  z-index: 0;
}
.lb-img-frame.crossfading .lb-img--next {
  opacity: 1;
  z-index: 1;
}

.lb-footer { margin-top: 1.2rem; text-align: center; }
.lb-caption {
  font-family: var(--ff-serif); font-style: italic;
  font-size: 17px; color: rgba(245,240,232,0.5); margin-bottom: 0.8rem;
  transition: opacity 0.3s ease;
}
.lb-row { display: flex; align-items: center; justify-content: center; gap: 1.4rem; }
.lb-save-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--gold); border: 1px solid rgba(181,145,90,0.3);
  border-radius: 2px; padding: 6px 14px;
  transition: background 0.2s, border-color 0.2s;
}
.lb-save-btn:hover { background: rgba(181,145,90,0.1); border-color: var(--gold); }
.lb-num { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(245,240,232,0.25); }

.lb-arrow {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 70px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(245,240,232,0.3); transition: color 0.2s;
}
.lb-arrow:hover { color: rgba(245,240,232,0.85); }
.lb-prev { left: 1.2rem; }
.lb-next { right: 1.2rem; }

.lb-swipe-hint {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(245,240,232,0.2); pointer-events: none;
}

/* ── REVEAL ── */
.reveal {
  opacity: 0; transform: translateY(24px);
  transition: opacity 0.8s var(--ease-expo), transform 0.8s var(--ease-expo);
}
.reveal.revealed { opacity: 1; transform: translateY(0); }

@keyframes fadeup { to { opacity: 1; transform: translateY(0); } }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  .tribute-inner { grid-template-columns: 1fr; }
  .sec-num { font-size: 42px; }
  .gallery-header { padding: 0 1rem 1.5rem; }
  .bw-hint { padding: 0 1rem; }
  .lb-stage { padding: 4rem 1rem; }
  .lb-arrow { display: none; }
  .photo-card { padding: 8px 8px 30px 8px; }
  .photo-polaroid-caption { height: 22px; font-size: 10px; }
}
