/* ---------------------------------------------------------------------------
   Archive search -- stylesheet.

   Same design system as enron.algorithmicindexing.net: cool grey-blue chrome,
   Archivo for the interface, Courier Prime for anything that came out of the
   corpus itself, and one accent colour -- stamp red -- used for matches and
   nothing else. Every colour and both typefaces are tokens in the block
   below, so the two sites can be kept in step by comparing just that block.

   Fonts are self-hosted (both SIL OFL), so no page calls a third party.
--------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   Tokens.

   The scans are buff paper, bright and warm. So the interface goes cool and
   recedes, letting the paper be the warmest, lightest thing on screen -- a
   reading desk rather than a nostalgia piece. One accent only: the red of a
   rubber stamp, used for search matches and nothing else.
--------------------------------------------------------------------------- */
:root {
  --ground:     #e7eaef;
  --paper:      #fbfbf9;
  --paper-edge: #d9d2c2;
  --ink:        #19212e;
  --ink-soft:   #586374;
  --ink-faint:  #8b94a1;
  --rule:       #c7ced8;
  --stamp:      #a62b1c;
  --stamp-wash: #f4dedb;
  --focus:      #1f5fa8;

  --shell: 68rem;
  --measure: 62ch;

  --fs-micro: .75rem;
  --fs-small: .875rem;
  --fs-body:  1rem;
  --fs-lead:  1.1875rem;
  --fs-h2:    1.375rem;
  --fs-h1:    clamp(1.6rem, 1.1rem + 2.2vw, 2.25rem);
  --fs-hero:  clamp(1.85rem, 1.1rem + 3.4vw, 2.9rem);

  --sans: "Archivo", "Helvetica Neue", Arial, system-ui, sans-serif;
  --type: "Courier Prime", "Courier New", ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:     #14181f;
    --paper:      #1d222b;
    --paper-edge: #3a3b3a;
    --ink:        #dfe4ec;
    --ink-soft:   #9aa4b3;
    --ink-faint:  #6d7684;
    --rule:       #333c49;
    --stamp:      #e08275;
    --stamp-wash: #3d2420;
    --focus:      #6fa8e8;
  }
}
:root[data-theme="dark"] {
  --ground: #14181f; --paper: #1d222b; --paper-edge: #3a3b3a;
  --ink: #dfe4ec; --ink-soft: #9aa4b3; --ink-faint: #6d7684;
  --rule: #333c49; --stamp: #e08275; --stamp-wash: #3d2420; --focus: #6fa8e8;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: var(--ink-faint); text-underline-offset: .18em; }
a:hover { text-decoration-color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.shell { max-width: var(--shell); margin: 0 auto; padding: 0 1.5rem; }

/* --- Masthead ------------------------------------------------------------ */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.masthead-inner {
  max-width: var(--shell); margin: 0 auto; padding: .85rem 1.5rem;
  display: flex; align-items: baseline; gap: 1.25rem; flex-wrap: wrap;
}
.wordmark {
  font-size: var(--fs-body); font-weight: 600; letter-spacing: -.01em;
  margin: 0; text-decoration: none;
}
.wordmark a { text-decoration: none; }
/* Link back to the parent site, as on the sibling archives. Quiet: it is a
   way out, not a thing to click. */
.parent { margin: 0; font-size: var(--fs-small); color: var(--ink-soft); }
.parent a { text-decoration: none; }
.parent a:hover { text-decoration: underline; }

.holdings {
  margin-left: auto; font-size: var(--fs-small); color: var(--ink-soft);
  display: flex; gap: 1.25rem;
}
@media (max-width: 42rem) { .holdings { margin-left: 0; gap: 1rem; } }

/* --- Search field -------------------------------------------------------- */

.finder { display: flex; gap: .5rem; }
.finder input {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--sans); font-size: var(--fs-body);
  padding: .6rem .75rem;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  border-radius: 2px;
}
.finder input::placeholder { color: var(--ink-faint); }
.finder button {
  font-family: var(--sans); font-size: var(--fs-small); font-weight: 600;
  padding: .6rem 1.1rem; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--ink); border-radius: 2px;
  background: var(--ink); color: var(--paper);
}
.finder button:hover { background: var(--ink-soft); border-color: var(--ink-soft); }

.finder-hero input { font-size: var(--fs-lead); padding: .85rem 1rem; }
.finder-hero button { font-size: var(--fs-body); padding: .85rem 1.5rem; }

.masthead .finder { flex: 1 1 20rem; max-width: 30rem; }

/* --- Letterhead band -----------------------------------------------------
   Real first pages, cropped to their top edge. The collection is typed paper,
   and this says so before any interface copy does. It fades out at the right
   rather than ending, because the archive does not end here either. */

.band {
  height: 104px; overflow: hidden; display: flex; gap: 10px;
  background: var(--ground);
  padding: 0 0 0 1.5rem;
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 72%, transparent 100%);
          mask-image: linear-gradient(to right, #000 0, #000 72%, transparent 100%);
}
.band a {
  flex: 0 0 auto; width: 148px; height: 104px; overflow: hidden;
  background: var(--paper-edge); box-shadow: 0 1px 2px rgba(25, 33, 46, .18);
}
.band img {
  width: 100%; height: auto; display: block;
  object-fit: cover; object-position: top center;
}
@media (max-width: 40rem) { .band { height: 76px; } .band a { width: 108px; height: 76px; } }

/* --- Hero ---------------------------------------------------------------- */

.hero { padding: 2.5rem 0 1rem; }
.hero h1 {
  font-size: var(--fs-hero); font-weight: 600; line-height: 1.08;
  letter-spacing: -.025em; margin: 0 0 1.5rem; max-width: 34ch;
}
.hero-sub {
  font-size: var(--fs-lead); color: var(--ink-soft);
  max-width: var(--measure); margin: 0 0 2rem;
}

.suggestions { margin: 1.25rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.suggestions .lede { font-size: var(--fs-small); color: var(--ink-soft); margin-right: .25rem; }
/* The query itself is set in the typewriter face, because that is what the
   archive's own text looks like. The note beside it is interface language,
   so it stays in the sans -- the two never get confused for each other. */
.chip {
  font-family: var(--type); font-size: var(--fs-small);
  padding: .3rem .65rem; border: 1px solid var(--rule); border-radius: 2px;
  background: var(--paper); color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: baseline; gap: .55rem;
}
.chip:hover { border-color: var(--ink-soft); }
.chip em {
  font-family: var(--sans); font-style: normal; font-size: var(--fs-micro);
  color: var(--ink-faint); border-left: 1px solid var(--rule); padding-left: .55rem;
}

/* --- Scope note ---------------------------------------------------------- */

.scope {
  border-top: 1px solid var(--rule); margin-top: 2rem; padding-top: 2rem;
  display: grid; gap: 2.5rem; grid-template-columns: 1fr;
}
@media (min-width: 52rem) { .scope { grid-template-columns: 1.4fr 1fr; } }
.scope h2 { font-size: var(--fs-h2); font-weight: 600; margin: 0 0 .75rem; letter-spacing: -.015em; }
.scope p { margin: 0 0 1rem; max-width: var(--measure); color: var(--ink-soft); }
.scope p strong { color: var(--ink); font-weight: 500; }

.breakdown { margin: 0; font-size: var(--fs-small); }
.breakdown div {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: .4rem 0; border-bottom: 1px solid var(--rule);
}
.breakdown div:first-child { border-top: 1px solid var(--rule); }
.breakdown a { text-decoration: none; }
.breakdown a:hover { text-decoration: underline; }
.breakdown .tally { font-family: var(--type); color: var(--ink-soft); }

/* --- Results ------------------------------------------------------------- */

.resultbar {
  padding: 1.5rem 0 .5rem; display: flex; gap: 1rem;
  align-items: baseline; flex-wrap: wrap;
}
.resultbar h1 { font-size: var(--fs-h2); font-weight: 600; margin: 0; letter-spacing: -.015em; }
.resultbar .toggle { font-size: var(--fs-small); color: var(--ink-soft); margin-left: auto; }

.results { list-style: none; margin: 0; padding: 0; }
.result {
  display: grid; gap: 1.25rem; padding: 1.5rem 0;
  border-top: 1px solid var(--rule);
  grid-template-columns: 1fr;
}
@media (min-width: 40rem) { .result { grid-template-columns: 5.5rem 1fr; } }

/* The paper motif: portrait A4, square corners, a representational shadow.
   Paper has no border-radius, so neither does this. */
.sheet {
  display: block; width: 5.5rem; aspect-ratio: 210 / 297;
  background: var(--paper-edge);
  box-shadow: 0 1px 2px rgba(25, 33, 46, .22);
  overflow: hidden; text-decoration: none;
}
.sheet img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.sheet-empty {
  display: grid; place-items: center;
  font-family: var(--type); font-size: var(--fs-micro); color: var(--ink-soft);
  background: var(--paper); border: 1px solid var(--rule); box-shadow: none;
}

.result h2 { font-size: var(--fs-body); font-weight: 600; margin: 0 0 .3rem; letter-spacing: -.005em; }
.result h2 a { text-decoration: none; }
.result h2 a:hover { text-decoration: underline; }

.meta { font-size: var(--fs-small); color: var(--ink-soft); margin: 0 0 .7rem; }
.meta .at { color: var(--ink-faint); }

.snippet {
  font-family: var(--type); font-size: var(--fs-small); line-height: 1.6;
  margin: 0; max-width: var(--measure); color: var(--ink-soft);
}
.snippet mark { background: var(--stamp-wash); color: var(--stamp); font-weight: 700; padding: 0 .12em; }

.provenance {
  margin: .6rem 0 0; font-size: var(--fs-small); color: var(--ink-soft);
}
.asread { font-family: var(--type); color: var(--stamp); }

/* --- Empty and error states --------------------------------------------- */

.empty { padding: .5rem 0 3rem; max-width: var(--measure); }
.empty h2 { font-size: var(--fs-h2); font-weight: 600; margin: 0 0 .75rem; letter-spacing: -.015em; }
.empty p { color: var(--ink-soft); margin: 0 0 1rem; }

/* --- Document and page views -------------------------------------------- */

.dochead { padding: 2rem 0 1.5rem; }
.dochead h1 {
  font-size: var(--fs-h1); font-weight: 600; line-height: 1.15;
  letter-spacing: -.02em; margin: 0 0 .5rem; max-width: 34ch;
}
.crumb { font-size: var(--fs-small); color: var(--ink-soft); margin: 0 0 1.5rem; }

.catalogue { font-size: var(--fs-small); margin: 0 0 2rem; max-width: 44rem; }
.catalogue div {
  display: grid; grid-template-columns: 9rem 1fr; gap: 1rem;
  padding: .45rem 0; border-bottom: 1px solid var(--rule);
}
.catalogue div:first-child { border-top: 1px solid var(--rule); }
.catalogue dt, .catalogue .k { color: var(--ink-soft); }
.catalogue .v { color: var(--ink); }

.plate {
  background: var(--paper-edge);
  box-shadow: 0 2px 8px rgba(25, 33, 46, .2);
  margin: 0 0 2rem;
}
.plate img { display: block; width: 100%; height: auto; }

.leaves { display: flex; flex-wrap: wrap; gap: 1rem; margin: 0 0 2rem; padding: 0; list-style: none; }
.leaf { width: 5.5rem; }
.leaf .caption {
  font-family: var(--type); font-size: var(--fs-micro); color: var(--ink-soft);
  margin-top: .35rem; display: flex; justify-content: space-between;
}

.readings { display: grid; gap: 1.5rem; grid-template-columns: 1fr; margin-bottom: 3rem; }
@media (min-width: 58rem) { .readings { grid-template-columns: 1fr 1fr; } }
.reading h3 {
  font-size: var(--fs-small); font-weight: 600; margin: 0 0 .5rem;
}
.reading .which { color: var(--ink-soft); font-weight: 400; }
.transcript {
  font-family: var(--type); font-size: var(--fs-small); line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  background: var(--paper); border: 1px solid var(--rule);
  padding: .9rem; margin: 0; max-height: 24rem; overflow: auto;
}

.aside {
  background: var(--paper); border-left: 2px solid var(--stamp);
  padding: .9rem 1.1rem; margin: 0 0 2rem; font-size: var(--fs-small);
  max-width: 44rem;
}
.aside p { margin: 0 0 .5rem; color: var(--ink-soft); }
.aside p:last-child { margin-bottom: 0; }


footer.foot {
  border-top: 1px solid var(--rule); margin-top: 2rem;
  padding: 1.5rem 0 3rem; font-size: var(--fs-small); color: var(--ink-faint);
}
footer.foot p { margin: 0; max-width: var(--measure); }

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