:root {
  --bg: #f6f1e8;
  --bg-card: #fffaf0;
  --fg: #1f1b16;
  --fg-soft: #5b5147;
  --rule: #d8cdb8;
  --accent: #7a3b1a;
  --accent-soft: #b07a4a;
  --flame: #ffb347;
  --flame-hot: #fff3c2;
  --maxw: 68ch;
  --serif: "Iowan Old Style", "Hoefler Text", "Charter", "Georgia", "Cambria", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15110d;
    --bg-card: #1d1813;
    --fg: #ece4d4;
    --fg-soft: #b4a892;
    --rule: #322a21;
    --accent: #e8b787;
    --accent-soft: #c98a55;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  padding: 4rem 1.25rem 6rem;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
}

header.hero {
  text-align: center;
  margin-bottom: 4rem;
}

.candle {
  width: 80px;
  height: 110px;
  margin: 0 auto 1.5rem;
  display: block;
}

.candle .flame {
  transform-origin: 32px 38px;
  animation: flicker 2.4s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { transform: scale(1, 1) rotate(0deg); opacity: 1; }
  20%      { transform: scale(0.97, 1.04) rotate(-1.5deg); opacity: 0.93; }
  45%      { transform: scale(1.03, 0.98) rotate(1deg); opacity: 1; }
  70%      { transform: scale(0.96, 1.05) rotate(-0.5deg); opacity: 0.9; }
  85%      { transform: scale(1.02, 0.99) rotate(0.8deg); opacity: 0.97; }
}

@media (prefers-reduced-motion: reduce) {
  .candle .flame { animation: none; }
}

h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(1.6rem, 1rem + 2vw, 2.3rem);
  letter-spacing: 0.01em;
  margin: 0 0 0.4rem;
  color: var(--fg);
}

h1 strong {
  display: block;
  font-style: normal;
  font-weight: 600;
  font-size: clamp(2.2rem, 1.4rem + 3vw, 3.4rem);
  letter-spacing: -0.01em;
  margin-top: 0.2rem;
}

.dates {
  font-variant-numeric: oldstyle-nums;
  color: var(--fg-soft);
  letter-spacing: 0.15em;
  font-size: 0.95rem;
  margin-top: 1rem;
}

.epitaph {
  font-style: italic;
  color: var(--fg-soft);
  margin: 1.5rem auto 0;
  max-width: 52ch;
}

section {
  margin: 3.5rem 0;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 700ms ease, transform 700ms ease;
}

section.in-view {
  opacity: 1;
  transform: none;
}

section + section {
  border-top: 1px solid var(--rule);
  padding-top: 3.5rem;
}

h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  margin: 0 0 1rem;
  color: var(--fg);
}

h2 .ornament {
  display: inline-block;
  color: var(--accent);
  margin-right: 0.5em;
  font-style: italic;
  font-weight: 400;
}

p { margin: 0 0 1rem; }

blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 1.25rem;
  border-left: 2px solid var(--accent-soft);
  color: var(--fg-soft);
  font-style: italic;
}

ul.features {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 1rem;
}

ul.features li {
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 6px;
}

ul.features li strong {
  color: var(--accent);
  font-weight: 600;
  font-style: normal;
}

ul.features li em {
  font-style: italic;
  color: var(--fg-soft);
  font-size: 0.92em;
}

.stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  margin-top: 1rem;
}

.stack span {
  font-family: var(--sans);
  font-size: 0.83rem;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--fg-soft);
  background: var(--bg-card);
}

.survived-by {
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 2rem 1.5rem;
  margin: 2rem 0;
}

.survived-by .label {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--fg-soft);
}

.survived-by .name {
  display: block;
  font-size: clamp(1.6rem, 1rem + 2vw, 2.2rem);
  font-weight: 600;
  margin: 0.75rem 0 0.5rem;
}

.survived-by .name a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
}

.survived-by .name a:hover {
  border-bottom-color: var(--accent);
}

.survived-by .blurb {
  color: var(--fg-soft);
  font-style: italic;
  max-width: 44ch;
  margin: 0 auto 0.75rem;
}

.survived-by .links a {
  color: var(--fg-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 0.92rem;
  margin: 0 0.4rem;
}

.signature {
  margin-top: 3.5rem;
  text-align: center;
  color: var(--fg-soft);
  font-style: italic;
}

footer {
  text-align: center;
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  color: var(--fg-soft);
  font-family: var(--sans);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}

footer a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

@media print {
  body { background: #fff; color: #000; padding: 1rem; }
  .candle .flame { animation: none; }
  section { opacity: 1; transform: none; break-inside: avoid; }
}
