:root {
  --ink: #000;
  --paper: #fff;
  --rule: 3px solid var(--ink);
  --gutter: clamp(1rem, 4vw, 3rem);
  --measure: 38rem;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  /* Screen serifs that ship with the reader's device: Charter on Apple, Georgia elsewhere. */
  --serif: Charter, "Bitstream Charter", Georgia, "Times New Roman", serif;
  --mono: "Courier New", Courier, monospace;
}

/* Dark is a warm charcoal with off-white ink, not black and white. */
:root[data-theme="dark"] {
  --ink: #e6e2d9;
  --paper: #1d1c1a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

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

a {
  color: inherit;
}

img {
  display: block;
  width: 100%;
  height: auto;
}

::selection {
  background: var(--ink);
  color: var(--paper);
}

/* Masthead */

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem var(--gutter);
  border-bottom: var(--rule);
  font-family: var(--mono);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.masthead nav {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.masthead a {
  text-decoration: none;
}

.masthead a:hover,
.masthead a[aria-current] {
  text-decoration: underline;
}

.theme-toggle {
  margin: 0 0 0 0.5rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.theme-toggle:hover {
  text-decoration: underline;
}

:root[data-theme="dark"] .to-dark,
:root:not([data-theme="dark"]) .to-light {
  display: none;
}

/* Index */

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

.index li {
  position: relative;
  overflow: hidden;
  border-bottom: var(--rule);
}

/* The row is as tall as its text makes it; the image fills that height and
   sits at --at along the row, never past either edge. */
.index-image {
  position: absolute;
  top: 0;
  left: var(--at);
  width: auto;
  max-width: 70%;
  height: 100%;
  object-fit: cover;
  transform: translateX(calc(-1 * var(--at)));
}

.index a {
  position: relative;
  display: grid;
  grid-template-columns: 4rem 1fr auto;
  align-items: baseline;
  gap: 1rem;
  padding: 1.5rem var(--gutter);
  text-decoration: none;
  outline: none;
}

.index li:hover,
.index li:focus-within {
  background: var(--ink);
}

/* White text in difference mode reads as the opposite of whatever is behind
   it: the paper, the hover fill, or the image. */
.index a span {
  color: #fff;
  mix-blend-mode: difference;
}

.index-no,
.index-date {
  font-family: var(--mono);
  font-size: 0.875rem;
}

.index-title {
  font-family: var(--sans);
  font-weight: 900;
  font-size: clamp(2.25rem, 9vw, 7.5rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

/* Article */

/* Container so wide figures can size to the page without the scrollbar. */
.article {
  container-type: inline-size;
}

.article-head {
  padding: 2rem var(--gutter) 1rem;
  border-bottom: var(--rule);
}

.article-head h1 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 900;
  font-size: clamp(2.75rem, 13vw, 11rem);
  line-height: 0.85;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.article-date {
  margin: 1.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.875rem;
}

.article-body {
  display: flow-root;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  padding: 2rem var(--gutter) 4rem;
  counter-reset: figure;
}

.article-body p {
  margin: 0;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.article-body p + p {
  margin-top: 0.6em;
  text-indent: 2em;
}

/* Figures */

.figure {
  margin: 2rem 0;
  counter-increment: figure;
}

.figure figcaption {
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.figure figcaption::before {
  content: "Fig. " counter(figure) " — ";
}

/* Wide runs edge to edge of the page, past the text column. */
.figure-wide {
  clear: both;
  width: 100vw;
  width: 100cqw;
  margin-left: calc(-1 * var(--gutter));
  border-block: var(--rule);
}

.figure-wide figcaption {
  margin: 0;
  padding: 0.5rem var(--gutter);
  border-top: var(--rule);
}

@media (min-width: 40rem) {
  .figure-left,
  .figure-right {
    width: 50%;
    margin-top: 0.4rem;
    margin-bottom: 1rem;
  }

  .figure-left {
    float: left;
    margin-right: 1.5rem;
  }

  .figure-right {
    float: right;
    margin-left: 1.5rem;
  }
}

/* Pager */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: var(--rule);
  border-bottom: var(--rule);
  font-family: var(--sans);
  font-weight: 900;
  font-size: clamp(1rem, 3vw, 2rem);
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.pager a {
  padding: 1.5rem var(--gutter);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.pager a:hover,
.pager a:focus-visible {
  background: var(--ink);
  color: var(--paper);
  outline: none;
}

.pager a[rel="next"] {
  grid-column: 2;
  border-left: var(--rule);
  text-align: right;
}

@media (max-width: 40rem) {
  body {
    font-size: 1.125rem;
  }

  .index a {
    grid-template-columns: 1fr auto;
    gap: 0.5rem 1rem;
    padding-block: 1.25rem;
  }

  .index-title {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
