/*
 * The Niceness Conjectures: a typeset problem list.
 *
 * The model is a printed mathematics paper, not a web app. One column of serif
 * text on warm paper; hairline rules where a web page would draw a box; run-in
 * labels ("Why it matters.") where it would add another heading; a table of
 * contents with dot leaders for the list; a theorem block for each statement.
 * No rounded corners, no shadows, no cards, no pills.
 *
 * Two inks. Everything is in black except the rubric, a vermilion kept for one
 * job: saying whether each conjecture is proved. Because nothing else on the
 * page is coloured, "Not proved" is the first thing the eye lands on without
 * needing a badge. (A proved conjecture would print in green ink instead.)
 * Please keep the rubric to status: once links or headings use it too, the
 * status stops standing out.
 *
 * Every class is prefixed nq-; the pages are generated by
 * components/niceness/pages.mjs.
 */

:root {
  color-scheme: light;
  --paper: #f5f0e6;
  --sheet: #fbf8f2;
  --ink: #1d1b18;
  --muted: #5c564c;
  --faint: #8d8578;
  --rule: #d5ccbc;
  --rule-strong: #a99f8e;
  --ruling: #e6dfd2;
  --rubric: #a8321b;
  --proved: #2c6a3f;

  --serif: Charter, "Bitstream Charter", "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* About 80 characters of body text a line: wide for a web page, normal for a printed one. */
  --measure: 52rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #171513;
    --sheet: #1d1b18;
    --ink: #e9e3d8;
    --muted: #b1a99b;
    --faint: #857d70;
    --rule: #37322b;
    --rule-strong: #5a5247;
    --ruling: #2a2622;
    --rubric: #f0805f;
    --proved: #86c99a;
  }
}

* { box-sizing: border-box; }

body.nq {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 19px/1.6 var(--serif);
  font-variant-numeric: oldstyle-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.nq p { margin: 0 0 1rem; }
.nq-nowrap { white-space: nowrap; }
.nq i, .nq em { font-style: italic; }
.nq sub, .nq sup { font-size: 0.72em; line-height: 0; }

.nq a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.nq a:hover { text-decoration-color: var(--ink); }
.nq :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.nq-runin {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.nq-hint { font-size: 0.82rem; font-style: italic; color: var(--muted); }

/* --- page frame ----------------------------------------------------------- */

.nq-running {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  max-width: var(--measure); margin: 0 auto; padding: 1.4rem 1.5rem 0.5rem;
  border-bottom: 1px solid var(--rule);
  font-variant-caps: all-small-caps; letter-spacing: 0.08em; color: var(--muted);
  box-sizing: content-box;
}
.nq-running a { text-decoration: none; }
.nq-running a:hover { text-decoration: underline; }

.nq-page { max-width: var(--measure); margin: 0 auto; padding: 0 1.5rem; box-sizing: content-box; }

.nq-colophon {
  max-width: var(--measure); margin: 4.5rem auto 0; padding: 1rem 1.5rem 3rem;
  border-top: 1px solid var(--rule);
  font-size: 0.8rem; color: var(--muted); text-align: center;
  box-sizing: content-box;
}
.nq-colophon p { margin: 0.2rem 0; }

/* --- titles and sections -------------------------------------------------- */

.nq-titleblock { text-align: center; margin: 4rem 0 2.2rem; }
.nq-titleblock-left { text-align: left; margin-top: 3rem; }
.nq h1 {
  font-size: clamp(2rem, 5.5vw, 2.7rem); line-height: 1.12; font-weight: 700;
  letter-spacing: -0.01em; margin: 0 0 0.6rem; text-wrap: balance;
}
.nq-subtitle { font-style: italic; font-size: 1.12rem; color: var(--muted); text-wrap: balance; }
.nq-kicker {
  margin: 0 0 0.5rem !important;
  font-variant-caps: all-small-caps; letter-spacing: 0.1em; color: var(--muted);
}

.nq-abstract { margin: 0 2rem 1rem !important; font-size: 0.95rem; }

.nq-section { margin-top: 3.2rem; scroll-margin-top: 1.5rem; }
.nq h2 { font-size: 1.28rem; font-weight: 700; margin: 0 0 1rem; line-height: 1.3; }
.nq-secnum { display: inline-block; min-width: 1.6em; font-variant-numeric: lining-nums; }

/* --- the list: a table of contents ---------------------------------------- */

.nq-entries { list-style: none; padding: 0; margin: 1.3rem 0 0; }
.nq-entry {
  position: relative;
  display: grid; grid-template-columns: 2.4rem minmax(0, 1fr);
  margin-bottom: 1.35rem;
}
/*
 * Each entry clicks through as a whole: the title's link is stretched over it.
 * At rest the title is underlined like every other link on the page; on hover
 * or keyboard focus the entry takes a paper-tone highlight that bleeds past
 * the text (a box-shadow spread, so the layout does not move), the underline
 * darkens and the number turns to ink.
 */
.nq-entry-line a::after { content: ""; position: absolute; inset: 0; }
.nq-entry:hover, .nq-entry:focus-within {
  background: var(--sheet);
  box-shadow: 0 0 0 0.55rem var(--sheet);
}
.nq-entry:hover .nq-entry-n, .nq-entry:focus-within .nq-entry-n { color: var(--ink); }
.nq-entry:hover .nq-entry-line a, .nq-entry:focus-within .nq-entry-line a { text-decoration-color: var(--ink); }
.nq-entry-line a:focus-visible { outline: none; }
.nq-entry:focus-within { outline: 2px solid var(--ink); outline-offset: 0.55rem; }
.nq-entry > p { grid-column: 2; margin: 0; }
.nq-entry-n {
  grid-row: 1; grid-column: 1;
  font-weight: 700; font-variant-numeric: lining-nums; color: var(--faint);
}
.nq-entry-line { display: flex; align-items: baseline; gap: 0.45rem; }
.nq-entry-line a { font-weight: 700; text-decoration-thickness: 1.5px; }
.nq-leader {
  flex: 1 1 1.5rem; min-width: 1.5rem;
  border-bottom: 2px dotted var(--rule-strong);
  transform: translateY(-0.3em);
}
.nq-entry-gist { color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.nq-entry-meta { font-size: 0.8rem; font-style: italic; color: var(--faint); margin-top: 0.15rem !important; }

/* Hang the numbers in the left margin when there is a margin to hang them in. */
@media (min-width: 60rem) {
  .nq-entries { margin-left: -2.4rem; }
}

/* --- status: the rubric --------------------------------------------------- */

.nq-mark {
  flex: none;
  font-variant-caps: all-small-caps; letter-spacing: 0.09em; font-weight: 700;
  font-size: 1.3rem; line-height: 1; white-space: nowrap;
}
.nq-mark-open { color: var(--rubric); }
.nq-mark-proved { color: var(--proved); }
.nq-mark-disproved { color: var(--ink); text-decoration: line-through; }

/* On a conjecture page the status is a ruled line of its own, under the title. */
.nq-verdict {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem 1.1rem;
  padding: 0.75rem 0 0.8rem; margin: 0 0 2.4rem !important;
  border-top: 2px solid var(--rubric); border-bottom: 1px solid var(--rubric);
}
.nq-verdict-proved { border-color: var(--proved); }
.nq-verdict-disproved { border-color: var(--ink); }
.nq-verdict .nq-mark { font-size: 1.9rem; letter-spacing: 0.07em; }
.nq-verdict-text { flex: 1 1 18rem; font-size: 0.9rem; color: var(--muted); }

/* --- the statement, set as a theorem ------------------------------------- */

.nq-theorem { margin: 0 0 0.6rem; }
.nq-theorem-head { margin: 0 0 0.35rem !important; }
.nq-theorem .nq-runin { font-variant-caps: normal; letter-spacing: 0; }
.nq-theorem-body { font-style: italic; }
.nq-theorem-body strong { font-style: normal; }
.nq-theorem-body p { margin: 0.6rem 0 !important; }
.nq-theorem-body ul { list-style: none; counter-reset: clause; padding-left: 2.7rem; margin: 0.4rem 0; }
.nq-theorem-body li { counter-increment: clause; position: relative; margin: 0.45rem 0; }
.nq-theorem-body li::before {
  content: "(" counter(clause, lower-roman) ")";
  position: absolute; left: -2.7rem; width: 2.2rem; text-align: right; font-style: normal;
}

.display {
  display: block; text-align: center; margin: 0.9rem 0; font-size: 1.1rem;
  overflow-x: auto; overflow-y: hidden; padding: 0.2rem 0;
}
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 0.2em; }
.frac-num { padding: 0 0.25em 0.1em; border-bottom: 1px solid currentColor; }
.frac-den { padding: 0.1em 0.25em 0; }

.nq-theorem + .nq-hint { margin-bottom: 2rem; }

/* --- the 69 figure -------------------------------------------------------- */

.nq-figure { margin: 1.6rem 0 2rem; text-align: center; }
.nq-figure-eq {
  display: flex; justify-content: center; gap: 0.6rem 2.6rem; flex-wrap: wrap;
  font-size: 1.3rem; font-variant-numeric: lining-nums; margin-bottom: 0.9rem !important;
}
.nq-figure-digits { margin: 0 0 0.6rem !important; font-variant-numeric: lining-nums tabular-nums; }
.nq-digit {
  display: inline-block; width: 2.1rem; font-size: 1.45rem; line-height: 1.2;
  border-bottom: 1px solid var(--rule-strong);
}
.nq-digit + .nq-digit { border-left: 1px solid var(--rule); }
.nq-digit-from { display: block; font-size: 0.8rem; line-height: 1.7; color: var(--muted); font-variant-numeric: normal; }
.nq-figure figcaption {
  font-size: 0.85rem; color: var(--muted); max-width: 30rem; margin: 0 auto; text-wrap: balance;
}

/* --- notation, references, tables ---------------------------------------- */

/*
 * Notation as a booktabs table: heavy rules top and bottom, hairlines between
 * entries. Symbols are set as math (plain italic, as in the statements, not
 * bold); words are set in small caps so the two kinds of term read apart.
 */
.nq-notation {
  display: grid; grid-template-columns: 9rem minmax(0, 1fr); margin: 0;
  border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink);
  font-size: 0.95rem;
}
.nq-notation dt, .nq-notation dd { padding: 0.6rem 0; border-top: 1px solid var(--rule); }
.nq-notation dt:first-of-type, .nq-notation dt:first-of-type + dd { border-top: 0; }
.nq-notation dt { padding-right: 1.4rem; font-size: 1.05rem; line-height: 1.5; }
.nq-notation .nq-term-word { font-variant-caps: all-small-caps; letter-spacing: 0.06em; font-weight: 700; font-size: 1rem; }
.nq-notation dd { margin: 0; }
.nq-notation .frac { font-size: 0.9em; }

.nq-references { list-style: none; counter-reset: ref; padding-left: 2.2rem; margin: 0; font-size: 0.92rem; }
.nq-references li { counter-increment: ref; position: relative; margin: 0.3rem 0; }
.nq-references li::before {
  content: "[" counter(ref) "]"; position: absolute; left: -2.2rem; width: 1.8rem;
  text-align: right; color: var(--muted); font-variant-numeric: lining-nums;
}

.nq-tablefig { margin: 2rem 0 0; }
.nq-tablefig figcaption { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.7rem; }
.nq-tablescroll { overflow-x: auto; }
.nq-table {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
  font-variant-numeric: lining-nums tabular-nums;
  border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink);
}
.nq-table th, .nq-table td { padding: 0.28rem 0.7rem; text-align: right; }
.nq-table th:first-child, .nq-table td:first-child { text-align: left; padding-left: 0; }
.nq-table th:last-child, .nq-table td:last-child { padding-right: 0; }
.nq-table thead th { font-weight: 400; font-style: italic; border-bottom: 0.75px solid var(--ink); padding-top: 0.45rem; }
.nq-table tbody tr:first-child td { padding-top: 0.45rem; }
.nq-table tfoot td { border-top: 0.75px solid var(--ink); font-weight: 700; padding-bottom: 0.45rem; }

/* --- the answer sheet ----------------------------------------------------- */

.nq-form { margin-top: 1.4rem; }
.nq-label {
  display: block; margin: 0 0 0.35rem;
  font-variant-caps: all-small-caps; letter-spacing: 0.08em; font-weight: 700; color: var(--muted);
}
.nq-optional { font-weight: 400; letter-spacing: 0.04em; }

.nq textarea {
  display: block; width: 100%; min-height: 23.8rem; resize: vertical;
  font: 0.9rem/1.7rem var(--mono); color: var(--ink);
  padding: 0 0.8rem; border: 1px solid var(--rule-strong); border-radius: 0;
  background-color: var(--sheet);
  background-image: linear-gradient(to bottom, transparent calc(1.7rem - 1px), var(--ruling) calc(1.7rem - 1px));
  background-size: 100% 1.7rem;
  background-attachment: local;
}
.nq textarea::placeholder { color: var(--faint); font-style: italic; }
.nq-form > .nq-hint { margin: 0.35rem 0 1.6rem; }
.nq-hint .nq-over { color: var(--rubric); font-style: normal; font-weight: 700; }

.nq-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1.6rem; }
.nq-field { margin: 0 0 1.4rem !important; }
.nq input, .nq select {
  display: block; width: 100%; font: 1rem/1.4 var(--serif); color: var(--ink);
  padding: 0.3rem 0; border: 0; border-bottom: 1px solid var(--ink); border-radius: 0;
  background: transparent; -webkit-appearance: none; appearance: none;
}
.nq select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: right 0.35rem center, right 0.05rem center;
  background-size: 0.3rem 0.3rem; background-repeat: no-repeat; padding-right: 1.2rem;
}
.nq [aria-invalid="true"] { border-color: var(--rubric); }

.nq-send { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.2rem; margin: 0.4rem 0 0 !important; }
.nq-send .nq-hint { flex: 1 1 16rem; }
.nq-button {
  font: 700 1rem/1 var(--serif); font-variant-caps: all-small-caps; letter-spacing: 0.08em;
  color: var(--paper); background: var(--ink); border: 1px solid var(--ink); border-radius: 0;
  padding: 0.7rem 1.3rem 0.8rem; cursor: pointer;
}
.nq-button:hover { background: transparent; color: var(--ink); }
.nq-button:disabled { opacity: 0.55; cursor: progress; }
.nq-button-quiet { background: transparent; color: var(--ink); }
.nq-button-quiet:hover { background: var(--ink); color: var(--paper); }

.nq-status { margin: 1rem 0 0 !important; font-size: 0.92rem; }
.nq-status:empty { display: none; }
.nq-status-error { color: var(--rubric); }

.nq-received { margin-top: 1.4rem; padding: 0.2rem 0 0.2rem 1.1rem; border-left: 2px solid var(--proved); }
.nq-received strong { color: var(--proved); font-variant-caps: all-small-caps; letter-spacing: 0.06em; font-size: 1.05rem; }

/* Honeypot: off-screen rather than display:none, which some bots skip. */
.nq-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* --- previous and next ---------------------------------------------------- */

.nq-pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
  margin-top: 3.5rem; padding-top: 0.9rem; border-top: 1px solid var(--rule);
  font-size: 0.92rem;
}
.nq-pager a { text-decoration: none; }
.nq-pager a:hover { text-decoration: underline; }
.nq-pager-next { text-align: right; }

/* --- large screens: a size up, so the wider column keeps its proportions --- */

@media (min-width: 90rem) {
  body.nq { font-size: 20px; }
  .nq-abstract { margin-left: 4rem !important; margin-right: 4rem !important; }
}

/* --- narrow screens ------------------------------------------------------- */

@media (max-width: 40rem) {
  body.nq { font-size: 17.5px; }
  .nq-titleblock { margin-top: 2.6rem; }
  .nq-abstract { margin: 0 0 1rem !important; }
  .nq-entry { grid-template-columns: 1.9rem minmax(0, 1fr); }
  .nq-entry-line { display: block; }
  .nq-entry-line a { display: block; }
  .nq-leader { display: none; }
  .nq-entry-line .nq-mark { display: inline-block; margin-top: 0.3rem; }
  .nq-notation { grid-template-columns: 1fr; }
  .nq-notation dt { padding-bottom: 0; }
  .nq-notation dd { border-top: 0; padding-top: 0.15rem; }
  .nq-fields { grid-template-columns: 1fr; }
  .nq-pager { grid-template-columns: 1fr; gap: 0.6rem; }
  .nq-pager-next { text-align: left; }
  .nq-digit { width: 1.75rem; font-size: 1.25rem; }
}
