/* Psyche — a quiet reading room: warm paper, moss green, serif headings. No webfonts. */
:root {
  --paper: #f6f3eb;
  --paper-deep: #ece7da;
  --ink: #1e2a23;
  --ink-soft: #4a554e;
  --moss: #3d5c49;
  --moss-deep: #2c4637;
  --sage: #dfe7dc;
  --rule: #d6d0c1;
  --amber-bg: #f3e6c8;
  --amber-ink: #6e4a0e;
  --rose-bg: #f2dcd7;
  --rose-ink: #7a2e22;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --radius: 6px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.6 var(--sans);
}
a { color: var(--moss-deep); text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--moss); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -0.005em; }
code { font-size: 0.92em; background: var(--paper-deep); padding: 0.05em 0.3em; border-radius: 3px; }

.wrap { max-width: 50rem; margin: 0 auto; padding: 0 1rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: 0.5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* masthead */
.masthead { border-bottom: 1px solid var(--rule); background: var(--paper); }
.masthead .wrap { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; align-items: baseline; justify-content: space-between; padding-top: 1rem; padding-bottom: 0.75rem; }
.brand { margin: 0; font-family: var(--serif); font-size: 1.6rem; line-height: 1; }
.brand a { color: var(--ink); text-decoration: none; font-weight: 700; }
.brand span { font-size: 1rem; color: var(--ink-soft); font-style: italic; margin-left: 0.25rem; }
nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.95rem; }
nav a { text-decoration: none; color: var(--ink-soft); padding: 0.25rem 0; border-bottom: 2px solid transparent; }
nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--moss); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 0.4em; border-radius: 1em; background: var(--sage); color: var(--moss-deep); font-size: 0.8em; text-align: center; }

/* intro */
.intro { padding: 2rem 0 1rem; }
.intro h1 { font-size: clamp(1.7rem, 4.5vw, 2.4rem); margin: 0 0 0.5rem; max-width: 22ch; }
.intro p { margin: 0; color: var(--ink-soft); max-width: 60ch; }
.prose h2 { font-size: 1.3rem; margin: 2rem 0 0.5rem; }
.prose p { max-width: 65ch; margin: 0 0 1rem; color: var(--ink); }

/* filters */
.filters { margin: 0.5rem 0 1.5rem; padding: 1rem; background: var(--paper-deep); border-radius: var(--radius); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: 0.75rem; margin-top: 0.75rem; }
.field { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--ink-soft); }
.field input, .field select {
  font: inherit; font-size: 1rem; color: var(--ink); background: #fffdf8;
  border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.55rem 0.6rem; min-height: 2.75rem; width: 100%;
}
.search input { font-size: 1.05rem; }
.checks { border: 0; padding: 0; margin: 0.75rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.check { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 2.75rem; cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--moss); }
.form-actions { margin-top: 0.75rem; display: flex; align-items: center; gap: 1rem; }
.js .form-actions .button { display: none; }
.reset { font-size: 0.9rem; }

/* buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.5rem; padding: 0.4rem 0.9rem;
  font: inherit; font-size: 0.92rem; color: var(--moss-deep); background: transparent; text-decoration: none;
  border: 1px solid var(--moss); border-radius: var(--radius); cursor: pointer;
}
.button:hover { background: var(--sage); color: var(--ink); }
.button.primary { background: var(--moss); color: #fff; }
.button.primary:hover { background: var(--moss-deep); color: #fff; }
.button.small { min-height: 2.25rem; font-size: 0.85rem; }
.button.save[aria-pressed="true"] { background: var(--sage); border-color: var(--moss-deep); }

/* results */
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; }
.count { margin: 0; font-weight: 600; }
.empty { padding: 2rem 0; color: var(--ink-soft); }
.events { list-style: none; margin: 0; padding: 0; }

/* the one memorable element: a serif date stub beside each event */
.event { display: grid; grid-template-columns: 4.25rem 1fr; gap: 1rem; padding: 1.4rem 0; border-top: 1px solid var(--rule); }
.stub { display: flex; flex-direction: column; align-items: center; padding-top: 0.15rem; font-family: var(--serif); color: var(--moss-deep); }
.stub-day { font-size: 2.3rem; line-height: 1; font-weight: 600; font-variant-numeric: lining-nums; }
.stub-month { font-size: 0.95rem; font-style: italic; color: var(--ink-soft); }
.stub-any .stub-day { font-size: 1.8rem; }
.stub-any .stub-month { font-size: 0.8rem; text-align: center; }
.event-title { margin: 0; font-size: 1.25rem; }
/* Glossary tooltips: native title on hover, styled bubble on focus/tap (bottom sheet on phones). */
abbr.term { text-decoration: underline dotted var(--moss); text-underline-offset: 0.2em; cursor: help; position: relative; }
abbr.term:focus { outline: 2px solid var(--moss); outline-offset: 1px; border-radius: 2px; }
abbr.term:focus::after {
  content: attr(title); position: absolute; left: 0; top: calc(100% + 0.35rem); z-index: 20;
  width: max-content; max-width: min(20rem, 80vw); padding: 0.5rem 0.65rem; border-radius: var(--radius);
  background: var(--ink); color: var(--paper); font: 400 0.85rem/1.45 var(--sans); letter-spacing: 0; white-space: normal; text-align: left;
}
.event-provider { margin: 0.15rem 0 0.6rem; color: var(--ink-soft); font-size: 0.92rem; }
.facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 1.25rem; font-size: 0.95rem; }
.facts div { min-width: 0; }
.facts dt { font-size: 0.78rem; color: var(--ink-soft); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.note { display: block; font-size: 0.82rem; color: var(--ink-soft); }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0 0; padding: 0; }
.tag { font-size: 0.8rem; padding: 0.15rem 0.55rem; border-radius: 1rem; background: var(--paper-deep); color: var(--ink-soft); }
.tag-good { background: var(--sage); color: var(--moss-deep); }
.tag-new { background: var(--moss); color: #fff; }
.tag-warn { background: var(--rose-bg); color: var(--rose-ink); }
.tag-neutral { background: #e6e2f0; color: #3e3a5c; }
.review-reason, .stale { margin: 0.6rem 0 0; font-size: 0.88rem; color: var(--amber-ink); background: var(--amber-bg); padding: 0.35rem 0.6rem; border-radius: var(--radius); }
.proof { margin-top: 0.75rem; font-size: 0.92rem; }
.proof summary { cursor: pointer; color: var(--moss-deep); min-height: 2.25rem; display: flex; align-items: center; }
.proof[open] summary { margin-bottom: 0.4rem; }
.proof p { margin: 0 0 0.5rem; max-width: 65ch; }
.evidence { padding-left: 0.75rem; border-left: 3px solid var(--sage); color: var(--ink-soft); }
.evidence-label { font-weight: 600; color: var(--ink); }
.checked { font-size: 0.82rem; color: var(--ink-soft); }
.desc { color: var(--ink-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; }

/* sources */
.table-wrap { overflow-x: auto; }
.sources { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.sources th, .sources td { text-align: left; vertical-align: top; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--rule); }
.sources thead th { font-size: 0.8rem; color: var(--ink-soft); font-weight: 500; }
.src-blocked td:nth-child(2), .src-error td:nth-child(2) { color: var(--rose-ink); }
.src-stale td:nth-child(2) { color: var(--amber-ink); }
.glossary div { margin-bottom: 0.75rem; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; color: var(--ink-soft); }

.foot { padding-top: 2rem; padding-bottom: 3rem; font-size: 0.85rem; color: var(--ink-soft); border-top: 1px solid var(--rule); margin-top: 2rem; }
.foot p { margin: 0 0 0.4rem; }

@media (max-width: 34rem) {
  abbr.term:focus::after { position: fixed; left: 1rem; right: 1rem; top: auto; bottom: 1rem; max-width: none; width: auto; font-size: 0.95rem; padding: 0.75rem 0.9rem; box-shadow: 0 6px 24px rgba(30, 42, 35, 0.25); }
  .sources thead { display: none; }
  .sources tr { display: block; padding: 0.6rem 0; border-bottom: 1px solid var(--rule); }
  .sources th, .sources td { display: block; border: 0; padding: 0.15rem 0; }
  .sources td::before { content: attr(data-label) ": "; color: var(--ink-soft); font-size: 0.8rem; }
  .event { grid-template-columns: 3.1rem 1fr; gap: 0.75rem; }
  .stub-day { font-size: 1.8rem; }
  .facts { grid-template-columns: 1fr; }
  .actions .button { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: no-preference) {
  .results[aria-busy="true"] { opacity: 0.6; transition: opacity 120ms; }
}
