:root {
  --bg: #f6f8f7;
  --surface: #ffffff;
  --ink: #1d2b26;
  --muted: #56645e;
  --line: #d5ddd9;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --shadow: 0 1px 2px rgba(29, 43, 38, 0.06), 0 4px 14px rgba(29, 43, 38, 0.06);
  --shadow-lg: 0 2px 4px rgba(29, 43, 38, 0.06), 0 14px 34px rgba(29, 43, 38, 0.12);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151c19;
    --surface: #1c2521;
    --ink: #e4ebe7;
    --muted: #a3b2ab;
    --line: #33413b;
    --accent: #7cc39f;
    --accent-ink: #10201a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 14px 34px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}

.wrap {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

a { color: var(--accent); text-underline-offset: 0.18em; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.mark { width: 1.75rem; height: 1.75rem; color: var(--accent); }
nav { display: flex; gap: 1.25rem; }
nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
nav a:hover { color: var(--ink); }
nav a[aria-current] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.4em; }

/* Skip link: hidden until focused */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 10;
  padding: 0.5rem 0.9rem;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 4px;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }
main:focus { outline: none; }

/* Content */
main { padding-top: 2.5rem; padding-bottom: 4rem; }

.prose h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
}
.prose h2 {
  font-size: 1.3rem;
  line-height: 1.3;
  margin: 2.25rem 0 0.5rem;
}
.prose p, .prose ul { margin: 0 0 1rem; }
.prose ul { padding-left: 1.25rem; }

.crumb { margin: 0 0 0.5rem; font-size: 0.95rem; }
.crumb ol { list-style: none; margin: 0; padding: 0; }
.crumb a { color: var(--muted); }
.byline {
  color: var(--muted);
  font-size: 0.95rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem !important;
  border-bottom: 1px solid var(--line);
}
.byline a { color: var(--muted); }

.article-list { list-style: none; padding: 0 !important; }
.article-list li { border-bottom: 1px solid var(--line); }
.article-list a {
  display: block;
  padding: 0.85rem 0;
  text-decoration: none;
  font-weight: 500;
}
.article-list a:hover { text-decoration: underline; }

/* Figures and images */
.prose::after { content: ""; display: table; clear: both; }

.figure { margin: 2rem 0; }
.figure .frame {
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.figure img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.8s cubic-bezier(.2,.7,.2,1);
}
.figure figcaption {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Hero: gentle rise on load, slow zoom on hover */
.figure.hero { margin: 0.5rem 0 2rem; animation: rise 0.9s cubic-bezier(.2,.7,.2,1) both; }
.figure.hero .frame { border-radius: 18px; box-shadow: var(--shadow-lg); }
.figure.hero:hover img { transform: scale(1.035); }

/* Gallery cards: lift on hover, reveal on scroll */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}
@media (max-width: 30rem) {
  .gallery { gap: 0.6rem; }
  .gallery .figure figcaption { padding: 0.5rem 0.6rem 0.6rem; font-size: 0.82rem; }
}
.gallery .figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.gallery .figure .frame { border: 0; border-radius: 0; box-shadow: none; }
.gallery .figure figcaption {
  margin: 0;
  padding: 0.7rem 0.9rem 0.85rem;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
}
.gallery .figure:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.gallery .figure:hover img { transform: scale(1.06); }

/* Author avatar: round, with an accent ring */
.figure.avatar {
  float: left;
  width: 6rem;
  margin: 0.25rem 1.25rem 0.75rem 0;
}
.figure.avatar .frame {
  border-radius: 50%;
  border: 0;
  padding: 3px;
  background: linear-gradient(135deg, var(--accent), #e7b75f);
}
.figure.avatar img { border-radius: 50%; border: 3px solid var(--surface); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@supports (animation-timeline: view()) {
  .gallery .figure, .figure.avatar {
    animation: rise linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 60%;
  }
}

@media (prefers-color-scheme: dark) {
  .figure img { filter: brightness(0.9) saturate(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  .figure, .figure img, .gallery .figure { animation: none !important; transition: none !important; }
  .figure.hero:hover img, .gallery .figure:hover img, .gallery .figure:hover { transform: none; }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1.5rem 0 2.5rem;
}
.site-footer p { margin: 0.25rem 0; }
