:root {
  color-scheme: light;
  --paper: #f4ebdf;
  --paper-2: #faf4eb;
  --card: #fffaf3;
  --ink: #4a2617;
  --ink-soft: #6e4a38;
  --muted: #8c7262;
  --gold: #b08a4a;
  --gold-soft: #d8c39b;
  --line: #e6d7c1;
  --ok: #3f6b3a;
  --danger: #9a3324;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(74, 38, 23, 0.06), 0 8px 24px rgba(74, 38, 23, 0.08);
  --script: "Great Vibes", "Snell Roundhand", cursive;
  --serif: "EB Garamond", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper) radial-gradient(ellipse at top, #fbf6ee 0%, var(--paper) 60%) fixed;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.55;
}

img { max-width: 100%; display: block; }
a { color: var(--ink); text-decoration-color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--gold); }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* ---------- hero (mirrors the memorial card) ---------- */
.hero {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}
.hero-photo {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1024 / 600;
  /* Soft vignette: fades the photo into the paper and hides the card's frame corners. */
  -webkit-mask-image: radial-gradient(ellipse 52% 72% at 50% 42%, #000 50%, transparent 98%);
          mask-image: radial-gradient(ellipse 52% 72% at 50% 42%, #000 50%, transparent 98%);
}
/* Zoom slightly so the card's thin gold frame falls outside the crop. */
.hero-photo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/images/card.jpg") top center / 100% auto no-repeat;
  transform: scale(1.12);
  transform-origin: 50% 62%;
}
.hero-text { margin-top: -6%; position: relative; padding: 0 16px; }
.script {
  font-family: var(--script);
  font-weight: 400;
  font-size: clamp(52px, 13vw, 96px);
  line-height: 1.05;
  margin: 0;
  color: var(--ink);
}
.caps {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  margin: 0.2em 0 0;
}
.hero .of { font-size: clamp(20px, 5vw, 30px); letter-spacing: 0.32em; }
.hero .dates { font-size: clamp(14px, 3.6vw, 18px); color: var(--ink-soft); margin-top: 0.6em; }

.flourish {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px auto;
  max-width: 520px;
  color: var(--gold);
}
.flourish::before, .flourish::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold));
}
.flourish::after { background: linear-gradient(to left, transparent, var(--gold)); }
.flourish svg { width: 64px; height: 18px; flex: none; }

.intro { white-space: pre-line; text-align: center; font-size: 20px; max-width: 34em; margin: 0 auto; }
.intro p { margin: 0 0 1em; }
.signoff { text-align: center; font-size: 15px; margin-top: 8px; }

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(244, 235, 223, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  margin-top: 36px;
}
.nav ul {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 0 auto;
  padding: 6px 8px;
  max-width: 720px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav ul::-webkit-scrollbar { display: none; }
@media (max-width: 480px) {
  .nav ul { justify-content: flex-start; gap: 0; }
  .nav a { padding: 8px 9px; font-size: 12px; letter-spacing: 0.1em; }
}
.nav a {
  display: block;
  padding: 8px 12px;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 13px;
  border-radius: 999px;
  white-space: nowrap;
}
.nav a:hover { background: var(--paper-2); color: var(--ink); }

/* ---------- sections ---------- */
section { padding: 40px 0 8px; scroll-margin-top: calc(var(--nav-h, 52px) - 16px); }
h2 {
  font-family: var(--script);
  font-weight: 400;
  font-size: 46px;
  line-height: 1.1;
  text-align: center;
  margin: 0 0 6px;
}
.section-sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 17px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 16px;
}

/* events */
.event h3 { margin: 0 0 6px; font-size: 22px; font-weight: 600; line-height: 1.3; }
.event .when { font-size: 18px; color: var(--ink); }
.event .where { margin-top: 6px; color: var(--ink-soft); }
.event .tba { font-style: italic; color: var(--muted); }
.event .notes { margin-top: 10px; white-space: pre-line; }
.event .links { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }

/* updates */
.update { border-left: 3px solid var(--gold-soft); }
.update .meta, .memory .meta { color: var(--muted); font-size: 15px; margin-bottom: 6px; }
.update .body, .memory .body { white-space: pre-line; overflow-wrap: anywhere; }

/* memories */
.memory .who { font-weight: 600; font-size: 19px; }
.memory .rel { color: var(--muted); font-weight: 400; }
/* Width is worked out from the photo's shape (--ar = width / height) so the space is
   reserved before it loads: nothing below jumps, and section links land correctly. */
.memory img {
  margin-top: 12px;
  border-radius: 10px;
  width: min(100%, calc(420px * (var(--ar, 4 / 3))));
  height: auto;
  aspect-ratio: auto var(--ar, 4 / 3);
  cursor: zoom-in;
  background: var(--paper-2);
}

/* life story */
.story p { margin: 0 0 1em; }
.story p:last-child { margin-bottom: 0; }
.story p:first-child::first-letter {
  font-family: var(--serif);
  font-size: 3.1em;
  float: left;
  line-height: 0.85;
  padding: 0.06em 0.1em 0 0;
  color: var(--gold);
}

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  font: inherit;
  border-radius: 10px;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--line);
  box-shadow: var(--shadow);
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.tile:hover img { transform: scale(1.04); }
.tile:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.tile-caption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 24px 10px 8px;
  font-size: 14px;
  line-height: 1.3;
  text-align: left;
  color: #fff;
  background: linear-gradient(to top, rgba(30, 16, 10, 0.75), transparent);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
@media (max-width: 560px) { .gallery { grid-template-columns: repeat(2, 1fr); gap: 8px; } }

.empty { text-align: center; color: var(--muted); font-style: italic; }

/* ---------- forms & buttons ---------- */
label { display: block; font-size: 16px; color: var(--ink-soft); margin: 14px 0 4px; }
.hint { font-size: 14px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="date"], input[type="url"], textarea {
  width: 100%;
  font: inherit;
  font-size: 18px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { outline: 2px solid var(--gold-soft); border-color: var(--gold); }
input[type="file"] { font: inherit; font-size: 16px; max-width: 100%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 16px;
  letter-spacing: 0.04em;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}
.btn:hover { background: var(--paper-2); color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff8ef; }
.btn.primary:hover { background: #5c311e; color: #fff; }
.btn.small { font-size: 14px; padding: 6px 12px; min-height: 36px; }
.btn.danger { border-color: #d9b2aa; color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: default; }

.form-actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.status { font-size: 16px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* share: last section, so give it enough height that its link can scroll it to the top */
#share { min-height: calc(100vh - var(--nav-h, 52px) - 170px); }
.share-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

footer { text-align: center; color: var(--muted); font-size: 15px; padding: 48px 16px 40px; }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(30, 16, 10, 0.88);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; cursor: zoom-out;
}
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: default; }
.lightbox img { max-height: 84vh; max-width: 100%; border-radius: 8px; }
.lb-caption { color: #f3e6d6; text-align: center; font-size: 17px; max-width: 40em; }
.lb-caption:empty { display: none; }
.lb-count { position: absolute; top: 18px; left: 20px; color: #d8c39b; font-size: 15px; letter-spacing: 0.1em; }
.lb-btn {
  position: absolute;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(216, 195, 155, 0.5);
  background: rgba(30, 16, 10, 0.5);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}
.lb-btn:hover { background: rgba(74, 38, 23, 0.8); }
.lb-close { top: 10px; right: 12px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
@media (max-width: 560px) { .lb-prev, .lb-next { top: auto; bottom: 16px; transform: none; } }

@media (max-width: 480px) {
  body { font-size: 18px; }
  .card { padding: 16px; }
  h2 { font-size: 40px; }
  .intro { font-size: 18px; }
  .hero .dates { letter-spacing: 0.12em; font-size: 14px; }
}

@media print {
  body { background: #fff; font-size: 13pt; }
  .nav, .no-print, footer { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
}
