:root {
  --ink: #000;
  --paper: #fff;

  /* Type size from the Figma draft. Content shrinks from here if a page
     has more lines than fit on the screen (see script.js). */
  --font-size: 30px;

  /* Distance of the nav links to the screen edges: 6/8px on a 402px phone,
     growing to 81/68px on a 1280px desktop, as in the two Figma frames. */
  --edge-x: clamp(6px, calc(8.54vw - 28px), 96px);
  --edge-y: clamp(8px, calc(6.83vw - 19px), 72px);

  --nav-size: var(--font-size);

  /* On wide screens the four links stop spreading: they stay on the corners
     of a centred stage of this width, and the content stays inside it. */
  --stage: 1000px;
  --side: max(var(--edge-x), calc((100vw - var(--stage)) / 2));
}

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

html,
body {
  height: 100%;
}

body {
  font: 400 var(--font-size) / 1.2 Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.js body {
  overflow: hidden;
}

/* ---------- corner navigation ---------- */

.nav {
  position: fixed;
  z-index: 2;
  color: inherit;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  font-size: var(--nav-size);
}

/* Phones: smaller links, and the same visible gap to the edge on all sides.
   With line-height 1 the empty space above the capitals and below the
   baseline is about 0.137em (Inter), so that is taken off the vertical
   distance; 0.07em is the left side bearing of the first letter. */
@media (max-width: 699px) {
  :root {
    --nav-size: clamp(16px, 4.8vw, 24px);
    --margin: clamp(12px, 3.5vw, 24px);
    --edge-x: calc(var(--margin) - 0.07 * var(--nav-size));
    --edge-y: calc(var(--margin) - 0.137 * var(--nav-size));
  }

  .nav {
    line-height: 1;
  }
}

/* larger tap target without changing the visual box */
.nav::after {
  content: "";
  position: absolute;
  inset: -10px;
}

.nav[data-corner^="t"] { top: calc(var(--edge-y) + env(safe-area-inset-top, 0px)); }
.nav[data-corner^="b"] { bottom: calc(var(--edge-y) + env(safe-area-inset-bottom, 0px)); }
.nav[data-corner$="l"] { left: calc(var(--side) + env(safe-area-inset-left, 0px)); }
.nav[data-corner$="r"] { right: calc(var(--side) + env(safe-area-inset-right, 0px)); }

.nav:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 6px;
}

@media (hover: hover) {
  .nav:hover {
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 0.18em;
  }
}

/* ---------- content on circles ---------- */

.orbit {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  fill: var(--ink);
}

.orbit a {
  fill: inherit;
  text-decoration: none;
}

.orbit a:hover text,
.orbit .is-focus text {
  text-decoration: underline;
}

/* a page turns as one piece around the centre of its circles (see script.js) */
.orbit .layer {
  transform-origin: var(--cx) var(--cy);
}

/* The HTML content stays in the page for screen readers and search
   engines; visually it is replaced by the SVG. */
.js main {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- without JavaScript: a plain readable page ---------- */

html:not(.js) .orbit {
  display: none;
}

html:not(.js) main {
  max-width: 22em;
  margin: 0 auto;
  padding: 5em 1em;
  font-size: 18px;
  line-height: 1.5;
}

html:not(.js) main h1 {
  position: absolute;
  clip-path: inset(50%);
}

html:not(.js) main section {
  padding-top: 5em;
}

html:not(.js) main h2 {
  margin-top: 1.5em;
  font: inherit;
  text-transform: uppercase;
}

html:not(.js) main a {
  color: inherit;
}
