: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);

  /* the typeface; script.js swaps it (see the font variations) */
  --family: "Satoshi", "General Sans", sans-serif;

  /* 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));
}

/* ---------- colour concept ----------
   Four variations, selected by name (the order below is the order of double
   tapping). Only these pairs of ink on ground are used:

     Papier    black on white
     Rosa      black on pinkish white
     Elektro   white on blue
     Neon      pink on black. This is the default.

   Nothing else is coloured: the page you are on is the sharp corner link,
   the other three are slightly blurred. Underlines always take the colour of
   their text. */
:root {
  --nav-blur: 0.05em;
}

:root[data-tone="papier"] { --nav-blur: 0; }
:root[data-tone="rosa"] { --ink: #000000; --paper: #fff0f5; }
:root[data-tone="elektro"] { --ink: #ffffff; --paper: #1f35ff; }
:root[data-tone="neon"] { --ink: #ff4fa3; --paper: #000000; }

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

html,
body {
  height: 100%;
}

body {
  font: 400 var(--font-size) / 1.2 var(--family);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.5s ease, background-color 0.5s ease;
}

/* The page takes over taps and swipes itself (double tap, swipe between
   pages): no double-tap zoom, no pull to refresh, no rubber band. Pinch
   zoom stays available. */
html {
  touch-action: pinch-zoom;
  overscroll-behavior: none;
}

.js body {
  user-select: none;
  -webkit-user-select: none;
}

.js body {
  overflow: hidden;
}

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

.nav {
  position: fixed;
  z-index: 2;
  color: var(--ink);
  filter: blur(var(--nav-blur));
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  font-size: var(--nav-size);
  transition: color 0.5s ease, filter 0.5s ease;
}

/* The page you are on, and any link you point at or focus, is sharp.
   A detail page has aria-current="true" on its corner link. */
.nav[aria-current],
.nav:focus-visible {
  color: var(--ink);
  filter: blur(0);
}

/* 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 {
    color: var(--ink);
    filter: blur(0);
    text-decoration: underline;
    text-decoration-color: currentColor;
    text-decoration-thickness: 0.075em; /* as thick as the letters' stems, like the underlines on the circles */
    text-underline-offset: 0.18em;
  }
}

/* keyboard-only handles for the colour variations (top) and the typeface
   (bottom): invisible until focused */
.handle {
  position: fixed;
  z-index: 3;
  left: 50%;
  width: 3em;
  height: 1.4em;
  translate: -50% 0;
  border: 0;
  border-radius: 0.7em;
  background: transparent;
  opacity: 0;
  pointer-events: none;
}

.tone { top: calc(var(--edge-y) + env(safe-area-inset-top, 0px)); }
.face { bottom: calc(var(--edge-y) + env(safe-area-inset-bottom, 0px)); }

.handle:focus-visible {
  opacity: 1;
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

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

.orbit {
  color: var(--ink);       /* the underlines draw in currentColor */
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  fill: var(--ink);
  transition: fill 0.5s ease, color 0.5s ease;
}

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

/* Underline of a link: a stroke drawn along its circle by script.js, shown
   on keyboard focus, and on hover where there is a pointer. */
.orbit .underline {
  fill: none;
  stroke: currentColor;
  stroke-linecap: butt;
  visibility: hidden;
  transition: stroke 0.5s ease;
}

.orbit .is-focus .underline {
  visibility: visible;
}

@media (hover: hover) {
  .orbit a:hover .underline,
  .orbit .is-hover .underline {
    visibility: visible;
  }
}

/* photo of a detail page: a quarter disc on the corner of its nav link */
.orbit .photo {
  cursor: zoom-in;
  outline: none;
}

.orbit .photo:focus-visible .photo-ring {
  visibility: visible;
}

.orbit .photo-ring {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  visibility: hidden;
}

/* full-width view of the photo */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2;              /* before <nav> in the page, so the links stay on top */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  cursor: zoom-out;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  display: block;
  width: 100%;
  max-height: 100%;
  object-fit: cover;
}

/* 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;
}
