:root {
  --bg: #f4f1ea;
  --fg: #1a1a1a;
  --muted: #55524b;
  --accent: #5b3a1e;
  --card: #fffdf7;
  --border: rgba(0, 0, 0, 0.12);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
  --radius: 10px;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --fg: #ece9e1;
    --muted: #a29d92;
    --accent: #d8b98a;
    --card: #171a20;
    --border: rgba(255, 255, 255, 0.12);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  line-height: 1.2;
  margin: 0;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button {
  font: inherit;
}

/* -------------------------------------------------------------------------
   Person header
------------------------------------------------------------------------- */

.person-header {
  text-align: center;
  padding: 24px 0 8px;
}

.person-header h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: 0.01em;
}

.dates {
  color: var(--muted);
  margin: 8px 0 0;
}

.epitaph {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--accent);
  margin: 20px auto 0;
  max-width: 46ch;
}

.bio {
  max-width: 62ch;
  margin: 24px auto 0;
  color: var(--muted);
}

.bio p {
  margin: 0 0 1em;
}

/* -------------------------------------------------------------------------
   Sections
------------------------------------------------------------------------- */

.section {
  margin-top: 40px;
}

.section h2 {
  font-size: 1.4rem;
  color: var(--muted);
  margin-bottom: 16px;
}

/* -------------------------------------------------------------------------
   Carousel
------------------------------------------------------------------------- */

.carousel {
  position: relative;
}

.carousel-track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 8px 4px 16px;
  scrollbar-width: thin;
}

.carousel-track::-webkit-scrollbar {
  height: 8px;
}

.carousel-item {
  flex: 0 0 78%;
  max-width: 560px;
  scroll-snap-align: start;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}

.carousel-item img,
.carousel-item video {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.carousel-media {
  cursor: pointer;
  border: 0;
  padding: 0;
  width: 100%;
  background: none;
  position: relative;
  display: block;
}

.carousel-media .play-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 2.4rem;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.carousel-caption {
  padding: 10px 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.carousel-btn {
  position: absolute;
  top: 40%;
  transform: translateY(-50%);
  z-index: 2;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.carousel-btn:hover {
  background: rgba(0, 0, 0, 0.75);
}

.carousel-btn.prev {
  left: 8px;
}

.carousel-btn.next {
  right: 8px;
}

/* -------------------------------------------------------------------------
   Gallery grid
------------------------------------------------------------------------- */

.gallery-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.data-saver-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--muted);
  cursor: pointer;
}

.data-saver-btn[aria-pressed='true'] {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.tile {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
  border: none;
  padding: 0;
  width: 100%;
  cursor: zoom-in;
  text-align: left;
}

.tile-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: #ddd;
}

@media (prefers-color-scheme: dark) {
  .tile-image {
    background: #222;
  }
}

.tile-image--thumb {
  filter: blur(1px) saturate(0.9);
  transform: scale(1.02);
}

.tile-caption {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.tile-text {
  aspect-ratio: 4 / 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--fg);
  overflow: hidden;
  cursor: default;
}

.tile-text .tile-text-body {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-text .tile-caption {
  margin-top: auto;
}

.tile-video {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
}

.tile-video img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile-video .play-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 2rem;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.tile-audio {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: var(--card);
  font-size: 2.4rem;
  color: var(--accent);
}

/* -------------------------------------------------------------------------
   Lightbox
------------------------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.94);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-media {
  max-width: min(96vw, 1400px);
  max-height: 82vh;
  border-radius: 6px;
}

.lightbox-media img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 6px;
}

.lightbox-media video {
  max-width: 100%;
  max-height: 82vh;
}

.lightbox-text {
  max-width: 640px;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.7;
  text-align: center;
  white-space: pre-wrap;
  max-height: 82vh;
  overflow-y: auto;
}

.lightbox-caption {
  margin-top: 14px;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  min-height: 1.4em;
}

.lightbox-controls {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 12px;
  pointer-events: none;
}

.lightbox-controls button {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 1.4rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.lightbox-controls button:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 2;
}

.lightbox-nav {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
}

.lightbox-video-sources {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  justify-content: center;
}

.lightbox-video-sources button {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.lightbox-video-sources button[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* -------------------------------------------------------------------------
   Home
------------------------------------------------------------------------- */

.home {
  text-align: center;
  padding-top: 15vh;
}

.home h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
}

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

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