:root {
  color-scheme: light;
  --ground: #d3cac6;
  --paper: #ebe5e3;
  --paper-deep: #e1dad7;
  --ink: #2b2622;
  --muted: #4b433e;
  --accent: #0b6139;
  --accent-ink: #ffffff;
  --edge: #c8bdb8;
  --display: "Young Serif", Georgia, serif;
  --text: "Source Serif 4", Georgia, serif;
  --page-width: 1040px;
  --side: clamp(20px, 5vw, 72px);
  --small: 1rem;
  --body: clamp(1.0625rem, 1.1vw, 1.125rem);
  --lead: clamp(1.375rem, 2vw, 1.75rem);
  --head: clamp(2.5rem, 1.5rem + 4vw, 5.25rem);
  --section-head: clamp(2rem, 1.4rem + 2.5vw, 3.5rem);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 78px;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--text);
  font-size: var(--body);
  line-height: 1.58;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { color: inherit; }

.site-header {
  width: min(var(--page-width), calc(100% - var(--side) * 2));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.wordmark {
  font-family: var(--display);
  font-size: 1.2rem;
  white-space: nowrap;
}

.site-header nav { display: flex; gap: clamp(18px, 3vw, 40px); }
.site-header nav a, .footer-content a { font-size: var(--small); }
.site-header nav a:hover, .text-link:hover { color: var(--accent); }

main {
  position: relative;
  z-index: 1;
  background: var(--ground);
  padding: 18px var(--side) 110px;
}

.hero-sheet, .intro-sheet, .next-sheet, .learning-section, .projects-section {
  width: min(var(--page-width), 100%);
  margin-left: auto;
  margin-right: auto;
}

.paper-sheet { background: var(--paper); }

.hero-sheet {
  min-height: min(790px, calc(100svh - 112px));
  padding: clamp(32px, 6vw, 72px) clamp(28px, 7vw, 80px) 0;
  display: grid;
  grid-template-columns: 1fr minmax(260px, 0.9fr);
  align-items: center;
  column-gap: clamp(26px, 5vw, 74px);
  position: relative;
  overflow: hidden;
  animation: arrive 700ms ease-out both;
}

.hero-copy { max-width: 520px; padding-bottom: 40px; }
.hero-note, .section-note { margin: 0 0 18px; font-size: var(--small); color: var(--muted); }

h1, h2, h3, h4, p, figure { margin-top: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; }
h1 {
  max-width: 650px;
  margin-bottom: 24px;
  font-size: var(--head);
  line-height: 0.99;
  letter-spacing: -0.035em;
}

.hero-intro { max-width: 480px; margin-bottom: 30px; font-size: var(--lead); line-height: 1.55; }
.action-link, .text-link { display: inline-flex; align-items: center; gap: 15px; font-size: var(--body); }
.action-link {
  min-height: 48px;
  padding: 9px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  transition: background 180ms ease, transform 180ms ease;
}
.action-link:hover { background: #095e34; transform: translateY(-2px); }

.map-illustration { margin: 12px 0 24px; align-self: center; }
.map-illustration svg { display: block; width: 100%; height: auto; overflow: visible; }
.map-illustration figcaption { margin-top: 12px; color: var(--muted); font-size: var(--small); }
.route { fill: none; stroke: var(--edge); stroke-width: 2; stroke-linecap: round; }
.route-main { stroke: var(--accent); stroke-dasharray: 600; stroke-dashoffset: 600; animation: draw-route 2.1s 350ms ease forwards; }
.route-side { stroke-dasharray: 8 8; }
.node { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.node-root, .node-end { fill: var(--accent); stroke: var(--accent); }
.map-illustration text { fill: var(--ink); font: 17px var(--text); }
.map-illustration .small-label { fill: white; font-size: 10px; text-anchor: middle; }

.hero-foot {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 0 20px;
  color: var(--muted);
  font-size: var(--small);
}

.intro-sheet {
  margin-top: 34px;
  padding: clamp(32px, 6vw, 70px);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 34px clamp(34px, 8vw, 110px);
  align-items: start;
  clip-path: polygon(0 0, 100% 0, 100% 94%, 97% 96%, 94% 94%, 91% 96%, 88% 94%, 85% 96%, 82% 94%, 79% 96%, 76% 94%, 73% 96%, 70% 94%, 67% 96%, 64% 94%, 61% 96%, 58% 94%, 55% 96%, 52% 94%, 49% 96%, 46% 94%, 43% 96%, 40% 94%, 37% 96%, 34% 94%, 31% 96%, 28% 94%, 25% 96%, 22% 94%, 19% 96%, 16% 94%, 13% 96%, 10% 94%, 7% 96%, 4% 94%, 0 96%);
}

.section-heading h2, .section-title-row h2, .next-sheet h2 {
  margin-bottom: 0;
  font-size: var(--section-head);
  line-height: 1.06;
  letter-spacing: -0.025em;
}

.intro-body p { margin-bottom: 16px; }
.intro-body p, .topic-main p, .topic-details p, .next-copy p { max-width: 42em; }
.text-link { margin-top: 3px; color: var(--accent); }
.perforation { grid-column: 1 / -1; border-top: 2px dotted var(--edge); }
.tear-note { grid-column: 1 / -1; margin: -18px 0 4px; color: var(--muted); font-size: var(--small); }

.learning-section { padding-top: clamp(72px, 10vw, 128px); }
.section-title-row { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 30px; }
.section-side-note { max-width: 340px; margin-bottom: 4px; color: var(--muted); font-size: var(--small); }
.learning-controls { display: grid; grid-template-columns: minmax(220px, 0.7fr) 1.3fr; align-items: end; gap: 24px; }
.search-box { display: grid; gap: 7px; }
.search-label { font-size: var(--small); }
.search-box input {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  outline: none;
  background: var(--paper);
  color: var(--ink);
  padding: 10px 13px;
}
.search-box input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.search-box input::placeholder { color: #8b817b; }
.filter-list { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-button {
  min-height: 40px;
  padding: 6px 13px;
  border: 0;
  background: var(--paper-deep);
  cursor: pointer;
  font-size: var(--small);
  transition: background 160ms ease, color 160ms ease;
}
.filter-button:hover { background: #d6e2d8; }
.filter-button.is-active { background: var(--accent); color: var(--accent-ink); }
.filter-button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.results-count { min-height: 24px; margin: 18px 0 10px; color: var(--muted); font-size: var(--small); }

.topic-list { display: grid; grid-template-columns: 1fr; gap: 12px; }
.topic-sheet {
  min-height: 270px;
  padding: clamp(22px, 3vw, 32px);
  background: var(--paper);
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: start;
  transition: background 180ms ease, transform 180ms ease;
}
.topic-sheet:hover { background: #f8f4ef; transform: translateY(-2px); }
.topic-kind { display: block; margin-bottom: 12px; color: var(--accent); font-size: var(--small); }
.topic-sheet h3 { margin-bottom: 7px; font-size: var(--lead); line-height: 1.18; }
.topic-main p, .topic-details p { margin-bottom: 0; }
.topic-details {
  align-self: end;
  margin-top: 28px;
  padding-top: 0;
  color: var(--muted);
  font-size: var(--small);
}
.topic-details h4 { margin-bottom: 7px; color: var(--ink); font-size: var(--body); font-weight: 600; }
.topic-details .evidence { margin-top: 10px; font-style: italic; }
.topic-sheet[hidden] { display: none; }
.topic-sheet:nth-child(4n + 1) {
  grid-column: 1 / -1;
  grid-template-columns: 0.82fr 1.18fr;
  grid-template-rows: auto;
  align-items: end;
  gap: 24px;
  background: var(--paper-deep);
}
.topic-sheet:nth-child(4n + 1) .topic-details { margin-top: 0; }
.topic-sheet:nth-child(4n + 3) { background: #e5ddda; }
.empty-state { padding: 25px 0; }

.projects-section { padding-top: clamp(78px, 11vw, 140px); }
.project-stack { display: grid; gap: 12px; }
.project-sheet { background: var(--paper); }
.project-featured {
  min-height: 330px;
  padding: clamp(28px, 5vw, 58px);
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  align-items: center;
  gap: 36px;
  background: var(--paper);
}
.project-stage { display: block; margin-bottom: 13px; color: var(--accent); font-size: var(--small); }
.project-copy h3, .project-row h3 { margin-bottom: 12px; font-size: clamp(1.65rem, 1.2rem + 1.8vw, 2.8rem); line-height: 1.08; letter-spacing: -0.02em; }
.project-copy p, .project-row p { max-width: 680px; margin-bottom: 19px; }
.tech-list { display: flex; flex-wrap: wrap; gap: 7px 16px; margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: var(--small); }
.tech-list li { padding-bottom: 2px; }
.project-diagram { display: grid; justify-items: center; gap: 6px; padding: 26px 18px; background: var(--paper-deep); text-align: center; }
.project-diagram span { width: min(100%, 290px); padding: 10px 14px; background: var(--paper); }
.project-diagram i { color: var(--accent); font-style: normal; line-height: 1; }
.project-diagram .diagram-accent { background: var(--accent); color: var(--accent-ink); }
.animal-samples { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 20px 0; }
.animal-samples img { width: 100%; height: clamp(82px, 10vw, 136px); object-fit: cover; }
.animal-samples figcaption, .ocr-result figcaption { grid-column: 1 / -1; margin-top: 4px; color: var(--muted); font-size: var(--small); }
.ocr-result { margin: 18px 0; }
.ocr-result img { display: block; width: min(100%, 520px); height: auto; }

.project-row {
  padding: 28px clamp(25px, 5vw, 58px);
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.project-row .project-stage { margin-top: 2px; }
.project-row h3 { font-size: var(--lead); }
.project-row p { margin-bottom: 14px; }
.project-row:nth-child(even) { background: var(--paper-deep); }

.next-sheet {
  margin-top: clamp(78px, 11vw, 140px);
  padding: clamp(32px, 6vw, 70px);
  display: grid;
  grid-template-columns: 1fr 0.8fr;
  gap: 32px clamp(35px, 8vw, 110px);
  align-items: start;
}
.next-sheet h2 { max-width: 560px; }
.next-copy p { margin-bottom: 14px; }
.next-areas { color: var(--muted); font-size: var(--small); }

.site-footer {
  position: sticky;
  bottom: 0;
  z-index: 0;
  min-height: 230px;
  margin-top: -112px;
  padding: 86px var(--side) 26px;
  background: var(--accent);
  color: var(--accent-ink);
}
.footer-content, .footer-caption { width: min(var(--page-width), 100%); margin-left: auto; margin-right: auto; }
.footer-content { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.footer-content p { margin: 0; font-size: var(--body); line-height: 1.5; }
.footer-content a { border-bottom: 1px solid currentColor; padding-bottom: 4px; }
.footer-caption { margin-top: 34px; margin-bottom: 0; opacity: 0.78; font-size: var(--small); }

@keyframes arrive { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes draw-route { to { stroke-dashoffset: 0; } }

@media (max-width: 760px) {
  :root { --side: 18px; }
  .site-header { min-height: 64px; }
  .site-header nav { gap: 14px; }
  .site-header nav a { font-size: 0.8125rem; }
  main { padding-top: 10px; padding-bottom: 85px; }
  .hero-sheet { min-height: 0; padding: 38px 25px 0; grid-template-columns: 1fr; gap: 8px; }
  .hero-copy { padding-bottom: 0; }
  h1 { font-size: clamp(2.7rem, 12vw, 4.5rem); }
  .hero-intro { font-size: 1.125rem; }
  .map-illustration { width: min(100%, 410px); margin: 4px auto 18px; }
  .hero-foot { flex-wrap: wrap; justify-content: flex-start; gap: 8px 18px; }
  .intro-sheet { margin-top: 18px; padding: 32px 25px 30px; grid-template-columns: 1fr; gap: 22px; }
  .perforation { margin-top: 6px; }
  .tear-note { margin-top: -11px; }
  .section-title-row { align-items: start; flex-direction: column; gap: 12px; }
  .section-side-note { max-width: 100%; }
  .learning-controls { grid-template-columns: 1fr; gap: 17px; }
  .topic-list { grid-template-columns: 1fr; }
  .topic-sheet { min-height: 0; }
  .topic-sheet:nth-child(4n + 1) { grid-template-columns: 1fr; gap: 0; }
  .topic-sheet:nth-child(4n + 1) .topic-details { margin-top: 24px; }
  .project-featured { grid-template-columns: 1fr; gap: 23px; }
  .project-row { grid-template-columns: 1fr; gap: 0; padding-top: 24px; padding-bottom: 25px; }
  .project-row .project-stage { margin-bottom: 9px; }
  .next-sheet { grid-template-columns: 1fr; gap: 22px; }
  .site-footer { min-height: 210px; padding-top: 78px; }
}

@media (max-width: 420px) {
  .site-header { align-items: flex-start; flex-direction: column; justify-content: center; gap: 4px; padding: 10px 0; }
  .site-header nav { width: 100%; justify-content: space-between; }
  .site-header nav a { font-size: 0.8rem; }
  .hero-sheet { padding-left: 20px; padding-right: 20px; }
  .hero-foot { display: grid; grid-template-columns: 1fr 1fr; }
  .hero-foot span:last-child { grid-column: 1 / -1; }
  .footer-content { align-items: start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

.has-motion .intro-sheet,
.has-motion .learning-section,
.has-motion .topic-sheet,
.has-motion .project-sheet,
.has-motion .next-sheet {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 520ms ease, transform 520ms ease;
}
.has-motion .is-visible { opacity: 1; transform: translateY(0); }
