/* Newsreader by Production Type, SIL Open Font License (fonts/OFL.txt). */
@font-face {
  font-family: "Newsreader Display";
  src: url("/fonts/nr-display.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}

@font-face {
  font-family: "Newsreader Text";
  src: url("/fonts/nr-text.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/*
 * Golden ratio (1.618) throughout. One size, --frame, drives the type:
 *   the changing word     frame x 1.618
 *   "Building", "for..."  frame
 *   supporting line       frame / 4.236   (ratio^3)
 *   wordmark, address     supporting / 1.272
 * The statement is centred with the changing word at the exact middle of the screen. The
 * picture (threads.js) fills the background and its wire passes through that word.
 */
:root {
  /* Space above the headline that balances everything below the word. */
  --balance: calc(var(--b) * 3.118);
}

/*
 */
@font-face {
  font-family: "Newsreader Display";
  src: url("/fonts/nr-italic.woff2") format("woff2");
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}

:root {
  --ink: #0b0c10;
  --paper: #f1efe9;
  --stone: #bdb8ae;
  --copper: #c47a48;
  --copper-light: #e3a374;

  --frame: min(5.6vw, 9.8vh);
  --word: calc(var(--frame) * 1.618);
  --b: max(1rem, calc(var(--frame) / 3.6));
  --utility: max(0.8125rem, calc(var(--b) / 1.272));
  --gutter: clamp(1.25rem, 4.5vw, 5rem);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* One screen: the statement over the picture. */
body {
  min-height: 100vh;
  min-height: 100svh;
  padding: 0 var(--gutter);
  color: var(--paper);
  font-family: "Newsreader Text", Georgia, "Times New Roman", serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Without the script: the copper wire, still, fading out as it passes the word. */
html:not(.has-stage) body::before {
  content: "";
  position: fixed;
  z-index: -1;
  top: 50%;
  right: 4%;
  left: 4%;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--copper) 12%, rgba(196, 122, 72, 0.08) 28%,
    rgba(196, 122, 72, 0.08) 72%, var(--copper) 88%, transparent);
}

/* Selected text sits on gold. The gold word would vanish into it, so it turns black. */
::selection {
  background: var(--copper-light);
  color: var(--ink);
}

.word::selection {
  background: var(--copper-light);
  color: #000;
  -webkit-text-fill-color: #000;
}

header {
  position: absolute;
  top: 0;
  right: var(--gutter);
  left: var(--gutter);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: calc(var(--b) * 1.272) 0 0;
}

.wordmark {
  font-size: var(--utility);
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

a {
  color: inherit;
  font-size: var(--utility);
  text-decoration: none;
  border-bottom: 1px solid rgba(241, 239, 233, 0.28);
  transition: border-color 0.3s ease;
}

a:hover {
  border-color: var(--copper);
}

a:focus-visible {
  outline: 1px solid var(--paper);
  outline-offset: 5px;
}

main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding-top: var(--balance);
  text-align: center;
}

h1 {
  font-family: "Newsreader Display", Georgia, "Times New Roman", serif;
  font-size: var(--frame);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.first,
.rest,
.slot {
  display: block;
}

.rest {
  text-wrap: balance;
}

/* The changing word has its own line, so "Building" never moves when it changes. */
.slot {
  font-size: var(--word);
  line-height: 1.1;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

/* True italic with a soft copper sheen. The padding keeps slanted letters and tails
   inside the painted area. */
.word {
  display: inline-block;
  padding: 0 0.12em 0.06em;
  color: var(--copper-light);
  font-style: italic;
  transition: opacity 0.5s cubic-bezier(0.45, 0, 0.25, 1), transform 0.5s cubic-bezier(0.45, 0, 0.25, 1);
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .word {
    background: linear-gradient(178deg, #f6d5bb 18%, #dc9d70 52%, #b8744a 82%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

.word.leaving {
  opacity: 0;
  transform: translateY(-0.06em);
}

.lede {
  margin-top: calc(var(--b) * 1.618);
  color: var(--stone);
  font-size: var(--b);
  line-height: 1.5;
  letter-spacing: 0.012em;
  text-wrap: balance;
}

/* Tall screens: sized by width, and the word steps down so "Infrastructure" fits. */
@media (max-aspect-ratio: 4/5) {
  :root {
    --frame: min(11vw, 7.2vh);
    --word: calc(var(--frame) * 1.272);
    --b: clamp(1rem, 4.6vw, 1.75rem);
    --gutter: clamp(1.25rem, 5vw, 3rem);
    /* Two lines each below the word. */
    --balance: calc(var(--frame) + var(--b) * 4.618);
  }

  .wordmark {
    letter-spacing: 0.22em;
  }
}

/* Phones held sideways. */
@media (max-height: 480px) {
  :root {
    --b: 0.9375rem;
  }

  header {
    padding-top: 0.75rem;
  }

  main {
    padding-top: 1.5rem;
  }

  .lede {
    margin-top: 0.4rem;
  }
}

@media (forced-colors: active) {
  .word {
    background: none;
    color: CanvasText;
  }
}

@media (prefers-reduced-motion: reduce) {
  a,
  .word {
    transition: none;
  }
}
