/* Memorial site: quiet, warm, readable. No external fonts or assets. */
:root {
  --bg: #f7f3ec;
  --surface: #fbf8f3;
  --text: #2e2a26;
  --muted: #776c60;
  --rule: #e2d9cc;
  --accent: #7d6550;
  --accent-hover: #5c4836;
  --shadow: 0 1px 2px rgba(60, 45, 30, .08), 0 6px 24px rgba(60, 45, 30, .06);
  --serif-latin: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, Cambria, "Times New Roman";
  --cjk: "Noto Serif SC", "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", "STSong",
         "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC";
  --font: var(--serif-latin), var(--cjk), serif;
  --font-zh: var(--cjk), var(--serif-latin), serif;
  --measure: 42rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1917;
    --surface: #23201d;
    --text: #e7e0d5;
    --muted: #a99d8f;
    --rule: #3a342e;
    --accent: #cdb69c;
    --accent-hover: #e6d3bd;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
  img { filter: brightness(.94); }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

:lang(zh-Hans) { font-family: var(--font-zh); }
p:lang(zh-Hans), li:lang(zh-Hans) { line-height: 1.95; letter-spacing: .02em; text-align: justify; }
[lang="en"] { font-family: var(--font); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover, a:focus-visible { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* ---------- header / nav ---------- */
.site-header {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2.25rem 1rem 1.25rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}
.site-title {
  display: inline-flex;
  flex-direction: column;
  gap: .1rem;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 1rem;
}
.site-title span:first-child { font-size: 1.3rem; letter-spacing: .18em; }
.site-title span + span { font-size: .85rem; letter-spacing: .12em; color: var(--muted); font-style: italic; }
.site-header nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .35rem 1.6rem;
  font-size: .98rem;
}
.site-header nav a {
  text-decoration: none;
  color: var(--muted);
  padding: .2rem 0;
  border-bottom: 1px solid transparent;
}
.site-header nav a:hover { color: var(--text); }
.site-header nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.site-header .sep { color: var(--rule); }

/* ---------- content ---------- */
main { padding: 0 1rem; }
.doc { max-width: var(--measure); margin: 0 auto; padding: 3rem 0 2rem; }
.doc-gallery { max-width: 72rem; }

h1 {
  font-weight: 500;
  font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.6rem);
  line-height: 1.3;
  letter-spacing: .04em;
  text-align: center;
  margin: 0 0 2.5rem;
}
h1 span:lang(en) { letter-spacing: .02em; }
.page-index h1 { margin-top: 1rem; }
.page-index h1 span:lang(en) { display: inline-block; margin-top: .3em; font-size: .62em; font-style: italic; color: var(--muted); }

.group { margin: 0 0 2.75rem; }
.group > p { margin: 0 0 1.15em; }
.group > :last-child { margin-bottom: 0; }

.lang-switch { text-align: right; margin: 0 0 1rem; font-size: .95rem; }

/* tribute entries read as a quiet dated list */
.page-tribute .group + .group { padding-top: 2.75rem; border-top: 1px solid var(--rule); }

/* home: welcome text and the list of pages */
.page-index .group.links { text-align: center; padding-top: 2rem; border-top: 1px solid var(--rule); }
.page-index .group.links p { margin: 0 0 .9em; font-size: 1.15rem; }
.group.links a { text-decoration: none; }
.group.links a:hover { text-decoration: underline; }

ul, ol { margin: 0 0 1.15em; padding-left: 1.4em; }
li { margin: .25em 0; }
.page-donation p, .page-donation li { overflow-wrap: anywhere; }

figure { margin: 2.5rem 0; }
figure img, figure video {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 3px;
  box-shadow: var(--shadow);
  background: var(--surface);
}
figure video { width: 100%; }
figure.hero { margin-top: 0; }

/* ---------- photo gallery: justified rows, original aspect ratios, no cropping ---------- */
.gallery { display: flex; flex-wrap: wrap; gap: 6px; }
.gallery::after { content: ""; flex-grow: 1e6; }
.tile {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--surface);
  border-radius: 2px;
}
.tile i { display: block; }
.tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity .2s ease;
}
.tile:hover img { opacity: .88; }
@media (max-width: 30rem) {
  .gallery { gap: 4px; }
  .tile { flex-basis: 40% !important; }
}

/* ---------- lightbox ---------- */
.lb {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 17, 14, .94);
  touch-action: pan-y;
}
.lb.open { display: flex; }
.lb img {
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 5rem);
  max-height: calc(100dvh - 5rem);
  width: auto;
  height: auto;
  box-shadow: 0 4px 30px rgba(0, 0, 0, .5);
  filter: none;
}
.lb button {
  position: absolute;
  border: 0;
  background: transparent;
  color: #e9e1d5;
  font: 2.2rem/1 Georgia, serif;
  width: 3rem;
  height: 3rem;
  cursor: pointer;
  opacity: .75;
}
.lb button:hover, .lb button:focus-visible { opacity: 1; }
.lb .lb-close { top: .5rem; right: .5rem; }
.lb .lb-prev { left: .25rem; top: 50%; transform: translateY(-50%); }
.lb .lb-next { right: .25rem; top: 50%; transform: translateY(-50%); }
.lb .lb-count { position: absolute; bottom: .9rem; left: 0; right: 0; text-align: center; color: #b7ab9c; font-size: .85rem; letter-spacing: .1em; }
body.lb-on { overflow: hidden; }

/* ---------- footer ---------- */
.site-footer {
  max-width: 64rem;
  margin: 2rem auto 0;
  padding: 2rem 1rem 3rem;
  border-top: 1px solid var(--rule);
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  letter-spacing: .06em;
}
.site-footer p { margin: 0; }

@media (max-width: 40rem) {
  body { font-size: 1.0625rem; }
  .site-header { padding-top: 1.5rem; }
  .site-header nav ul { gap: .2rem 1.1rem; font-size: .95rem; }
  .doc { padding-top: 2rem; }
  h1 { margin-bottom: 1.75rem; }
  figure { margin: 2rem -1rem; }
  figure img { border-radius: 0; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media print {
  .site-header nav, .lb { display: none !important; }
  body { background: #fff; color: #000; }
}
