:root {
  --paper: #faf6ee;
  --paper-raised: #ffffff;
  --ink: #2b2420;
  --ink-soft: #5c5248;
  --rule: #ddd2bf;
  --rust: #a3492b;
  --rust-dark: #7e3620;
  --moss: #4b5d3a;
  --gold: #b8873a;
  --max: 880px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.55;
}

a { color: var(--rust); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  background: var(--ink);
  color: var(--paper);
  padding: 1.75rem 1.25rem 1.5rem;
  text-align: center;
  border-bottom: 4px solid var(--rust);
}
.site-header a { color: inherit; }
.site-logo {
  display: inline-block;
  height: 64px;
  width: auto;
  border-radius: 6px;
}
.site-tagline {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: #d8cdb9;
  font-style: italic;
  text-wrap: balance;
}
.site-banner {
  margin: 0.6rem auto 0;
  max-width: 46ch;
  font-size: 0.82rem;
  color: #cbbfa8;
  line-height: 1.45;
  /* keeps the last line from stranding a word or two on its own */
  text-wrap: balance;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.1rem;
  margin-top: 1rem;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.site-nav a { color: #f1e9d8; }

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

h1, h2, h3 { font-family: Georgia, serif; color: var(--ink); }
h1 { font-size: 1.9rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.35rem; border-bottom: 1px solid var(--rule); padding-bottom: 0.4rem; }
h3 { font-size: 1.1rem; }

.meta {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.badge {
  display: inline-block;
  background: var(--moss);
  color: #fff;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.55rem;
  border-radius: 3px;
}
.badge.rust { background: var(--rust); }
.badge.gold { background: var(--gold); }

.article-list, .trial-list { list-style: none; margin: 0; padding: 0; }
.article-list li, .trial-list li {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
}
.article-list li:last-child, .trial-list li:last-child { border-bottom: none; }
.entry-headline { font-size: 1.08rem; font-weight: 600; }
.entry-excerpt { color: var(--ink-soft); font-size: 0.92rem; margin-top: 0.15rem; }

.article-body { font-size: 1.06rem; }
.article-body p { margin: 0 0 1em; }
.article-body img { max-width: 100%; height: auto; border-radius: 4px; }
.article-body h1, .article-body h2, .article-body h3 { margin-top: 1.4em; }

.byline { font-style: italic; color: var(--ink-soft); margin-bottom: 1.2rem; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; height: auto; border-radius: 4px; border: 1px solid var(--rule); }
.photo-grid figcaption { font-size: 0.82rem; color: var(--ink-soft); margin-top: 0.3rem; }

.related-box {
  background: #f3ead9;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
}
.related-box h3 { margin-top: 0; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; }
.related-box ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

table.results {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6rem 0 1.4rem;
  font-size: 0.92rem;
}
table.results th, table.results td {
  text-align: left;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--rule);
}
table.results th { color: var(--ink-soft); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
table.results tr:nth-child(1) td { font-weight: 600; }

.class-block { margin-bottom: 1.6rem; }
.class-block h3 { margin-bottom: 0.2rem; }
.class-meta { font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 0.4rem; }

/* Calendar */
.year-block { margin-bottom: 2rem; }
.year-block h2 { display: flex; align-items: baseline; gap: 0.6rem; }
.year-count { font-size: 0.85rem; color: var(--ink-soft); font-weight: normal; }
.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.6rem;
}
.month-cell {
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 0.6rem 0.5rem;
  text-align: center;
  background: var(--paper-raised);
}
.month-cell.empty { opacity: 0.35; }
.month-cell .m-name { display: block; text-transform: capitalize; font-weight: 600; }
.month-cell .m-count { display: block; font-size: 0.78rem; color: var(--ink-soft); }

.month-nav { display: flex; justify-content: space-between; margin: 1.5rem 0; font-size: 0.9rem; }

/* Categories */
.montage {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 6px;
  margin-bottom: 1.5rem;
}

#home-search { margin-bottom: 1.75rem; }

/* Search sits in the header on every page except the homepage, which has a
   prominent in-body one instead. */
.header-search {
  max-width: 560px;
  margin: 1rem auto 0;
  text-align: left;
  --pagefind-ui-scale: 0.8;
  --pagefind-ui-background: var(--paper-raised);
  --pagefind-ui-text: var(--ink);
  --pagefind-ui-primary: var(--rust);
  --pagefind-ui-border: var(--rule);
  --pagefind-ui-border-radius: 4px;
}
/* Keep the header compact: results overlay the page rather than pushing it. */
.header-search .pagefind-ui__drawer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 2.5rem));
  max-height: 60vh;
  overflow-y: auto;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 0 0 6px 6px;
  padding: 0 1rem 0.75rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  z-index: 50;
  text-align: left;
}
.site-header { position: relative; }

.lede {
  font-size: 1.08rem;
  color: var(--ink-soft);
  margin: 0 0 1.75rem;
}

.section-head {
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--rust);
  padding-bottom: 0.35rem;
  margin: 2.25rem 0 0.5rem;
}

/* Year x month density matrix */
.calendar-matrix-wrap { overflow-x: auto; margin: 1rem 0 0; }
.calendar-matrix {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}
.calendar-matrix th, .calendar-matrix td {
  border: 1px solid var(--rule);
  text-align: center;
  padding: 0;
}
.calendar-matrix thead th {
  background: #f3ead9;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  padding: 0.35rem 0.2rem;
  font-weight: 600;
}
.calendar-matrix th.yr {
  background: #f3ead9;
  font-weight: 700;
  padding: 0.35rem 0.5rem;
  white-space: nowrap;
}
.calendar-matrix th.yr a { color: var(--ink); }
.calendar-matrix td a {
  display: block;
  padding: 0.4rem 0.2rem;
  color: inherit;
  text-decoration: none;
}
.calendar-matrix td a:hover { outline: 2px solid var(--rust); outline-offset: -2px; }
.calendar-matrix td.lv0 { color: #c9bda9; background: var(--paper-raised); }
.calendar-matrix td.lv1 { background: #f0e2cd; }
.calendar-matrix td.lv2 { background: #e0c39a; }
.calendar-matrix td.lv3 { background: #c98d54; }
.calendar-matrix td.lv4 { background: #a3492b; color: #fff; }
.calendar-matrix td.tot, .calendar-matrix th.tot {
  background: #f3ead9;
  font-weight: 600;
  padding: 0.4rem 0.5rem;
}

.entry-points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.entry-point {
  display: block;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--rust);
  border-radius: 5px;
  background: var(--paper-raised);
  padding: 0.85rem 1rem;
  color: inherit;
}
.entry-point:hover { text-decoration: none; border-left-color: var(--moss); }
.entry-point strong { display: block; color: var(--rust); margin-bottom: 0.15rem; }
.entry-point span { font-size: 0.85rem; color: var(--ink-soft); }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 2rem;
}
.category-pill {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 0.6rem 0.8rem;
  background: var(--paper-raised);
  color: inherit;
}
.category-pill:hover { text-decoration: none; border-color: var(--rust); }
.category-pill .c-count {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.site-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.82rem;
  padding: 2rem 1rem 3rem;
}

#search input[type="text"] {
  font: inherit;
  padding: 0.5rem 0.75rem;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.download-btn {
  display: inline-block;
  background: var(--rust);
  color: #fff !important;
  padding: 0.35rem 0.8rem;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.download-btn:hover { background: var(--rust-dark); text-decoration: none; }
