/* =====================================================
   The Marble Project — Wrapped
   Mobile-first, full-bleed cards, Spotify-Wrapped feel.
   Brand colours match local-wordpress/wp-content/custom-style.css.
   ===================================================== */

:root {
  --marb-deep: #5c0404;
  --marb-red: #b81c1c;
  --marb-bright: #dc1c24;
  --marb-gold: #c9a21e;
  --marb-gold-light: #f5e6a3;
  --marb-cream: #fdf8f0;
  --marb-charcoal: #1a1412;
  --marb-warm-gray: #4a4040;
  --marb-sepia: #d9c89a;

  --display: 'Cormorant Garamond', 'Georgia', 'Times New Roman', serif;
  --body: 'Lora', 'Georgia', 'Times New Roman', serif;

  /* Used for safe-area on iPhones */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  /* Warm cream canvas — nothing on the page is pitch-black anymore. */
  background: #f3e9d2;
  color: var(--marb-charcoal);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  /* Soft warm gradient behind any card — visible at edges if the card
     doesn't fill the viewport, and as the fallback before any card renders. */
  background: linear-gradient(170deg, #fdf8f0 0%, #f3e9d2 60%, #ecd9b0 100%);
}

/* ---------- Ambient marble-run background ---------- */
/* A subtle layer that sits behind every card. Three marbles roll along
   gently curving tracks. Brand-coloured (deep maroon → bright red, with
   a gold sheen highlight). Suppressed on memorial cards. */
.marblerun-ambient {
  position: fixed;
  inset: 0;
  z-index: 1; /* above body but below cards */
  pointer-events: none;
  opacity: 0.32;
  transition: opacity 1.2s ease;
  mix-blend-mode: screen;
}
.marblerun-ambient svg { width: 100%; height: 100%; display: block; }
.marblerun-ambient .marble {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)) drop-shadow(0 0 8px rgba(245,230,163,0.25));
}
/* Suppress on memorial cards */
body.memorial-active .marblerun-ambient { opacity: 0.05; }
/* Cream cards: tone right down (the gold gets lost on cream) */
body.theme-active-cream .marblerun-ambient { opacity: 0.18; mix-blend-mode: multiply; }

/* ---------- Top progress bar (marble-run style) ---------- */
.progress {
  position: fixed;
  top: calc(10px + var(--safe-top));
  left: 14px;
  right: 14px;
  height: 14px;
  z-index: 50;
  pointer-events: none;
}
.progress .progress-rail {
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  height: 2px;
  margin-top: -1px;
  background: linear-gradient(90deg,
    rgba(245,230,163,0.05) 0%,
    rgba(245,230,163,0.32) 6%,
    rgba(245,230,163,0.32) 94%,
    rgba(245,230,163,0.05) 100%);
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.4);
}
.progress .progress-segments {
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  height: 4px;
  margin-top: -2px;
  display: flex;
  gap: 0;
}
.progress .progress-segments .tick {
  flex: 1;
  height: 100%;
  position: relative;
}
.progress .progress-segments .tick::after {
  /* tiny notch at end of each segment — like little gateposts on the run */
  content: "";
  position: absolute;
  right: 0;
  top: -3px;
  width: 1px;
  height: 10px;
  background: rgba(245,230,163,0.35);
}
.progress .progress-segments .tick:last-child::after { display: none; }
.progress .progress-segments .tick.done {
  background: linear-gradient(90deg, rgba(245,230,163,0.55) 0%, rgba(220,28,36,0.65) 100%);
  border-radius: 1px;
}
.progress .progress-marble {
  position: absolute;
  top: 50%;
  left: 0;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  margin-left: -8px;
  border-radius: 50%;
  pointer-events: none;
  transition: left 0.7s cubic-bezier(.55,.05,.4,1.05);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.55));
}
.progress .progress-marble .pm-body {
  position: absolute; inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #fff5b8 0%, transparent 26%),
    linear-gradient(135deg, #5c0404 0%, #dc1c24 55%, #b81c1c 100%);
  box-shadow:
    inset -2px -3px 4px rgba(0,0,0,0.55),
    inset 2px 2px 3px rgba(255,255,255,0.18),
    0 0 12px rgba(245,230,163,0.35);
}
.progress .progress-marble .pm-sheen {
  position: absolute;
  top: 18%; left: 22%;
  width: 30%; height: 28%;
  background: radial-gradient(circle at 30% 30%, rgba(255,245,184,0.95) 0%, rgba(245,230,163,0.4) 50%, transparent 100%);
  border-radius: 50%;
  filter: blur(0.6px);
}
@keyframes progress-marble-roll {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.progress .progress-marble.rolling .pm-body { animation: progress-marble-roll 1.2s linear infinite; }
body.memorial-active .progress .progress-marble { opacity: 0.45; }

/* ---------- Top bar (logo + controls) ---------- */
.topbar {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  z-index: 40;
  pointer-events: none;
}
.topbar .brand,
.topbar .ctrl {
  pointer-events: auto;
}
.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--marb-cream);
  text-decoration: none;
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  opacity: 0.85;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.topbar .brand img { display: block; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5)); }
.topbar .controls { display: flex; gap: 8px; }
.ctrl {
  position: relative;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--marb-cream);
  width: 38px; height: 38px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background .2s, transform .15s;
}
.ctrl:hover { background: rgba(0,0,0,0.55); }
.ctrl:active { transform: scale(0.94); }
.ctrl.pulse { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,230,163,0); }
  50%      { box-shadow: 0 0 0 8px rgba(245,230,163,0.25); }
}

/* ---------- Stage / Cards ---------- */
.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* dynamic viewport on mobile */
  overflow: hidden;
  outline: none;
  z-index: 2; /* above .marblerun-ambient (z=1) */
}

/* Tap zones */
.zone {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 28%;
  background: transparent;
  border: 0;
  cursor: pointer;
  z-index: 20;
}
.zone-prev { left: 0; }
.zone-next { right: 0; width: 72%; } /* bigger right zone like Stories */
.zone:focus-visible { outline: 2px dashed rgba(255,255,255,0.4); outline-offset: -10px; }

/* Card base */
.card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 7vw, 64px);
  padding-top: calc(60px + var(--safe-top));
  padding-bottom: calc(40px + var(--safe-bottom));
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .9s ease, transform 1.1s ease;
  will-change: opacity, transform;
}
.card.show { opacity: 1; transform: translateY(0); }

/* Photo background layer + gradient overlay */
.bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.bg img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.06);
  animation: kenburns 18s ease-out forwards;
  filter: saturate(1.05) contrast(1.02);
}
@keyframes kenburns {
  from { transform: scale(1.0); }
  to   { transform: scale(1.12) translate(-1.5%, -1%); }
}
.bg::after {
  content: "";
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.15) 30%, rgba(0,0,0,0.7) 100%),
    radial-gradient(60% 50% at 50% 60%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.45) 100%);
}

/* Card text wrapper */
.card .body {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  text-align: left;
}
.card.center .body { text-align: center; }

/* ====================================================================
   Split layout: text claims a band/panel, imagery claims the rest.
   No more floating-on-top backing blocks that smother the photos.
   Mode is decided by viewport aspect ratio:
     - portrait / square-ish  → bottom band (full width, content-tall)
     - landscape (incl ultrawide) → right-side panel (~38% wide)
   ==================================================================== */
.card.split {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;   /* portrait default: image on top, text band below */
  grid-template-columns: minmax(0, 1fr);
  padding: 0;
  align-items: stretch;
}
.card.split .mosaic,
.card.split .photo-wall {
  position: relative !important;
  inset: auto !important;
  width: 100%;
  height: 100%;
  grid-row: 1;
  grid-column: 1;
  min-height: 0;          /* allow grid cell to constrain it cleanly */
}
.card.split .body {
  grid-row: 2;
  grid-column: 1;
  max-width: none;
  margin: 0;
  text-align: center;
  padding: 1.4rem 1.8rem 1.6rem;
  /* Bright, warm panel everywhere — the look the user picked from the
     thanks card. Dark warm text for contrast. Variation between cards
     comes from mosaic content, not from heavy panel theming. */
  background: linear-gradient(180deg, #fdf8f0 0%, #f3e9d2 100%);
  color: #2a160c;
  box-shadow: 0 -3px 24px rgba(60, 30, 10, 0.18);
  border-top: 1px solid rgba(120, 60, 30, 0.18);
}
/* Memorial cards (now using theme=cream) get an extra-thin gold rule above
   the panel as a small respectful flourish — celebration in warm tones. */
.card.split[data-id^="memorial"] .body {
  border-top: 2px solid var(--marb-gold);
}
/* Sub-text and kicker on the panel */
.card.split .body .kicker  { opacity: 0.78; }
.card.split .body .big     { font-size: clamp(1.7rem, 3.6vw, 2.6rem); margin: 0.15em 0 0.2em; }
.card.split .body .sub     { font-size: clamp(0.95rem, 1.4vw, 1.05rem); max-width: 56ch; margin-left: auto; margin-right: auto; }
.card.split .body .big-suffix { display: block; margin: 0.15em 0 0.4em; opacity: 0.85; }

/* Landscape and wider: right-side panel instead of bottom band. */
@media (min-aspect-ratio: 4/3) and (min-width: 720px) {
  .card.split {
    grid-template-rows: minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr) minmax(300px, 38%);
  }
  .card.split .mosaic,
  .card.split .photo-wall {
    grid-column: 1;
    grid-row: 1;
  }
  .card.split .body {
    grid-column: 2;
    grid-row: 1;
    text-align: center;
    padding: 2rem 2.2rem;
    box-shadow: -3px 0 24px rgba(60, 30, 10, 0.18);
    border-top: none;
    border-left: 1px solid rgba(120, 60, 30, 0.18);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .card.split[data-id^="memorial"] .body {
    border-top: none;
    border-left: 2px solid var(--marb-gold);
  }
}
/* Ultrawide: keep panel proportionally narrower */
@media (min-aspect-ratio: 21/9) {
  .card.split {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 28%);
  }
}
/* Mobile portrait: cap band height so the image keeps real estate */
@media (max-aspect-ratio: 3/4) {
  .card.split {
    grid-template-rows: minmax(0, 1.4fr) auto;
  }
  .card.split .body { padding: 1.1rem 1.2rem 1.3rem; }
  .card.split .body .big { font-size: clamp(1.5rem, 5.5vw, 2rem); }
}
.card .kicker {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(13px, 2.3vw, 16px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--marb-gold-light);
  margin-bottom: 14px;
  opacity: 0.9;
}
.card .year {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(14px, 2.5vw, 18px);
  letter-spacing: 0.3em;
  color: var(--marb-gold-light);
  margin-bottom: 18px;
  opacity: 0.85;
}
.card .big {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(48px, 12vw, 128px);
  line-height: 1.0;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
  color: var(--marb-cream);
  text-shadow: 0 2px 14px rgba(0,0,0,0.35);
}
.card .big-suffix {
  display: block;
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(18px, 3.4vw, 30px);
  line-height: 1.25;
  color: var(--marb-gold-light);
  margin-top: 4px;
  letter-spacing: 0;
}
.card .sub {
  font-family: var(--body);
  font-size: clamp(15px, 2.4vw, 19px);
  line-height: 1.65;
  color: var(--marb-cream);
  max-width: 640px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.card.center .sub { margin-left: auto; margin-right: auto; }

/* Lists (institutions card etc.) */
.card .list {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  columns: 1;
}
.card .list li {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(17px, 3vw, 22px);
  padding: 6px 0;
  border-bottom: 1px solid rgba(245,230,163,0.18);
  color: var(--marb-cream);
}
.card .list li::before {
  content: "·  ";
  color: var(--marb-gold);
}

/* ===== Themes (per-card backgrounds & accents) ===== */

/* All themes brightened toward warm beige/cream — the user explicitly wants
   the celebratory thanks-card aesthetic across the deck. Each theme keeps a
   distinct accent (gold = honey, red = terracotta, deep = warm tan) but no
   theme is dark/black anymore. Text stays in deep warm tones for contrast. */
.theme-gold {
  background: linear-gradient(170deg, #fdf3d4 0%, #f0d27a 100%);
  color: var(--marb-charcoal);
}
.theme-gold .big { color: var(--marb-deep); text-shadow: none; }
.theme-gold .big-suffix { color: var(--marb-warm-gray); }
.theme-gold .sub { color: var(--marb-charcoal); }
.theme-gold .kicker, .theme-gold .year { color: var(--marb-red); }

.theme-red {
  background: linear-gradient(170deg, #f8d8c0 0%, #d99b80 100%);
  color: var(--marb-charcoal);
}
.theme-red .big { color: var(--marb-deep); text-shadow: none; }
.theme-red .big-suffix { color: var(--marb-warm-gray); }
.theme-red .sub { color: var(--marb-charcoal); }
.theme-red .kicker, .theme-red .year { color: var(--marb-deep); }

.theme-deep {
  background: linear-gradient(170deg, #f5e8d2 0%, #d4b88c 100%);
  color: var(--marb-charcoal);
}
.theme-deep .big {
  color: var(--marb-deep);
  text-shadow: none;
}
.theme-deep .big-suffix { color: var(--marb-warm-gray); }
.theme-deep .sub { color: var(--marb-charcoal); }
.theme-deep .kicker, .theme-deep .year { color: var(--marb-red); }

.theme-cream {
  background: linear-gradient(170deg, #fdf8f0 0%, #f5e6a3 100%);
  color: var(--marb-charcoal);
}
.theme-cream .big { color: var(--marb-deep); text-shadow: none; }
.theme-cream .big-suffix { color: var(--marb-warm-gray); }
.theme-cream .sub { color: var(--marb-charcoal); text-shadow: none; }
.theme-cream .kicker, .theme-cream .year { color: var(--marb-red); }
.theme-cream .list li { color: var(--marb-charcoal); border-color: rgba(92,4,4,0.15); }
.theme-cream .list li::before { color: var(--marb-red); }
/* When a cream card has a bg image, apply slightly different overlay */
.theme-cream .bg::after {
  background:
    linear-gradient(180deg, rgba(253,248,240,0.55) 0%, rgba(253,248,240,0.35) 40%, rgba(253,248,240,0.85) 100%);
}

/* ===== Memorial theme — sepia, soft, slow ===== */
.theme-memorial {
  background: linear-gradient(180deg, #f3ead4 0%, #e6d4a8 100%);
  color: var(--marb-charcoal);
}
.theme-memorial .big {
  color: var(--marb-deep);
  font-style: italic;
  font-weight: 500;
}
.theme-memorial .sub { color: var(--marb-charcoal); text-shadow: none; }
.theme-memorial .kicker { color: var(--marb-deep); }
.theme-memorial .bg img {
  filter: sepia(0.55) saturate(0.85) contrast(0.95) brightness(0.95);
  animation-duration: 26s; /* slower ken-burns */
}
.theme-memorial .bg::after {
  background:
    linear-gradient(180deg, rgba(243,234,212,0.55) 0%, rgba(243,234,212,0.25) 30%, rgba(230,212,168,0.85) 100%);
}
.theme-memorial .body { text-align: center; }
.theme-memorial .candle {
  display: block;
  width: 6px; height: 60px;
  margin: 0 auto 18px;
  background: linear-gradient(180deg, transparent 0%, var(--marb-gold) 30%, var(--marb-deep) 100%);
  border-radius: 3px;
  position: relative;
}
.theme-memorial .candle::before {
  content: "";
  position: absolute; top: -14px; left: 50%;
  transform: translateX(-50%);
  width: 10px; height: 16px;
  background: radial-gradient(circle at 50% 60%, #fff5b8 0%, #f5c04a 50%, transparent 70%);
  border-radius: 50% 50% 30% 30%;
  filter: blur(0.5px);
  animation: flicker 1.6s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.95; }
  50%      { transform: translateX(-52%) scale(1.06); opacity: 1; }
}

/* ===== Hero numbers — count-up emphasis ===== */
.card .big.numeric {
  font-feature-settings: "tnum", "lnum";
  font-variant-numeric: tabular-nums lining-nums;
}

/* ===== Thanks / share card ===== */
.share-actions {
  margin-top: 28px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: var(--marb-cream);
  color: var(--marb-deep);
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.04em;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s, background .2s;
}
.btn:hover { transform: translateY(-1px); background: var(--marb-gold-light); }
.btn-ghost {
  background: transparent;
  color: var(--marb-cream);
  border: 1px solid rgba(253,248,240,0.4);
}
.btn-ghost:hover { background: rgba(253,248,240,0.12); }

/* ===== Initial hint overlay ===== */
.hint {
  position: fixed;
  inset: 0;
  z-index: 200;
  /* Warm cream welcome screen — matches the rest of the deck. */
  background: linear-gradient(170deg, #fdf8f0 0%, #f3e9d2 55%, #ecd9b0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}
.hint.hidden { display: none; }
.hint-inner {
  max-width: 520px;
  animation: rise 1s ease forwards;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px);} to {opacity:1; transform:none;} }
.hint-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(40px, 9vw, 84px);
  color: var(--marb-deep);
  line-height: 1.0;
  margin-bottom: 18px;
  letter-spacing: -0.02em;
}
.hint-sub {
  color: var(--marb-charcoal);
  opacity: 0.78;
  font-size: 16px;
  margin-bottom: 28px;
}
.hint-start {
  background: var(--marb-deep);
  color: var(--marb-cream);
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.06em;
  padding: 14px 36px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: 0 4px 16px rgba(60, 30, 10, 0.22);
}
.hint-start:hover { background: var(--marb-red); color: var(--marb-cream); }

/* ===== Tiny utilities ===== */
.noscript-warn {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--marb-deep); color: var(--marb-cream); padding: 20px; text-align: center; z-index: 9999;
}

/* ===== Desktop tweaks ===== */
@media (min-width: 900px) {
  .card { padding: 96px 80px; }
  .card .body { max-width: 820px; }
  .card .list { columns: 2; column-gap: 40px; }
}

/* ===== Photo-mosaic / curated photo-wall background =====
   Drives every multi-image card. Layout adapts to tile count:
   3  → 1 large feature + 2 small (asymmetric)
   4  → 2x2 grid
   5  → 1 large feature + 4 small (asymmetric)
   6  → 3x2 grid (default)
   7-8→ 4x2 grid
   9+ → 3x3 grid
*/
.mosaic {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  overflow: hidden;
  /* Warm cream backdrop: shows in any letterbox bands. No more black voids. */
  background: #f3e9d2;
}
.mosaic .tile {
  position: relative;
  overflow: hidden;
  background: #f3e9d2;
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(120, 60, 30, 0.12),
    0 1px 2px rgba(60, 30, 10, 0.18);
}
.mosaic .tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;  /* bias toward upper-middle: faces sit higher than centre */
  /* No tinting filter — show photos at full natural brightness. */
  animation: kenburns 28s ease-out forwards;
  will-change: transform;
}
/* "contain" mode for cards where face-preservation matters more than tile fill.
   Renderer adds .contain-tiles to .mosaic for memorial/people/lives_intertwined.
   Tiles letterbox against the dark tile background — reads as a deliberate frame. */
.mosaic.contain-tiles .tile img {
  object-fit: contain;
  object-position: center;
  transform: none;
  animation: none;
  filter: none;
  padding: 4px;
}
.mosaic.contain-tiles .tile {
  background: #f3e9d2;
}
/* ---- Smart justified-rows layout (default for all mosaic cards) ----
   JS measures each image's natural aspect ratio and positions tiles absolutely
   so every tile box equals its image aspect — zero cropping, zero letterbox.
   Reflows on resize. */
.mosaic.justified {
  display: block;            /* override grid */
  padding: 0;                /* JS handles gap math */
}
.mosaic.justified .tile {
  /* position/size set inline by layoutJustifiedMosaic() */
  border-radius: 2px;
}
.mosaic.justified .tile img {
  object-fit: cover;         /* tile aspect == image aspect, so cover == no crop */
  object-position: center;
  transform: none;           /* no over-scale; the layout already fits perfectly */
  animation: none;
  /* No tinting / dimming — show photos as they are. */
  filter: none;
  padding: 0;
}
/* Posters (gig flyers, quiz-night flyers etc.) must be shown WHOLE — never
   cropped by a cover-fit. The renderer adds .poster to tiles that ref a
   known poster filename. The dark tile background reads as a frame. */
.mosaic .tile.poster {
  background: #f3e9d2;
}
.mosaic .tile.poster img {
  object-fit: contain;
  filter: saturate(1) contrast(1) brightness(1);
  transform: none;
  animation: none;
  padding: 6px;
}
/* No global mosaic overlay — photos render at full clarity. The intro card
   (full-bleed, text overlays the mosaic) keeps a faint vignette below for
   text legibility; everything else (split layout) doesn't need any overlay. */
.card:not(.split) .mosaic::after {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 80% at 50% 100%, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.0) 60%);
  pointer-events: none;
}

/* ---- Tile-count variants (asymmetric where it suits) ---- */
.mosaic.count-3 {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.mosaic.count-3 .tile:nth-child(1) { grid-row: 1 / span 2; }

.mosaic.count-4 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.mosaic.count-5 {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
}
/* Feature image spans 2x2, then four small fill the right column */
.mosaic.count-5 .tile:nth-child(1) { grid-column: 1 / span 2; grid-row: 1 / span 2; }

.mosaic.count-6 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.mosaic.count-7,
.mosaic.count-8 {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.mosaic.count-9 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

/* On narrow phones, asymmetric 5 reverts to 2x3 to keep tiles readable */
@media (max-width: 600px) {
  .mosaic.count-5 {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }
  .mosaic.count-5 .tile:nth-child(1) {
    grid-column: 1 / span 2; grid-row: auto;
  }
  .mosaic.count-3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1.4fr 1fr;
  }
  .mosaic.count-3 .tile:nth-child(1) {
    grid-column: 1 / span 2; grid-row: 1;
  }
}

@media (min-width: 900px) {
  .mosaic { gap: 5px; padding: 5px; }
}

/* All themes use the same warm cream mosaic backdrop now; no per-theme
   tinting or dimming — photos read at full clarity regardless of theme. */
.theme-cream .mosaic,
.theme-gold .mosaic,
.theme-red .mosaic,
.theme-deep .mosaic { background: #f3e9d2; }
.theme-cream .mosaic .tile img,
.theme-gold .mosaic .tile img,
.theme-red .mosaic .tile img,
.theme-deep .mosaic .tile img { filter: none; }

/* Memorial theme — dignified single photo, no grid (handled by mosaic=false in manifest) */

/* ===== Music-coming-soon hint tooltip on mute button ===== */
.ctrl[data-music-state="placeholder"]::after {
  content: "Music coming soon";
  position: absolute;
  top: 46px;
  right: 0;
  background: rgba(0,0,0,0.85);
  color: var(--marb-cream);
  font-family: var(--body);
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 5px 9px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.ctrl[data-music-state="placeholder"]:hover::after,
.ctrl[data-music-state="placeholder"]:focus::after { opacity: 1; }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .card { transition: opacity .25s linear; transform: none; }
  .card.show { transform: none; }
  .bg img { animation: none !important; transform: none !important; }
  .ctrl.pulse { animation: none !important; }
  .theme-memorial .candle::before { animation: none !important; }
  .marblerun-ambient { display: none !important; }
  .progress .progress-marble.rolling .pm-body { animation: none !important; }
  .mosaic .tile img { animation: none !important; transform: none !important; }
}

/* ---- Background music credit (Pink Floyd attribution) ---- */
.bgm-credit {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  font-family: 'Lora', Georgia, serif;
  font-style: italic;
  font-size: 0.8rem;
  color: rgba(253, 248, 240, 0.85);
  background: rgba(26, 20, 18, 0.55);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
  z-index: 30;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
}
.bgm-credit.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
@media (max-width: 520px) {
  .bgm-credit { font-size: 0.72rem; bottom: 0.85rem; }
}

/* ===== Closing thanks card: scrolling photo wall =====
   FB-photos-grid feel: small square thumbnails, ~10 across desktop, scrolling
   slowly upward as a single carpet. We render the grid TWICE inside .photo-wall-track
   and translateY -50% over a long duration so the loop is seamless. */
.photo-wall {
  position: absolute; inset: 0;
  overflow: hidden;
  z-index: 0;
  /* No dimming — photos at full brightness. Split layout puts text in a
     separate panel, so we don't need to suppress the carousel anymore. */
  background: #f3e9d2;
  contain: strict;
}
.photo-wall-track {
  display: flex; flex-direction: column;
  width: 100%;
  animation: pwScrollUp 220s linear infinite;
  /* Promote to its own compositor layer and tell the browser the only
     thing that changes is transform — this avoids per-frame layout work
     across the ~320 image children that was causing judder. */
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  contain: layout paint;
}
@keyframes pwScrollUp {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(0, -50%, 0); }
}
.photo-wall-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
  width: 100%;
}
@media (min-width: 1600px) { .photo-wall-grid { grid-template-columns: repeat(14, 1fr); } }
@media (min-width: 2000px) { .photo-wall-grid { grid-template-columns: repeat(16, 1fr); } }
.photo-wall-grid img {
  width: 100%; height: auto; display: block;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  transform: translateZ(0);
  backface-visibility: hidden;
}
@media (prefers-reduced-motion: reduce) {
  .photo-wall-track { animation: none !important; }
}
@media (max-width: 1100px) {
  .photo-wall-grid { grid-template-columns: repeat(10, 1fr); }
}
@media (max-width: 900px) {
  .photo-wall-grid { grid-template-columns: repeat(8, 1fr); }
}
@media (max-width: 700px) {
  .photo-wall-grid { grid-template-columns: repeat(7, 1fr); gap: 2px; }
}
@media (max-width: 540px) {
  .photo-wall-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 420px) {
  .photo-wall-grid { grid-template-columns: repeat(5, 1fr); }
}
.card .photo-wall + .body,
.card.center .photo-wall + .body {
  position: relative; z-index: 1;
}

/* ===== Impact-stats grid (stat-card with stats[] array) ===== */
.impact-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem 2rem;
  margin-top: 1.5rem;
  width: min(100%, 720px);
}
.impact-stat { text-align: center; }
.impact-value {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(1.6rem, 3.4vw, 2.6rem);
  font-weight: 600; line-height: 1.1;
  color: var(--accent, #c9a23a);
}
.impact-label {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.72;
  margin-top: 0.35rem;
}
@media (max-width: 600px) {
  .impact-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem 1.4rem; }
}
