/* Self-hosted, both under the SIL Open Font License 1.1 (fonts/*-OFL.txt):
   JetBrains Mono 2.304 and IBM Plex Serif 2.0.0. The system faces stay as
   fallbacks while these load. */
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Regular.a9cb1cd82332b23a.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-SemiBold.918edad542a1da60.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Serif";
  src: url("/fonts/IBMPlexSerif-Regular.024ebce13cec984b.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Serif";
  src: url("/fonts/IBMPlexSerif-Italic.ba5feed9ebae36e3.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Serif";
  src: url("/fonts/IBMPlexSerif-Bold.3b9eb99793dd9fed.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* WCAG 2 contrast, computed from these values (text on its background):
   light: ink/paper 15.3, quiet/paper 6.7, attention/paper 6.7,
   ink/raised 13.7, quiet/raised 6.0, ink/glow 12.3; accent/paper 5.0
   (the mark's lens, a graphic). Dark: ink/paper 15.1, quiet/paper 8.1,
   attention/paper 9.1, ink/raised 13.0, quiet/raised 7.0, ink/glow 7.1;
   accent/paper 8.0. */
:root {
  color-scheme: light dark;
  --ink: #1d1b16;
  --paper: #f6f1e7;
  --raised: #ece5d6;
  --line: #cfc6b4;
  --quiet: #5b5446;
  --attention: #8f3a0c;
  --glow: #f0d98f;
  --accent: #a4501c;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #efe8da;
    --paper: #16140f;
    --raised: #25221c;
    --line: #3e382e;
    --quiet: #b5ab97;
    --attention: #f4a46a;
    --glow: #5a4a1f;
    --accent: #e39a63;
  }
}

/* An element the page hides stays hidden whatever display a rule gives
   it, as the HTML hidden attribute promises. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.5;
}

/* Wide: the text with its examples beneath on the left, the values on
   the right. Narrow: text, then values, then examples, so a loaded
   example's values are next to it; 16 px gutters and nothing wider than
   the screen. */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  grid-template-areas:
    "text values"
    "examples values";
  grid-template-rows: auto 1fr;
  gap: 1.5rem 2rem;
  padding: 1.5rem;
  max-width: 76rem;
  margin-inline: auto;
}

.text {
  grid-area: text;
}

.panel {
  grid-area: values;
}

.examples-section {
  grid-area: examples;
}

.narrow-only {
  display: none;
}

@media (max-width: 48rem) {
  main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "text"
      "values"
      "examples";
    grid-template-rows: auto;
    padding: 1rem;
  }

  header {
    padding-inline: 1rem;
  }

  .wide-only {
    display: none;
  }

  .narrow-only {
    display: inline;
  }
}

header {
  max-width: 76rem;
  margin-inline: auto;
  padding: 1rem 1.5rem 0;
}

section {
  min-width: 0;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mark {
  flex: none;
}

h1 {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.tagline {
  font-family: var(--serif);
  margin: 0.25rem 0 0;
  color: var(--quiet);
}

h2 {
  font-size: 1rem;
  margin-block: 0 0.5rem;
}

/* The gutter and the textarea are one block: same font, line height and
   padding, so line n of the text sits beside number n. The textarea grows
   with its content and never wraps, so it never scrolls vertically inside
   itself and one line of text is one row. */
.editor {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  font: 1rem/1.5 var(--mono);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.editor:focus-within {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.gutter {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0.5rem 0.5rem 0.75rem;
  border-inline-end: 1px solid var(--line);
  color: var(--quiet);
  text-align: right;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: calc(12lh + 1rem);
  field-sizing: content;
  font: inherit;
  padding: 0.5rem;
  margin: 0;
  color: inherit;
  background: inherit;
  border: 0;
  outline: none;
  resize: none;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  overflow-y: hidden;
}

.problems,
.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.problem {
  color: var(--attention);
  font-size: 0.9375rem;
  padding-block: 0.25rem;
}

.row {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 0.25rem 1rem;
  padding-block: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.name {
  font-family: var(--mono);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.controls {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.set input {
  width: 8rem;
  font: 1rem/1.5 var(--mono);
  margin-inline-start: 0.25rem;
  padding: 0.125rem 0.375rem;
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--quiet);
  border-radius: 3px;
}

.sentence {
  grid-column: 1 / -1;
  margin: 0.25rem 0 0;
  color: var(--attention);
}

button {
  font: inherit;
  min-height: 2.25rem;
  padding: 0 0.875rem;
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--quiet);
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  border-color: var(--ink);
}

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

.caution {
  margin: 0 0 0.5rem;
  color: var(--quiet);
}


.examples {
  list-style: none;
  margin: 0;
  padding: 0;
}

.example {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 1rem;
  align-items: center;
  padding-block: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.example-title {
  font-weight: 600;
}

.notice {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.875rem;
  color: var(--quiet);
}

/* A standing that changes arrives as a fresh element (it is keyed by its
   text), so this plays once per change. */
.said {
  border-radius: 3px;
  animation: arrive 600ms ease-out;
}

@keyframes arrive {
  from {
    background-color: var(--glow);
  }
  to {
    background-color: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .said {
    animation: none;
  }
}

.value {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.empty {
  font-family: var(--serif);
  margin: 0;
  color: var(--quiet);
}

code {
  font-family: var(--mono);
  font-size: 0.9375em;
}

.sentence,
.standing,
.problem {
  overflow-wrap: anywhere;
}

@media (max-width: 30rem) {
  .row {
    grid-template-columns: minmax(0, 1fr);
  }

  .controls {
    grid-column: 1;
  }
}
