/* The College of All Minds — site stylesheet.
   Design tokens are defined once, below, and used everywhere. */

:root {
  --paper: #f5f4ef;        /* laid writing paper */
  --ink: #1d1b16;          /* iron-gall near-black */
  --accent: #2c3a58;       /* registrar's blue-black */
  --rule: #cbc7bb;         /* hairline rules */
  --rule-strong: #9d988a;
  --muted: #6c675b;        /* annotation grey */
  --measure: 66ch;
  --serif: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --display: "Cardo", "EB Garamond", Georgia, serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2.75rem 1.25rem 4rem;
}

/* ---- Letterhead ---- */

.letterhead { text-align: center; margin-bottom: 0.75rem; }

.letterhead .latin {
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.6rem;
}
.letterhead .latin a { color: inherit; text-decoration: none; }

.letterhead .english {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.9rem, 5.5vw, 2.6rem);
  letter-spacing: 0.015em;
  margin: 0;
  line-height: 1.15;
}

.letterhead .motto {
  font-style: italic;
  color: var(--muted);
  margin: 0.5rem 0 0;
  font-size: 1.02rem;
}

.tally {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-align: center;
  margin: 0.9rem 0 0;
}

/* ---- Navigation ---- */

nav.primary {
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  margin: 1.4rem 0 2.6rem;
  padding: 0.55rem 0;
  text-align: center;
}
nav.primary a {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  margin: 0 0.55rem;
  white-space: nowrap;
}
nav.primary a[aria-current="page"] {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}

/* ---- General text ---- */

h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.55rem, 4.5vw, 2rem);
  line-height: 1.2;
  margin: 0 0 1.1rem;
}
h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.18rem;
  margin: 2.2rem 0 0.7rem;
}
p { margin: 0 0 1.05rem; }
.small { font-size: 0.95rem; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.2rem 0; }

/* The opening question on the front page */
.opening-question {
  font-family: var(--display);
  font-size: clamp(1.7rem, 6vw, 2.5rem);
  line-height: 1.25;
  margin: 2.8rem 0 0.4rem;
  text-align: center;
}
.opening-attrib {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-align: center;
  margin: 0 0 2.6rem;
}

/* ---- Rubric box (examination-cover style) ---- */

.rubric {
  border: 1px solid var(--rule-strong);
  padding: 1rem 1.2rem;
  margin: 1.6rem 0 2rem;
  text-align: center;
  font-size: 1rem;
}
.rubric p { margin: 0.35rem 0; }
.rubric .head {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ---- Question lists ---- */

ol.questions {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: none;
}
ol.questions li {
  display: grid;
  grid-template-columns: 3.1rem 1fr;
  column-gap: 0.4rem;
  padding: 0.72rem 0;
  border-bottom: 1px solid var(--rule);
}
ol.questions li:first-child { border-top: 1px solid var(--rule); }
ol.questions .qnum {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
  padding-top: 0.28rem;
}
ol.questions .qtext { margin: 0; }

.amendment-note {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 1.1rem;
}

.paper-download {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  margin-top: 1.6rem;
}

/* ---- Tables ---- */

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2rem 0 1.6rem;
  font-size: 1rem;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid var(--rule-strong);
}
td.num, th.num { font-family: var(--mono); font-size: 0.85rem; }
tr.total td { border-top: 1px solid var(--rule-strong); border-bottom: none; font-weight: 600; }

/* ---- The Register (responses ledger) ---- */

.register { margin-top: 1.4rem; }
.register td { height: 2.35rem; }
.register caption {
  caption-side: top;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  padding-bottom: 0.5rem;
}

/* ---- Paper index ---- */

ul.paper-index { list-style: none; margin: 0; padding: 0; }
ul.paper-index li {
  display: grid;
  grid-template-columns: 3.1rem 1fr auto;
  align-items: baseline;
  column-gap: 0.4rem;
  padding: 0.72rem 0;
  border-bottom: 1px solid var(--rule);
}
ul.paper-index li:first-child { border-top: 1px solid var(--rule); }
ul.paper-index .pnum { font-family: var(--mono); font-size: 0.82rem; color: var(--accent); }
ul.paper-index .pcount { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }

/* ---- Footer ---- */

footer.colophon {
  margin-top: 4rem;
  border-top: 1px solid var(--rule-strong);
  padding-top: 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
footer.colophon .ver {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  display: block;
  margin-top: 0.45rem;
}

/* ---- Small screens ---- */

@media (max-width: 480px) {
  body { font-size: 1.09rem; }
  ol.questions li, ul.paper-index li { grid-template-columns: 2.5rem 1fr; }
  ul.paper-index .pcount { grid-column: 2; }
  nav.primary a { margin: 0 0.35rem; }
}

/* ---- Print: the pages should print as examination papers ---- */

@media print {
  :root { --paper: #ffffff; }
  nav.primary, .paper-download, footer.colophon .ver { display: none; }
  body { font-size: 11pt; }
  a { color: var(--ink); text-decoration: none; }
}

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

/* ---- References ---- */
.qrefs { border-top: 1px solid var(--rule); padding: 1.1rem 0 0.4rem; margin-top: 1.1rem; }
.qhead { display: grid; grid-template-columns: 3.1rem 1fr; column-gap: 0.4rem; margin: 0 0 0.8rem; }
.qhead .qnum { font-family: var(--mono); font-size: 0.82rem; color: var(--accent); padding-top: 0.28rem; }
.refentry { margin: 0 0 1.1rem 3.5rem; }
.reftitle { margin: 0 0 0.25rem; }
.refmeta { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.refdesc { margin: 0 0 0.3rem; font-size: 1.02rem; }
.refauthors { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); margin: 0; }
.refbackground { margin: 0.2rem 0 0.8rem 3.5rem; font-size: 0.95rem; color: var(--muted); }
@media (max-width: 480px) {
  .refentry, .refbackground { margin-left: 0; }
  .qhead { grid-template-columns: 2.5rem 1fr; }
}


/* Subject index (Website v3.0) */
.subject-index { list-style: none; padding: 0; margin: 1.6rem 0 0; }
.subject-index li { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: baseline;
  padding: 0.55rem 0; border-top: 1px solid var(--rule, #ddd); }
.subject-index li:last-child { border-bottom: 1px solid var(--rule, #ddd); }
.topic-name { flex: 0 0 15rem; font-variant: small-caps; letter-spacing: 0.02em; }
.topic-refs { flex: 1 1 12rem; font-size: 0.92em; }
.topic-refs a { white-space: nowrap; }
@media (max-width: 40rem) { .topic-name { flex-basis: 100%; } }


/* Reciprocal question/reference links (Website v3.1) */
.qlinks { margin: 0.35rem 0 0; font-size: 0.82em; letter-spacing: 0.01em; }
.qlinks a { color: var(--muted, #666); text-decoration: none; border-bottom: 1px dotted currentColor; }
.qlinks a:hover, .qlinks a:focus { color: inherit; }
.questions li, .qrefs { scroll-margin-top: 2rem; }
.questions li:target, .qrefs:target { background: var(--target, rgba(180,160,90,0.10));
  box-shadow: -0.75rem 0 0 var(--target, rgba(180,160,90,0.10)), 0.75rem 0 0 var(--target, rgba(180,160,90,0.10)); }


/* Paper prefaces (Website v3.2) */
.preface { margin: 1.4rem 0 1.8rem; }
.preface p { margin: 0 0 0.9rem; text-align: justify; hyphens: auto; }
.preface p:first-child::first-line { font-variant: small-caps; letter-spacing: 0.03em; }
.preface p:last-child { margin-bottom: 0; }
@media (max-width: 40rem) { .preface p { text-align: left; hyphens: manual; } }


/* Per-question pages (Website v3.5) */
.capsule { margin: 1.4rem 0; padding: 0.9rem 1.1rem; border-left: 3px solid var(--rule, #bba76a); background: var(--target, rgba(180,160,90,0.08)); }
.capsule em { font-style: normal; font-variant: small-caps; letter-spacing: 0.03em; }


/* Search (Website v4.0) */
.search-form { margin: 1.6rem 0 0.4rem; }
.search-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.45rem;
}
input.search-input {
  width: 100%;
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  padding: 0.55rem 0.7rem;
}
.search-filters { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0.9rem 0 1.6rem; }
.search-filters button {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ink);
  padding: 0 0 2px;
  cursor: pointer;
}
.search-filters button[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.search-count {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 1.1rem;
}
ol.search-results { list-style: none; margin: 0; padding: 0; }
ol.search-results li { padding: 0.9rem 0; border-bottom: 1px solid var(--rule); }
ol.search-results li:first-child { border-top: 1px solid var(--rule); }
.search-results .rtitle { margin: 0 0 0.2rem; }
.search-results .rkind { margin: 0 0 0.1rem; }
.search-results .rexcerpt { margin: 0.25rem 0 0.15rem; font-size: 1.02rem; }
.search-results mark { background: var(--target, rgba(180,160,90,0.28)); color: inherit; padding: 0 1px; }
.search-more {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  background: none;
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  margin: 1.4rem 0 0;
  cursor: pointer;
}
.search-note { font-size: 0.95rem; color: var(--muted); }
@media print { .search-form, .search-filters, .search-more { display: none; } }
