/* Project pages under /papers/. Pages are generated by build_papers.py in
   ~/code/cv; this file is hand-written. These stand apart from the one-page
   home site: no menu, just the name in the corner to go home. Colours,
   type and the saved theme are shared with index.html. */

:root {
  color-scheme: light dark;
  --paper: #F1F0ED;
  --ink: #22211F;
  --muted: #6B6861;
  --crimson: #A51C30;
  --hairline: #DCD9D2;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #1B1B1A;
    --ink: #E9E6E0;
    --muted: #9B968D;
    --crimson: #E0707F;
    --hairline: #3A3833;
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1B1B1A;
  --ink: #E9E6E0;
  --muted: #9B968D;
  --crimson: #E0707F;
  --hairline: #3A3833;
}
*, *::before, *::after { box-sizing: inherit; }
html {
  font-size: clamp(1rem, 0.1075rem + 0.952vw, 1.45rem);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-optical-sizing: auto;
  font-size: 1.125rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--crimson); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--crimson);
  outline-offset: 3px;
  border-radius: 2px;
}

.wrap { max-width: 78rem; margin: 0 auto; padding: 0 clamp(1.1rem, 3vw, 2.25rem); }

/* The corner: name home, theme toggle. Not sticky, no bar. */
header.corner .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
}
.wordmark {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  white-space: nowrap;
}
.wordmark:hover { color: var(--crimson); text-decoration: none; }
.theme-toggle {
  display: none;
  flex: none;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: color 0.2s ease, border-color 0.2s ease;
}
html.has-js .theme-toggle { display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle:hover { color: var(--crimson); border-color: var(--crimson); }
.theme-toggle svg { width: 1.0625rem; height: 1.0625rem; display: block; }

/* ---- The page: one centred reading column ---- */
.paper {
  max-width: 44rem;
  margin: 0 auto;
  padding: 3.5rem 0 5.5rem;
}
.up { margin: 0 0 2.2rem; font-size: 1rem; }
.up a { color: var(--muted); }
.up a:hover { color: var(--crimson); text-decoration: none; }

.paper h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.75rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 1.2rem;
  text-wrap: balance;
}
.authors { font-size: 1.15rem; margin: 0 0 0.3rem; }
.authors .me { color: var(--ink); }
/* A name or a page range never breaks across lines. */
.authors a, .authors .me, .nowrap { white-space: nowrap; }
.status { color: var(--muted); font-size: 1.02rem; margin: 0; }
.status em { color: var(--ink); }

/* Outbound resources as quiet pills: clearly clickable, never loud. */
.paper-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.3rem 0 0;
}
.paper-links a {
  font-size: 0.95rem;
  padding: 0.3rem 0.95rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  transition: border-color 0.2s ease;
}
.paper-links a:hover { border-color: var(--crimson); text-decoration: none; }

/* Small spaced capitals, the same voice as the home page's sub-headings. */
.paper-text h2,
.index h2 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}
.paper-text {
  margin-top: 2.4rem;
  padding-top: 2.1rem;
  border-top: 1px solid var(--hairline);
}
.paper-text h2 { margin: 0 0 1.1rem; }
.paper-text p {
  font-size: 1.15rem;
  line-height: 1.75;
  margin: 0 0 1.1rem;
}

/* ---- Index ---- */
.index h1::after {
  content: "";
  display: block;
  width: 2.25rem;
  height: 2px;
  background: var(--crimson);
  margin-top: 0.55rem;
}
.index h2 {
  margin: 3.2rem 0 1.8rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--hairline);
}
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { margin: 0 0 2.2rem; }
.entries li:last-child { margin-bottom: 0; }
.entry-title {
  display: inline-block;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  margin: 0 0 0.35rem;
}
.entry-title:hover { color: var(--crimson); text-decoration: none; }
.entries .authors { font-size: 1.02rem; }
.entries .status { font-size: 0.98rem; }

/* ---- Reader: /papers/<slug>/read/ ---- */
.reader { max-width: 54rem; margin: 0 auto; padding: 2.5rem 0 4rem; }
.reader .up { margin-bottom: 1.4rem; }
.reader-title {
  font-size: clamp(1.3rem, 2.4vw, 1.75rem);
  font-weight: 500;
  line-height: 1.25;
  margin: 0 0 1.1rem;
  text-wrap: balance;
}
.reader-actions { margin: 0 0 1.8rem; }
.pill {
  display: inline-block;
  font-size: 0.95rem;
  padding: 0.3rem 0.95rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  transition: border-color 0.2s ease;
}
.pill:hover { border-color: var(--crimson); text-decoration: none; }
.pdf-status { color: var(--muted); }
/* Sheets of paper stay white in dark mode too: it is the PDF itself. */
.pdf-page {
  width: 100%;
  background: #fff;
  box-shadow: 0 0 0 1px var(--hairline), 0 2px 10px rgba(0, 0, 0, 0.07);
  margin: 0 0 1.25rem;
}
.pdf-page canvas { display: block; width: 100%; height: auto; }

footer.site {
  border-top: 1px solid var(--hairline);
  padding: 1.6rem 0 2.2rem;
  color: var(--muted);
  font-size: 0.98rem;
}
footer.site .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---- Phones ---- */
@media (max-width: 700px) {
  body { font-size: 1.0625rem; line-height: 1.7; }
  header.corner .wrap { padding-top: 0.8rem; padding-bottom: 0.8rem; }
  .wordmark { font-size: 1rem; }
  .paper { padding: 2rem 0 3.5rem; }
  .up { margin-bottom: 1.6rem; }
  .paper h1 { font-size: 1.65rem; }
  .authors { font-size: 1.05rem; }
  .paper-text { margin-top: 1.9rem; padding-top: 1.7rem; }
  .paper-text p { font-size: 1.0625rem; }
  .paper-links a { padding: 0.45rem 1rem; }
  .index h2 { margin-top: 2.6rem; }
  .entry-title { font-size: 1.12rem; }
  .reader { padding: 1.6rem 0 3rem; }
  .pdf-page { margin-bottom: 0.75rem; }
  .pill { padding: 0.45rem 1rem; }
  footer.site .wrap { flex-direction: column; gap: 0.4rem; }
}
