/* =============================================================================
   Memorial Page - Sergey Bogaev (1961-2011)
   Warm amber/candle color scheme, dignified and respectful design
   Scoped with .memorial-page prefix to prevent style leakage
   ============================================================================= */

:root {
  --memorial-gold: #d4a843;
  --memorial-amber: #b8860b;
  --memorial-warm: #f5e6c8;
  --memorial-candle: #ffcc44;
  --memorial-dark: #1a1510;
  --memorial-dark-warm: #2a2118;
  --memorial-text: #e8dcc8;
  --memorial-text-muted: #a89880;
  --memorial-border: rgba(212, 168, 67, 0.2);
}

/* ============================================================================
   CRITICAL FIX: Override animation classes that hide content
   The .typewriter class sets width:0 and the .text-reveal class sets opacity:0.
   The vp-section-reveal scroll-driven animation (modern-fixes.css ~L12887)
   sets .memorial-section to opacity:0 with animation-timeline:view(), which
   can leave inner content permanently invisible if the view timeline doesn't
   fire (e.g. content-visibility:auto or initial viewport position).
   We force visibility on the memorial page to ensure content is always readable.
   ============================================================================ */

/* Force hero name visible — typewriter animation sets width:0, overflow:hidden */
.memorial-page .memorial-hero-name.typewriter {
  width: 100% !important;
  overflow: visible !important;
  white-space: normal !important;
  border-right: none !important;
  animation: memorial-name-fade-in 1.5s ease-out both !important;
}

/* Force hero dates visible — text-reveal sets opacity:0 */
.memorial-page .memorial-hero-dates {
  opacity: 1 !important;
  animation: memorial-dates-fade-in 2s ease-out 0.5s both;
}

/* Force hero role visible */
.memorial-page .memorial-hero-role {
  opacity: 1 !important;
  animation: memorial-role-fade-in 2s ease-out 1s both;
}

/* Force hero section fully visible — ink-reveal can get stuck at partial opacity */
.memorial-page .memorial-hero {
  opacity: 1 !important;
  clip-path: none !important;
}

/* CRITICAL: Force .memorial-section inner divs visible.
   modern-fixes.css ~L12887 applies vp-section-reveal with animation-timeline:view()
   to .memorial-section, starting at opacity:0. The Phase 97 fix at ~L21530 tries to
   override with !important but the @supports(animation-timeline:view()) block wins
   in browsers that support the API, leaving all 8 inner content sections invisible.
   Using .memorial-page prefix for higher specificity (0,2,0 vs 0,1,0). */
.memorial-page .memorial-section {
  animation: none !important;
  animation-timeline: none !important;
  opacity: 1 !important;
  transform: none !important;
}

/* Force all parent sections visible — text-reveal / scroll-reveal can leave them at opacity 0.6 */
.memorial-page .memorial-counter-section,
.memorial-page .memorial-biography,
.memorial-page .memorial-creation-counter,
.memorial-page .memorial-timeline,
.memorial-page .memorial-gallery,
.memorial-page .memorial-quotes,
.memorial-page .memorial-candle-wall,
.memorial-page .memorial-book,
.memorial-page .memorial-memories-cta {
  opacity: 1 !important;
}

/* Force .memorial-bio-text and .timeline-item visible — they also have
   memorial-text-reveal with animation-timeline:view() from modern-fixes.css ~L15920 */
.memorial-page .memorial-bio-text,
.memorial-page .timeline-item {
  animation: none !important;
  animation-timeline: none !important;
  opacity: 1 !important;
  transform: none !important;
}

/* Force text-reveal children inside memorial to be visible */
.memorial-page .text-reveal,
.memorial-page .text-reveal-group > * {
  opacity: 1 !important;
  transform: none !important;
}

/* Force memorial quote visible regardless of typewriter class */
.memorial-page .memorial-quote.typewriter {
  width: 100% !important;
  overflow: visible !important;
  white-space: normal !important;
  border-right: none !important;
}

/* ---- Page wrapper ---- */
.memorial-page {
  background: var(--memorial-dark);
  color: var(--memorial-text);
  min-height: 100vh;
  position: relative;
}

/* ---- Hero Section ---- */
.memorial-page .memorial-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 6rem 2rem 4rem;
  text-align: center;
  overflow: hidden;
  background: radial-gradient(ellipse at center bottom, rgba(212, 168, 67, 0.08) 0%, transparent 60%),
              var(--memorial-dark);
}

.memorial-page .memorial-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(26, 21, 16, 0.4) 100%);
  pointer-events: none;
  z-index: 0;
}

/* ---- Candle flame animation ---- */
.memorial-page .candle-container {
  position: relative;
  width: 60px;
  height: 160px;
  margin: 0 auto 2.5rem;
  z-index: 2;
}

.memorial-page .candle-body {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 80px;
  background: linear-gradient(180deg, #f5e6c8 0%, #d4c4a0 100%);
  border-radius: 3px 3px 2px 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.memorial-page .candle-wick {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 12px;
  background: #4a3a2a;
}

.memorial-page .candle-flame {
  position: absolute;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 40px;
}

.memorial-page .flame-outer {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 40px;
  background: radial-gradient(ellipse at center bottom, var(--memorial-candle) 0%, #ff9500 40%, transparent 70%);
  border-radius: 50% 50% 35% 35%;
  animation: memorial-flame-flicker 2.2s ease-in-out infinite alternate;
}

.memorial-page .flame-mid {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 30px;
  background: radial-gradient(ellipse at center bottom, #ffe080 0%, #ff9500 50%, transparent 100%);
  border-radius: 50% 50% 35% 35%;
  animation: memorial-flame-mid-sway 1.8s ease-in-out infinite alternate;
  z-index: 1;
}

.memorial-page .flame-inner {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 24px;
  background: radial-gradient(ellipse at center bottom, #fff8e0 0%, var(--memorial-candle) 60%, transparent 100%);
  border-radius: 50% 50% 35% 35%;
  animation: memorial-flame-inner-sway 1.4s ease-in-out infinite alternate;
  z-index: 2;
}

.memorial-page .flame-glow {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, rgba(255, 204, 68, 0.2) 0%, rgba(255, 153, 0, 0.08) 40%, transparent 70%);
  border-radius: 50%;
  animation: memorial-glow-breathe 3.5s ease-in-out infinite alternate;
}

/* Sparks */
.memorial-page .flame-spark {
  position: absolute;
  bottom: 32px;
  left: 50%;
  width: 2px;
  height: 2px;
  background: var(--memorial-candle);
  border-radius: 50%;
  opacity: 0;
  animation: memorial-spark-rise 3s ease-out infinite;
  z-index: 3;
}

.memorial-page .flame-spark-2 {
  animation-delay: 1.5s;
  left: calc(50% + 4px);
}

/* Smoke */
.memorial-page .candle-smoke {
  position: absolute;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 30px;
  background: linear-gradient(to top, rgba(200, 180, 160, 0.08), transparent);
  border-radius: 50%;
  filter: blur(3px);
  animation: memorial-smoke-drift 4s ease-out infinite;
  opacity: 0.3;
}

/* Wax drips */
.memorial-page .candle-drip {
  position: absolute;
  top: 2px;
  right: -2px;
  width: 5px;
  height: 12px;
  background: linear-gradient(180deg, #f5e6c8, #e8d5b0);
  border-radius: 0 0 50% 50%;
  animation: memorial-wax-drip 8s ease-in-out infinite;
}

.memorial-page .candle-drip-2 {
  right: auto;
  left: -1px;
  width: 4px;
  height: 8px;
  animation-delay: 4s;
  animation-duration: 10s;
}

/* ---- Hero text ---- */
.memorial-page .memorial-hero-name {
  position: relative;
  font-family: var(--font-primary, 'Bebas Neue', sans-serif);
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  color: var(--memorial-warm);
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  line-height: 1.15;
  z-index: 2;
  text-shadow: 0 0 40px rgba(212, 168, 67, 0.15);
}

.memorial-page .memorial-hero-dates {
  position: relative;
  font-family: var(--font-secondary, 'Inter', sans-serif);
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  color: var(--memorial-gold);
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
  font-weight: 300;
  z-index: 2;
}

.memorial-page .memorial-hero-role {
  position: relative;
  font-family: var(--font-secondary, 'Inter', sans-serif);
  font-size: clamp(0.9rem, 1.8vw, 1.1rem);
  color: var(--memorial-text-muted);
  max-width: 600px;
  line-height: 1.6;
  z-index: 2;
}

.memorial-page .memorial-hero-divider {
  position: relative;
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--memorial-gold), transparent);
  margin: 2rem auto;
  z-index: 2;
}

/* ---- Section common styles ---- */
.memorial-page .memorial-section {
  padding: 5rem 2rem;
  max-width: 900px;
  margin: 0 auto;
}

.memorial-page .memorial-section-title {
  font-family: var(--font-primary, 'Bebas Neue', sans-serif);
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  color: var(--memorial-gold);
  text-align: center;
  margin-bottom: 1rem;
  letter-spacing: 0.04em;
}

.memorial-page .memorial-section-subtitle {
  text-align: center;
  color: var(--memorial-text-muted);
  font-size: 1rem;
  margin-bottom: 3rem;
  line-height: 1.6;
}

.memorial-page .memorial-divider {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--memorial-amber), transparent);
  margin: 0 auto 3rem;
}

/* ---- Counter Section ---- */
.memorial-page .memorial-counter-section {
  padding: 2rem 0;
  text-align: center;
}

.memorial-page .date-counter-header {
  color: var(--memorial-text-muted);
}

/* ---- Biography Section ---- */
.memorial-page .memorial-biography {
  background: var(--memorial-dark-warm);
  border-top: 1px solid var(--memorial-border);
  border-bottom: 1px solid var(--memorial-border);
}

.memorial-page .memorial-bio-text {
  font-family: var(--font-secondary, 'Inter', sans-serif);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--memorial-text);
  margin-bottom: 1.5rem;
}

.memorial-page .memorial-bio-text:last-of-type {
  margin-bottom: 0;
}

.memorial-page .memorial-quote {
  position: relative;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--memorial-gold);
  text-align: center;
  padding: 2rem 2.5rem;
  margin: 2.5rem 0;
  border-left: 3px solid var(--memorial-amber);
  background: rgba(212, 168, 67, 0.04);
  border-radius: 0 8px 8px 0;
  line-height: 1.7;
}

.memorial-page .memorial-quote::before {
  content: '\201C';
  position: absolute;
  top: -0.3rem;
  left: 1rem;
  font-size: 4rem;
  color: var(--memorial-gold);
  opacity: 0.2;
  font-family: Georgia, serif;
  line-height: 1;
}

/* ---- Creation Stats (Years of Creation) ---- */
.memorial-page .memorial-creation-counter {
  background: var(--memorial-dark);
  border-top: 1px solid var(--memorial-border);
}

.memorial-page .creation-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  max-width: 700px;
  margin: 0 auto;
}

.memorial-page .creation-stat-card {
  text-align: center;
  padding: 2rem 1.5rem;
  background: rgba(212, 168, 67, 0.04);
  border: 1px solid var(--memorial-border);
  border-radius: 12px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.memorial-page .creation-stat-card:hover {
  border-color: rgba(212, 168, 67, 0.4);
  box-shadow: 0 0 20px rgba(212, 168, 67, 0.08);
}

.memorial-page .creation-stat-primary {
  border-color: rgba(212, 168, 67, 0.35);
  background: rgba(212, 168, 67, 0.06);
}

.memorial-page .creation-stat-number {
  font-family: var(--font-primary, 'Bebas Neue', sans-serif);
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  color: var(--memorial-gold);
  line-height: 1.1;
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.memorial-page .creation-stat-label {
  font-size: 0.9rem;
  color: var(--memorial-text);
  font-weight: 500;
}

.memorial-page .creation-stat-sublabel {
  font-size: 0.8rem;
  color: var(--memorial-text-muted);
  margin-top: 0.25rem;
}

/* ---- Timeline Section ---- */
.memorial-page .memorial-timeline {
  background: var(--memorial-dark);
}

.memorial-page .timeline-list {
  position: relative;
  list-style: none;
  padding: 0;
  margin: 0;
}

.memorial-page .timeline-list::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--memorial-amber), var(--memorial-border), transparent);
}

.memorial-page .timeline-item {
  position: relative;
  padding: 0 0 3rem 56px;
  transition: transform 0.3s ease;
}

.memorial-page .timeline-item:last-child {
  padding-bottom: 0;
}

.memorial-page .timeline-item:hover {
  transform: translateX(4px);
}

.memorial-page .timeline-dot {
  position: absolute;
  left: 12px;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--memorial-dark);
  border: 2px solid var(--memorial-amber);
  z-index: 1;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.memorial-page .timeline-dot-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(212, 168, 67, 0.2);
  animation: memorial-dot-pulse 3s ease-in-out infinite;
}

.memorial-page .timeline-item:hover .timeline-dot {
  background: var(--memorial-amber);
  box-shadow: 0 0 12px rgba(212, 168, 67, 0.5);
}

.memorial-page .timeline-item.timeline-final .timeline-dot {
  background: var(--memorial-amber);
  box-shadow: 0 0 12px rgba(212, 168, 67, 0.4);
}

.memorial-page .timeline-year {
  font-family: var(--font-primary, 'Bebas Neue', sans-serif);
  font-size: 1.3rem;
  color: var(--memorial-gold);
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

.memorial-page .timeline-era-title {
  font-family: var(--font-secondary, 'Inter', sans-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--memorial-warm);
  margin-bottom: 0.6rem;
}

.memorial-page .timeline-description {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--memorial-text-muted);
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.memorial-page .timeline-album-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--memorial-gold);
  text-decoration: none;
  font-weight: 500;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.memorial-page .timeline-album-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.memorial-page .timeline-album-link .icon {
  color: var(--memorial-amber);
}

/* ---- Album Gallery Section ---- */
.memorial-page .memorial-gallery {
  background: var(--memorial-dark-warm);
  border-top: 1px solid var(--memorial-border);
  border-bottom: 1px solid var(--memorial-border);
}

.memorial-page .memorial-gallery .memorial-section {
  max-width: 1100px;
}

.memorial-page .album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
}

.memorial-page .album-grid-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
  transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.memorial-page .album-grid-item:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.memorial-page .album-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.6) brightness(0.9);
  transition: filter 0.6s ease;
}

.memorial-page .album-grid-item:hover img {
  filter: grayscale(0) brightness(1);
}

.memorial-page .album-grid-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2.5rem 0.75rem 0.75rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  opacity: 0;
  transition: opacity 0.4s ease;
}

.memorial-page .album-grid-item:hover .album-grid-overlay {
  opacity: 1;
}

.memorial-page .album-grid-overlay span {
  display: block;
  font-size: 0.8rem;
  color: var(--memorial-warm);
  font-weight: 500;
  line-height: 1.3;
}

.memorial-page .album-grid-overlay .album-year-label {
  font-size: 0.7rem;
  color: var(--memorial-gold);
  margin-top: 0.2rem;
}

/* ============================================================================
   CANDLE WALL — "Light a Candle" interactive feature
   Up to 50 CSS-animated candles on a responsive grid, with staggered flames.
   ============================================================================ */

/* ---- Section wrapper ---- */
.memorial-page .memorial-candle-wall {
  background: var(--memorial-dark);
  border-top: 1px solid var(--memorial-border);
  border-bottom: 1px solid var(--memorial-border);
}

/* ---- Counter display ---- */
.memorial-page .candle-wall-counter {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
  font-family: var(--font-secondary, 'Inter', sans-serif);
}

.memorial-page .candle-wall-count {
  font-family: var(--font-primary, 'Bebas Neue', sans-serif);
  font-size: clamp(2rem, 4vw, 3rem);
  color: var(--memorial-gold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.memorial-page .candle-wall-label {
  font-size: 0.95rem;
  color: var(--memorial-text-muted);
}

/* ---- Candle grid ---- */
.memorial-page .candle-wall-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 0.75rem;
  min-height: 80px;
  margin-bottom: 2.5rem;
}

/* ---- Individual candle ---- */
.memorial-page .cw-candle {
  position: relative;
  width: 22px;
  height: 56px;
  flex-shrink: 0;
}

/* New candle entrance animation */
.memorial-page .cw-candle--new {
  animation: cw-candle-appear 0.7s ease-out both;
}

/* ---- Candle body (wax stick) ---- */
.memorial-page .cw-body {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 28px;
  background: linear-gradient(180deg, #f5e6c8 0%, #d4c4a0 50%, #c8b898 100%);
  border-radius: 2px 2px 1px 1px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ---- Wick ---- */
.memorial-page .cw-wick {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 1.5px;
  height: 5px;
  background: #4a3a2a;
}

/* ---- Flame container ---- */
.memorial-page .cw-flame {
  position: absolute;
  bottom: 31px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 20px;
}

/* ---- Outer flame (warm orange) ---- */
.memorial-page .cw-flame-outer {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 18px;
  background: radial-gradient(
    ellipse at center bottom,
    var(--memorial-candle) 0%,
    #ff9500 45%,
    transparent 75%
  );
  border-radius: 50% 50% 35% 35%;
  animation: cw-flame-flicker 2.2s ease-in-out infinite alternate;
  animation-delay: var(--cw-delay, 0s);
}

/* ---- Inner flame (bright core) ---- */
.memorial-page .cw-flame-inner {
  position: absolute;
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 12px;
  background: radial-gradient(
    ellipse at center bottom,
    #fff8e0 0%,
    var(--memorial-candle) 60%,
    transparent 100%
  );
  border-radius: 50% 50% 35% 35%;
  animation: cw-flame-inner-sway 1.6s ease-in-out infinite alternate;
  animation-delay: var(--cw-delay, 0s);
  z-index: 1;
}

/* ---- Ambient glow beneath the flame ---- */
.memorial-page .cw-glow {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  background: radial-gradient(
    circle,
    rgba(255, 204, 68, 0.18) 0%,
    rgba(255, 153, 0, 0.06) 50%,
    transparent 75%
  );
  border-radius: 50%;
  pointer-events: none;
  animation: cw-glow-pulse 3s ease-in-out infinite alternate;
  animation-delay: var(--cw-delay, 0s);
}

/* ---- "Light a Candle" button ---- */
.memorial-page .candle-wall-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.9rem 2.2rem;
  margin: 0 auto;
  max-width: 260px;
  background: transparent;
  border: 1px solid var(--memorial-amber);
  color: var(--memorial-gold);
  font-family: var(--font-secondary, 'Inter', sans-serif);
  font-size: 1rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease,
              color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
  letter-spacing: 0.03em;
}

.memorial-page .candle-wall-btn:hover {
  background: rgba(212, 168, 67, 0.12);
  border-color: var(--memorial-gold);
  color: var(--memorial-warm);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212, 168, 67, 0.15);
}

.memorial-page .candle-wall-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(212, 168, 67, 0.1);
}

/* Small decorative flame icon inside button */
.memorial-page .candle-wall-btn-flame {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: radial-gradient(
    ellipse at center bottom,
    var(--memorial-candle) 0%,
    #ff9500 60%,
    transparent 90%
  );
  border-radius: 50% 50% 30% 30%;
  animation: cw-btn-flame-dance 1.8s ease-in-out infinite alternate;
  flex-shrink: 0;
}

/* ---- Thank-you message ---- */
.memorial-page .candle-wall-thanks {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.95rem;
  color: var(--memorial-gold);
  font-style: italic;
  animation: cw-thanks-appear 0.5s ease-out both;
}

/* ============================================================================
   CANDLE WALL KEYFRAMES
   ============================================================================ */

/* New candle grows in from nothing */
@keyframes cw-candle-appear {
  0%   { opacity: 0; transform: scaleY(0.3) scaleX(0.6); }
  60%  { opacity: 1; transform: scaleY(1.05) scaleX(1.02); }
  100% { opacity: 1; transform: scaleY(1) scaleX(1); }
}

/* Wall-candle flame flicker — subtler than hero candle */
@keyframes cw-flame-flicker {
  0%   { transform: translateX(-50%) scale(1) rotate(-1deg); opacity: 0.95; }
  15%  { transform: translateX(-50%) scale(1.06) rotate(1deg); opacity: 0.88; }
  35%  { transform: translateX(-50%) scale(0.94) rotate(-0.5deg); opacity: 1; }
  55%  { transform: translateX(-50%) scale(1.08) rotate(1.5deg); opacity: 0.85; }
  75%  { transform: translateX(-50%) scale(0.97) rotate(-1deg); opacity: 0.92; }
  100% { transform: translateX(-50%) scale(1.03) rotate(0.5deg); opacity: 0.96; }
}

/* Inner flame sway */
@keyframes cw-flame-inner-sway {
  0%   { transform: translateX(-50%) scaleY(1) scaleX(1); opacity: 0.9; }
  25%  { transform: translateX(-50%) scaleY(1.12) scaleX(0.92); opacity: 1; }
  50%  { transform: translateX(-50%) scaleY(0.88) scaleX(1.08); opacity: 0.85; }
  75%  { transform: translateX(-50%) scaleY(1.06) scaleX(0.96); opacity: 0.95; }
  100% { transform: translateX(-50%) scaleY(0.94) scaleX(1.04); opacity: 0.9; }
}

/* Ambient glow pulse */
@keyframes cw-glow-pulse {
  0%   { opacity: 0.5; transform: translateX(-50%) scale(1); }
  50%  { opacity: 0.8; transform: translateX(-50%) scale(1.1); }
  100% { opacity: 0.55; transform: translateX(-50%) scale(0.95); }
}

/* Button flame icon */
@keyframes cw-btn-flame-dance {
  0%   { transform: scaleY(1) rotate(-2deg); }
  50%  { transform: scaleY(1.1) rotate(1deg); }
  100% { transform: scaleY(0.95) rotate(-1deg); }
}

/* Thanks message entrance */
@keyframes cw-thanks-appear {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Book of Memory Section ---- */
.memorial-page .memorial-book {
  background: var(--memorial-dark);
  text-align: center;
}

.memorial-page .memorial-book-text {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--memorial-text);
  max-width: 700px;
  margin: 0 auto 2rem;
}

/* ---- Memories CTA Section ---- */
.memorial-page .memorial-memories-cta {
  background: var(--memorial-dark-warm);
  border-top: 1px solid var(--memorial-border);
}

.memorial-page .memories-cta-card {
  text-align: center;
  padding: 3rem 2rem;
  background: rgba(212, 168, 67, 0.03);
  border: 1px solid var(--memorial-border);
  border-radius: 16px;
}

.memorial-page .memories-cta-icon {
  color: var(--memorial-gold);
  margin-bottom: 1.5rem;
  opacity: 0.7;
}

.memorial-page .memories-cta-title {
  font-family: var(--font-primary, 'Bebas Neue', sans-serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--memorial-gold);
  margin-bottom: 1rem;
}

.memorial-page .memories-cta-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--memorial-text-muted);
  max-width: 600px;
  margin: 0 auto 2rem;
}

/* ---- CTA links ---- */
.memorial-page .memorial-cta-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2.5rem;
  background: transparent;
  border: 1px solid var(--memorial-amber);
  color: var(--memorial-gold);
  font-family: var(--font-secondary, 'Inter', sans-serif);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.3s ease;
  letter-spacing: 0.03em;
}

.memorial-page .memorial-cta-link:hover {
  background: rgba(212, 168, 67, 0.1);
  border-color: var(--memorial-gold);
  color: var(--memorial-warm);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212, 168, 67, 0.15);
}

/* ---- Footer memorial note ---- */
.memorial-page .memorial-footer-note {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--memorial-text-muted);
  font-style: italic;
  font-size: 0.95rem;
  border-top: 1px solid var(--memorial-border);
  line-height: 1.6;
}

.memorial-page .memorial-footer-candle {
  display: inline-block;
  width: 6px;
  height: 16px;
  background: linear-gradient(180deg, var(--memorial-candle), var(--memorial-amber));
  border-radius: 2px 2px 1px 1px;
  margin-bottom: 1rem;
  position: relative;
}

.memorial-page .memorial-footer-candle::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 10px;
  background: radial-gradient(ellipse at center bottom, var(--memorial-candle) 0%, #ff9500 50%, transparent 80%);
  border-radius: 50% 50% 30% 30%;
  animation: memorial-footer-candle-flicker 2s ease-in-out infinite alternate;
}

/* ---- Floating particles ---- */
.memorial-page .memorial-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.memorial-page .memorial-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: radial-gradient(circle, rgba(212, 168, 67, 0.6), transparent);
  border-radius: 50%;
  animation: memorial-particle-float linear infinite;
  opacity: 0;
}

/* Stagger particles across the viewport */
.memorial-page .memorial-particle:nth-child(1) { left: 10%; bottom: -5%; animation-duration: 18s; animation-delay: 0s; width: 2px; height: 2px; }
.memorial-page .memorial-particle:nth-child(2) { left: 25%; bottom: -5%; animation-duration: 22s; animation-delay: 3s; width: 4px; height: 4px; }
.memorial-page .memorial-particle:nth-child(3) { left: 40%; bottom: -5%; animation-duration: 16s; animation-delay: 1s; }
.memorial-page .memorial-particle:nth-child(4) { left: 55%; bottom: -5%; animation-duration: 24s; animation-delay: 5s; width: 2px; height: 2px; }
.memorial-page .memorial-particle:nth-child(5) { left: 70%; bottom: -5%; animation-duration: 20s; animation-delay: 2s; width: 4px; height: 4px; }
.memorial-page .memorial-particle:nth-child(6) { left: 85%; bottom: -5%; animation-duration: 19s; animation-delay: 7s; }
.memorial-page .memorial-particle:nth-child(7) { left: 15%; bottom: -5%; animation-duration: 25s; animation-delay: 4s; width: 2px; height: 2px; }
.memorial-page .memorial-particle:nth-child(8) { left: 65%; bottom: -5%; animation-duration: 21s; animation-delay: 6s; }

/* ---- Atmospheric fog layers ---- */
.memorial-page .memorial-fog {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.memorial-page .fog-layer {
  position: absolute;
  inset: 0;
  opacity: 0.8;
  background: linear-gradient(90deg,
    transparent 0%, rgba(200, 195, 185, 0.04) 20%,
    rgba(200, 195, 185, 0.07) 50%, rgba(200, 195, 185, 0.04) 80%, transparent 100%);
  animation: memorial-fog-drift-1 45s linear infinite;
  will-change: transform;
}

.memorial-page .fog-layer-2 {
  opacity: 0.6;
  animation: memorial-fog-drift-2 60s linear infinite;
  background: linear-gradient(90deg,
    transparent 0%, rgba(180, 175, 165, 0.03) 30%,
    rgba(180, 175, 165, 0.06) 55%, rgba(180, 175, 165, 0.03) 75%, transparent 100%);
}

/* ---- Drop cap on first bio paragraph ---- */
.memorial-page .memorial-bio-text:first-of-type::first-letter {
  float: left;
  font-family: var(--font-display, 'Bebas Neue', serif);
  font-size: 3.5em;
  line-height: 0.8;
  padding-right: 0.1em;
  color: var(--memorial-gold);
  font-weight: 400;
}

/* ---- Portrait photo in hero ---- */
.memorial-page .memorial-hero-portrait {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--memorial-gold);
  box-shadow: 0 0 40px rgba(212, 168, 67, 0.2), 0 0 80px rgba(212, 168, 67, 0.08);
  z-index: 2;
  animation: memorial-portrait-appear 1.2s ease-out both;
}

.memorial-page .memorial-hero-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(0.15) contrast(1.05);
  transition: filter 0.6s ease;
}

.memorial-page .memorial-hero-portrait:hover img {
  filter: sepia(0) contrast(1);
}

/* ---- Scroll-triggered entrance animations ---- */
/* These use CSS animation with IntersectionObserver via data-reveal attribute,
   but also work standalone via animation-timeline if supported */

.memorial-page .memorial-biography,
.memorial-page .memorial-creation-counter,
.memorial-page .memorial-timeline,
.memorial-page .memorial-gallery,
.memorial-page .memorial-quotes,
.memorial-page .memorial-candle-wall,
.memorial-page .memorial-book,
.memorial-page .memorial-memories-cta {
  animation: memorial-section-fade-in 0.8s ease-out both;
}

.memorial-page .memorial-counter-section { animation-delay: 0.2s; }
.memorial-page .memorial-biography { animation-delay: 0.1s; }
.memorial-page .memorial-creation-counter { animation-delay: 0.15s; }

/* ============================================================================
   KEYFRAMES
   ============================================================================ */

/* Hero entrance animations */
@keyframes memorial-portrait-appear {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes memorial-name-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes memorial-dates-fade-in {
  from { opacity: 0; letter-spacing: 0.3em; }
  to   { opacity: 1; letter-spacing: 0.15em; }
}

@keyframes memorial-role-fade-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Section entrance */
@keyframes memorial-section-fade-in {
  from { opacity: 0.7; }
  to   { opacity: 1; }
}

/* Candle flame animations */
@keyframes memorial-flame-flicker {
  0%   { transform: translateX(-50%) scale(1) rotate(-1.5deg); opacity: 1; }
  12%  { transform: translateX(-50%) scale(1.04) rotate(1deg); opacity: 0.94; }
  28%  { transform: translateX(-50%) scale(0.96) rotate(-0.5deg); opacity: 1; }
  45%  { transform: translateX(-50%) scale(1.06) rotate(1.5deg); opacity: 0.9; }
  62%  { transform: translateX(-50%) scale(0.98) rotate(-1deg); opacity: 0.97; }
  78%  { transform: translateX(-50%) scale(1.02) rotate(0.5deg); opacity: 0.93; }
  100% { transform: translateX(-50%) scale(0.97) rotate(-2deg); opacity: 1; }
}

@keyframes memorial-flame-inner-sway {
  0%   { transform: translateX(-50%) scaleY(1) scaleX(1); opacity: 0.9; }
  20%  { transform: translateX(-50%) scaleY(1.1) scaleX(0.95); opacity: 1; }
  40%  { transform: translateX(-50%) scaleY(0.92) scaleX(1.05); opacity: 0.88; }
  60%  { transform: translateX(-50%) scaleY(1.08) scaleX(0.98); opacity: 0.95; }
  80%  { transform: translateX(-50%) scaleY(0.96) scaleX(1.02); opacity: 0.85; }
  100% { transform: translateX(-50%) scaleY(1.05) scaleX(0.97); opacity: 0.92; }
}

@keyframes memorial-flame-mid-sway {
  0%   { transform: translateX(-50%) scale(1) rotate(0deg); opacity: 0.85; }
  33%  { transform: translateX(-50%) scale(1.05) rotate(1deg); opacity: 0.9; }
  66%  { transform: translateX(-50%) scale(0.95) rotate(-1deg); opacity: 0.82; }
  100% { transform: translateX(-50%) scale(1.02) rotate(0.5deg); opacity: 0.88; }
}

@keyframes memorial-glow-breathe {
  0%   { opacity: 0.4; transform: translateX(-50%) scale(1); }
  30%  { opacity: 0.65; transform: translateX(-50%) scale(1.08); }
  60%  { opacity: 0.45; transform: translateX(-50%) scale(0.95); }
  100% { opacity: 0.7; transform: translateX(-50%) scale(1.12); }
}

@keyframes memorial-spark-rise {
  0%   { transform: translateX(-50%) translateY(0); opacity: 0; }
  10%  { opacity: 0.8; }
  50%  { opacity: 0.4; transform: translateX(calc(-50% + 5px)) translateY(-20px); }
  100% { opacity: 0; transform: translateX(calc(-50% - 3px)) translateY(-40px); }
}

@keyframes memorial-smoke-drift {
  0%   { transform: translateX(-50%) translateY(0) scaleX(1); opacity: 0.15; }
  50%  { transform: translateX(calc(-50% + 5px)) translateY(-15px) scaleX(1.5); opacity: 0.08; }
  100% { transform: translateX(calc(-50% - 3px)) translateY(-30px) scaleX(2); opacity: 0; }
}

@keyframes memorial-wax-drip {
  0%, 70% { transform: translateY(0); opacity: 0.8; }
  85%     { transform: translateY(6px); opacity: 0.6; }
  100%    { transform: translateY(0); opacity: 0.8; }
}

/* Particles */
@keyframes memorial-particle-float {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  10%  { opacity: 0.6; }
  50%  { opacity: 0.3; }
  90%  { opacity: 0.5; }
  100% { transform: translateY(-100vh) translateX(30px); opacity: 0; }
}

/* Fog drift */
@keyframes memorial-fog-drift-1 {
  0%   { transform: translateX(-15%) scaleX(1.3); }
  50%  { transform: translateX(15%) scaleX(1.1); }
  100% { transform: translateX(-15%) scaleX(1.3); }
}

@keyframes memorial-fog-drift-2 {
  0%   { transform: translateX(10%) scaleX(1.2); }
  50%  { transform: translateX(-20%) scaleX(1.4); }
  100% { transform: translateX(10%) scaleX(1.2); }
}

/* Timeline dot pulse */
@keyframes memorial-dot-pulse {
  0%, 100% { opacity: 0; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(1.3); }
}

/* Footer candle */
@keyframes memorial-footer-candle-flicker {
  0%   { transform: translateX(-50%) scale(1) rotate(-2deg); opacity: 0.8; }
  50%  { transform: translateX(-50%) scale(1.1) rotate(1deg); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.95) rotate(-1deg); opacity: 0.85; }
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
  .memorial-page .memorial-hero {
    min-height: 70vh;
    padding: 5rem 1.5rem 3rem;
  }

  .memorial-page .memorial-section {
    padding: 3.5rem 1.5rem;
  }

  .memorial-page .album-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
  }

  .memorial-page .memorial-quote {
    padding: 1.5rem;
    margin: 2rem 0;
  }

  .memorial-page .timeline-list::before {
    left: 14px;
  }

  .memorial-page .timeline-dot {
    left: 6px;
    width: 16px;
    height: 16px;
  }

  .memorial-page .timeline-item {
    padding-left: 44px;
  }

  .memorial-page .creation-stats-grid {
    gap: 1rem;
  }

  .memorial-page .creation-stat-card {
    padding: 1.5rem 1rem;
  }

  .memorial-page .creation-stat-number {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
  }

  .memorial-page .candle-wall-grid {
    gap: 0.75rem 0.5rem;
  }

  .memorial-page .cw-candle {
    width: 18px;
    height: 48px;
  }
}

@media (max-width: 480px) {
  .memorial-page .memorial-hero {
    min-height: 65vh;
    padding: 4rem 1rem 2.5rem;
  }

  .memorial-page .memorial-section {
    padding: 2.5rem 1rem;
  }

  .memorial-page .album-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .memorial-page .candle-container {
    transform: scale(0.85);
    margin-bottom: 2rem;
  }

  .memorial-page .memorial-hero-portrait {
    width: 120px;
    height: 120px;
  }

  .memorial-page .creation-stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .memorial-page .creation-stat-card {
    padding: 1.25rem;
  }

  .memorial-page .memories-cta-card {
    padding: 2rem 1rem;
  }

  .memorial-page .candle-wall-grid {
    gap: 0.6rem 0.4rem;
  }

  .memorial-page .cw-candle {
    width: 16px;
    height: 42px;
  }

  .memorial-page .cw-body {
    width: 8px;
    height: 22px;
  }

  .memorial-page .cw-wick {
    bottom: 22px;
    height: 4px;
  }

  .memorial-page .cw-flame {
    bottom: 24px;
    width: 10px;
    height: 16px;
  }

  .memorial-page .cw-flame-outer {
    width: 8px;
    height: 14px;
  }

  .memorial-page .cw-flame-inner {
    width: 5px;
    height: 10px;
  }

  .memorial-page .cw-glow {
    bottom: 18px;
    width: 22px;
    height: 22px;
  }

  .memorial-page .candle-wall-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
  }
}

/* ============================================================================
   ACCESSIBILITY & REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .memorial-page .memorial-hero-name.typewriter,
  .memorial-page .memorial-hero-dates,
  .memorial-page .memorial-hero-role,
  .memorial-page .memorial-hero-portrait {
    animation: none !important;
    opacity: 1 !important;
  }

  .memorial-page .flame-outer,
  .memorial-page .flame-inner,
  .memorial-page .flame-mid,
  .memorial-page .flame-glow,
  .memorial-page .flame-spark,
  .memorial-page .candle-smoke,
  .memorial-page .candle-drip,
  .memorial-page .memorial-footer-candle::before {
    animation: none !important;
  }

  .memorial-page .memorial-particles,
  .memorial-page .memorial-fog {
    display: none;
  }

  .memorial-page .timeline-dot-pulse {
    animation: none;
  }

  /* Candle wall: disable flame animations but keep candles visible */
  .memorial-page .cw-flame-outer,
  .memorial-page .cw-flame-inner,
  .memorial-page .cw-glow,
  .memorial-page .candle-wall-btn-flame,
  .memorial-page .cw-candle--new {
    animation: none !important;
  }

  .memorial-page .cw-candle--new {
    opacity: 1;
    transform: none;
  }
}

/* ============================================================================
   PRINT
   ============================================================================ */

@media print {
  .memorial-page {
    background: white;
    color: #333;
  }

  .memorial-page .memorial-particles,
  .memorial-page .memorial-fog,
  .memorial-page .candle-container,
  .memorial-page .candle-wall-grid,
  .memorial-page .candle-wall-btn {
    display: none;
  }

  .memorial-page .memorial-hero {
    min-height: auto;
    background: none;
  }

  .memorial-page .memorial-hero-name {
    color: #333;
  }

  .memorial-page .memorial-hero-dates {
    color: #666;
  }

  .memorial-page .album-grid-item img {
    filter: none;
  }
}
