/* =========================================================================
   Serenity & Legacy — In Loving Memory of Dr. William Chao Wei Mow
   Design tokens from DESIGN.md, hand-written (no framework, no CDN).
   ========================================================================= */

:root {
  /* Surfaces */
  --surface: #fbf9f4;
  --surface-dim: #dbdad5;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f5f3ee;
  --surface-container: #f0eee9;
  --surface-container-high: #eae8e3;
  --surface-container-highest: #e4e2de;

  /* Text */
  --on-surface: #1b1c19;
  --on-surface-variant: #424844;
  --inverse-surface: #30312e;
  --inverse-on-surface: #f2f1ec;

  /* Lines */
  --outline: #727973;
  --outline-variant: #c2c8c2;

  /* Greens */
  --primary: #173124;            /* deep forest — headings, key text */
  --on-primary: #ffffff;
  --primary-container: #2d4739;  /* card backgrounds */
  --on-primary-container: #98b5a3;

  /* Accents */
  --secondary: #6c5e06;          /* muted olive-gold — labels, quotes */
  --gold: #c5b358;               /* lighter gold — frames, dividers, glyphs */

  /* Spacing */
  --container-max: 1100px;
  --gutter: 24px;
  --margin-mobile: 20px;
  --stack-lg: 80px;
  --stack-md: 48px;
  --stack-sm: 24px;

  /* Radius */
  --radius-sm: 0.125rem;
  --radius: 0.25rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--on-surface);
  font-family: "Libre Franklin", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #f7e382; }   /* secondary-container */

img { display: block; max-width: 100%; }

a { color: inherit; }

/* ------------------------------------------------------------- Typography utils */
.serif { font-family: "EB Garamond", Georgia, "Times New Roman", serif; }

.display-lg {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 500;
  font-size: 48px;
  line-height: 56px;
  letter-spacing: -0.01em;
}
.headline-md {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 400;
  font-size: 32px;
  line-height: 40px;
}
.headline-sm {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 500;
  font-size: 24px;
  line-height: 32px;
  letter-spacing: 0.02em;
}
.body-lg { font-size: 18px; line-height: 28px; font-weight: 300; }
.body-md { font-size: 16px; line-height: 24px; font-weight: 400; }
.label-caps {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.quote-italic {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 400;
  font-style: italic;
  font-size: 22px;
  line-height: 32px;
}

/* ------------------------------------------------------------------- Layout */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--margin-mobile);
}
@media (min-width: 768px) {
  .container { padding-inline: var(--gutter); }
}

/* --------------------------------------------------------------------- Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface-container-low);
  border-bottom: 0.5px solid rgba(108, 94, 6, 0.25);
}
.site-header .bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 80px;
  gap: 16px;
}
.site-header .brand {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 500;
  font-size: 24px;
  line-height: 1.1;
  color: var(--primary);
}
.nav-links { display: none; align-items: center; gap: 32px; }
@media (min-width: 768px) { .nav-links { display: flex; } }
.nav-links a {
  text-decoration: none;
  color: var(--on-surface-variant);
  transition: color 0.3s ease;
}
.nav-links a:hover { color: var(--secondary); }

.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-lg);
  padding: 10px 24px;
  transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { opacity: 0.9; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: var(--on-primary); }
.header-cta { display: none; }
@media (min-width: 768px) { .header-cta { display: inline-block; } }

/* ----------------------------------------------------------------------- Main */
main { padding-block: var(--stack-lg); padding-bottom: 96px; }
@media (min-width: 768px) { main { padding-bottom: var(--stack-lg); } }

/* Offset anchor scroll targets so headings clear the 80px sticky header. */
section, [id] { scroll-margin-top: 96px; }

/* ----------------------------------------------------------------------- Hero */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: var(--stack-lg); }
.hero h1 { margin: 32px 0 0; color: var(--primary); }
.hero .dates {
  color: var(--secondary);
  margin-top: 10px;
  letter-spacing: 0.18em;
}
.hero .dedication {
  max-width: 640px;
  margin: 20px auto 0;
  color: var(--on-surface-variant);
}

/* Matted, framed hero portrait — a thin outer hairline, an inset gold line,
   a soft lift, and a gentle inner glow blending the photo into the mat. */
.hero-portrait {
  position: relative;
  width: 78%;
  max-width: 430px;
  margin: 0 auto;
  padding: 14px;
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  box-shadow: 0 18px 42px -28px rgba(27, 28, 25, 0.45);
}
.hero-portrait img {
  display: block;
  width: 100%;
  aspect-ratio: 0.8;
  object-fit: cover;
  border: 1px solid rgba(27, 28, 25, 0.10);
}
.hero-portrait::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 0.5px solid var(--gold);
  pointer-events: none;
}
.hero-portrait::before {
  content: "";
  position: absolute;
  inset: 14px;
  box-shadow: inset 0 0 18px 3px rgba(251, 249, 244, 0.55);
  pointer-events: none;
  z-index: 2;
}

/* ------------------------------------------------------------- Photo framing */
.photo-frame {
  border: 1px solid var(--outline-variant);
  padding: 8px;
  position: relative;
  background: var(--surface-container-lowest);
}
.photo-frame::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 0.5px solid var(--gold);
  pointer-events: none;
}
.hero .photo-frame { width: 100%; max-width: 480px; }

/* Elegant placeholder shown until a real photo is dropped in.
   Replace the <img> sources in index.html with real photos and this never shows. */
.photo-placeholder {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background:
    radial-gradient(circle at 30% 20%, rgba(152,181,163,0.18), transparent 60%),
    radial-gradient(circle at 80% 90%, rgba(197,179,88,0.14), transparent 55%),
    var(--surface-container);
  color: var(--secondary);
  text-align: center;
  aspect-ratio: 0.8;
}
.photo-placeholder .glyph { font-family: "EB Garamond", serif; font-size: 44px; opacity: 0.5; }
.photo-placeholder .note { color: var(--on-surface-variant); opacity: 0.7; padding: 0 16px; }

/* ------------------------------------------------------------------ Dividers */
.leaf-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-block: var(--stack-lg);
  color: var(--secondary);
}
.leaf-divider .line { height: 0.5px; width: 96px; background: rgba(108, 94, 6, 0.3); }
.leaf-divider .glyph { font-family: "EB Garamond", serif; font-style: italic; font-size: 20px; }

/* --------------------------------------------------------------- Two-column grid */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--stack-md);
}
@media (min-width: 1024px) {
  .layout { grid-template-columns: 8fr 4fr; gap: var(--stack-lg); }
}

/* ----------------------------------------------------------------- Obituary body */
.obituary h2 { color: var(--primary); margin: 0 0 24px; }
.obituary .lead {
  color: var(--on-surface);
  font-style: italic;
  border-left: 2px solid var(--gold);
  padding-left: 24px;
  margin: 0 0 36px;
}
.obituary p {
  color: var(--on-surface-variant);
  margin: 0 0 20px;
}
.obituary .subhead {
  color: var(--primary);
  margin: 40px 0 16px;
}

/* Featured pull-quote block */
.feature-quote {
  position: relative;
  overflow: hidden;
  background: var(--surface-container-low);
  border-radius: var(--radius-xl);
  padding: var(--stack-sm);
  margin: 36px 0;
}
.feature-quote .bleed {
  position: absolute;
  top: -30px; right: -20px;
  font-family: "EB Garamond", serif;
  font-size: 140px;
  line-height: 1;
  color: var(--primary);
  opacity: 0.10;
  transform: rotate(8deg);
  pointer-events: none;
}
.feature-quote blockquote {
  margin: 0;
  color: var(--secondary);
  font-style: italic;
}
.feature-quote cite { display: block; margin-top: 16px; font-style: normal; color: var(--on-surface-variant); }

/* "Survived by" */
.survived {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 0.5px solid rgba(108, 94, 6, 0.3);
}
.survived h3 { color: var(--primary); margin: 0 0 16px; }
.survived p { color: var(--on-surface-variant); margin: 0; }

/* ------------------------------------------------------------------- Sidebar */
.sidebar { display: flex; flex-direction: column; gap: var(--stack-sm); }

.card {
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.card h3 {
  color: var(--primary);
  margin: 0 0 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(108, 94, 6, 0.2);
}
.highlights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 24px; }
.highlights li { display: flex; gap: 16px; }
.highlights .glyph {
  flex-shrink: 0;
  font-family: "EB Garamond", serif;
  font-size: 22px;
  line-height: 1.2;
  color: var(--gold);
}
.highlights .term { color: var(--on-surface); margin: 0 0 4px; }
.highlights .desc { color: var(--on-surface-variant); margin: 0; }
.card .closing-quote {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid rgba(108, 94, 6, 0.15);
  color: var(--secondary);
  text-align: center;
}
.rotating-quote {
  transition: opacity 0.9s ease;
  min-height: 4.5em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rotating-quote.is-fading { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .rotating-quote { transition: none; }
}

/* Memorial gift card */
.card-accent {
  background: var(--primary-container);
  color: var(--on-primary-container);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
}
.card-accent h3 { color: #ffffff; margin: 0 0 12px; }
.card-accent p { margin: 0 0 24px; opacity: 0.92; }
.card-accent .btn-light {
  display: inline-block;
  width: 100%;
  background: var(--on-primary-container);
  color: var(--primary-container);
  border-radius: var(--radius-lg);
  padding: 12px;
  text-decoration: none;
  transition: background 0.2s ease;
}
.card-accent .btn-light:hover { background: #ffffff; }

/* ----------------------------------------------------------- Service details */
.service { text-align: center; }
.service h2 { color: var(--primary); margin: 0 0 8px; }
.service .intro { color: var(--on-surface-variant); max-width: 620px; margin: 0 auto var(--stack-md); }
.service-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gutter);
  max-width: 820px;
  margin-inline: auto;
  text-align: left;
}
@media (min-width: 640px) { .service-grid { grid-template-columns: 1fr 1fr; } }
.service-card {
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.service-card .term { color: var(--secondary); margin: 0 0 8px; }
.service-card .detail { color: var(--on-surface); margin: 0; }
.service-card .detail.muted { color: var(--on-surface-variant); font-style: italic; }
.service .map-link { display: inline-block; margin-top: var(--stack-sm); }
.service-date {
  color: var(--primary);
  font-size: 18px;
  letter-spacing: 0.08em;
  margin: 0 0 var(--stack-sm);
}
.schedule { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.schedule li { display: flex; align-items: baseline; gap: 16px; }
.schedule .time {
  flex: 0 0 84px;
  text-align: right;
  font-family: "EB Garamond", Georgia, serif;
  font-size: 17px;
  color: var(--secondary);
}
.schedule .event {
  border-left: 1px solid rgba(108, 94, 6, 0.3);
  padding-left: 16px;
  color: var(--on-surface);
}
.service-card .detail + .detail { margin-top: 4px; }

/* -------------------------------------------------------------------- Gallery */
.gallery { text-align: center; }
.gallery h2 { color: var(--primary); margin: 0 0 8px; }
.gallery .intro { color: var(--on-surface-variant); margin: 0 auto var(--stack-md); max-width: 620px; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gutter);
}
@media (min-width: 768px) { .gallery-grid { grid-template-columns: repeat(3, 1fr); } }
.gallery-grid .photo-frame { padding: 6px; }
.gallery-grid .photo-placeholder { aspect-ratio: 1; }
.gallery-grid img { aspect-ratio: 1; object-fit: cover; width: 100%; }

/* --------------------------------------------------------------------- Footer */
.site-footer {
  background: var(--surface-container-low);
  border-top: 0.5px solid var(--secondary);
  margin-top: var(--stack-lg);
}
.site-footer .inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--stack-sm);
  text-align: center;
  padding-block: var(--stack-md);
}
.site-footer .motto { color: var(--secondary); }
.site-footer .fineprint { color: var(--on-surface-variant); margin: 0; }

/* ----------------------------------------------------- Mobile bottom nav bar */
.mobile-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--outline-variant);
  box-shadow: 0 -2px 12px rgba(27,28,25,0.06);
}
@media (min-width: 768px) { .mobile-nav { display: none; } }
.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--on-surface-variant);
  font-family: "EB Garamond", serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.mobile-nav .glyph { font-size: 18px; }

/* --------------------------------------------------------------- Animations */
.fade-in { opacity: 0; transform: translateY(12px); }
.fade-in.is-visible { animation: fadeIn 1.2s ease-out forwards; }
@keyframes fadeIn { to { opacity: 1; transform: translateY(0); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fade-in { opacity: 1; transform: none; animation: none; }
}

/* Mobile type scale */
@media (max-width: 767px) {
  .display-lg { font-size: 36px; line-height: 42px; }
  .headline-md { font-size: 28px; line-height: 36px; }
}
