/* Layout: the site title and essay list sit in a narrow column at the
   top left, with a fixed 500px column of text beside them. The layout is
   the same at every screen size: on a phone the page is shown zoomed out,
   like any desktop site (see fit.js). */

body {
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #000;
  background: #fff;
  margin: 0;
  /* Keeps #page's margins inside the body, so that when fit.js trims the
     scaled page's height the body shrinks with it. */
  display: flow-root;
}

/* Everything on the page sits in #page, which fit.js scales as one piece.
   The typography panel (look.js) lives outside it, so it is never scaled. */
#page {
  padding-block: 8px;
  /* --fit is the page scale set by fit.js. Dividing by it keeps the
     gutter clear of a phone's side system bar when the page is scaled. */
  padding-left: max(16px, calc(env(safe-area-inset-left, 0px) / var(--fit, 1)));
  padding-right: max(16px, calc(env(safe-area-inset-right, 0px) / var(--fit, 1)));
}

#menu {
  float: left;
  margin-top: 30px;
  margin-left: 12px;
  margin-right: 30px;
  width: 150px;
  font-family: "Myriad Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

#menu ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

#menu li a {
  display: inline-block;
  color: #0864c7;
}

/* Sits beside the floated menu, 500px wide. It can narrow only as a
   fallback, when fit.js has not run to scale the page instead. */
#content {
  margin-top: 15px;
  display: flow-root;
  max-width: 500px;
}

#content h1, #content h2, #content h3, #content h4 {
  font-family: "Myriad Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
  margin: 0;
}

/* The page heading starts level with the site title: the tops of their
   capital letters line up. This offset is an estimate from typical
   font metrics, for browsers without text-box-trim. */
#content h1:first-child {
  margin-top: 12px;
}

/* Where the browser can trim a line to the top of its capitals, place
   both lines by that edge so the alignment is exact in any font. */
@supports (text-box-trim: trim-start) {
  #menu {
    margin-top: 33px;
    text-box: trim-start cap alphabetic;
  }

  #content h1:first-child {
    margin-top: 18px;
    text-box: trim-start cap alphabetic;
  }
}

#content h2 {
  margin-top: 2em;
}

#content h3 {
  margin-top: 1.8em;
}

#content h2 + h3 {
  margin-top: 0.8em;
}

#content h4 {
  font-size: 13px;
  margin-top: 1.6em;
}

#content h4 + p {
  margin-top: 0.5em;
}

#content .byline, #content .byline a, #content .note {
  font-size: 10px;
  color: #aaa;
}

#content a, #content a:visited {
  color: #0864c7;
}

#content p, #content ul, #content ol {
  color: #333;
  line-height: 18px;
  text-align: justify;
}

#content p.notop {
  margin-top: 0;
}

#content .thanks {
  margin-top: 2em;
  padding-top: 1em;
  border-top: 1px solid #eee;
  margin-bottom: 4em;
  font-size: smaller;
  color: #777;
}

#content .thanks a {
  color: #777;
}

/* The last section of an essay is at least a screen tall, so its heading
   can scroll to the top like the others when picked from the table of
   contents. --fit is the page scale set by fit.js. */
#content .final {
  min-height: calc(100vh / var(--fit, 1));
}

#content li {
  margin-bottom: 0.7em;
}

#content li > ul, #content li > ol {
  margin-top: 0.7em;
}

#content ol.key {
  text-align: left;
}

#content ol.key li {
  font-weight: bold;
}

.post + .post {
  margin-top: 50px;
}

sup, sub {
  vertical-align: baseline;
  position: relative;
  top: -0.4em;
}
sub {
  top: 0.4em;
}

/* Small text boxes that readers can type into (see track.js):
     <form data-box="a-name"><input name="text" placeholder="..."></form>
   They only show when the site's server is there to receive what is typed.
   Each is a ruled line to write on, in the text's own type, with Send
   after it as a plain link; a textarea starts one line tall and grows. */
form[data-box] {
  display: none;
  margin: 1em 0;
}

.ay-live form[data-box] {
  display: block;
}

.ay-live form[data-box][hidden] {
  display: none;
}

form[data-box] p {
  display: flex;
  align-items: flex-end;
  margin: 0;
}

form[data-box] input,
form[data-box] textarea {
  font: inherit;
  color: inherit;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 26em;
  margin: 0;
  padding: 0 0 1px;
  border: 0;
  border-bottom: 1px solid #999;
  border-radius: 0;
  background: none;
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
}

form[data-box] textarea {
  display: block;
  height: 19px;
  resize: none;
  overflow: hidden;
  text-align: left;
}

form[data-box] input:focus,
form[data-box] textarea:focus {
  border-bottom-color: #0864c7;
}

form[data-box] ::placeholder {
  color: #767676;
  opacity: 1;
}

form[data-box] :focus::placeholder {
  color: transparent;
}

form[data-box] button {
  font: inherit;
  flex: none;
  margin: 0 0 0 0.8em;
  padding: 0;
  border: 0;
  background: none;
  color: #0864c7;
  text-decoration: underline;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

form[data-box] button:focus-visible,
button.opens:focus-visible {
  outline: 1px dashed currentColor;
  outline-offset: 2px;
}

form[data-box] .box-msg {
  display: block;
  min-height: 1.3em;
  margin-top: 4px;
  color: #333;
}

/* The box at the foot of an essay, set off by a rule. */
#content form.end {
  margin-top: 2em;
  padding-top: 1.2em;
  border-top: 1px solid #eee;
  margin-bottom: 4em;
}

/* A word in the text that opens one of the boxes (data-opens="its id").
   Without the server it is plain text. */
button.opens {
  font: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: text;
  -webkit-appearance: none;
  appearance: none;
}

.ay-live button.opens {
  color: #0864c7;
  text-decoration: underline;
  cursor: pointer;
}

/* With the animation on (look.js), the boxes take the look's colours. */
html.lk form[data-box] input,
html.lk form[data-box] textarea {
  border-bottom-color: var(--lk-ink);
}

html.lk form[data-box] ::placeholder,
html.lk form[data-box] button,
html.lk form[data-box] .box-msg,
html.lk.ay-live button.opens {
  color: var(--lk-ink);
}

html.lk form[data-box] :focus::placeholder {
  color: transparent;
}

html.lk #content form.end {
  border-top: 1px dashed var(--lk-line);
}

/* Commenting on a passage (track.js): select some of the essay's text and
   a small Comment tag appears beside it; pressing it opens a line to write
   on, while the passage stays marked. These sit outside #page, and
   track.js sets their size of type. */
.ay-c {
  position: absolute;
  z-index: 2147481000;
  box-sizing: border-box;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 18px;
  color: #333;
  background: #fff;
  border: 1px solid #999;
}

.ay-c-tag {
  padding: 0.08em 0.54em;
  color: #0864c7;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.ay-c-form {
  display: flex;
  align-items: flex-end;
  box-sizing: border-box;
  width: 22em;
  max-width: 100%;
  padding: 0.46em 0.6em 0.54em;
}

.ay-c-form textarea {
  font: inherit;
  color: inherit;
  display: block;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-width: 0;
  height: 19px;
  margin: 0;
  padding: 0 0 1px;
  border: 0;
  border-bottom: 1px solid #999;
  border-radius: 0;
  background: none;
  outline: 0;
  resize: none;
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}

.ay-c-form textarea:focus {
  border-bottom-color: #0864c7;
}

.ay-c-form ::placeholder {
  color: #767676;
  opacity: 1;
}

.ay-c-form button {
  font: inherit;
  flex: none;
  margin: 0 0 0 0.8em;
  padding: 0;
  border: 0;
  background: none;
  color: #0864c7;
  text-decoration: underline;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.ay-c-form button.ay-c-x {
  text-decoration: none;
  color: #767676;
}

.ay-c-form button:focus-visible {
  outline: 1px dashed currentColor;
  outline-offset: 2px;
}

.ay-c-said {
  padding: 0.46em 0.6em;
}

.ay-c-mark {
  position: absolute;
  z-index: 2147480999;
  pointer-events: none;
  background: #ffe066;
  mix-blend-mode: multiply;
}

html.lk .ay-c {
  color: var(--lk-ink);
  background: var(--lk-bg);
  border-color: var(--lk-ink);
}

html.lk .ay-c-tag,
html.lk .ay-c-form button,
html.lk .ay-c-form button.ay-c-x,
html.lk .ay-c-form ::placeholder {
  color: var(--lk-ink);
}

html.lk .ay-c-form textarea,
html.lk .ay-c-form textarea:focus {
  border-bottom-color: var(--lk-ink);
}

html.lk .ay-c-mark {
  background: var(--lk-ink);
  mix-blend-mode: normal;
  opacity: 0.3;
}
