/* Self-hosted fonts (SIL Open Font License, texts in fonts/).
   Mona Sans: the Latin subset of the variable font.
   Recursive: only the letters of "Coming soon." and "Page not found." (the two headlines).
   If a headline changes, this file needs the new letters; see README. */
@font-face {
  font-family: "Mona Sans";
  src: url("fonts/mona-sans.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Recursive";
  src: url("fonts/recursive-headline-v1.woff2") format("woff2");
  font-weight: 300 1000;
  font-style: normal;
  font-display: block;
}

/* Dawn palette: midnight indigo sky, coral horizon. See DESIGN.md.
   Light theme is the same scene in the morning. */
:root {
  --text: #15123b;
  --muted: #403b78;
  --accent: #ff7a5c;
  --accent-hover: #ff8e74; /* a lighter coral for hover: feedback without a coloured glow */
  --on-accent: #15123b;
  --glass: rgba(255, 255, 255, 0.4);
  --glass-line: rgba(21, 18, 59, 0.2);
  --shadow: rgba(36, 28, 110, 0.3);

  --sky-1: #a3bcff;
  --sky-2: #d9d4ff;
  --sky-3: #ffd5c4;
  --glow: rgba(255, 168, 128, 0.32);
  --sun-core: #ffcfb5;
  --sun-edge: #ff7e5d; /* coral, like the button and the dark-mode sun */
  --sun-halo: rgba(255, 126, 93, 0.3);
  --blob-1: rgba(128, 112, 255, 0.32);
  --blob-2: rgba(255, 140, 120, 0.3);
  --hill-3a: #cec8fa;
  --hill-3b: #b5aef2;
  --hill-2a: #a49ced;
  --hill-2b: #8b83e0;
  --hill-1a: #776dd8;
  --hill-1b: #5b51c4;
  --stars: 0;

  --pad: clamp(16px, 4.5vw, 72px);
  --ctl: clamp(54px, 1.9vw + 26px, 72px); /* contact button height; grows on big monitors */
  --hills-h: clamp(120px, 34vh, 420px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text: #f3f1ff;
    --muted: #bab6e4;
    --on-accent: #120f33;
    --glass: rgba(255, 255, 255, 0.06);
    --glass-line: rgba(243, 241, 255, 0.24);
    --shadow: rgba(2, 2, 14, 0.55);

    --sky-1: #060918;
    --sky-2: #17184a;
    --sky-3: #4a2660;
    --glow: rgba(255, 110, 96, 0.45);
    --sun-core: #ffb39b;
    --sun-edge: #ff6f5a;
    --sun-halo: rgba(255, 105, 90, 0.32);
    --blob-1: rgba(110, 90, 255, 0.3);
    --blob-2: rgba(255, 95, 120, 0.2);
    --hill-3a: #573985;
    --hill-3b: #2d2266;
    --hill-2a: #2c2768;
    --hill-2b: #1b184c;
    --hill-1a: #17143f;
    --hill-1b: #0b0a24;
    --stars: 1;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --text: #f3f1ff;
  --muted: #bab6e4;
  --on-accent: #120f33;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-line: rgba(243, 241, 255, 0.24);
  --shadow: rgba(2, 2, 14, 0.55);

  --sky-1: #060918;
  --sky-2: #17184a;
  --sky-3: #4a2660;
  --glow: rgba(255, 110, 96, 0.45);
  --sun-core: #ffb39b;
  --sun-edge: #ff6f5a;
  --sun-halo: rgba(255, 105, 90, 0.32);
  --blob-1: rgba(110, 90, 255, 0.3);
  --blob-2: rgba(255, 95, 120, 0.2);
  --hill-3a: #573985;
  --hill-3b: #2d2266;
  --hill-2a: #2c2768;
  --hill-2b: #1b184c;
  --hill-1a: #17143f;
  --hill-1b: #0b0a24;
  --stars: 1;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow-x: clip; /* leaning letters must never cause sideways scrolling */
  background: var(--sky-2);
  color: var(--text);
  font-family: "Mona Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 450;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
}

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

.icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
  flex: none;
}

/* Scene: sky, drifting colour, stars, sun and three hills, back to front */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(70% 45% at 50% 100%, var(--glow), transparent 70%),
    linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 55%, var(--sky-3) 100%);
}

.layer {
  position: absolute;
  inset: 0;
}

.blob {
  position: absolute;
  width: 62vmax;
  aspect-ratio: 1;
  border-radius: 50%;
}

.blob--one {
  top: -26vmax;
  left: -20vmax;
  background: radial-gradient(circle, var(--blob-1), transparent 65%);
  animation: drift-one 28s ease-in-out infinite alternate;
}

.blob--two {
  top: 4vh;
  right: -24vmax;
  background: radial-gradient(circle, var(--blob-2), transparent 65%);
  animation: drift-two 34s ease-in-out infinite alternate;
}

@keyframes drift-one {
  to {
    transform: translate(9vw, 7vh) scale(1.08);
  }
}

@keyframes drift-two {
  to {
    transform: translate(-7vw, -5vh) scale(0.94);
  }
}

.starfield {
  -webkit-mask-image: radial-gradient(ellipse 44% 30% at 50% 46%, transparent 35%, #000 100%);
  mask-image: radial-gradient(ellipse 44% 30% at 50% 46%, transparent 35%, #000 100%);
}

.stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  opacity: var(--stars);
  transition: opacity 0.6s ease;
}

.stars--twinkle {
  animation: twinkle 3.2s ease-in-out infinite alternate;
  animation-play-state: paused; /* stars are only visible in the dark theme */
}

:root[data-theme="dark"] .stars--twinkle {
  animation-play-state: running;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .stars--twinkle {
    animation-play-state: running;
  }
}

@keyframes twinkle {
  from {
    opacity: calc(var(--stars) * 0.2);
  }
}

.sun {
  position: absolute;
  left: 80%;
  bottom: calc(var(--hills-h) * 0.45);
  width: clamp(96px, 14vw, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, var(--sun-core), var(--sun-edge) 72%);
  box-shadow: 0 0 70px 24px var(--sun-halo), 0 0 220px 90px var(--sun-halo);
  transform: translateX(-50%);
  animation: sunrise 2.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes sunrise {
  from {
    opacity: 0.3;
    transform: translate(-50%, 70%);
  }
}

/* Hills stretch to their box, so wide screens get gentler slopes. The box never gets
   narrower than 960px, so phones see a centred slice instead of steep, squeezed waves.
   The extra 96px on wide screens leaves room for the parallax shift. */
.hill {
  --hill-w: max(100% + 96px, 960px);
  --h: var(--hills-h);
  position: absolute;
  left: 50%;
  width: var(--hill-w);
  margin-left: calc(var(--hill-w) / -2);
  /* The drawing is 600 units tall but only the top 400 sit on screen: the rest hangs
     below the edge, so when the hills rise with the pointer there is always hill underneath. */
  bottom: calc(var(--h) * -0.5);
  height: calc(var(--h) * 1.5);
  animation: hill-in 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.hill--back {
  animation-delay: 0.1s;
}

.hill--mid {
  --h: calc(var(--hills-h) * 0.82);
  animation-delay: 0.2s;
}

.hill--front {
  --h: calc(var(--hills-h) * 0.62);
  animation-delay: 0.3s;
}

@keyframes hill-in {
  from {
    opacity: 0;
    transform: translateY(16%);
  }
}

.stop-3a { stop-color: var(--hill-3a); }
.stop-3b { stop-color: var(--hill-3b); }
.stop-2a { stop-color: var(--hill-2a); }
.stop-2b { stop-color: var(--hill-2b); }
.stop-1a { stop-color: var(--hill-1a); }
.stop-1b { stop-color: var(--hill-1b); }

/* Fine noise keeps the big gradients from banding */
.grain {
  position: absolute;
  inset: 0;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Top bar */
.top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(var(--pad), env(safe-area-inset-right, 0px)) 16px max(var(--pad), env(safe-area-inset-left, 0px));
}

/* Without JavaScript the theme button can't work, so it isn't shown. */
:root:not(.js) .theme-toggle {
  visibility: hidden;
}

.name {
  margin: 0;
  color: inherit;
  text-decoration: none;
  font-size: clamp(1rem, 0.55rem + 0.65vw, 1.5rem);
  font-weight: 650;
  letter-spacing: -0.005em;
}

.icon-btn {
  --size: var(--ctl);
  display: inline-grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  padding: 0;
  border: 1px solid var(--glass-line);
  border-radius: 50%;
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.icon-btn--small {
  --size: clamp(44px, 1.2vw + 26px, 56px);
}

.icon-btn .icon {
  width: calc(var(--size) * 0.42);
  height: calc(var(--size) * 0.42);
}

.icon-btn--small .icon {
  width: calc(var(--size) * 0.45);
  height: calc(var(--size) * 0.45);
}

@media (hover: hover) {
  .icon-btn:hover {
    border-color: var(--text);
    background: var(--text);
    color: var(--sky-2);
    transform: translateY(-2px);
  }
}

.icon-btn:active {
  transform: scale(0.95);
}

.theme-toggle .icon--sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon--sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon--moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon--sun {
    display: block;
  }

  :root:not([data-theme="light"]) .theme-toggle .icon--moon {
    display: none;
  }
}

/* Centred content, sitting in the sky above the hills */
.stage {
  --hs: min(11vw, 21dvh);
  position: relative;
  z-index: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 0 max(var(--pad), env(safe-area-inset-right, 0px)) max(14vh, 72px, env(safe-area-inset-bottom, 0px)) max(var(--pad), env(safe-area-inset-left, 0px));
  text-align: center;
}

.headline {
  --rest-wght: 420;
  margin: 0;
  font-family: Recursive, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--hs);
  font-weight: 420;
  line-height: 1;
  letter-spacing: -0.03em;
}

.type {
  position: relative;
  display: block;
  touch-action: pan-y pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
}

.word {
  display: inline-block;
  white-space: nowrap;
}

.ch {
  display: inline-block;
  font-variation-settings: "wght" var(--rest-wght), "CASL" 0;
  transform-origin: 50% 80%;
}

.ch--dot {
  color: var(--accent);
}

/* Hidden until the font is ready so the headline never swaps fonts in view.
   The delayed animation is a safety net if the script never runs. */
.js .type {
  opacity: 0;
  animation: type-fallback 0s linear 2.5s forwards;
}

.js .type.is-ready {
  opacity: 1;
  animation: none;
  transition: opacity 0.5s ease-out;
}

@keyframes type-fallback {
  to {
    opacity: 1;
  }
}

.role {
  margin: max(16px, calc(var(--hs) * 0.32)) 0 clamp(26px, 4.4vh, 44px);
  color: var(--muted);
  font-size: clamp(1.05rem, 0.6rem + 0.7vw, 1.75rem);
  font-weight: 450;
  animation: rise-in 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.5s both;
}

.contact {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  animation: rise-in 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.65s both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--ctl) * 0.19);
  height: var(--ctl);
  padding: 0 calc(var(--ctl) * 0.48);
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: clamp(1.0625rem, 0.45rem + 0.6vw, 1.5rem);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 2px var(--shadow), 0 8px 18px -10px var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

@media (hover: hover) {
  .btn-primary:hover {
    transform: translateY(-2px);
    background: var(--accent-hover);
    box-shadow: 0 2px 4px var(--shadow), 0 12px 22px -10px var(--shadow);
  }
}

.btn-primary .icon {
  width: calc(var(--ctl) * 0.4);
  height: calc(var(--ctl) * 0.4);
  margin-left: calc(var(--ctl) * -0.07);
}

.btn-primary:active {
  transform: translateY(0) scale(0.98);
}

/* 404 page: same scene, a smaller headline that may wrap */
.not-found .stage {
  --hs: min(7.5vw, 15dvh);
}

.not-found .headline {
  text-wrap: balance;
}

/* The 404 page's name is a link home: give it a full-size tap target. */
a.name {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* Upright screens up to tablet size: the headline breaks onto two lines and grows.
   Phones held sideways keep the one-line layout, which fits their width better. */
@media (max-width: 1080px) and (orientation: portrait) {
  .stage {
    --hs: min(24vw, 16dvh);
    padding-bottom: max(18vh, 80px, env(safe-area-inset-bottom, 0px));
  }

  .headline {
    line-height: 0.95;
  }

  .word {
    display: block;
  }

  .sun {
    left: 84%;
  }

  .not-found .stage {
    --hs: min(13vw, 10dvh);
  }

  .not-found .word {
    display: inline-block;
  }
}

/* Phones held upright: the email button gets its own row, the profile links sit below. */
@media (max-width: 699px) and (orientation: portrait) {
  .contact > li:first-child {
    display: flex;
    flex-basis: 100%;
    justify-content: center;
  }
}

@media (max-height: 500px) {
  .top {
    min-height: 60px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-bottom: 8px;
  }

  .stage {
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }

  .sun {
    left: 88%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  .js .type {
    opacity: 1;
  }
}
