/* rbcpa.ai.
   A short letter on stationery.
   One stylesheet for the landing page (main.home) and the reading pages (main.page). */


/* Fonts. Two variable files, latin subset, upright only. */

@font-face {
  font-family: "Besley";
  src: url("fonts/besley-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  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: "Libre Franklin";
  src: url("fonts/libre-franklin-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  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;
}


/* Tokens */

:root {
  color-scheme: light;

  --paper: #F7F4EE;
  --ink: #161511;
  --hairline: #E7E1D6;
  --rust: #B2451F;

  --clarendon: "Besley", Georgia, "Times New Roman", serif;
  --franklin: "Libre Franklin", "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* Text sizes: 16, 18 and 21px. The two h1 sizes are set where they are used. */
  --small: 1rem;
  --body: 1.125rem;
  --large: 1.3125rem;

  /* One line of body text, 18px on 27px. All vertical space is counted in lines. */
  --line: 1.6875rem;

  /* The sheet: a 44rem column that sits left of center, with a 33rem measure for running text. */
  --column: 44rem;
  --measure: 33rem;
  --gutter-start: clamp(1.25rem, 10vw - 1.25rem, 9rem);
  --gutter-end: clamp(1.25rem, 5vw, 4rem);

  /* Space between the parts of the letter: two lines on a phone, three on a desk. */
  --between: clamp(var(--line) * 2, var(--line) * 1.5 + 4vw, var(--line) * 3);

  /* Space from a hairline down to the text under it. Less the 1px of the rule itself. */
  --under-rule: calc(var(--line) * 0.7 - 1px);
}


/* Base */

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

html {
  background: var(--paper);
  /* The whole sheet is set in rem, so it grows a little on wide monitors: 16px up to 1440, 20px from about 2300. */
  font-size: clamp(100%, 0.6rem + 0.45vw, 125%);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0 var(--gutter-end) 0 var(--gutter-start);
  color: var(--ink);
  font-family: var(--franklin);
  font-size: var(--body);
  font-weight: 400;
  line-height: 1.5;
  overflow-wrap: break-word;
  /* The footer rests at the foot of the window when the letter is shorter than the screen. */
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

main {
  flex: 1 0 auto;
}

h1 {
  /* The small outdent lines the heavy stems up with the text below. */
  margin: 0 0 0.5em -0.025em;
  font-family: var(--clarendon);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h2 {
  margin: 0;
  font-family: var(--clarendon);
  font-size: var(--large);
  font-weight: 500;
  line-height: var(--line);
  text-wrap: balance;
}

p,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0 0 0 1.25em;
}

p,
ul,
ol {
  max-width: var(--measure);
}

p,
dd,
li {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 3px;
}

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


/* Letterhead, sheet and footer. Shared by every page. */

.masthead,
main,
.colophon {
  max-width: var(--column);
}

.masthead {
  display: flex;
  padding-top: clamp(var(--line), 5vw, var(--line) * 2);
}

.wordmark {
  font-family: var(--clarendon);
  font-size: var(--large);
  font-weight: 500;
  line-height: var(--line);
  text-decoration-line: none;
}

.wordmark:hover {
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
}

/* Empty paper above the heading. On a desk the h1 starts about a fifth of the way down the window. */
main {
  padding-top: clamp(var(--line) * 2, 20vh - var(--line) * 3, var(--line) * 6);
}

.colophon {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  column-gap: var(--line);
  margin-top: calc(var(--between) * 1.5);
  padding: var(--under-rule) 0 calc(var(--line) * 2);
  border-top: 1px solid var(--hairline);
  font-size: var(--small);
  line-height: var(--line);
}

.colophon nav {
  display: flex;
  column-gap: 1.5rem;
}


/* Landing page: a short letter. */

/* Two lines on a desk, three on a phone. */
.home h1 {
  max-width: 14em;
  margin-bottom: 0.65em;
  font-size: clamp(2.25rem, 1.35rem + 2.9vw, 3.25rem);
  line-height: 1.1;
}

.home p {
  max-width: 27em;
  font-size: var(--large);
}

.home p + p {
  margin-top: var(--line);
}

.home .signature {
  margin-top: calc(var(--line) * 2);
  font-size: var(--body);
}


/* Reading pages: privacy, terms, 404 */

.page h1 {
  font-size: clamp(2.25rem, 1.5rem + 3.3vw, 3rem);
}

.updated {
  font-size: var(--small);
  line-height: var(--line);
}

.page > * + * {
  margin-top: var(--line);
}

.page > h2 {
  margin-top: calc(var(--line) * 2);
}

.page > h2 + *,
.page > p + ul,
.page > p + ol {
  margin-top: calc(var(--line) * 0.5);
}

/* The h1 carries its own space below. */
.page > h1 + * {
  margin-top: 0;
}

.page > .updated + * {
  margin-top: calc(var(--line) * 2);
}

.page li + li {
  margin-top: calc(var(--line) * 0.5);
}
