/* Onnum. One stylesheet, one typeface, no scripts. */

@font-face {
  font-family: 'Hanken Grotesk';
  src: url('/fonts/hanken-grotesk-latin-v1.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

/* Arial resized to Hanken's metrics, so nothing moves when the font arrives. */
@font-face {
  font-family: 'Hanken Fallback';
  src: local('Arial'), local('Helvetica Neue'), local('Helvetica');
  size-adjust: 102.25%;
  ascent-override: 97.8%;
  descent-override: 29.63%;
  line-gap-override: 0%;
}

:root {
  color-scheme: light dark;
  --bg: #fff;
  --fg: #000;
  --dim: #757575;
  --margin: clamp(1.25rem, 3.1vw, 2.75rem);

  /*
    Type size. Everything else (the smaller text, the wrap width, the gaps) is
    derived from --large, so the composition scales as one piece.

    --large-w  follows the window's width, between a floor (phones) and a
               ceiling (wide windows).
    --pad-v    the least space above and below the text block.
    --fit-h    the largest size at which the home page fits the window's height
               without scrolling. --room is the height left for the text block
               (the window less the margins, the logo, the footer line and the
               space above and below), and 16.3 is that block's height in ems
               of the large size,
               measured with the home page's current copy: re-measure if the
               copy gets longer or shorter. It stops at 1.875rem; a window too
               short for that scrolls instead of shrinking the type further.
    --large    the width-based size, shrunk to fit a short window. It never
               grows past --large-w.
    --mid      the smaller text: always half of --large on desktop, so both
               sizes wrap at the same width.
  */
  --pad-v: clamp(2.5rem, 6vh, 4.5rem);
  --large-w: clamp(1.5rem, 0.765rem + 1.935vw, 2.925rem);
  --room: calc(100vh - 2 * var(--margin) - 2.8125rem - 2 * var(--pad-v));
  --fit-h: max(1.875rem, calc(var(--room) / 16.3));
  --large: min(var(--large-w), var(--fit-h));
  --mid: calc(var(--large) * 0.5);
  --measure: calc(var(--large) * 25);

  /*
    Vertical spacing, measured as the eye sees it: from the baseline of one
    paragraph to the top of the capitals of the next. Each line box holds some
    space above its capitals and below its baseline (line-height / 2 - 0.3485,
    in ems, for this typeface), so the margins subtract that.

    --gap       between the two large statements
    --gap-tier  between the large statements and the smaller text below them
    The smaller paragraphs are separated by their own font size (1em).
  */
  --gap: max(1.75rem, calc(var(--large) * 1.04));
  --gap-tier: calc(var(--gap) * 1.45);
  --inset-large: calc(var(--large) * 0.2215); /* line-height 1.14 */
  --inset-mid: calc(var(--mid) * 0.3115); /* line-height 1.32 */
}

/*
  Keep the page margin on a whole pixel. The wordmark is drawn on a pixel grid,
  and it only stays crisp if it starts on one.
*/
@supports (width: round(down, 1.5px, 1px)) {
  :root {
    --margin: clamp(1.25rem, round(down, 3.1vw, 1px), 2.75rem);
  }
}

/* On narrow windows the smaller text keeps a readable minimum. */
@media (max-width: 56rem) {
  :root {
    --mid: max(1.125rem, calc(var(--large) * 0.5));
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --fg: #fff;
    --dim: #8f8f8f;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font:
    400 0.9375rem/1.4 'Hanken Grotesk',
    'Hanken Fallback',
    'Helvetica Neue',
    Helvetica,
    Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

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

a:hover {
  text-decoration: none;
}

a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

p {
  margin: 0;
}

/* Page frame: wordmark at the top, statement in the middle, small print at the bottom. */

.page {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100svh;
  padding: var(--margin);
}

.top a {
  display: block;
  width: max-content;
}

.mark {
  display: block;
  width: auto;
  height: 1.5rem;
}

/*
  The text block sits midway between the logo and the footer link. The bottom
  padding is adjusted so the two gaps are equal as seen: logo to the top of the
  first line's capitals, and the last line's baseline to the top of the footer
  link's capitals (0.33rem is the space above the capitals in the footer line).
*/
main {
  align-self: center;
  padding: var(--pad-v) 0 calc(var(--pad-v) + var(--inset-large) - var(--inset-mid) - 0.33rem);
}

/* Large: the two things to remember. The first runs on into a grey sentence. */

.statement {
  max-width: var(--measure);
  margin-left: -0.03em;
  font-size: var(--large);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -0.02em;
  text-wrap: pretty;
}

.statement h1,
.statement p {
  display: inline;
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
}

.statement p,
.statement span,
.quiet {
  color: var(--dim);
}

.offer {
  margin-top: calc(var(--gap) - 2 * var(--inset-large));
}

/* Middle: everything else, half the size, same left edge and same width. */

.support,
.prose {
  max-width: var(--measure);
  margin-top: calc(var(--gap-tier) - var(--inset-large) - var(--inset-mid));
  font-size: var(--mid);
  line-height: 1.32;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

.support {
  color: var(--dim);
}

.support p + p,
.prose p + p {
  margin-top: 1em;
}

.support .go {
  color: var(--fg);
}

.support a,
.prose a {
  white-space: nowrap;
}

/* Small print */

.notes {
  display: flex;
  align-items: flex-end;
  gap: 2rem;
}

/* Privacy and 404 */

@media print {
  :root {
    --bg: #fff;
    --fg: #000;
    --dim: #555;
  }

  .page {
    min-height: 0;
  }
}
