/* Frontier Research Fund. One typeface, white paper, black ink, set as a preprint.
   Every colour is a token; the two dark blocks re-issue all of them. */

@font-face {
  font-family: "STIX Two Text";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/stix-two-text-latin.woff2") format("woff2");
}
@font-face {
  font-family: "STIX Two Text";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/stix-two-text-latin-italic.woff2") format("woff2");
}

:root {
  --paper: #ffffff;
  --ink: #000000;
  --ink-soft: #5a5a5a;
  --line: #000000;
  --link: #1f3a93;
  --mark: #fff3b0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141414;
    --ink: #eceae4;
    --ink-soft: #a09e98;
    --line: #c9c6bf;
    --link: #a3b3dc;
    --mark: #4a4210;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141414;
  --ink: #eceae4;
  --ink-soft: #a09e98;
  --line: #c9c6bf;
  --link: #a3b3dc;
  --mark: #4a4210;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  font-family: "STIX Two Text", "STIX Two", "Times New Roman", Times, serif;
  font-size: clamp(17px, 0.95rem + 0.3vw, 19px);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

::selection { background: var(--mark); color: var(--ink); }

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
}
a:hover { text-decoration-thickness: 1.5px; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }

.paper {
  max-width: 33em;
  margin: 0 auto;
  padding: 5.5rem 16px 4rem;
  counter-reset: sec;
}

/* Title block */
.title-block { text-align: center; margin-bottom: 2.25rem; }
.title {
  font-size: 1.75em;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.6rem;
}
.dateline {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9em;
}
.correspondence {
  margin: 0.35rem 0 0;
  font-size: 0.9em;
}

/* Abstract */
.abstract {
  margin: 0 auto 2.75rem;
  padding: 0 2em;
  font-size: 0.9em;
  line-height: 1.5;
}
.abstract-heading {
  font-size: 1em;
  font-weight: 700;
  text-align: center;
  margin: 0 0 0.6rem;
}
.abstract p { margin: 0; }
.abstract p + p { margin-top: 0.7rem; }

/* Numbered sections, counted by CSS as a paper numbers them */
.sec { margin: 0 0 2.25rem; }
.sec h2 {
  counter-increment: sec;
  font-size: 1em;
  font-weight: 700;
  margin: 0 0 0.6rem;
}
.sec h2::before { content: counter(sec) "\2002"; }
.sec p { margin: 0; }
.sec p + p { text-indent: 1.5em; }

/* Field list: term in italic and one clause, run in */
.fields { margin: 0; }
.fields dt {
  display: inline;
  font-style: italic;
  font-weight: 400;
}
.fields dt::after { content: ":"; }
.fields dd {
  display: inline;
  margin: 0;
}
.fields dd::after {
  content: "";
  display: block;
  height: 0.25rem;
}

/* Figure 1 */
.fig { margin: 2rem 0 0; }
.fig-drawing { padding-top: 0.25rem; }
.fig-fields {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 0 0.4em;
  font-size: 0.78em;
  line-height: 1.15;
  text-align: center;
}
.fig-fields span {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 2.3em;
  padding-bottom: 2.2rem;
}
.fig-fields span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  height: 1.8rem;
  border-left: 1px solid var(--line);
}
.fig-stack {
  border: 1px solid var(--line);
  padding: 0.55rem 0.8rem;
  text-align: center;
  font-size: 0.85em;
}
figcaption {
  margin-top: 0.9rem;
  font-size: 0.85em;
  line-height: 1.45;
}
.fig-label { font-weight: 700; }

/* Footnotes: the short rule a paper draws, and nothing else */
.fnref { line-height: 0; font-size: 0.7em; vertical-align: super; }
.fnref a { text-decoration: none; }
.footnotes {
  position: relative;
  margin-top: 3rem;
  padding-top: 0.75rem;
  font-size: 0.85em;
}
.footnotes::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 10em;
  border-top: 1px solid var(--line);
}
.footnotes ol {
  margin: 0;
  padding-left: 1.4em;
}
.footnotes li { margin: 0 0 0.35rem; }
.footnotes li:target { background: var(--mark); }

/* Phones: the fields stack on the left, each with a tick into the shared box on the right */
@media (max-width: 640px) {
  .paper { padding-top: 3rem; }
  .title { font-size: 1.5em; }
  .abstract { padding: 0; font-size: 1em; }
  .fig-drawing {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 8.2em;
    align-items: stretch;
  }
  .fig-fields {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 0.5rem 0;
    text-align: right;
    font-size: 0.85em;
    line-height: 1.3;
  }
  .fig-fields span {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 2rem;
    align-items: center;
    justify-content: stretch;
    min-height: 0;
    padding-bottom: 0;
  }
  .fig-fields span::after {
    position: static;
    display: block;
    height: auto;
    margin-left: 0.5rem;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .fig-stack {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.6rem 0.6rem;
    text-align: left;
    line-height: 1.35;
  }
}

/* Print is always paper: the light tokens, whatever the screen theme */
@media print {
  :root,
  :root[data-theme="light"],
  :root[data-theme="dark"] {
    color-scheme: light;
    --paper: #ffffff;
    --ink: #000000;
    --ink-soft: #5a5a5a;
    --line: #000000;
    --link: #1f3a93;
    --mark: #fff3b0;
  }
  .paper { max-width: none; padding: 0; }
  a { color: var(--ink); text-decoration: none; }
}
