/*
 * One typeface, one weight, one size. Hierarchy comes from where a thing sits on the grid: the left
 * quarter says when and who, the rest says what, and every level of reply moves one fixed step right.
 * Grey is for what you can skip; red is for what the pointer is on.
 */

@font-face {
  font-family: "Helvetica Now Display";
  src: url("/fonts/HelveticaNowDisplayMedium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --ink: #0a0a0a;
  --mute: #6b6b6b;
  --rule: #d6d6d6;
  --red: #e00b00;
  --gutter: 12px;
  --size: 17px;
  --lead: 1.38;
  /* On a phone a reply steps in by one gutter; deeper than six, the stairs stop. */
  --step: var(--gutter);
  --dmax: 6;
}

@media (min-width: 768px) {
  :root {
    --gutter: 16px;
    --size: 18px;
    /* Five steps leave four of the nine body columns for the words. */
    --dmax: 5;
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: var(--size);
  font-synthesis-weight: none;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 2rem;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: "Helvetica Now Display", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  line-height: var(--lead);
  letter-spacing: 0.01em;
  text-rendering: optimizeLegibility;
}

main {
  flex: 1;
}

h1,
h2,
h3,
b,
strong,
th {
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--red);
}

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

.grid12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* Header and footer: a hairline, a name, a few words. */
.bar {
  padding-top: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.bar .name {
  grid-column: span 3;
}

.bar nav {
  grid-column: span 9;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  column-gap: 0.75rem;
}

.bar a[aria-current="page"],
.tabs a[aria-current="page"] {
  color: var(--red);
}

.foot {
  border-bottom: 0;
  border-top: 1px solid var(--rule);
  padding-top: 0.5rem;
  padding-bottom: 0.75rem;
  color: var(--mute);
}

.foot p {
  grid-column: span 12;
}

.foot a,
.prose a,
.said a,
.lede a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

/* A row: register on the left, speech on the right, a hairline above. */
.row {
  padding-top: 0.25lh;
  padding-bottom: 1lh;
  border-top: 1px solid var(--rule);
}

main > .row:first-child,
#stream > .row:first-child {
  border-top: 0;
}

.reg {
  grid-column: span 12;
  color: var(--mute);
  font-variant-numeric: lining-nums tabular-nums;
  overflow-wrap: anywhere;
}

.reg br {
  display: none;
}

.reg .who::before {
  content: " ";
}

.body {
  grid-column: span 12;
  min-width: 0;
}

.where,
.sep,
.lede,
.was,
.day {
  color: var(--mute);
}

.where a {
  color: var(--ink);
}

.where a:hover {
  color: var(--red);
}

/* The fixed step. A class carries the level of the reply (d0…d12); the stairs stop at --dmax. */
.d1 {
  --d: 1;
}

.d2 {
  --d: 2;
}

.d3 {
  --d: 3;
}

.d4 {
  --d: 4;
}

.d5 {
  --d: 5;
}

.d6 {
  --d: 6;
}

.d7 {
  --d: 7;
}

.d8 {
  --d: 8;
}

.d9 {
  --d: 9;
}

.d10 {
  --d: 10;
}

.d11 {
  --d: 11;
}

.d12 {
  --d: 12;
}

.said {
  padding-left: calc(min(var(--d, 0), var(--dmax)) * var(--step));
  overflow-wrap: anywhere;
  hyphens: auto;
}

.said p + p,
.said p + ul,
.said p + ol,
.said p + dl,
.said ul + p,
.said ol + p,
.said dl + p,
.said blockquote + p,
.said p + blockquote,
.prose p + p {
  margin-top: 0.5lh;
}

.said ul,
.said ol,
.said dl {
  margin: 0;
  padding-left: 1.25em;
}

.said dd {
  margin-left: 0;
}

.said blockquote {
  margin: 0;
  padding-left: 1.25em;
  color: var(--mute);
}

.said pre,
.said code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  font-weight: 400;
  letter-spacing: 0;
}

.said pre {
  margin: 0.5lh 0;
  white-space: pre-wrap;
}

.said sup,
.said sub {
  font-size: 0.7em;
  line-height: 0;
}

.said small {
  font-size: inherit;
  color: var(--mute);
}

/* The comment being answered: grey, three lines at most. */
.was {
  margin-bottom: 0.25lh;
}

.was a {
  text-decoration: none;
}

.clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.clamp p,
.clamp ul,
.clamp ol,
.clamp dl,
.clamp blockquote {
  display: inline;
  margin: 0;
  padding: 0;
}

.clamp li,
.clamp dd {
  display: inline;
}

/* Inside a thread only a new top-level comment gets a hairline; replies sit under it. */
.thread .row {
  border-top: 0;
  padding-top: 0;
  padding-bottom: 0.75lh;
}

.thread .row.top {
  border-top: 1px solid var(--rule);
  padding-top: 0.25lh;
}

.thread .row.tight {
  padding-bottom: 0.25lh;
}

.thread .row.head {
  border-top: 1px solid var(--rule);
  padding-top: 0.25lh;
  padding-bottom: 0.5lh;
  margin-top: 0.75lh;
}

.thread .row:target .said {
  color: var(--red);
}

.no::after {
  content: ".";
}

.lede {
  margin-top: 0.5lh;
  max-width: 44em;
}

.tabs {
  margin-top: 0.5lh;
  display: flex;
  column-gap: 0.75rem;
}

.prose {
  max-width: 44em;
}

.more {
  padding-bottom: 1.5lh;
}

/* A comment that has just arrived: red until the eye has had it. */
.row.new .where a {
  color: var(--red);
}

@media (min-width: 768px) {
  :root {
    /* One column of the page grid plus its gutter: the body spans nine of twelve columns. */
    --step: calc((100% + var(--gutter)) / 9);
  }

  .bar .name {
    grid-column: span 3;
  }

  .bar nav {
    grid-column: span 9;
    justify-content: flex-start;
    column-gap: 1rem;
  }

  .foot .f1 {
    grid-column: span 3;
  }

  .foot .f2 {
    grid-column: span 6;
  }

  .foot .f3 {
    grid-column: span 3;
    text-align: right;
  }

  .reg {
    grid-column: span 3;
  }

  .reg br {
    display: inline;
  }

  .reg .who::before {
    content: none;
  }

  .body {
    grid-column: span 9;
  }

  .said > *,
  .where,
  .body > h1,
  .body > h2 {
    max-width: 38em;
  }
}
