@font-face {
  font-family: "Jost";
  src: url("/fonts/jost-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* The colours are the island's own: its night sky, its blocks, the ice of the
   visitor's visor, the cobalt of the doorways and the amber of the beacon. */
:root {
  color-scheme: dark;

  --night: #02030a;
  --slab: #080b1f;
  --depth: #141a40;
  --moon: #eef0ff;
  --mist: #aab0d0;
  --dusk: #7c84ab;
  --glow: #a3adff;
  --cobalt: #2b3fe6;
  --signal: #ffc83d;

  --edge: clamp(1rem, 3.2vw, 2rem);
  --column: 74rem;
}

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

[hidden] {
  display: none !important;
}

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  background: var(--night) url("/sky.svg") 50% 0 / 75rem 75rem;
  color: var(--mist);
  font-family: "Jost", "Avenir Next", "Century Gothic", system-ui, sans-serif;
  font-size: 1.125rem;
  font-weight: 400;
  line-height: 1.6;
}

::selection {
  background: var(--cobalt);
  color: #ffffff;
}

a:focus-visible,
button:focus-visible {
  outline: 0.1875rem solid var(--signal);
  outline-offset: 0.2em;
}

.skip {
  position: absolute;
  top: 1rem;
  left: -999rem;
  z-index: 2;
  padding: 0.5rem 0.75rem;
  background: var(--moon);
  color: var(--night);
}

.skip:focus {
  left: 1rem;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- The name and the links, top of every page ---------- */

.bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: max(var(--edge), env(safe-area-inset-top)) var(--edge) 0;
}

.bar-name,
.hud-name {
  color: var(--moon);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.bar-nav,
.hud-nav {
  display: flex;
  gap: 1.5rem;
  font-size: 1.0625rem;
}

.bar-nav a,
.hud-nav a {
  color: var(--mist);
  text-decoration: none;
}

.bar-nav a:hover,
.hud-nav a:hover {
  color: var(--moon);
}

/* The page you are on: a short amber bar under its name. */
.bar-nav a[aria-current="page"] {
  padding-bottom: 0.2rem;
  border-bottom: 0.1875rem solid var(--signal);
  color: var(--moon);
}

/* ---------- The written pages ---------- */

/* A piece of the island floats beside a slab that carries the words. On a
   narrow screen the island sits above the slab. */
.page {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 1.5rem var(--edge) 3.5rem;
}

.chunk {
  display: block;
  justify-self: end;
  width: min(42vw, 10rem);
  height: auto;
  margin: 0 0.75rem 1rem 0;
}

.slab {
  /* The hard shadow is the slab's thickness, so leave room for it. */
  margin-right: 0.5rem;
  padding: clamp(1.5rem, 5.5vw, 3.25rem);
  border: 0.125rem solid rgb(238 240 255 / 0.85);
  background: var(--slab);
  box-shadow: 0.5rem 0.5rem 0 var(--depth);
}

@media (min-width: 56rem) {
  .page {
    grid-template-columns: minmax(0, 42rem) minmax(16rem, 1fr);
    column-gap: clamp(2rem, 5vw, 4.5rem);
    align-items: start;
    padding-top: clamp(2.5rem, 6vw, 4.5rem);
    padding-bottom: 5rem;
  }

  .slab {
    grid-row: 1;
    grid-column: 1;
    margin-right: 0;
  }

  .chunk {
    position: sticky;
    top: 4.5rem;
    grid-row: 1;
    grid-column: 2;
    justify-self: center;
    width: min(100%, 21rem);
    margin: 1rem 0 0;
  }
}

.slab h1 {
  margin: 0 0 1.25rem;
  color: var(--moon);
  font-size: clamp(2.75rem, 1.9rem + 4vw, 4.25rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
}

/* A page whose heading is a whole sentence. */
.note .slab h1 {
  max-width: 14ch;
  font-size: clamp(2.1rem, 1.5rem + 2.6vw, 3.1rem);
  line-height: 1.06;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.slab .dated {
  margin-top: -0.65rem;
  margin-bottom: 2.25rem;
  color: var(--dusk);
  font-size: 1rem;
}

.slab h2 {
  margin: 2.25rem 0 0.4rem;
  color: var(--moon);
  font-size: 1.3125rem;
  font-weight: 600;
  line-height: 1.25;
}

.slab p,
.slab ul {
  max-width: 35rem;
  margin: 0 0 1rem;
  text-wrap: pretty;
}

.slab ul {
  padding-left: 1.2em;
}

.slab li {
  margin-bottom: 0.35rem;
}

.slab a {
  color: var(--glow);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

.slab a:hover {
  color: var(--moon);
}

/* Addresses stay in one piece instead of breaking at the hyphen. */
.whole,
a[href^="mailto:"] {
  white-space: nowrap;
}

.slab .reach {
  margin-top: 2rem;
}

.slab .way-back {
  margin: 2.5rem 0 0;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1.75rem;
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 var(--edge) max(1.5rem, env(safe-area-inset-bottom));
  color: var(--dusk);
  font-size: 1.0625rem;
}

.foot a {
  color: inherit;
  text-underline-offset: 0.2em;
}

.foot a:hover {
  color: var(--moon);
}

/* ---------- Blocky controls ---------- */

/* Square corners, a solid edge and a hard drop shadow, on the island and on
   the written pages alike. */
.prompt,
.jump,
.panel button,
.slab .btn {
  border: 0.125rem solid var(--moon);
  background: #0b0f2a;
  box-shadow: 0.25rem 0.25rem 0 rgb(0 0 0 / 0.55);
  color: var(--moon);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.prompt:hover,
.jump:hover,
.panel button:hover,
.slab .btn:hover {
  background: var(--cobalt);
}

.slab .btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  box-shadow: 0.25rem 0.25rem 0 var(--depth);
  text-decoration: none;
}

/* The one moving thing on a written page: the piece of island rides up and
   down, slowly, the way the real one hangs in the dark. */
@media (prefers-reduced-motion: no-preference) {
  .chunk {
    animation: hang 7s ease-in-out infinite alternate;
  }
}

@keyframes hang {
  from {
    transform: translateY(0.4rem);
  }

  to {
    transform: translateY(-0.4rem);
  }
}

/* ---------- The island (home page, when the 3D scene is running) ---------- */

.world-on,
.world-on body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#scene:active {
  cursor: grabbing;
}

/* Everything drawn over the scene. The layer itself lets clicks through to
   the scene; the things in it take them. */
.hud {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  font-size: 1.0625rem;
  line-height: 1.55;
}

.hud a,
.hud button {
  pointer-events: auto;
}

.hud-top {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: max(var(--edge), env(safe-area-inset-top)) var(--edge) 0;
}

.hud-foot {
  position: absolute;
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  left: var(--edge);
  max-width: min(22rem, 60vw);
}

.hud-foot p {
  margin: 0;
}

.hud-line {
  color: var(--moon);
}

.hud-hint {
  margin-top: 0.25rem;
  color: var(--dusk);
  font-size: 0.9375rem;
  transition: opacity 0.8s 1.5s;
}

.hud-hint.gone {
  opacity: 0;
}

.prompt {
  position: absolute;
  bottom: clamp(5.5rem, 16vh, 9rem);
  left: 50%;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.6rem 1rem 0.6rem 0.6rem;
  transform: translateX(-50%);
  white-space: nowrap;
}

.prompt kbd {
  display: grid;
  width: 1.9rem;
  height: 1.9rem;
  place-items: center;
  background: var(--moon);
  color: #0b0f2a;
  font: inherit;
  font-weight: 600;
}

.panel {
  position: absolute;
  top: 50%;
  right: var(--edge);
  width: min(23rem, calc(100vw - 2 * var(--edge)));
  padding: 1.5rem;
  transform: translateY(-50%);
  border: 0.125rem solid rgb(238 240 255 / 0.85);
  background: rgb(6 9 26 / 0.92);
  box-shadow: 0.375rem 0.375rem 0 rgb(0 0 0 / 0.55);
  color: var(--mist);
  pointer-events: auto;
}

.panel h2 {
  margin: 0 0 0.75rem;
  color: var(--moon);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.15;
}

.panel p {
  margin: 0 0 1rem;
}

.panel a {
  color: var(--glow);
  text-underline-offset: 0.2em;
}

.panel button {
  margin-top: 0.5rem;
  padding: 0.4rem 0.9rem;
}

/* Touch controls. */
.stick {
  position: absolute;
  width: 7rem;
  height: 7rem;
  transform: translate(-50%, -50%);
  border: 0.125rem solid rgb(238 240 255 / 0.3);
  border-radius: 50%;
}

.knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3rem;
  height: 3rem;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgb(238 240 255 / 0.35);
}

.jump {
  position: absolute;
  right: var(--edge);
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  display: none;
  padding: 0.9rem 1.2rem;
}

@media (pointer: coarse) {
  .jump {
    display: block;
  }

  .prompt kbd {
    display: none;
  }

  .prompt {
    padding-left: 1rem;
  }
}

@media (max-width: 40rem) {
  .panel {
    top: auto;
    right: var(--edge);
    bottom: clamp(5.5rem, 16vh, 9rem);
    left: var(--edge);
    width: auto;
    transform: none;
  }

  .hud-foot {
    max-width: 58vw;
  }
}
