/* One tone, one ink, one line weight. Anything that is not a link or a word
   people need has been left out on purpose. The palette is the same ecru the
   library uses, so the two sites read as one hand. */

:root {
  --ink: #2b2822;
  --muted: #8c8578;
  --faint: #a9a294;
  --line: #ddd6c4;
  --bg: #f3eee2;
  --raised: #e9e2d1;
  --max: 46rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

a { color: inherit; }

/* ---- the page ---- */

.wrap {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: 4.5rem 1.75rem 8rem;
}

/* Before the first keystroke the search sits where the eye already is. It
   slides up out of the way once there is something to read. */
.masthead {
  margin-bottom: 2.5rem;
  padding-top: min(20vh, 170px);
}
/* The slide-up belongs to the first keystroke, not to the page load. Arriving
   on a shared search should look settled, not caught mid-animation. */
body.ready .masthead { transition: padding-top .35s ease; }
body.searching .masthead { padding-top: 0; }

.title {
  margin: 0;
  font-size: 1.05rem; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase;
}
.title a { text-decoration: none; }
.strap {
  margin: .55rem 0 2.5rem;
  color: var(--muted); font-size: .88rem; max-width: 30rem;
}
body.searching .strap { display: none; }

/* ---- search ---- */

.search { position: relative; }
#q {
  width: 100%;
  padding: .7rem 0;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: none;
  font: inherit; font-size: 1.35rem; color: var(--ink);
}
#q::placeholder { color: var(--faint); }
#q:focus { outline: 0; border-bottom-color: var(--ink); }
#q::-webkit-search-cancel-button { display: none; }

.count {
  margin: .75rem 0 0;
  color: var(--muted); font-size: .78rem;
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
}

/* ---- filters: nothing on screen until they are wanted ---- */

.filters { margin-top: 1.5rem; }
.filter-toggle {
  border: 0; background: none; padding: 0;
  color: var(--muted); font: inherit; font-size: .78rem;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.filter-toggle:hover { color: var(--ink); }

.facets { margin-top: 1.5rem; }
.facet { margin-bottom: 1.25rem; }
.facet h3 {
  margin: 0 0 .5rem;
  font-size: .64rem; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
}
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  border: 1px solid var(--line); border-radius: 100px;
  padding: .22rem .7rem;
  background: none; color: var(--muted);
  font: inherit; font-size: .78rem; cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--muted); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--ink); border-color: var(--ink); color: var(--bg);
}
.chip .n { font-variant-numeric: tabular-nums; opacity: .6; margin-left: .35rem; }
.chip[aria-pressed="true"] .n { opacity: .55; }

/* The tip jar, top right. Borrows the chip's shape so it reads as part of the
   site rather than a badge dropped on top of it — no brand colour, no logo.
   Absolute rather than fixed on purpose: it belongs to the top of the page and
   scrolls away, so it can never sit on top of a result. */
.corner {
  position: absolute; top: 1.5rem; right: 1.75rem;
  display: flex; gap: .4rem; align-items: center;
}

.tip {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--line); border-radius: 100px;
  padding: .3rem .8rem;
  background: var(--raised);
  color: var(--muted); font-size: .75rem;
  text-decoration: none; white-space: nowrap;
  transition: color .18s ease, border-color .18s ease, transform .18s ease;
}
.tip svg { width: 13px; height: 13px; flex: none; }
.tip:hover { border-color: var(--muted); color: var(--ink); transform: translateY(-1px); }

@media (max-width: 30rem) {
  .corner { top: 1rem; right: 1rem; }
}

.clear {
  margin-top: .4rem;
  border: 0; background: none; padding: 0;
  color: var(--muted); font: inherit; font-size: .78rem;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.clear:hover { color: var(--ink); }

/* ---- results ---- */

#results { margin-top: 3rem; }

.group h2 {
  margin: 2.75rem 0 .35rem;
  font-size: .64rem; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
  border-bottom: 1px solid var(--line);
  padding-bottom: .5rem;
}
.group:first-child h2 { margin-top: 0; }

/* One paper, one line. The question paper is the line itself; its mark scheme
   and examiner report sit under it rather than somewhere further down the page. */
.item { border-bottom: 1px solid rgba(221,214,196,.5); padding: .6rem 0; }
.item .row { border-bottom: 0; padding: 0; }

.alts { display: flex; flex-wrap: wrap; gap: .9rem; margin-top: .3rem; }
.alt-link {
  color: var(--muted); font-size: .78rem;
  text-decoration: none; border-bottom: 1px solid var(--line);
}
.alt-link:hover { color: var(--ink); border-bottom-color: var(--muted); }
.alt-link:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }

.row {
  display: block;
  padding: .6rem 0;
  border-bottom: 1px solid rgba(221,214,196,.5);
  color: var(--ink); text-decoration: none;
}
.row:hover .name { text-decoration: underline; text-underline-offset: 3px; }
.row:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }
.name { font-size: .98rem; }
.meta {
  display: block; margin-top: .12rem;
  color: var(--muted); font-size: .78rem;
}
.meta span + span::before { content: " · "; color: var(--faint); }
.ext { color: var(--faint); font-size: .74rem; }

.more {
  display: block; width: 100%; margin: 2.5rem 0 0;
  border: 1px solid var(--line); border-radius: 2px;
  padding: .65rem 1rem;
  background: none; color: var(--muted);
  font: inherit; font-size: .82rem; cursor: pointer;
}
.more:hover { border-color: var(--muted); color: var(--ink); }

.empty { margin-top: 3rem; color: var(--muted); font-size: .9rem; }
.empty code {
  background: var(--raised); border-radius: 2px; padding: .1rem .35rem;
  font-size: .85em;
}

/* ---- the quiet shelf shown before anyone types ---- */

.shelf { margin-top: 3.5rem; }
.shelf h2 {
  margin: 0 0 .9rem;
  font-size: .64rem; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
}
.shelf-row {
  display: flex; align-items: baseline; gap: 1rem;
  padding: .5rem 0;
  border: 0; border-bottom: 1px solid rgba(221,214,196,.5);
  background: none; width: 100%; text-align: left;
  color: var(--ink); font: inherit; font-size: .98rem; cursor: pointer;
}
.shelf-row:hover .shelf-name { text-decoration: underline; text-underline-offset: 3px; }
.shelf-name { flex: 1; min-width: 0; }
.shelf-n { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }

/* ---- foot ---- */

.foot {
  display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: baseline;
  margin-top: 6rem; padding-top: 1.25rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .75rem;
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--ink); }
.foot .grow { flex: 1; }

/* ---- prose pages ---- */

.prose { max-width: 34rem; }
.prose h2 {
  margin: 3rem 0 .6rem;
  font-size: .64rem; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
}
.prose p { margin: 0 0 1.1rem; }
.prose a { color: var(--ink); text-underline-offset: 3px; }
.prose ul { margin: 0 0 1.1rem; padding-left: 1.1rem; }
.prose li { margin-bottom: .45rem; }
.prose .dim { color: var(--muted); font-size: .88rem; }

@media (max-width: 30rem) {
  .wrap { padding: 3rem 1.25rem 5rem; }
  .masthead { padding-top: min(12vh, 90px); }
  #q { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  .masthead { transition: none; }
  .tip { transition: none; }
  .tip:hover { transform: none; }
}
