/* ---------- Design tokens ---------- */
:root {
  --bg: #f7f5f0;
  --text: #1f2328;
  --muted: #5d6470;
  --line: #e1dccf;
  --accent: #25405f;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --slide: 380ms;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --text: #e8e6e1;
    --muted: #9aa1ad;
    --line: #2a2f38;
    --accent: #9dbbe0;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 44rem;
  margin: 0 auto;
  padding: clamp(2.5rem, 8vw, 5.5rem) 1.25rem 3rem;
}

/* ---------- Masthead ---------- */
.masthead {
  padding-bottom: 1.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
}

.masthead h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.4rem, 7vw, 3.2rem);
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.masthead__tagline {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

/* ---------- Collapsible sections ---------- */
.item { border-bottom: 1px solid var(--line); }

.item__title { margin: 0; font-weight: inherit; }

.item__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1.15rem 0;
  background: none;
  border: 0;
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: color 160ms var(--ease);
}

.item__head:hover { color: var(--accent); }

.item__head:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

.item__chevron {
  flex: none;
  color: var(--muted);
  transition: transform var(--slide) var(--ease), color 160ms var(--ease);
}

.item__head:hover .item__chevron { color: var(--accent); }
.item.is-open .item__chevron { transform: rotate(180deg); }

/* Height animation: a grid row that grows from 0fr to 1fr */
.item__panel {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;                       /* keeps hidden content out of tab order */
  transition: grid-template-rows var(--slide) var(--ease),
              visibility 0s linear var(--slide);
}

.item.is-open .item__panel {
  grid-template-rows: 1fr;
  visibility: visible;
  transition-delay: 0s;
}

.item__inner {
  min-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 240ms var(--ease);
}

.item.is-open .item__inner {
  opacity: 1;
  transition-delay: 90ms;
}

.item__inner > :first-child { margin-top: 0; }
.item__inner > :last-child  { margin-bottom: 1.5rem; }

.item__inner p { margin: 0 0 1rem; max-width: 38rem; }

.empty { color: var(--muted); font-style: italic; }

/* ---------- Paper entries ---------- */
.entry {
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}
.entry:first-child { border-top: 0; padding-top: 0; }

.entry h3 {
  margin: 0 0 0.15rem;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.35;
}

.entry__meta {
  margin: 0 0 0.5rem !important;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.entry__link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.entry__link:hover { text-decoration-thickness: 2px; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.footer p { margin: 0; }

/* ---------- Entrance animation ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.masthead,
.item,
.footer {
  animation: rise 600ms var(--ease) both;
}
.item:nth-child(1) { animation-delay: 120ms; }
.item:nth-child(2) { animation-delay: 190ms; }
.item:nth-child(3) { animation-delay: 260ms; }
.item:nth-child(4) { animation-delay: 330ms; }
.footer            { animation-delay: 400ms; }

/* ---------- Respect reduced-motion settings ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
