/* CSS Variables for Core Design System */
:root {
  --bg-color: #f7f5f0;        /* Soft warm cream background */
  --text-color: #2c2a29;      /* Deep charcoal for body text */
  --text-muted: #6e6a68;      /* Muted charcoal for captions/dates */
  --accent: #5e6b5c;          /* Soft natural sage green */
  --accent-light: #d1d9cf;    /* Light sage green for focus highlights */
  --accent-hover: #485346;    /* Darker sage green for hovers */
  --white: #ffffff;
  
  --font-serif-display: 'Cormorant Garamond', Georgia, serif;
  --font-serif-body: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  
  --spacing-sm: 16px;
  --spacing-md: 24px;
  --spacing-lg: 48px;
  --spacing-xl: 96px;
  
  --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: all 0.2s ease;
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-serif-body);
  font-size: 1.125rem;
  line-height: 1.75;
  overflow-x: hidden;
}

/* Accessibility: Keyboard Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 24px;
  background-color: var(--text-color);
  color: var(--bg-color);
  padding: 12px 24px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  z-index: 1000;
  border-radius: 0 0 4px 4px;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--accent);
}

/* Focus styles for keyboard accessibility */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* Hidden Utility class */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- 1. Hero Section --- */
.hero {
  position: relative;
  height: 85vh;
  min-height: 500px;
  width: 100vw;
  background-position: center 30%;
  background-size: cover;
  background-repeat: no-repeat;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--white);
  padding: 24px;
}

.hero-content {
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: translateY(20px);
  animation: heroFadeIn 1.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hero-title {
  font-family: var(--font-serif-display);
  font-size: clamp(3.5rem, 8vw, 6.5rem);
  font-weight: 300;
  line-height: 1.1;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-family: var(--font-serif-body);
  font-style: italic;
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 300;
  opacity: 0.9;
  margin-bottom: 24px;
}

.hero-divider {
  width: 40px;
  height: 1px;
  background-color: rgba(255, 255, 255, 0.5);
  margin: 0 auto 24px;
}

.hero-dates {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 300;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  opacity: 0.75;
}

.scroll-cue {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.6);
  z-index: 2;
}

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

/* --- 2. Opening Remembrance --- */
.remembrance {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--spacing-xl) 24px;
  text-align: center;
}

.remembrance-text {
  font-size: clamp(1.25rem, 2.5vw, 1.45rem);
  line-height: 1.85;
  color: var(--text-color);
  font-weight: 300;
}

/* --- 3. Photo Gallery --- */
.gallery {
  padding: 0 24px var(--spacing-xl);
  max-width: 1400px;
  margin: 0 auto;
}

.section-title {
  font-family: var(--font-serif-display);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 400;
  text-align: center;
  margin-bottom: var(--spacing-lg);
  position: relative;
  letter-spacing: -0.01em;
}

/* Masonry Gallery Grid via CSS Columns */
.gallery-grid {
  columns: 3 320px;
  column-gap: var(--spacing-md);
  width: 100%;
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: var(--spacing-md);
  background-color: rgba(0, 0, 0, 0.02);
}

.gallery-btn {
  display: block;
  width: 100%;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

.gallery-btn img {
  display: block;
  width: 100%;
  height: auto;
  transition: var(--transition-smooth);
}

/* Premium micro-interaction: subtle zoom and opacity on hover */
.gallery-btn:hover img {
  transform: scale(1.025);
  opacity: 0.95;
}

.gallery-footer {
  text-align: center;
  margin-top: var(--spacing-lg);
}

.album-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif-body);
  font-style: italic;
  font-size: 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: var(--transition-fast);
}

.album-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.external-icon {
  opacity: 0.7;
}

/* --- 4. "Things We'll Remember" Section --- */
.memories {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--spacing-xl) 24px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.memories-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 40px;
  margin-top: var(--spacing-lg);
}

.memory-item {
  text-align: center;
  font-family: var(--font-serif-body);
  font-style: italic;
  font-size: clamp(1.1rem, 2.5vw, 1.25rem);
  line-height: 1.8;
  color: var(--text-muted);
  position: relative;
}

/* Subtle separator between memories */
.memory-item:not(:last-child)::after {
  content: "";
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 1px;
  background-color: rgba(0, 0, 0, 0.06);
}

/* --- 5. Closing Section & Footer --- */
.footer {
  background-color: #f2efe8; /* Slightly darker cream for footer grounding */
  text-align: center;
  padding: var(--spacing-xl) 24px;
}

.closing-message {
  font-family: var(--font-serif-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 300;
  font-style: italic;
  color: var(--text-color);
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}

.back-to-top {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-fast);
}

.back-to-top:hover {
  color: var(--accent);
}

/* --- 6. Lightbox Modal --- */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(21, 20, 19, 0.98); /* Muted warm dark */
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox.active {
  display: flex;
  opacity: 1;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.lightbox.active img {
  opacity: 1;
  transform: scale(1);
}

.lightbox-caption {
  color: #dfdbd4;
  font-family: var(--font-serif-body);
  font-style: italic;
  font-size: 1rem;
  margin-top: 16px;
  text-align: center;
  min-height: 24px;
}

/* Lightbox Controls */
.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: none;
  border: none;
  color: #dfdbd4;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: var(--transition-fast);
}

.lightbox-close {
  top: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  z-index: 10;
}

.lightbox-close:hover {
  color: var(--white);
}

.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 64px;
  height: 64px;
  z-index: 5;
}

.lightbox-nav:hover {
  color: var(--white);
}

.lightbox-prev {
  left: 24px;
}

.lightbox-next {
  right: 24px;
}

/* --- 7. Custom 404 Page --- */
.error-page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;
  padding: 24px;
  background-color: var(--bg-color);
  text-align: center;
}

.error-container {
  max-width: 500px;
}

.error-title {
  font-family: var(--font-serif-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 300;
  line-height: 1.3;
  margin-bottom: 24px;
  letter-spacing: -0.01em;
}

.error-link {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 4px;
  transition: var(--transition-fast);
}

.error-link:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
}

/* --- Responsive Media Queries --- */
@media (max-width: 1024px) {
  .gallery-grid {
    columns: 2 340px;
  }
  .lightbox-nav {
    display: none; /* Rely on mobile swipes instead of navigation buttons on tablets */
  }
}

@media (max-width: 640px) {
  .gallery-grid {
    columns: 1 100%;
  }
  .hero {
    height: 70vh; /* Shorter hero on mobile */
  }
  .remembrance {
    padding: var(--spacing-lg) 24px;
  }
  .gallery {
    padding-bottom: var(--spacing-lg);
  }
  .memories {
    padding: var(--spacing-lg) 24px;
  }
  .footer {
    padding: var(--spacing-lg) 24px;
  }
  .lightbox-close {
    top: 16px;
    right: 16px;
  }
}

/* --- Accessibility: Accessibility Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .hero-content {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .gallery-btn img,
  .lightbox,
  .lightbox img,
  .lightbox-close,
  .lightbox-nav {
    transition: none !important;
  }
  .gallery-btn:hover img {
    transform: none;
  }
}
