@font-face {
  font-family: "DM Serif Display";
  src: url("assets/dm-serif.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Work Sans";
  src: url("assets/work-sans.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #F4F0E6;
  --ink: #1B1A17;
  --muted: #6B655B;
  --line: #D8D1C2;
  --primary: #2F5D50;
  --accent: #D96A3A;
  --focus: #1B1A17;
  --radius: 6px;
  --maxw: 1180px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Work Sans", system-ui, sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.75rem;
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.masthead {
  border-bottom: 1px solid var(--line);
  padding: 3rem 1.5rem 2.5rem;
}
.masthead-inner {
  max-width: var(--maxw);
  margin: 0 auto;
}
.kicker {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.brand {
  font-family: "DM Serif Display", Georgia, serif;
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  line-height: 1.05;
  margin: 0 0 0.75rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}
.tagline {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2.5rem;
  align-items: start;
}

.controls {
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.control-group { display: flex; flex-direction: column; gap: 0.4rem; }
.control-group label {
  font-size: 0.9rem;
  color: var(--muted);
}
.control-group input,
.control-group select {
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
.control-group input:focus,
.control-group select:focus,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.control-row { flex-direction: row; align-items: center; }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius);
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
button:hover { border-color: var(--ink); }
button[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
#saved-filter { align-self: flex-start; }

.result-count { color: var(--muted); font-size: 0.9rem; margin: 0; }

.event-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
.event-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  background: #fff;
  display: grid;
  gap: 0.6rem;
}
.event-card h3 {
  margin: 0;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1.2;
}
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.category {
  color: var(--accent);
  font-size: 0.85rem;
  white-space: nowrap;
}
.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.summary {
  margin: 0;
  font-size: 0.98rem;
}
.open-item {
  justify-self: start;
  margin-top: 0.25rem;
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.open-item:hover { background: #244a40; border-color: #244a40; }

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}
.empty-state h2 { font-family: "DM Serif Display", Georgia, serif; font-weight: 400; margin: 0 0 0.5rem; }
.empty-state p { color: var(--muted); margin: 0 0 1rem; }

.detail-dialog {
  border: none;
  border-radius: 10px;
  padding: 0;
  width: min(640px, 92vw);
  max-height: 85vh;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(27,26,23,0.18);
}
.detail-dialog::backdrop {
  background: rgba(27,26,23,0.45);
}
.detail {
  padding: 1.6rem 1.8rem 2rem;
  overflow: auto;
  max-height: 85vh;
  display: grid;
  gap: 1rem;
}
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.detail-title {
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1.15;
  margin: 0;
}
#close-detail { flex-shrink: 0; }
.detail-body {
  font-size: 1rem;
  white-space: pre-line;
  line-height: 1.65;
}
.detail-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1rem;
  margin: 0;
  font-size: 0.92rem;
}
.detail-facts dt { color: var(--muted); }
.detail-facts dd { margin: 0; }
.detail-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
#save-item {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#save-item[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; gap: 1.5rem; padding: 1.5rem 1rem 3rem; }
  .controls { position: static; }
  .masthead { padding: 2rem 1rem 1.5rem; }
  .detail-dialog { width: 100vw; max-height: 100vh; border-radius: 0; }
  .detail { max-height: 100vh; }
}

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