/*
  Memorial single-page site styles
  - Responsive, accessible, minimal JS
  - Edit colors, spacing, and typography via CSS variables
*/

:root {
  --bg: #f7f9fc; /* soft white-blue */
  --fg: #0f1a2a; /* deep ink */
  --muted: #5c6b80; /* cool gray */
  --brand: #1f4aa2; /* royal blue */
  --brand-ink: #0f2f6b; /* navy */
  --card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 6px 20px rgba(0,0,0,0.06);
  --radius: 14px;

  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --max-w: 1100px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; /* deep navy */
    --fg: #e6edf7;
    --muted: #9bb0c9;
    --brand: #5ea3ff; /* bright blue accent */
    --brand-ink: #d6e6ff;
    --card: #0f172a;
    --border: #24324d;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 10px 24px rgba(0,0,0,0.4);
  }
}

html { 
  scroll-behavior: smooth; 
}

/* Basic reset */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font: 400 16px/1.6 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--fg);
  background: var(--bg);
  text-rendering: optimizeLegibility;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: fixed;
  left: var(--space-3);
  top: var(--space-3);
  width: auto;
  height: auto;
  padding: var(--space-2) var(--space-3);
  background: var(--brand);
  color: white;
  border-radius: 999px;
  z-index: 9999;
}

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--space-3) var(--space-6);
}

.muted { color: var(--muted); }

.site-header {
  background: linear-gradient(180deg, rgba(31,74,162,0.16), rgba(31,74,162,0.06));
  padding: var(--space-6) var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.hero-banner {
  display: block;
  width: 100%;
  height: auto;
  max-width: var(--max-w);
  margin: 0 auto var(--space-4) auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.topbar {
  max-width: var(--max-w);
  margin: 0 auto var(--space-2) auto;
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 0 var(--space-3);
}
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.icon-link:hover { filter: brightness(0.98); }
.icon-link:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.sr-only { position: absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-4);
  align-items: center;
  max-width: var(--max-w);
  margin: 0 auto;
}
.hero__portrait {
  width: clamp(150px, 22vw, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.8);
  box-shadow: var(--shadow);
  object-fit: cover;
  object-position: center; /* center on the middle of the photo */
}
.hero__title {
  margin: 0 0 var(--space-1) 0;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: 0.3px;
}
.hero__name {
  margin: 0 0 var(--space-1) 0;
  font-size: clamp(22px, 2.5vw, 28px);
}
.hero__years { margin: 0 0 var(--space-1) 0; color: var(--muted); }
.hero__tag { margin: 0; color: var(--brand-ink); }

.nav {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  max-width: var(--max-w);
  margin-left: auto;
  margin-right: auto;
  padding: 0 var(--space-3);
}
.nav__links { display: flex; gap: var(--space-2); justify-content: center; flex-wrap: wrap; }
.nav__icons { display: flex; gap: var(--space-2); justify-self: end; }
.nav__link {
  display: inline-block;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  color: var(--brand-ink);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}
.nav__link:hover { filter: brightness(0.98); }
.nav__link:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }

/* Mobile nav: stack links and icons, center them */
@media (max-width: 600px) {
  .nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
  }
  .nav__links {
    justify-content: center;
    width: 100%;
  }
  .nav__icons {
    justify-content: center;
    width: 100%;
  }
}

.section {
  margin-top: var(--space-6);
}
.section--intro { margin-top: var(--space-4); }
.section__title {
  font-size: clamp(22px, 2.4vw, 28px);
  margin: 0 0 var(--space-2) 0;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-3);
}
.gallery__item {
  grid-column: span 12;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.gallery__item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  display: block;
  object-fit: cover;      /* fill square without distortion */
  object-position: center;/* center crop */
  cursor: zoom-in;
}
.gallery__item figcaption {
  padding: var(--space-2) var(--space-3);
  font-size: 0.95rem;
  color: var(--muted);
}

/* Improve default crop to favor faces/heads */
.gallery__item img { object-position: 50% 22%; }

/* Sections with mostly people photos: bias crop toward top */
#debbie .gallery__item img,
#friends-and-family .gallery__item img { object-position: 50% 15%; }

/* Per-image opt-in if any still need more headroom */
img.focus-top { object-position: 50% 10% !important; }
img.focus-left { object-position: 15% 50% !important; }
img.zoomable { cursor: zoom-in; }

@media (min-width: 600px) {
  .gallery__item { grid-column: span 6; }
}
@media (min-width: 768px) {
  .gallery__item { grid-column: span 4; }
}

.gallery--two .gallery__item { grid-column: span 12; }
@media (min-width: 600px) {
  .gallery--two .gallery__item { grid-column: span 6; }
}
@media (min-width: 900px) {
  /* Keep 2 columns on large screens for the 4-up gallery */
  .gallery--two .gallery__item { grid-column: span 6; }
}

.see-all-link {
  display: inline-block;
  margin-top: var(--space-3);
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--brand-ink);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.see-all-link:hover,
.see-all-link:focus-visible {
  border-color: var(--brand);
  outline: none;
}

.stories {
  display: grid;
  gap: var(--space-3);
}
.story {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  /* Equal padding on all sides for visual consistency */
  padding: var(--space-2);
  position: relative; /* enable tail positioning */
}
/* Remove default paragraph margins inside memories to avoid extra top/bottom space */
.story p { margin: 0; }

/* Speech-bubble tail (left side) */
.story::after {
  content: "";
  position: absolute;
  left: -8px;             /* offset into the gutter */
  top: 16px;              /* roughly align to first text line */
  width: 12px;
  height: 12px;
  background: var(--card);
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}
.story details { cursor: pointer; }
.story summary {
  list-style: none;
}
.story summary::-webkit-details-marker { display: none; }
.story summary {
  position: relative;
  padding-right: 2rem;
}
.story summary::after {
  content: "\25BE"; /* ▼ */
  position: absolute;
  right: 0.25rem;
  top: 0;
  color: var(--muted);
}
.story details[open] summary::after {
  content: "\25B4"; /* ▴ */
}
/* .story p { margin: var(--space-2) 0 0 0; } */

.site-footer {
  text-align: center;
  padding: var(--space-6) var(--space-3);
  color: var(--muted);
}

/* Timeline */
.timeline { position: relative; padding-left: 100px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 60px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline__year { position: relative; margin-bottom: var(--space-4); }
.timeline__year-title {
  position: absolute;
  left: 0;
  top: 0;
  width: 80px;
  text-align: right;
  color: var(--brand-ink);
  font-weight: 600;
}
.timeline__dot {
  position: absolute;
  left: 54px;
  top: 0.55rem;
  width: 12px;
  height: 12px;
  background: var(--brand);
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.timeline__events { list-style: none; margin: 0 0 0 0; padding: 0 0 0 0; margin-left: 100px; }
.timeline__event {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
  position: relative;
  /* Remove left offset since we no longer show icons */
  padding-left: var(--space-3);
}

/* Split layout for timeline rows with a thumbnail + text */
.timeline__event--split {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.timeline__event--split img { flex: 0 0 auto; }
.timeline__event--split > div { flex: 1 1 auto; }
@media (max-width: 600px) {
  .timeline__event--split { flex-direction: column; }
}

.timeline__event::before {
  /* Hide per-event icons in timeline rows */
  content: none;
  display: none;
}

/* Per-event icons */
.timeline__event--graduation::before { background-image: url("../images/icon-graduation.svg"); }
.timeline__event--move::before       { background-image: url("../images/icon-move.svg"); }
.timeline__event--marriage::before   { background-image: url("../images/icon-marriage.svg"); }
.timeline__event--home::before       { background-image: url("../images/icon-home.svg"); }
.timeline__event--birth::before      { background-image: url("../images/icon-baby.svg"); }

/* Give */
.timeline__year[aria-label="Year 1990"],
.timeline__year[aria-label="Year 1995"],
.timeline__year[aria-label="Year 2002"] { display: none; }
.timeline__year[aria-label="Year 1990"],
.timeline__year[aria-label="Year 1995"],
.timeline__year[aria-label="Year 2002"] { display: none; }

.give { list-style: none; margin: 0; padding: 0; }
.give__item { margin-bottom: var(--space-2); display: flex; align-items: center; gap: 0.75rem; }
.give__item a { color: var(--brand-ink); text-decoration: none; border-bottom: 1px solid var(--border); }
.give__item a:hover { border-bottom-color: currentColor; }
.give__logo { width: 40px; height: 40px; display: inline-block; border-radius: 0; object-fit: contain; background: transparent; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Small screens (phones) */

/* Desktop timeline enhancements (mobile unchanged) */
@media (min-width: 900px) {
  .timeline { padding-left: 130px; }
  .timeline::before { left: 90px; }
  .timeline__year-title {
    width: 110px;
    font-size: 1.1rem;
    letter-spacing: 0.3px;
  }
  .timeline__dot { left: 84px; }
  .timeline__events { margin-left: 130px; }
}

/* Lightbox (image preview) */
.lightbox[hidden] { display: none !important; }
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 4vw, 28px);
  z-index: 9999;
}
.lightbox__img {
  max-width: 96vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.lightbox__close {
  position: fixed;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.lightbox__close:hover { background: rgba(255,255,255,0.18); }
.lightbox__close:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* Prevent background scroll when lightbox open */
body.lightbox-open { overflow: hidden; }
@media (max-width: 600px) {
  /* Nav: stack icons below links on small screens */
  .nav { grid-template-columns: 1fr; row-gap: var(--space-2); }
  .nav__icons { justify-self: center; }

  /* Top hero: stack image and text, center align */
  .hero { grid-template-columns: 1fr; text-align: center; gap: var(--space-3); }
  .hero__portrait { width: 120px; height: 120px; margin: 0 auto; }
  .hero__text { justify-self: center; }

  /* Timeline: reduce left gutter and make year inline above events */
  .timeline { padding-left: 0; }
  .timeline::before { left: 20px; }
  .timeline__year-title {
    position: static;
    width: auto;
    text-align: left;
    margin: 0 0 var(--space-1) 48px;
  }
  .timeline__dot { left: 14px; top: 1.1rem; }
  .timeline__events { margin-left: 48px; }

  /* Give: stack logo, link, and text for readability */
  .give__item { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}
