/* ---------- Themes ---------- */
:root,
[data-theme="dove"] {
  --bg: #F4F4F2;
  --surface: #FFFFFF;
  --ink: #2A2B2E;
  --muted: #6C6E73;
  --line: #DCDCD8;
  --accent: #55677A;
  --on-accent: #FFFFFF;
  color-scheme: light;
}
[data-theme="sage"] {
  --bg: #EDF0EB;
  --surface: #FAFBF9;
  --ink: #26302A;
  --muted: #627066;
  --line: #D3DAD2;
  --accent: #52705C;
  --on-accent: #FFFFFF;
  color-scheme: light;
}
[data-theme="dusk"] {
  --bg: #1D2230;
  --surface: #262C3C;
  --ink: #EAE6DF;
  --muted: #A7AAB5;
  --line: #3A4154;
  --accent: #CDB78E;
  --on-accent: #1D2230;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Spectral", Georgia, "Times New Roman", serif;
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.7;
}
h1, h2, p { margin: 0; }
h2 {
  font-weight: 400;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  line-height: 1.2;
}
a { color: var(--accent); text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.ui { font-family: "Karla", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

.wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 24px; }
.wrap-wide { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 24px; }
.wrap-inner { max-width: 592px; margin: 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-family: "Karla", sans-serif; }
.skip:focus { top: calc(12px + env(safe-area-inset-top, 0px)); }

/* ---------- Hero: centred, quiet, like a printed order of service ---------- */
.hero {
  text-align: center;
  padding-top: calc(64px + env(safe-area-inset-top, 0px));
  padding-bottom: 24px;
}
.portrait {
  margin: 0 auto 36px;
  width: min(68vw, 280px);
  aspect-ratio: 4 / 5;
  border-radius: 999px 999px 0 0;
  overflow: hidden;
  background: var(--line);
}
.portrait[hidden] { display: none; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.loving { font-style: italic; color: var(--muted); font-weight: 300; }
.name {
  margin-top: 10px;
  font-weight: 300;
  font-size: clamp(2.4rem, 9vw, 3.8rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
}
.known { display: block; margin-top: 8px; font-size: 0.42em; font-style: italic; color: var(--muted); letter-spacing: 0; }
/* The years: the one engraved detail on the page */
.years {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 18px;
  font-variant-numeric: lining-nums tabular-nums;
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.years::before, .years::after { content: ""; width: 44px; height: 1px; background: var(--muted); }
.years span + span::before { content: "\2013"; margin-right: 0.6em; color: var(--muted); }
.dates { margin-top: 6px; color: var(--muted); font-family: "Karla", system-ui, sans-serif; font-size: 0.92rem; }
.dates:empty { display: none; }
.quote {
  margin: 30px auto 0;
  max-width: 30ch;
  font-style: italic;
  font-weight: 300;
  font-size: 1.3rem;
  line-height: 1.55;
}
.quote:empty { display: none; }

/* ---------- Sections ---------- */
.section { padding-top: 64px; }

.service {
  text-align: center;
  padding: 34px 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.when { margin-top: 12px; font-size: 1.25rem; }
.where { margin-top: 6px; color: var(--muted); }
.where span { display: block; }
.where span:first-child { color: var(--ink); }
.service-note { margin: 18px auto 0; max-width: 40ch; color: var(--muted); font-style: italic; }
.service-note:empty { display: none; }
.actions { margin-top: 24px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: "Karla", system-ui, sans-serif;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn[hidden] { display: none; }

/* Story */
.story p { margin-top: 18px; }
.story p:first-child::first-letter {
  float: left;
  font-size: 3.4em;
  line-height: 0.9;
  padding: 0.08em 0.1em 0 0;
  font-weight: 300;
  color: var(--accent);
}

/* Timeline: a real sequence through a life */
.timeline { list-style: none; margin: 40px 0 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 4.2em 1fr;
  gap: 18px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.timeline li:last-child { border-bottom: 1px solid var(--line); }
.timeline .yr { font-variant-numeric: lining-nums tabular-nums; color: var(--accent); }
.timeline:empty { display: none; }

/* Gallery */
.gallery { list-style: none; margin: 24px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 760px) { .gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.gallery button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; text-align: left; color: inherit; }
.gallery img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--line); }
.gallery .cap { display: block; margin-top: 8px; font-family: "Karla", system-ui, sans-serif; font-size: 0.88rem; color: var(--muted); }

/* Memories */
.memories { margin-top: 20px; }
.memories blockquote { margin: 0; padding: 22px 0; border-top: 1px solid var(--line); }
.memories blockquote p { font-style: italic; font-weight: 300; font-size: 1.2rem; }
.memories cite { display: block; margin-top: 8px; font-style: normal; font-family: "Karla", system-ui, sans-serif; font-size: 0.95rem; color: var(--muted); }
.share { margin-top: 8px; padding-top: 24px; border-top: 1px solid var(--line); }
.share p { color: var(--muted); margin-bottom: 14px; }

/* Donation */
#donate { text-align: center; }
.donate-text { max-width: 42ch; margin: 0 auto 20px; }

/* Footer */
.footer { padding-top: 64px; padding-bottom: 56px; text-align: center; color: var(--muted); }
.family { font-style: italic; }
.link-btn {
  margin-top: 18px; background: none; border: 0; padding: 0;
  color: var(--accent); font-family: "Karla", system-ui, sans-serif; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.demo-switcher { margin-top: 28px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; font-family: "Karla", system-ui, sans-serif; font-size: 0.95rem; }
.demo-switcher button { min-height: 40px; padding: 6px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; }
.demo-switcher button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* Lightbox */
.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(20, 22, 28, 0.96); color: #EAE6DF; }
.lightbox::backdrop { background: rgba(20, 22, 28, 0.96); }
.lightbox figure { margin: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 56px 16px 24px; }
.lightbox img { max-width: 100%; max-height: calc(100% - 44px); object-fit: contain; }
.lightbox figcaption { font-style: italic; color: #CFCBC4; }
.lb-btn { position: absolute; width: 48px; height: 48px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.35); background: rgba(20, 22, 28, 0.5); color: #FFFFFF; font-size: 1.8rem; line-height: 1; cursor: pointer; }
.lb-btn:hover { border-color: #FFFFFF; }
.lb-close { top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
@media (max-width: 600px) {
  .lb-prev, .lb-next { top: auto; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: none; }
  .lightbox figure { padding-bottom: 84px; }
}

/* Print: a simple order of service */
@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  .demo-switcher, .link-btn, .actions, .share, #donate .btn, #photos, .skip { display: none !important; }
  .portrait { width: 5cm; }
  .section { padding-top: 24pt; break-inside: avoid; }
  a { color: #000; }
}
