/* article.css — the reading surface. */

/* The measure sits flush with the page head's left edge, so the title and
   the first line of body text share one margin; the sidenote column runs
   down the right of it and the remainder is canvas. */
.article {
  display: grid;
  grid-template-columns:
    [full-start main-start] minmax(0, var(--measure))
    [main-end] minmax(0, 22rem)
    [side-end] minmax(0, 1fr) [full-end];
  column-gap: calc(var(--space) * 4);
}

.article > * {
  grid-column: main;
}

.article .figure--wide {
  grid-column: full;
}

.article .sidenote {
  grid-column: main-end / side-end;
}

@media (max-width: 1100px) {
  .article {
    grid-template-columns: [full-start main-start] minmax(0, 1fr) [main-end side-end full-end];
  }

  .article .figure--wide,
  .article .sidenote {
    grid-column: main;
  }

  /* Sidenotes render inline as a bordered aside directly after their
     paragraph rather than in a side column. */
  .article .sidenote {
    border-left: none;
    border-top: var(--border) solid var(--accent);
    margin: 1em 0 1.5em;
    padding-top: 0.75em;
  }
}

.article p {
  margin: 0 0 1.15em;
  text-indent: 0;
  text-align: left; /* never justified — on a 66ch measure justification produces rivers */
}

/* Heading rhythm: a heading belongs to the text under it, so the space above
   it is roughly twice the space below. */
.article h2 {
  font-size: 1.625rem;
  margin: 2em 0 0.6em;
}

.article h3 {
  font-size: 1.25rem;
  margin: 1.75em 0 0.5em;
}

.article ul,
.article ol {
  margin: 0 0 1.15em;
  padding-left: 1.4em;
}

.article li {
  margin-bottom: 0.4em;
}

.article li::marker {
  color: var(--accent);
}

.article hr {
  height: 1px;
  border: 0;
  margin: 2.5em 0;
  background: var(--panel-border);
}

/* Tables are data, so they get the tight-inside/airy-outside treatment:
   compressed rows, a hairline rule per row, and no vertical rules at all. */
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 2em 0;
  font-size: 1rem;
}

.article th,
.article td {
  padding: 0.6em 1em 0.6em 0;
  text-align: left;
  vertical-align: top;
  border-bottom: var(--border) solid var(--panel-border);
}

.article th {
  font: 600 0.9375rem var(--font-ui);
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom-color: var(--panel-border-bright);
}

/* Numeric columns tabulate, so they take the mono face and align right. */
.article td:not(:first-child) {
  font-variant-numeric: tabular-nums;
}

.article blockquote {
  margin: 1.5em 0;
  padding-left: 1.25em;
  border-left: 3px solid var(--accent);
  font-style: italic;
  color: var(--text-secondary);
}

.article code,
.article pre {
  font-family: var(--font-mono);
}

.article code {
  color: var(--text-primary);
  background: var(--recess-fill);
  border-radius: 4px;
  padding: 0.15em 0.4em;
}

.article pre {
  background: var(--recess-fill);
  border-radius: var(--radius-sm);
  border: var(--border) solid var(--panel-border);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.4);
  padding: calc(var(--space) * 2);
  overflow-x: auto;
}

.article pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Pygments classes, themed for the dark ground. */
.article .highlight .c,
.article .highlight .c1,
.article .highlight .cm {
  color: var(--text-secondary);
  font-style: italic;
}

.article .highlight .k,
.article .highlight .kn,
.article .highlight .kd,
.article .highlight .kc {
  color: var(--accent);
  font-weight: 600;
}

.article .highlight .s,
.article .highlight .s1,
.article .highlight .s2 {
  color: #B9BCC4;
}

.article .highlight .n,
.article .highlight .nv {
  color: var(--text-primary);
}

.article .highlight .nf,
.article .highlight .nc {
  color: var(--text-primary);
  font-weight: 600;
}

.article .highlight .mi,
.article .highlight .mf {
  color: var(--text-primary);
}

.article .highlight .o,
.article .highlight .p {
  color: var(--text-secondary);
}

.article .figure {
  background: var(--panel-fill);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: var(--border) solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--panel-lift);
  margin-block: calc(var(--space) * 5);
  padding: calc(var(--space) * 2);
}

.article .figure figcaption {
  margin-top: calc(var(--space) * 1.5);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.article .sidenote {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text-secondary);
  border-top: 2px solid var(--accent);
  padding-top: 0.75em;
}

.article .sidenote p {
  margin: 0 0 0.5em;
}

.article .sidenote p:last-child {
  margin-bottom: 0;
}

.article .footnote-ref {
  vertical-align: super;
  font-size: 0.7em;
  line-height: 0;
}

.article .footnote-ref a {
  color: var(--accent);
  text-decoration: none;
  padding: 0 0.15em;
}

.article .footnote-ref a:hover {
  text-decoration: underline;
}

@media (pointer: coarse) {
  .article .footnote-ref {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    min-height: 24px;
    padding: 0.25em;
  }
}

/* ---------------------------------------------------------------------- */
/* Print — invert to black-on-white, drop glass and glow, expand sidenotes
   inline, hide nav and search. */

@media print {
  body {
    background: #FFFFFF;
    background-image: none;
    color: #111111;
  }

  .site-header,
  .nav,
  .search,
  .glow,
  .glow::before,
  .card::after {
    display: none !important;
  }

  .article,
  .panel,
  .panel--raised,
  .card,
  .article .figure {
    background: #FFFFFF;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    border-color: #CCCCCC;
    color: #111111;
  }

  .article {
    grid-template-columns: [full-start main-start] minmax(0, 1fr) [main-end side-end full-end];
  }

  .article .figure--wide,
  .article .sidenote {
    grid-column: main;
  }

  .article .sidenote {
    border-left: none;
    border-top: 1px solid #999999;
    color: #333333;
  }

  a {
    color: #111111;
  }
}
