:root {
  --bg: #f7f6fb;
  --bg-alt: #eeecf6;
  --surface: #ffffff;
  --text: #1f1a33;
  --muted: #5f5a75;
  --blue: #1f4e9c;
  --purple: #3b1f5c;
  --gold: #b8892f;
  --gold-text: #8a6417;
  --accent: var(--blue);
  --line: #dcd8ea;
  --flame: #f3b54a;
  --shadow: 0 10px 30px rgba(31, 26, 51, 0.08);
  --hero-from: #2a1745;
  --hero-to: #1c3a7a;
  --on-dark: #f4f1fb;
  --on-dark-muted: #c9c2e0;
  --msg-bg: #f4f2fb;
  --msg-line: #e1dcf0;
  --msg-text: #2d2845;
  --msg-name: #4b2a7a;
  --map-land: #dfdcea;
  --map-edge: #f7f6fb;
  --map-visited: #6f8fd6;
  --map-lived: #3b1f5c;
  --map-pin: #b8892f;
  --display: "Montserrat", "Helvetica Neue", Arial, sans-serif;
  --sans: "Raleway", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: var(--sans);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12101c;
    --bg-alt: #181528;
    --surface: #1f1b33;
    --text: #ece9f6;
    --muted: #a7a2c0;
    --blue: #8fb0ff;
    --purple: #c3a6f0;
    --gold: #e0b85c;
    --gold-text: #e0b85c;
    --line: #2e2948;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    --hero-from: #1b1030;
    --hero-to: #10224d;
    --msg-bg: #1c1830;
    --msg-line: #2f2a4a;
    --msg-text: #dcd8ec;
    --msg-name: #c9b2f2;
    --map-land: #2a2640;
    --map-edge: #12101c;
    --map-visited: #4f6fc0;
    --map-lived: #9d7ad8;
    --map-pin: #e0b85c;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.04rem;
  line-height: 1.75;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); font-weight: 900; line-height: 1.1; margin: 0; letter-spacing: -0.01em; }

/* ── Nav ── */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: center; flex-wrap: wrap; gap: 0.25rem 1.5rem;
  padding: 0.85rem 1rem;
  background: var(--bg); /* fallback for browsers without color-mix() (e.g. iOS < 16.2) */
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-family: var(--display); font-weight: 600; font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase;
}
.nav a { color: var(--muted); text-decoration: none; transition: color 0.2s; }
.nav a:hover { color: var(--blue); }

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 4.5rem 1rem 4.25rem;
  background: radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.08), transparent 60%),
              linear-gradient(160deg, var(--hero-from) 0%, var(--hero-to) 100%);
  color: var(--on-dark);
}
.hero > * { max-width: 44rem; margin-left: auto; margin-right: auto; }
.portrait {
  width: min(15rem, 60vw); aspect-ratio: 4 / 5; margin: 0 auto 2rem;
  border-radius: 999px 999px 1rem 1rem; overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--gold);
  border: 6px solid rgba(255, 255, 255, 0.92);
  background: var(--hero-from);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 5%; }
.eyebrow { font-family: var(--display); font-weight: 600; font-size: 0.72rem; letter-spacing: 0.32em; text-transform: uppercase; color: var(--gold); margin: 0 auto 0.75rem; }
.hero h1 { font-size: clamp(2.3rem, 9vw, 4.4rem); text-transform: uppercase; letter-spacing: 0.01em; line-height: 1; }
.dates { font-family: var(--display); font-weight: 600; font-size: clamp(0.95rem, 2.6vw, 1.1rem); letter-spacing: 0.14em; text-transform: uppercase; color: var(--on-dark); margin: 1rem auto 0; }
.family { font-family: var(--sans); font-style: italic; font-size: 1.15rem; color: var(--gold); margin: 0.6rem auto 0; }
.family:empty { display: none; }
.place { color: var(--on-dark-muted); font-size: 0.92rem; margin: 0.3rem auto 0; }
.place:empty { display: none; }
.epitaph { font-family: var(--sans); font-style: italic; font-size: clamp(1.2rem, 3.4vw, 1.45rem); line-height: 1.5; margin: 1.75rem auto 0; white-space: pre-line; color: var(--on-dark); }

/* ── Candle ── */
.candle {
  margin-top: 2.25rem;
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1.2rem; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.08); color: var(--on-dark);
  font-family: var(--display); font-weight: 600; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.candle:hover { border-color: var(--gold); }
.flame {
  width: 0.7rem; height: 1rem; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: rgba(255, 255, 255, 0.35); transition: background 0.4s, box-shadow 0.4s;
}
.candle[aria-pressed="true"] .flame {
  background: radial-gradient(circle at 50% 70%, #fff6d6 0 25%, var(--flame) 60%, #e07a2a 100%);
  box-shadow: 0 0 14px 4px rgba(243, 181, 74, 0.45);
  animation: flicker 2.4s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-1deg); }
  50% { transform: scale(1.08, 0.95) rotate(1.5deg); }
}

/* ── Sections ── */
.section { padding: 4.5rem 1rem; }
.section:nth-child(even) { background: var(--bg-alt); }
.wrap { max-width: 42rem; margin: 0 auto; }
.wrap.wide { max-width: 64rem; }
.section h2 { font-size: clamp(1.8rem, 5vw, 2.6rem); text-align: center; margin-bottom: 2.5rem; color: var(--purple); text-transform: uppercase; letter-spacing: 0.02em; }
.section h2::after {
  content: ""; display: block; width: 3rem; height: 3px; border-radius: 3px;
  background: var(--gold); margin: 1.1rem auto 0;
}

.story p { margin: 0 0 1.3em; font-size: 1.08rem; }
.story .lead {
  font-family: var(--sans); font-style: italic; font-size: clamp(1.3rem, 3.4vw, 1.6rem); line-height: 1.5;
  text-align: center; margin-bottom: 2.5rem; color: var(--blue);
}
.story p.first { display: flow-root; }
.story p.first::first-letter {
  font-family: var(--display); font-weight: 900; float: left; font-size: 3.4em; line-height: 0.85;
  padding: 0.06em 0.12em 0 0; color: var(--purple);
}

/* Quotes */
.quotes { display: grid; gap: 2.5rem; }
.quote { margin: 0; text-align: center; }
.quote p { font-family: var(--sans); font-style: italic; font-size: clamp(1.5rem, 4vw, 2rem); line-height: 1.35; margin: 0; }
.quote p::before { content: "“"; } .quote p::after { content: "”"; }
.quote cite { display: block; margin-top: 0.75rem; font-style: normal; color: var(--muted); font-size: 0.9rem; }

/* Scripture */
.section.scripture-section { background: linear-gradient(160deg, var(--hero-from), var(--hero-to)); color: var(--on-dark); }
.scripture { margin: 0; text-align: center; }
.scripture p {
  font-family: var(--sans); font-style: italic; font-size: clamp(1.25rem, 3.6vw, 1.7rem);
  line-height: 1.55; margin: 0; white-space: pre-line;
}
.scripture cite { display: block; margin-top: 1.25rem; font-family: var(--display); font-weight: 700; font-style: normal; font-size: 0.75rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--gold); }

/* In Grief */
.mourners { list-style: none; margin: 0; padding: 0; text-align: center; display: grid; gap: 1.5rem; }
.m-names { display: block; font-family: var(--display); font-weight: 800; font-size: clamp(1.1rem, 3vw, 1.3rem); line-height: 1.35; white-space: pre-line; color: var(--purple); }
.m-rel { display: block; margin-top: 0.25rem; font-family: var(--display); font-weight: 600; font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 4.5rem; top: 0.5rem; bottom: 0.5rem; width: 1px; background: var(--line); }
.timeline li { display: grid; grid-template-columns: 4.5rem 1fr; gap: 1.75rem; padding-bottom: 2rem; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: calc(4.5rem - 4px); top: 0.6rem;
  width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px var(--bg);
}
.section:nth-child(even) .timeline li::before { box-shadow: 0 0 0 4px var(--bg-alt); }
.t-year { font-family: var(--display); font-weight: 900; font-size: 1.15rem; color: var(--blue); text-align: right; padding-right: 0.5rem; line-height: 1.6; }
.t-title { font-family: var(--display); font-size: 1rem; font-weight: 800; color: var(--purple); text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.6; }
.t-text { color: var(--muted); margin: 0.2rem 0 0; }
.t-text:empty { display: none; }

/* Photo strip */
.strip-wrap { position: relative; }
.strip {
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.strip::-webkit-scrollbar { display: none; }
.strip-track { display: flex; gap: 0.75rem; width: max-content; padding: 0.5rem 0; }
.thumb {
  flex: 0 0 auto; height: 150px; padding: 0; border: 0; border-radius: 0.5rem; overflow: hidden;
  background: var(--bg-alt); cursor: zoom-in; box-shadow: var(--shadow);
}
.thumb img { height: 100%; width: auto; max-width: none; transition: transform 0.4s ease; }
.thumb:hover img, .thumb:focus-visible img { transform: scale(1.05); }
.strip-nav {
  position: absolute; top: calc(0.5rem + 75px); transform: translateY(-50%);
  width: 2.5rem; height: 2.5rem; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 1.5rem; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; padding: 0 0 0.15rem;
}
.strip-nav.prev { left: -0.5rem; }
.strip-nav.next { right: -0.5rem; }
.strip-hint { text-align: center; color: var(--muted); font-size: 0.88rem; margin: 1.25rem 0 0; }

/* Tributes */
.tributes { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.tribute { background: var(--msg-bg); border: 1px solid var(--msg-line); border-top: 3px solid var(--blue); color: var(--msg-text); border-radius: 0.75rem; padding: 1.75rem; margin: 0; }
.tribute p { margin: 0 0 1rem; white-space: pre-line; }
.tribute footer { font-family: var(--display); font-size: 0.82rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--msg-name); }
.tribute footer small { display: block; font-family: var(--sans); font-size: 0.8rem; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--muted); margin-top: 0.2rem; }


/* Message boards */
.board-intro { text-align: center; color: var(--muted); max-width: 36rem; margin: -1rem auto 2.5rem; }
.messages { display: block; columns: 3 19rem; column-gap: 1.25rem; }
.messages .tribute { break-inside: avoid; margin: 0 0 1.25rem; }
.messages .tribute img { border-radius: 0.4rem; margin-bottom: 1rem; }
.messages.collapsed .extra { display: none; }
.tribute footer small.role { font-family: var(--sans); color: var(--msg-text); opacity: 0.85; margin-top: 0.15rem; }
.tribute .truncated { font-size: 0.8rem; font-style: italic; color: var(--muted); margin-top: -0.5rem; }
.career-summary {
  max-width: 42rem; margin: 0 auto 3.5rem; padding: 2rem 2.25rem;
  background: var(--msg-bg); border: 1px solid var(--msg-line); border-left: 4px solid var(--gold); border-radius: 0.75rem;
}
.career-summary h3 { font-size: 1.05rem; color: var(--purple); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 1rem; }
.career-summary p { margin: 0 0 1em; font-size: 1.02rem; }
.career-summary p:last-child { margin-bottom: 0; }
.more-wrap { text-align: center; margin-top: 1rem; }
.more { cursor: pointer; font-family: var(--display); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; }

/* Travels map */
.map-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; max-width: 36rem; margin: 0 auto 2rem; text-align: center; }
.stat b { display: block; font-family: var(--display); font-weight: 900; font-size: clamp(2.2rem, 7vw, 3.2rem); line-height: 1; color: var(--blue); }
.stat span { display: block; margin-top: 0.5rem; font-family: var(--display); font-weight: 600; font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.map-frame { position: relative; }
.map-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.world { display: block; width: 100%; height: auto; }
.world path { fill: var(--map-land); stroke: var(--map-edge); stroke-width: 0.5; }
.world path.visited { fill: var(--map-visited); cursor: pointer; }
.world path.lived { fill: var(--map-lived); cursor: pointer; }
.world path.visited:hover, .world path.lived:hover, .world path.on { filter: brightness(1.12); stroke: var(--map-pin); stroke-width: 0.8; }
.world path:focus { outline: none; }
.pin { cursor: pointer; }
.pin circle { fill: var(--map-pin); stroke: var(--map-edge); stroke-width: 1.2; transition: r 0.15s; }
.pin.home circle { fill: var(--surface); stroke: var(--map-pin); stroke-width: 2.4; }
.pin:hover circle, .pin.on circle, .pin:focus circle { r: 6; }
.pin:focus { outline: none; }
.map-tip {
  position: absolute; transform: translate(-50%, -100%); z-index: 2; pointer-events: none;
  width: max-content; max-width: 15rem; padding: 0.6rem 0.8rem; border-radius: 0.5rem;
  background: var(--purple); color: var(--bg); font-size: 0.82rem; line-height: 1.45; box-shadow: var(--shadow);
}
.map-tip[hidden] { display: none; }
.map-tip strong { display: block; font-family: var(--display); font-size: 0.9rem; font-weight: 800; letter-spacing: 0.02em; }
.map-tip span { display: block; }
.map-tip .tip-sub { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; }
.map-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 1.25rem; margin-top: 1rem; font-size: 0.82rem; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.sw { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 0.2rem; }
.sw.lived { background: var(--map-lived); }
.sw.visited { background: var(--map-visited); }
.sw.pin { background: var(--map-pin); border-radius: 50%; width: 0.55rem; height: 0.55rem; }
.map-legend .hint { font-style: italic; }
.country-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1.75rem 2rem; margin-top: 2.75rem; }
.region h3 { font-size: 0.95rem; color: var(--purple); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.75rem; }
.region h3 small { font-family: var(--sans); font-size: 0.8rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font: inherit; font-size: 0.82rem; padding: 0.3rem 0.7rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--msg-line); background: var(--msg-bg); color: var(--msg-text);
}
.chip.lived { background: var(--map-lived); border-color: var(--map-lived); color: var(--bg); font-weight: 600; }
.chip.has-note::after { content: ""; display: inline-block; width: 0.32rem; height: 0.32rem; margin-left: 0.4rem; border-radius: 50%; background: var(--gold); vertical-align: middle; }
.chip.lived.has-note::after { background: var(--bg); }
.chip:hover { border-color: var(--blue); }

/* Service */
.service { text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; padding: 2.5rem 1.5rem; }
.service h3 { font-size: 1.3rem; color: var(--purple); text-transform: uppercase; margin-bottom: 1rem; }
.service p { margin: 0.25rem 0; }
.service .note { color: var(--muted); margin-top: 1rem; }

/* Share */
.share { text-align: center; }
.share p { color: var(--muted); margin: 0 0 1.75rem; }
.btn {
  display: inline-block; padding: 0.8rem 1.6rem; border-radius: 999px;
  background: var(--purple); color: var(--bg); text-decoration: none; margin: 0.25rem;
  font-family: var(--display); font-weight: 700; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase;
}
.btn.ghost { background: transparent; color: var(--purple); border: 1.5px solid var(--purple); }

/* Leave a message */
.message-form { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--purple); border-radius: 0.9rem; padding: 2rem; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem 1.25rem; margin-bottom: 1.1rem; }
.field { display: block; }
.field-label { display: block; margin-bottom: 0.4rem; font-family: var(--display); font-weight: 700; font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--purple); }
.field-label b { color: var(--gold-text); }
.field input, .field select, .field textarea {
  display: block; width: 100%; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 0.5rem; padding: 0.7rem 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field textarea { resize: vertical; min-height: 8rem; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent); }
.message-form.tried :invalid { border-color: #c0392b; }
.field-hint { display: block; margin-top: 0.3rem; font-size: 0.8rem; color: var(--muted); }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; }
.form-actions .btn { border: 0; cursor: pointer; margin: 0; padding: 0.95rem 1.8rem; }
.form-actions .btn:disabled { opacity: 0.6; cursor: wait; }
.form-actions .field-hint { margin: 0; }
.form-status:empty { display: none; }
.form-status { margin: 1rem 0 0; padding: 0.75rem 1rem; border-radius: 0.5rem; font-size: 0.95rem; }
.form-status.ok { background: color-mix(in srgb, var(--blue) 12%, transparent); color: var(--text); }
.form-status.error { background: color-mix(in srgb, #c0392b 12%, transparent); color: var(--text); }
.form-privacy { margin: 1rem 0 0; font-size: 0.82rem; color: var(--muted); }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Footer */
.footer { text-align: center; padding: 3rem 1rem; background: linear-gradient(160deg, var(--hero-from), var(--hero-to)); color: var(--on-dark-muted); font-family: var(--display); font-weight: 600; font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; }

/* Lightbox */
.lightbox {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50; background: #0c0a08;
  display: flex; align-items: center; justify-content: center; padding: 3rem 1rem;
}
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; }
.lightbox img { max-height: 80vh; width: auto; border-radius: 0.25rem; }
.lightbox figcaption { color: #d9cfc2; margin-top: 0.85rem; text-align: center; line-height: 1.4; }
.lb-title { display: block; font-family: var(--display); font-weight: 800; font-size: 1rem; letter-spacing: 0.02em; }
.lb-meta { display: block; font-size: 0.8rem; color: #a99d8e; margin-top: 0.3rem; }
.lb-count { display: block; font-size: 0.75rem; color: #7d7266; margin-top: 0.3rem; letter-spacing: 0.1em; }
.lightbox button { position: absolute; background: none; border: 0; color: #eee; font-size: 2.5rem; cursor: pointer; padding: 0.5rem 1rem; line-height: 1; }
.lb-close { top: 0.5rem; right: 0.5rem; }
.lb-prev { left: 0; top: 50%; transform: translateY(-50%); }
.lb-next { right: 0; top: 50%; transform: translateY(-50%); }

/* Gentle reveal */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.9s ease, transform 0.9s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (max-width: 34rem) {
  .nav {
    flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; gap: 1.25rem;
    padding: 0.85rem 1rem; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 0 0 auto; }
  .lightbox figcaption { padding: 0 0.5rem; }
  .lb-title { font-size: 1.05rem; }
  .thumb { height: 110px; }
  .strip-nav { display: none; }
  .career-summary { padding: 1.5rem 1.25rem; }
  .form-grid { grid-template-columns: 1fr; }
  .message-form { padding: 1.4rem 1.1rem; }
  .map-stats { gap: 1.25rem 0.5rem; }
  .world { width: 720px; max-width: none; }
  .timeline::before { left: 3.25rem; }
  .timeline li { grid-template-columns: 3.25rem 1fr; gap: 1.25rem; }
  .timeline li::before { left: calc(3.25rem - 4px); }
  .t-year { font-size: 0.95rem; }
  .t-title { font-size: 0.9rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .candle[aria-pressed="true"] .flame { animation: none; }
}
