/* All Else Unequal: the essay template. Chalk paper for the page, a chalkboard for every model
   plate, a sheet of paper for every data plate. Every passage carries its layer: Data, Model or
   Opinion. */

@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-italic-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-math.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
  unicode-range: U+2192, U+2260;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/plex-mono-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/plex-mono-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/plex-mono-math.woff2") format("woff2");
  font-weight: 400 500;
  font-display: swap;
  unicode-range: U+2192, U+2260;
}

:root {
  color-scheme: light;
  /* The palette (PRODUCT.md). */
  --tiza: #f5f2e8;
  --tiza-2: #efebdd;
  --linea: #d8d3c2;
  --pizarra: #12261f;
  --pizarra-media: #4a5c54;
  --pizarra-clara: #8a9a91;
  --bermellon: #f2401f;
  /* Chalk on the board: muted chalk, the board's own rules, and what lies down. */
  --chalk-dim: #a9b5ae;
  --board-rule: #2b3f37;
  --board-low: #3b5248;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  /* The type ramp (DESIGN.md). */
  --fs-display: clamp(2.75rem, 1.3rem + 6.4vw, 6rem);
  --fs-dek: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  --fs-headline: clamp(1.75rem, 1.2rem + 1.7vw, 2.5rem);
  --fs-title: clamp(1.375rem, 1rem + 1.25vw, 1.875rem);
  --fs-body: 1.25rem;
  --fs-caption: 1.0625rem;
  --fs-figure: clamp(2.25rem, 1.6rem + 2.2vw, 3.25rem);
  --fs-label: 0.8125rem;
  /* Text set on vermilion: a deeper pizarra, so it clears 4.5:1 (5:1) where pizarra gives 4.2:1. */
  --ink-on-red: #08130e;

  --pad: clamp(1.25rem, 4.5vw, 4rem);
  --gutter: 8.5rem;
  --gap: clamp(1.5rem, 3vw, 3rem);
  --measure: 33em;
  --page-max: 80rem;
  --vw: 100vw; /* the viewport without its scrollbar, set by aeu.js */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--tiza);
  color: var(--pizarra);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--pizarra-clara) var(--tiza);
  scroll-padding-top: 1.5rem;
}
body {
  margin: 0;
  overflow-x: clip; /* plates run edge to edge */
  background: var(--tiza);
  font: 400 1.1875rem/1.6 var(--serif);
  font-optical-sizing: auto;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--bermellon);
}
@media (min-width: 900px) {
  body { font-size: 1.25rem; }
}

::selection { background: var(--pizarra); color: var(--tiza); }
.board ::selection { background: var(--tiza); color: var(--pizarra); }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--pizarra-clara);
  transition: text-decoration-color 0.2s;
}
a:hover { text-decoration-color: currentColor; }
.board a { text-decoration-color: var(--board-low); }
.board a:hover { text-decoration-color: currentColor; }

:focus-visible { outline: 2px solid var(--pizarra); outline-offset: 3px; }
.board :focus-visible { outline-color: var(--tiza); }

.skip {
  position: absolute;
  left: var(--pad);
  top: -4rem;
  padding: 0.6rem 0.9rem;
  background: var(--pizarra);
  color: var(--tiza);
  font: 500 0.875rem/1 var(--mono);
  z-index: 10;
}
.skip:focus { top: 0.75rem; }

.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- page frame ---------- */

.page {
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--pad);
}

.strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-block: 1.1rem;
  border-bottom: 1px solid var(--linea);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font: 500 1.0625rem/1 var(--serif);
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
}
.brand svg { width: 1.75rem; height: 1.75rem; flex: none; }
.strip-meta {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font: 500 0.8125rem/1 var(--mono);
  letter-spacing: 0.02em;
  color: var(--pizarra-media);
}
.strip-meta a { text-decoration: none; color: var(--pizarra); }
.strip-meta a:hover { text-decoration: underline; text-decoration-color: currentColor; }

/* ---------- the opening ---------- */

.opening { padding-block: clamp(2.75rem, 9vw, 6.5rem) 0; }
.opening h1 {
  margin: 0;
  max-width: 11.5em;
  font-weight: 500;
  font-size: clamp(2.75rem, 1.3rem + 6.4vw, 6rem);
  line-height: 0.98;
  letter-spacing: -0.028em;
  text-wrap: balance;
}
.dek {
  margin: clamp(1rem, 2.5vw, 1.6rem) 0 0;
  max-width: 28em;
  font-style: italic;
  font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  line-height: 1.3;
  color: var(--pizarra-media);
  text-wrap: pretty;
}
.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin: clamp(1.5rem, 3vw, 2.25rem) 0 0;
  font: 400 0.8125rem/1.4 var(--mono);
  color: var(--pizarra-media);
}
.byline strong { font-weight: 500; color: var(--pizarra); }

/* ---------- the essay grid: a layer gutter, the text, and air ---------- */

.essay {
  display: grid;
  grid-template-columns: [gutter-start] var(--gutter) [text-start] minmax(0, var(--measure)) [text-end] minmax(0, 1fr) [full-end];
  column-gap: var(--gap);
}
.essay > * { grid-column: text-start / text-end; }
.essay > .plate,
.essay > .wide { grid-column: gutter-start / full-end; }

.essay h2 {
  margin: clamp(3.5rem, 8vw, 6rem) 0 0.7em;
  font-weight: 500;
  font-size: clamp(1.75rem, 1.2rem + 1.7vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.018em;
  text-wrap: balance;
}
.layer .body p,
.endmatter p { margin: 0 0 1em; text-wrap: pretty; hanging-punctuation: first; }
.essay .plate + h2 { margin-top: clamp(3rem, 7vw, 5rem); }

/* A passage and its layer, set in the gutter beside its first line, with a rule down its length. */
.layer {
  grid-column: gutter-start / text-end;
  display: grid;
  grid-template-columns: subgrid;
  margin-top: 0.35rem;
}
.layer + .layer { margin-top: 1.1rem; }
.layer > .tag {
  grid-column: gutter-start / text-start;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin: 0;
  padding-top: 0.42em;
  font: 500 0.6875rem/1.2 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--pizarra-media);
}
.layer > .tag::after {
  content: "";
  flex: 1;
  width: 1px;
  margin-top: 0.6rem;
  margin-bottom: 1.6rem;
  background: var(--linea);
}
.layer > .body { grid-column: text-start / text-end; }
.layer > .body > :last-child { margin-bottom: 0; }
.layer[data-layer="opinion"] > .body { font-style: italic; }
.layer[data-layer="opinion"] > .body em { font-style: normal; }

/* ---------- plates ---------- */

/* Every plate is a band from edge to edge of the screen, its content on the page's own column.
   A chalkboard differs from the page, so above and below it a gradient of small numerals (canvas,
   drawn by aeu.js) dissolves it into the paper. A paper plate is the page's own colour: no edge. */
.plate {
  --stip: 0px;
  --plate-gap: clamp(2.25rem, 5.5vw, 3.75rem);
  position: relative;
  width: var(--vw);
  margin: calc(var(--stip) + var(--plate-gap)) 0 calc(var(--stip) + var(--plate-gap)) calc(50% - var(--vw) / 2);
  padding-inline: max(var(--pad), calc((var(--vw) - var(--page-max)) / 2 + var(--pad)));
  scroll-margin-top: calc(var(--stip) + 1.5rem);
}
.sheet { position: relative; }
.board {
  --stip: clamp(40px, 4.5vw, 64px);
  --plate-gap: clamp(1.5rem, 4vw, 2.75rem);
  padding-block: clamp(1.25rem, 3vw, 2.25rem) 0.25rem;
  background: var(--pizarra);
  color: var(--tiza);
}
.paper { color: var(--pizarra); }
.stipple {
  position: absolute;
  left: 0;
  display: block;
  width: 100%;
  height: var(--stip);
  pointer-events: none;
}
.stipple.top { bottom: calc(100% - 1px); }
.stipple.bottom { top: calc(100% - 1px); }

.plate-head { max-width: 46rem; margin-bottom: clamp(1.25rem, 2.5vw, 2rem); }
/* A plate's title: an h2 when the plate opens the essay, an h3 inside a section. */
.essay .plate-head h3,
.essay .plate-head .plate-title {
  margin: 0;
  font-weight: 500;
  font-size: clamp(1.375rem, 1rem + 1.25vw, 1.875rem);
  line-height: 1.15;
  letter-spacing: -0.012em;
  text-wrap: balance;
}
.plate-no {
  display: inline-block;
  margin-right: 0.7em;
  font: 500 0.75rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 0.32em;
  color: var(--pizarra-media);
}
.board .plate-no { color: var(--chalk-dim); }
.plate-q {
  margin: 0.55rem 0 0;
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--pizarra-media);
  text-wrap: pretty;
}
.board .plate-q { color: var(--chalk-dim); }

/* The credits row: everything a teacher needs to lift the plate whole. */
.credits {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
  border-top: 1px solid var(--linea);
  font: 400 0.8125rem/1.35 var(--mono);
  color: var(--pizarra-media);
}
.credits > * {
  display: flex;
  align-items: center;
  padding: 0.7rem 0.95rem;
  border-left: 1px solid var(--linea);
}
.credits > :first-child { padding-left: 0; border-left: 0; }
.credits > .src { display: block; align-self: center; flex: 1 1 18rem; }
.credits a,
.credits button { color: var(--pizarra); }
.credits button {
  margin: 0;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--pizarra-clara);
}
.credits button:hover { text-decoration-color: currentColor; }
.credits button[aria-pressed="true"] { background: var(--pizarra); color: var(--tiza); text-decoration: none; }
.credits .done { color: var(--pizarra-media); text-decoration: none; }
.cite-out {
  margin: 0;
  padding: 0.8rem 0;
  border-top: 1px solid var(--linea);
  font: 400 0.8125rem/1.5 var(--mono);
  user-select: all;
}
/* On the chalkboard the credits are chalk. */
.board .credits { border-top-color: var(--board-rule); color: var(--chalk-dim); }
.board .credits > * { border-left-color: var(--board-rule); }
.board .credits a,
.board .credits button { color: var(--tiza); text-decoration-color: var(--board-low); }
.board .credits a:hover,
.board .credits button:hover { text-decoration-color: currentColor; }
.board .credits button[aria-pressed="true"] { background: var(--tiza); color: var(--pizarra); }
.board .credits .done { color: var(--chalk-dim); }
.board .cite-out { border-top-color: var(--board-rule); }

/* The table view: every plate's numbers, readable without the chart. */
.plate-table { margin-top: 1.5rem; overflow-x: auto; }
.plate-table[hidden] { display: none; }
.plate-table table {
  width: 100%;
  border-collapse: collapse;
  font: 400 0.875rem/1.4 var(--mono);
  font-variant-numeric: tabular-nums;
}
.plate-table caption {
  caption-side: top;
  padding-bottom: 0.6rem;
  text-align: left;
  font: italic 400 1rem/1.4 var(--serif);
  color: inherit;
}
.plate-table th,
.plate-table td { padding: 0.45rem 0.9rem 0.45rem 0; text-align: left; vertical-align: top; }
.plate-table th { font-weight: 500; }
.plate-table td.r,
.plate-table th.r { text-align: right; }
.plate-table tr { border-bottom: 1px solid var(--linea); }
.board .plate-table tr { border-bottom-color: var(--board-rule); }

/* ---------- charts ---------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.paper .chart .tick,
.paper .chart .axis-title { fill: var(--pizarra-media); }
.board .chart .tick,
.board .chart .axis-title { fill: var(--chalk-dim); }
.chart .halo { paint-order: stroke; stroke-width: 4px; stroke-linejoin: round; }
.paper .chart .halo { stroke: var(--tiza); }
.board .chart .halo { stroke: var(--pizarra); }
.paper .chart .grid { stroke: var(--linea); }
.board .chart .grid { stroke: var(--board-rule); }
.chart .grid { stroke-width: 1; shape-rendering: crispEdges; }
.chart .label { fill: currentColor; font-weight: 500; }
.chart .label-dim { fill: var(--pizarra-media); }
.board .chart .label-dim { fill: var(--chalk-dim); }

.tip {
  position: absolute;
  z-index: 3;
  max-width: 17rem;
  padding: 0.55rem 0.75rem;
  pointer-events: none;
  font: 400 0.8125rem/1.45 var(--mono);
  background: var(--pizarra);
  color: var(--tiza);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.12s, transform 0.12s;
}
.tip.on { opacity: 1; transform: none; }
.tip b { font-weight: 500; }
.board .tip { background: var(--tiza); color: var(--pizarra); }

/* ---------- controls on the board ---------- */

.range {
  display: block;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  touch-action: pan-y;
}
.range::-webkit-slider-runnable-track { height: 2px; background: var(--tiza); }
.range::-moz-range-track { height: 2px; background: var(--tiza); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -10px;
  border: 2px solid var(--tiza);
  border-radius: 50%;
  background: var(--pizarra);
  transition: transform 0.15s var(--ease-out);
}
.range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid var(--tiza);
  border-radius: 50%;
  background: var(--pizarra);
}
.range:active::-webkit-slider-thumb { transform: scale(1.15); }
/* Focus rings the thumb, not the whole track. */
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--pizarra), 0 0 0 5px var(--tiza); }
.range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--pizarra), 0 0 0 5px var(--tiza); }
.range:disabled { opacity: 0.35; cursor: default; }

.btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.55rem 1.05rem;
  border: 1px solid transparent;
  border-radius: 0;
  font: 500 1rem/1.2 var(--serif);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.btn-chalk { background: var(--tiza); color: var(--pizarra); }
.btn-chalk:hover { background: var(--chalk-dim); }
.btn-line { background: transparent; color: var(--tiza); border-color: var(--board-low); }
.btn-line:hover { border-color: var(--tiza); }
.btn-line[aria-pressed="true"] { background: var(--tiza); color: var(--pizarra); border-color: var(--tiza); }
.btn .mono { font-size: 0.875rem; font-weight: 500; }

/* ---------- the end matter ---------- */

.endmatter h2 { font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2rem); }
.endmatter h3 {
  margin: 1.8em 0 0.4em;
  font: 500 1.0625rem/1.3 var(--serif);
}
.endmatter p,
.endmatter li { font-size: 1.0625rem; line-height: 1.55; }
.endmatter ul { margin: 0 0 1em; padding-left: 1.1em; }
.endmatter li { margin-bottom: 0.45em; }
.endmatter li::marker { color: var(--pizarra-clara); }

.cite-block {
  margin: 0 0 1rem;
  padding: 1rem 1.1rem;
  background: var(--tiza-2);
  font: 400 0.8125rem/1.55 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.copy {
  margin: 0 0 1.75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--pizarra);
  font: 500 0.8125rem/1 var(--mono);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--pizarra-clara);
}
.copy:hover { text-decoration-color: currentColor; }

.files { list-style: none; padding: 0 !important; border-top: 1px solid var(--linea); }
.files li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.2rem 1rem;
  margin: 0 !important;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--linea);
}
.files a { font: 500 0.875rem/1.4 var(--mono); }
.files span { grid-column: 1 / -1; font-size: 1rem; color: var(--pizarra-media); }

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem 2rem;
  margin-top: clamp(4rem, 9vw, 7rem);
  padding-block: 1.75rem 2.5rem;
  border-top: 1px solid var(--linea);
  font: 400 0.8125rem/1.5 var(--mono);
  color: var(--pizarra-media);
}
.foot .brand { color: var(--pizarra); }
.foot nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
.foot nav a { color: var(--pizarra); }

/* ---------- narrow screens ---------- */

@media (max-width: 899px) {
  .essay { grid-template-columns: [gutter-start text-start] minmax(0, 1fr) [text-end full-end]; column-gap: 0; }
  .layer { display: block; }
  .layer > .tag {
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
    padding: 0;
    margin-bottom: 0.45rem;
  }
  .layer > .tag::after { flex: none; width: 1.75rem; height: 1px; margin: 0; }
  /* On a phone: the source and its date as one block, then one row of actions. */
  .credits { font-size: 0.78rem; }
  .credits > * { padding: 0.7rem 0.75rem; }
  .credits > .src { flex-basis: 100%; padding: 0.8rem 0 0.15rem; }
  .credits > .when { flex-basis: 100%; padding: 0 0 0.8rem; border-left: 0; border-bottom: 1px solid var(--linea); }
  .board .credits > .when { border-bottom-color: var(--board-rule); }
  .credits > .when + * { padding-left: 0; border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { transition-duration: 0.01ms !important; transition-delay: 0s !important; animation-duration: 0.01ms !important; }
}

@media print {
  .strip-meta,
  .credits button,
  .copy,
  .skip { display: none; }
  .board { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
