/* Type system.
   The system is the classes .type-0 to .type-small: each is one set of size, line height and spacing,
   for any text element. Tags carry no size; the element only decides the font.
   Names are ranks: 0 is the largest step, base is body text.
   Every step has a landscape (desktop) and a portrait (mobile) size; the active one switches at 1:1. */

:root {
  /* Sizes, landscape rule: scale x 1.7 from 1rem, rounded. */
  --type-0-landscape: 14rem;
  --type-1-landscape: 8.5rem;
  --type-2-landscape: 5rem;
  --type-3-landscape: 3rem;
  --type-4-landscape: 1.7rem;
  --type-base-landscape: 1rem;
  --type-small-landscape: 0.75rem;

  /* Sizes, portrait rule. */
  --type-0-portrait: 5.5rem;
  --type-1-portrait: 4rem;
  --type-2-portrait: 3rem;
  --type-3-portrait: 2rem;
  --type-4-portrait: 1.25rem;
  --type-base-portrait: 1rem;
  --type-small-portrait: 0.75rem;

  /* Line heights, both rules. */
  --type-0-lh: 0.9;
  --type-1-lh: 0.925;
  --type-2-lh: 0.95;
  --type-3-lh: 0.975;
  --type-4-lh: 1;
  --type-base-lh: 1.5;
  --type-small-lh: 1.5;

  /* Active sizes. */
  --type-0: var(--type-0-landscape);
  --type-1: var(--type-1-landscape);
  --type-2: var(--type-2-landscape);
  --type-3: var(--type-3-landscape);
  --type-4: var(--type-4-landscape);
  --type-base: var(--type-base-landscape);
  --type-small: var(--type-small-landscape);
}

@media (orientation: portrait) {
  :root {
    --type-0: var(--type-0-portrait);
    --type-1: var(--type-1-portrait);
    --type-2: var(--type-2-portrait);
    --type-3: var(--type-3-portrait);
    --type-4: var(--type-4-portrait);
    --type-base: var(--type-base-portrait);
    --type-small: var(--type-small-portrait);
  }
}

/* Steps: size and line height. */
.type-0     { font-size: var(--type-0);     line-height: var(--type-0-lh); }
.type-1     { font-size: var(--type-1);     line-height: var(--type-1-lh); }
.type-2     { font-size: var(--type-2);     line-height: var(--type-2-lh); }
.type-3     { font-size: var(--type-3);     line-height: var(--type-3-lh); }
.type-4     { font-size: var(--type-4);     line-height: var(--type-4-lh); }
.type-base  { font-size: var(--type-base);  line-height: var(--type-base-lh); }
.type-small { font-size: var(--type-small); line-height: var(--type-small-lh); }

/* Spacing: every text carries its space before (top) and after (bottom). Stacked in normal flow the two margins
   collapse through any nesting, so the larger one applies. Headline steps: before size x 1.7, after size x 0.5.
   Text steps: both size x 0.5, type-small x 2/3 (0.5rem). Column blocks take them over at their edges (site.css). */
:root {
  --type-0-before: calc(var(--type-0) * 1.7);
  --type-0-after: calc(var(--type-0) * 0.5);
  --type-1-before: calc(var(--type-1) * 1.7);
  --type-1-after: calc(var(--type-1) * 0.5);
  --type-2-before: calc(var(--type-2) * 1.7);
  --type-2-after: calc(var(--type-2) * 0.5);
  --type-3-before: calc(var(--type-3) * 1.7);
  --type-3-after: calc(var(--type-3) * 0.5);
  --type-4-before: calc(var(--type-4) * 1.7);
  --type-4-after: calc(var(--type-4) * 0.5);
  --type-base-before: calc(var(--type-base) * 0.5);
  --type-base-after: calc(var(--type-base) * 0.5);
  --type-small-before: calc(var(--type-small) * 2 / 3);
  --type-small-after: calc(var(--type-small) * 2 / 3);
}
.type-0     { margin-block: var(--type-0-before) var(--type-0-after); }
.type-1     { margin-block: var(--type-1-before) var(--type-1-after); }
.type-2     { margin-block: var(--type-2-before) var(--type-2-after); }
.type-3     { margin-block: var(--type-3-before) var(--type-3-after); }
.type-4     { margin-block: var(--type-4-before) var(--type-4-after); }
.type-base  { margin-block: var(--type-base-before) var(--type-base-after); }
.type-small { margin-block: var(--type-small-before) var(--type-small-after); }
