:root {
  --bg: #07060a;
  --ink: #efe6d6;
  --dim: #9a8f80;
  --faint: #5a5249;
  --flame: #ffb347;
  --ember: #ff7a3d;
  --gold: #e9c98a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: radial-gradient(ellipse at 50% -10%, #1a1420 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

section { padding: 72px 0; }

h2 {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: center;
  margin-bottom: 28px;
}

.hint {
  text-align: center;
  color: var(--dim);
  font-style: italic;
  font-size: 15px;
  margin-bottom: 24px;
}

/* hero */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 40px;
}

.kicker {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--dim);
  opacity: 0;
  animation: fadeUp 1.6s 0.3s ease forwards;
}

.dash-hero {
  font-size: clamp(120px, 40vw, 200px);
  line-height: 1;
  color: var(--ink);
  margin: 12px 0 4px;
  text-shadow: 0 0 24px rgba(255, 179, 71, 0.55), 0 0 80px rgba(255, 122, 61, 0.35);
  animation: dashIn 2.4s 0.6s cubic-bezier(.2,.7,.2,1) both, breathe 5s 3s ease-in-out infinite;
}

h1 {
  font-weight: 400;
  font-size: 40px;
  letter-spacing: 0.01em;
  opacity: 0;
  animation: fadeUp 1.6s 1.4s ease forwards;
}

.dates {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--dim);
  letter-spacing: 0.08em;
  margin-top: 8px;
  opacity: 0;
  animation: fadeUp 1.6s 1.8s ease forwards;
}

.epitaph {
  font-style: italic;
  color: var(--gold);
  font-size: 18px;
  margin-top: 28px;
  opacity: 0;
  animation: fadeUp 1.6s 2.3s ease forwards;
}

.scroll-cue {
  margin-top: 64px;
  width: 1px;
  height: 56px;
  background: linear-gradient(var(--faint), transparent);
  position: relative;
  overflow: hidden;
  opacity: 0;
  animation: fadeUp 1.6s 3s ease forwards;
}
.scroll-cue span {
  position: absolute;
  left: 0; top: -20px;
  width: 1px; height: 20px;
  background: var(--flame);
  animation: drip 2.2s ease-in infinite;
}

/* obituary */
.obit p {
  font-size: 18px;
  margin-bottom: 18px;
  color: var(--ink);
}
.obit p:first-of-type::first-letter {
  float: left;
  font-size: 58px;
  line-height: 0.9;
  padding: 6px 10px 0 0;
  color: var(--gold);
}
.survived {
  color: var(--dim) !important;
  font-style: italic;
  font-size: 16px !important;
  border-top: 1px solid rgba(233, 201, 138, 0.15);
  padding-top: 18px;
  margin-top: 28px;
}

/* timeline */
.timeline ol {
  list-style: none;
  position: relative;
  padding-left: 28px;
}
.timeline ol::before {
  content: "";
  position: absolute;
  left: 6px; top: 8px; bottom: 8px;
  width: 1px;
  background: linear-gradient(var(--gold), rgba(233, 201, 138, 0.05));
}
.timeline li {
  position: relative;
  margin-bottom: 26px;
  display: flex;
  flex-direction: column;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -26px; top: 10px;
  width: 9px; height: 2px;
  background: var(--flame);
  box-shadow: 0 0 10px var(--flame);
}
.timeline li:last-child::before { background: var(--faint); box-shadow: none; }
.timeline b {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--gold);
  font-weight: 600;
}
.timeline span { font-size: 17px; color: var(--ink); }
.timeline li:last-child span { color: var(--dim); font-style: italic; }

/* eulogy sentences */
#sentences { display: flex; flex-direction: column; gap: 14px; }
.sentence {
  appearance: none;
  border: 1px solid rgba(233, 201, 138, 0.14);
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  text-align: left;
  padding: 18px 20px;
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .4s, background .4s, transform .2s;
  -webkit-tap-highlight-color: transparent;
}
.sentence:active { transform: scale(0.985); }
.sentence.gone { border-color: rgba(255, 255, 255, 0.05); background: rgba(0, 0, 0, 0.2); color: var(--dim); }
.sentence .d {
  display: inline-block;
  color: var(--flame);
  text-shadow: 0 0 12px rgba(255, 179, 71, 0.7);
  transition: transform 1.4s cubic-bezier(.3,.1,.3,1), opacity 1.4s, width .6s .8s, margin .6s .8s;
  width: 1em;
  text-align: center;
}
.sentence.gone .d {
  transform: translateY(-60px) rotate(-8deg);
  opacity: 0;
}
.sentence .r {
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  vertical-align: bottom;
  opacity: 0;
  transition: max-width .6s 1s, opacity .6s 1s;
  color: var(--ink);
}
.sentence.gone .r { max-width: 2em; opacity: 1; }
.sentence.gone .d { width: 0; }
.sentence .tag {
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 10px;
}

/* vigil */
#altar {
  position: relative;
  height: 280px;
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 110%, rgba(255, 122, 61, 0.14), transparent 65%),
    linear-gradient(#0c0a10, #050407);
  border: 1px solid rgba(233, 201, 138, 0.1);
  overflow: hidden;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
#altar:focus-visible { border-color: var(--gold); }
.altar-glow {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 179, 71, var(--glow, 0)), transparent 70%);
  transition: background 1s;
  pointer-events: none;
}
.candle {
  position: absolute;
  width: 10px;
  transform: translate(-50%, -100%);
  animation: rise .7s cubic-bezier(.2,.8,.2,1) both;
  pointer-events: none;
}
.candle .wax {
  width: 10px;
  height: var(--h, 26px);
  background: linear-gradient(90deg, #cdbfa8, #f3ead9 45%, #b3a58d);
  border-radius: 2px 2px 1px 1px;
}
.candle .flame {
  position: absolute;
  left: 50%;
  bottom: calc(var(--h, 26px) + 1px);
  width: 8px; height: 16px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 70%, #fff6d8 0%, var(--flame) 45%, var(--ember) 75%, transparent 80%);
  border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  filter: blur(.3px);
  animation: flicker 1.8s ease-in-out infinite alternate;
  animation-delay: var(--d, 0s);
  transform-origin: 50% 100%;
}
.candle .halo {
  position: absolute;
  left: 50%;
  bottom: calc(var(--h, 26px) - 16px);
  width: 90px; height: 90px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 179, 71, 0.22), transparent 65%);
  border-radius: 50%;
}

.count {
  text-align: center;
  margin-top: 18px;
  color: var(--dim);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.06em;
}
#candleCount { color: var(--flame); font-weight: 600; font-variant-numeric: tabular-nums; }

.ghost {
  display: block;
  margin: 14px auto 0;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--faint);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.1em;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .3s, border-color .3s;
}
.ghost:hover { color: var(--dim); border-color: rgba(255, 255, 255, 0.2); }

/* final */
.final { text-align: center; padding: 120px 0 60px; }
.last-words { color: var(--dim); font-style: italic; font-size: 15px; }
.quote {
  font-size: 30px;
  margin: 14px 0 42px;
  line-height: 1.3;
}
.sign {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--gold);
}

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity 1.2s ease, transform 1.2s ease; }
.reveal.in { opacity: 1; transform: none; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes dashIn {
  0% { opacity: 0; letter-spacing: 0.4em; filter: blur(12px); transform: scaleX(0.2); }
  100% { opacity: 1; filter: blur(0); transform: scaleX(1); }
}
@keyframes breathe {
  0%, 100% { text-shadow: 0 0 24px rgba(255, 179, 71, 0.55), 0 0 80px rgba(255, 122, 61, 0.35); }
  50% { text-shadow: 0 0 14px rgba(255, 179, 71, 0.3), 0 0 40px rgba(255, 122, 61, 0.15); opacity: .82; }
}
@keyframes drip { to { top: 60px; } }
@keyframes flicker {
  0% { transform: translateX(-50%) scale(1, 1) rotate(-2deg); opacity: 1; }
  40% { transform: translateX(-50%) scale(.92, 1.08) rotate(2deg); }
  70% { transform: translateX(-50%) scale(1.05, .94) rotate(-1deg); opacity: .9; }
  100% { transform: translateX(-50%) scale(.96, 1.04) rotate(1deg); opacity: 1; }
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, -80%); } to { opacity: 1; transform: translate(-50%, -100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}
