/* The page follows the reader's colour scheme: every colour is one of
   these, and the dark scheme below gives each another value. */
:root {
  color-scheme: light dark;
  --page: #fff;
  --ink: #333;
  --muted: #777;
  --band: #efefef;
  --rule: #d8d8d8;
  --link: #2f6fdc;
  --problem: #b3261e;
  --field: #fff;
  --field-hover: #f6f6f6;
  --scroll-edge: #0000002b;
  --measure: 64rem;

  /* Each part's colour, for its brackets and connector, at 3:1 or more
     against the page; punctuation alone is meant to recede. Primary is
     magenta, clear of the orange and red that lead into it in a
     format's optional opening fields (minus-one and minus-two), and
     of the green and blue that follow it. */
  --part-data: #5a5a5a;
  --part-punctuation: #b0b0b0;
  --part-primary: #cc3d9e;
  --part-secondary: #1fa463;
  --part-tertiary: #2f6fdc;
  --part-quandary: #e0474c;
  --part-quintessential: #8e5be8;
  --part-red: #d63a3a;
  --part-orange: #d86c00;
  --part-yellow: #a88100;
  --part-green: #2e9e4f;
  --part-blue: #2a7de1;
  --part-indigo: #4b3fbf;
  --part-violet: #a24bd6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #17181a;
    --ink: #e3e3e3;
    --muted: #9c9c9c;
    --band: #222327;
    --rule: #3a3b40;
    --link: #7eaaf7;
    --problem: #ff8a80;
    --field: #17181a;
    --field-hover: #2a2b30;
    --scroll-edge: #ffffff20;

    --part-data: #a8a8a8;
    --part-punctuation: #5e5e5e;
    --part-primary: #ea7cc9;
    --part-secondary: #3fcf86;
    --part-tertiary: #6fa0f5;
    --part-quandary: #f2777b;
    --part-quintessential: #ad8cf5;
    --part-red: #f06666;
    --part-orange: #f7a54a;
    --part-yellow: #e8c24e;
    --part-green: #52c878;
    --part-blue: #62a8f5;
    --part-indigo: #8f86f5;
    --part-violet: #cb85ee;
  }
}

* { box-sizing: border-box; }

html {
  font-size: 17px;
  /* 100vw counts a classic scrollbar, which the window then lacks room
     for; a frame reaching the window's edges must not scroll it. */
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--page);
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--link); }

.masthead {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

.masthead h1 {
  margin: 0;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.masthead h1 a { color: inherit; text-decoration: none; }

.tagline { margin: 0.4rem 0 0; color: var(--muted); }

.ask {
  background: var(--band);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 1rem;
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}

.ask input,
.ask button {
  font: inherit;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.35rem;
  border: 1px solid var(--rule);
  background: var(--field);
  color: var(--ink);
}

.ask input {
  flex: 1 1 auto;
  max-width: calc(var(--measure) - 7rem);
  padding: 0.5rem 0.8rem;
}

.ask button { padding: 0.5rem 1.4rem; cursor: pointer; }
.ask button:hover { background: var(--field-hover); }

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

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.welcome, .problem, .claim { margin: 0.6rem 0; }

/* A page that is only a status leads with it, large, each digit in a
   part's colour, and says what it means beneath. */
.status-page {
  text-align: center;
  padding: 2.5rem 0 1.5rem;
}

.status-page .status {
  margin: 0;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(4.5rem, 20vw, 8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
}

.status-page .status span:nth-child(1) { color: var(--part-primary); }
.status-page .status span:nth-child(2) { color: var(--part-secondary); }
.status-page .status span:nth-child(3) { color: var(--part-tertiary); }

.status-page p {
  margin: 1rem 0 0;
  font-size: 1.2rem;
  color: var(--muted);
}
.problem { color: var(--problem); }
.input { font-family: ui-monospace, Menlo, Consolas, monospace; }

.reading + .reading { border-top: 1px solid var(--rule); margin-top: 2rem; padding-top: 1rem; }
.result + .result { margin-top: 2.5rem; }

/* A diagram draws at one unit per pixel, which is what keeps its lines on
   the pixel grid: scaled, every line blurs, so it never is. The frame
   reaches the edges of the window, so a diagram wider than the text column
   spreads into the margins, centred; one wider than the window scrolls
   sideways within the frame, from its start.

   An edge with more of the diagram beyond it is shaded, by backgrounds
   alone: a shade stays at each edge of the frame, a long ellipse that
   keeps its strength for most of the frame's height before dying away
   inwards, upwards and downwards, and a cover in the page's colour at
   each end of the diagram scrolls with it, hiding the shade at an edge
   the diagram's end has reached. A diagram that fits covers both. Each
   fades on a curve, so neither ends in a line. */
.diagram-frame {
  margin: 0.8rem calc(50% - 50vw) 1.2rem;
  padding: 0 1rem;
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--page) 50%, 70%, transparent) left / 5rem 100% no-repeat local,
    linear-gradient(to left, var(--page) 50%, 70%, transparent) right / 5rem 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--scroll-edge) 35%, 65%, transparent) left / 2.5rem 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--scroll-edge) 35%, 65%, transparent) right / 2.5rem 100% no-repeat scroll;
}

.diagram {
  display: block;
  margin: 0 auto;
}

.diagram .muted { fill: var(--muted); }
.diagram .part-data { stroke: var(--part-data); }
.diagram .part-punctuation { stroke: var(--part-punctuation); }
.diagram .part-primary { stroke: var(--part-primary); }
.diagram .part-secondary { stroke: var(--part-secondary); }
.diagram .part-tertiary { stroke: var(--part-tertiary); }
.diagram .part-quandary { stroke: var(--part-quandary); }
.diagram .part-quintessential { stroke: var(--part-quintessential); }
.diagram .part-red { stroke: var(--part-red); }
.diagram .part-orange { stroke: var(--part-orange); }
.diagram .part-yellow { stroke: var(--part-yellow); }
.diagram .part-green { stroke: var(--part-green); }
.diagram .part-blue { stroke: var(--part-blue); }
.diagram .part-indigo { stroke: var(--part-indigo); }
.diagram .part-violet { stroke: var(--part-violet); }
.diagram .unit { text-decoration: underline dotted; cursor: help; }

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2rem 1rem;
  margin: 0.8rem 0;
}

.details dt { color: var(--muted); }
.details dd { margin: 0; }

.links {
  display: inline-block;
  vertical-align: top;
  background: var(--band);
  border: 1px solid var(--rule);
  padding: 0.6rem 1rem;
  margin: 0.6rem 1rem 0.6rem 0;
}

.links h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.links ul { margin: 0; padding-left: 1.2rem; }
.links li { margin: 0.15rem 0; }
.authority { color: var(--muted); }

.prose h2 { margin-top: 1.5rem; }

/* The story reads across two columns where there is room for both. */
.story .columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 2.5rem;
}

.story .columns p:first-child { margin-top: 0; }

@media (max-width: 44rem) {
  .story .columns { grid-template-columns: 1fr; }
  .story .columns p:first-child { margin-top: 1em; }
}
.prose code, .prose pre { font-family: ui-monospace, Menlo, Consolas, monospace; }
.prose pre { background: var(--band); padding: 0.8rem 1rem; overflow-x: auto; }
.examples li { margin: 0.35rem 0; }

footer {
  background: var(--band);
  padding: 0.8rem 1rem;
}

footer .inner {
  max-width: var(--measure);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

footer a { color: var(--ink); text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer p, footer nav { margin: 0; }
