/* Critical styles: everything the first section needs. Block styles load with their blocks. */

:root {
  /* One colour per release state. Text is always the artifact colour or the sheet colour. */
  --color-live: #2ec4b6;
  --color-preview: #ff9f1c;
  --color-rollback: #e71d36;
  --color-artifact: #011627;
  --color-sheet: #fdfffc;

  --heading-font-family: "Inter Tight", "Helvetica Neue", arial, sans-serif;
  --body-font-family: "Inter Tight", "Helvetica Neue", arial, sans-serif;
  --fixed-font-family: "JetBrains Mono", ui-monospace, menlo, monospace;

  --heading-font-size-xxl: clamp(46px, 7.8vw, 112px);
  --heading-font-size-xl: clamp(34px, 4.4vw, 64px);
  --heading-font-size-l: clamp(30px, 3vw, 40px);
  --heading-font-size-m: 26px;
  --body-font-size-l: clamp(19px, 1.6vw, 22px);
  --body-font-size-m: clamp(18px, 1.4vw, 20px);
  --body-font-size-s: 16px;
  --fixed-font-size: 14px;
  --fixed-font-size-s: 13px;

  --display-line-height: 0.88;
  --heading-line-height: 0.92;
  --body-line-height: 1.35;
  --display-tracking: -0.03em;
  --body-opacity: 86%;

  --content-width: 1240px;
  --page-padding: clamp(20px, 7vw, 100px);
  --page-inline: max(var(--page-padding), calc((100% - var(--content-width)) / 2));
  --section-padding: clamp(64px, 7.2vw, 104px);
  --rule: 1px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* The docs are for reading, so they use a smaller scale than the home page. */
body.docs {
  --heading-font-size-xxl: clamp(46px, 6.6vw, 96px);
  --heading-font-size-xl: clamp(32px, 3.4vw, 48px);
  --heading-font-size-m: 22px;
  --heading-line-height: 0.98;
  --body-line-height: 1.4;
  --section-padding: clamp(56px, 6.6vw, 96px);
}

/* Web fonts, preloaded by head.html. The page is shown once they're ready. */
@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/inter-tight-400.woff2") format("woff2");
}

@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/inter-tight-500.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-400.woff2") format("woff2");
}

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

html {
  background-color: var(--color-sheet);
  scroll-padding-top: 24px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  --fg: var(--color-artifact);

  margin: 0;
  color: var(--fg);
  font-family: var(--body-font-family);
  font-size: var(--body-font-size-m);
  line-height: var(--body-line-height);
  -webkit-font-smoothing: antialiased;
}

/*
 * Hide the page until scripts.js has built and loaded it, so it appears complete in one step rather
 * than in stages. If scripts cannot run, such as on a shared platform host, it appears after a
 * short delay instead.
 */
body:not(.ready) :is(header, main, footer) {
  visibility: hidden;
  animation: fold-reveal 0s 1.5s forwards;
}

@keyframes fold-reveal {
  to {
    visibility: visible;
  }
}

header {
  min-height: 64px;
}

footer {
  min-height: 152px;
  background-color: var(--color-artifact);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--heading-font-family);
  font-weight: 500;
  letter-spacing: var(--display-tracking);
}

h1 {
  padding-bottom: 0.06em;
  font-size: var(--heading-font-size-xxl);
  line-height: var(--display-line-height);
}

/* Italics in the page heading mark its second, quieter sentence. */
h1 em {
  color: color-mix(in srgb, var(--fg) 58%, transparent);
  font-style: normal;
}

h2 {
  max-width: 20ch;
  font-size: var(--heading-font-size-xl);
  line-height: var(--heading-line-height);
  text-wrap: balance;
}

h3 {
  font-size: var(--heading-font-size-m);
  line-height: 1.1;
  letter-spacing: -0.015em;
}

p,
ul,
ol {
  margin: 0;
}

p {
  color: color-mix(in srgb, var(--fg) var(--body-opacity), transparent);
}

code,
pre {
  font-family: var(--fixed-font-family);
  font-size: var(--fixed-font-size);
  letter-spacing: 0.02em;
}

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

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

:focus-visible {
  outline: 3px solid var(--fg);
  outline-offset: 4px;
}

::selection {
  background-color: var(--color-artifact);
  color: var(--color-sheet);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* The one button on a page: a link alone in its paragraph, in bold. */
a.button:any-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  background-color: var(--color-artifact);
  color: var(--color-sheet);
  font-family: var(--heading-font-family);
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.03em;
  text-decoration: none;
}

a.button:hover {
  background-color: var(--color-sheet);
  box-shadow: inset 0 0 0 2px var(--color-artifact);
  color: var(--color-artifact);
}

a.button:active {
  transform: translateY(1px);
}

@media (prefers-reduced-motion: no-preference) {
  a.button:any-link {
    transition:
      background-color 0.18s var(--ease),
      color 0.18s var(--ease),
      box-shadow 0.18s var(--ease);
  }
}

/* Sections: each sits on one flat colour and runs the full width of the page. */
main > .section {
  padding: var(--section-padding) var(--page-inline);
}

main > .section:not([data-state="loaded"]) {
  display: none;
}

main > .section.live {
  background-color: var(--color-live);
}

main > .section.preview {
  background-color: var(--color-preview);
}

main > .section.artifact {
  --fg: var(--color-sheet);

  background-color: var(--color-artifact);
  color: var(--fg);
}

main > .section.artifact ::selection {
  background-color: var(--color-sheet);
  color: var(--color-artifact);
}

main > .section h2 + p {
  max-width: 46ch;
  margin-top: 16px;
}

/* The first section holds the page heading, one sentence and the page's button. */
main > .section:first-child {
  padding-block: clamp(56px, 8.4vw, 120px) clamp(64px, 7.8vw, 112px);
}

main > .section:first-child h1 + p {
  max-width: 38ch;
  margin-block: clamp(28px, 3vw, 44px) clamp(28px, 2.5vw, 36px);
  font-size: var(--body-font-size-l);
  line-height: 1.3;
}

body.docs main > .section:first-child {
  padding-block: clamp(48px, 6.2vw, 88px) clamp(56px, 6.6vw, 96px);
}

body.docs main > .section:first-child h1 + p {
  max-width: 40ch;
  margin-block: 32px 36px;
  font-size: clamp(20px, 1.7vw, 24px);
}

/* Split: the heading stays in view on the left while the blocks on the right are read. */
@media (width >= 900px) {
  main > .section.split {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 72px;
    align-items: start;
  }

  main > .section.split > .section-content {
    position: sticky;
    top: 48px;
  }
}

main > .section.split h2 + p {
  max-width: 30ch;
  margin-block: 32px;
}

/* Tasks: each heading, its sentence and its list of topics form one ruled row. */
main > .section.tasks {
  padding-top: 40px;
}

main > .section.tasks ul,
main > .section.topics-inline ul {
  padding: 0;
  font-size: 18px;
  line-height: 1.3;
  list-style: none;
}

main > .section.tasks li {
  margin-bottom: 8px;
}

main > .section.tasks h2 {
  max-width: none;
  padding-top: 40px;
  font-size: var(--heading-font-size-l);
}

main > .section.tasks h2 + p {
  max-width: none;
  margin-block: 12px 20px;
}

main > .section.tasks ul {
  padding-bottom: 36px;
  border-bottom: var(--rule) solid var(--fg);
}

@media (width >= 900px) {
  main > .section.tasks > .section-content {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 4fr) minmax(0, 3fr);
  }

  main > .section.tasks :is(h2, h2 + p, ul) {
    margin: 0;
    padding-block: 40px 44px;
    border-bottom: var(--rule) solid var(--fg);
  }

  main > .section.tasks h2 {
    padding-right: max(48px, calc(100% - 12ch));
  }

  main > .section.tasks h2 + p {
    padding-right: max(48px, calc(100% - 34ch));
  }
}

/* Topics inline: a list after the section's blocks runs across the page. */
main > .section.topics-inline ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  margin-top: 28px;
}

/* Closing: the page's action again, as a large link. */
main > .section.closing h2 {
  max-width: none;
}

main > .section.closing h2 a {
  display: inline-flex;
  align-items: center;
  gap: 0.28em;
  line-height: 0.9;
  text-decoration-thickness: 4px;
  text-underline-offset: 0.14em;
}

main > .section.closing h2 a::before {
  flex: none;
  width: 1.05em;
  height: 0.42em;
  background-color: currentcolor;
  clip-path: polygon(
    0 0,
    33.3% 50%,
    33.3% 0,
    66.6% 50%,
    66.6% 0,
    100% 50%,
    66.6% 100%,
    66.6% 50%,
    33.3% 100%,
    33.3% 50%,
    0 100%
  );
  content: "";
}

main > .section.closing h2 + p {
  margin-top: 28px;
  font-family: var(--fixed-font-family);
  font-size: var(--fixed-font-size);
  letter-spacing: 0.04em;
}

@media (prefers-reduced-motion: no-preference) {
  main > .section.closing h2 a::before {
    transition: transform 0.25s var(--ease);
  }

  main > .section.closing h2 a:hover::before {
    transform: translateX(0.12em);
  }
}

/* A paragraph after a section's blocks holds a link onward. */
main > .section > div:not(.section-content) + .section-content > p:only-child {
  margin-top: clamp(32px, 3.4vw, 48px);
  font-weight: 500;
}

/* Articles: docs pages for reading, in one column. */
body.article {
  --heading-font-size-xxl: clamp(38px, 4.6vw, 64px);
  --heading-font-size-xl: clamp(26px, 2.4vw, 32px);
  --display-line-height: 0.96;
  --heading-line-height: 1.05;
  --body-font-size-m: 18px;
  --body-line-height: 1.5;
}

body.article main > .section:first-child {
  padding-block: clamp(40px, 5vw, 72px) var(--section-padding);
}

body.article main > .section > .section-content {
  max-width: 44rem;
}

body.article main > .section:first-child h1 + p {
  max-width: none;
  margin-block: 28px 0;
  font-size: clamp(19px, 1.6vw, 22px);
  line-height: 1.4;
}

body.article main h2 {
  max-width: none;
  margin-block: 56px 16px;
  padding-top: 20px;
  border-top: var(--rule) solid var(--fg);
  text-wrap: pretty;
}

body.article main h2 + p {
  max-width: none;
  margin-top: 0;
}

body.article main :is(p, ul, ol, pre, table) + :is(p, ul, ol, pre, table) {
  margin-top: 18px;
}

body.article main :is(ul, ol) {
  padding-left: 1.2em;
}

body.article main li {
  color: color-mix(in srgb, var(--fg) var(--body-opacity), transparent);
}

body.article main li + li {
  margin-top: 6px;
}

body.article main :not(pre) > code {
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

body.article main pre {
  margin-bottom: 0;
  padding: 16px 18px;
  overflow-x: auto;
  border-left: 3px solid var(--color-live);
  background-color: var(--color-artifact);
  color: var(--color-sheet);
  line-height: 1.55;
  tab-size: 2;
}

body.article main pre:focus-visible {
  outline-offset: 2px;
}

body.article main pre ::selection {
  background-color: var(--color-sheet);
  color: var(--color-artifact);
}

body.article main table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: var(--body-font-size-s);
  line-height: 1.4;
}

body.article main :is(th, td) {
  padding: 10px 20px 10px 0;
  border-bottom: var(--rule) solid var(--fg);
  text-align: start;
  vertical-align: top;
}

body.article main :is(th, td) code {
  overflow-wrap: normal;
}

body.article main th {
  font-weight: 500;
}

/* The last paragraph of an article links to the next one. */
body.article main > .section > .section-content > p:last-child {
  margin-top: 56px;
  padding-top: 20px;
  border-top: var(--rule) solid var(--fg);
  font-weight: 500;
}
