: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;
}

/* Muted colours for the words of a rant: brick, ochre, olive, teal, slate, plum. */
:root {
  --word-1: #9c4a3c;
  --word-2: #a17f2a;
  --word-3: #5f7046;
  --word-4: #3f6f73;
  --word-5: #4c5f8a;
  --word-6: #7d4f73;
}

/* Dark is a warm charcoal with off-white ink, not black and white. */
:root[data-theme="dark"] {
  --ink: #e6e2d9;
  --paper: #1d1c1a;
  --word-1: #d68f7e;
  --word-2: #d4b566;
  --word-3: #a5b588;
  --word-4: #82b3b3;
  --word-5: #97a9d0;
  --word-6: #c398b8;
}

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

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  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;
}

/* The rule above would otherwise show images that are marked hidden. */
[hidden] {
  display: none !important;
}

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

main {
  display: flex;
  flex: 1;
  flex-direction: column;
}

/* Masthead */

.masthead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.35rem 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;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 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-icon {
  width: 0.62em;
  height: 0.62em;
  margin-right: 0.12em;
  fill: currentColor;
}

.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;
  }
}

/* Gallery */

/* Columns of uncropped pictures, ruled off from each other. */
.gallery {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 3 18rem;
  column-gap: 0;
  column-rule: var(--rule);
}

.gallery li {
  break-inside: avoid;
  border-bottom: var(--rule);
}

.gallery a {
  display: block;
  text-decoration: none;
}

.gallery-meta,
.photo figcaption {
  display: flex;
  gap: 1rem;
  padding: 0.5rem var(--gutter);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gallery-meta {
  padding-inline: 0.75rem;
  border-top: var(--rule);
}

.gallery a:hover .gallery-meta,
.gallery a:focus-visible .gallery-meta {
  background: var(--ink);
  color: var(--paper);
}

.photo {
  margin: 0;
}

.photo img {
  max-height: calc(100vh - 9rem);
  object-fit: contain;
}

.photo figcaption {
  justify-content: space-between;
  border-top: var(--rule);
}

/* Rant */

/* Controls and progress on top; the stage takes whatever height is left. */
.rant {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.rant-bar {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem var(--gutter);
  font-family: var(--mono);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rant-bar h1 {
  flex: 1;
  margin: 0;
  overflow: hidden;
  font: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rant-play {
  min-width: 5.5em;
  padding: 0.35rem 0.75rem;
  border: var(--rule);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

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

.rant-progress {
  height: 1.5rem;
  border-block: var(--rule);
  cursor: pointer;
  touch-action: none;
}

.rant-progress div {
  width: 0;
  height: 100%;
  background: var(--ink);
}

.rant-stage {
  position: relative;
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 50vh;
  overflow: hidden;
  border-bottom: var(--rule);
  cursor: pointer;
}

.rant-word {
  font-family: var(--sans);
  font-weight: 900;
  line-height: 0.85;
  letter-spacing: -0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.rant-stage img {
  position: absolute;
  inset: 0;
  height: 100%;
  object-fit: cover;
}

/* 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;
  }
}
