@font-face {
  font-family: "Unbounded";
  src: url("/assets/fonts/unbounded-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Mona Sans";
  src: url("/assets/fonts/mona-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0b0a12;
  --fg: #f4f2ff;
  --muted: #c9c4e0;
  --accent: #3d2bff;
  --accent-soft: #8b80ff;
  --gutter: clamp(1rem, 3vw, 2.25rem);
  --display: "Unbounded", system-ui, sans-serif;
  --sans: "Mona Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html, body { margin: 0; height: 100%; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* nothing on the page is meant to be selected or long-pressed */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100svh;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 400;
}

img, svg { -webkit-user-drag: none; }

/* readable by screen readers, invisible on screen */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* the water: sheets of glass drawn by surface.js */
.surface {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  animation: fade 2.4s 0.2s ease forwards;
}

/* film grain. Kept still: animating an SVG noise filter re-rasterises it
   every step, which phones handle badly */
.grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.4 -.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.hero {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  padding-bottom: 24svh;
  text-align: center;
}

/* the wordmark, as in the Figma file: Unbounded ExtraBold, tracking -0.04em */
.name {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3.25rem, 17vw, 11.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  white-space: nowrap;
  opacity: 0;
  animation: rise 1.4s 0.15s cubic-bezier(.2, .7, .1, 1) forwards;
}

.name {
  display: inline-flex;
  align-items: center;
  /* how much narrower the letter s is than the mark (see .s below) */
  --gap: calc(0.95em - var(--sw, 0.72em));
}

.rest { display: inline-flex; }

/* VHS: the colour channels sit a hair apart. drop-shadow works on the
   painted pixels, so it fringes the SVG mark the same way as the letters */
.s, .rest {
  filter: drop-shadow(-0.008em 0 rgb(255 90 170 / 0.28)) drop-shadow(0.01em 0 rgb(90 190 255 / 0.22));
}

.soon { text-shadow: -1px 0 rgb(255 90 170 / 0.22), 1px 0 rgb(90 190 255 / 0.18); }

/*
 * The s slot. It starts as the letter, then on a 10 s loop (started by
 * site.js) the letter dissolves while the ring and wave of the mark draw
 * themselves in, the wave flips once like a standing wave, and the mark
 * unwinds back into the letter. The gap between the letter's advance (--sw,
 * measured) and the mark's 0.95em from the integrated lockup closes and
 * opens smoothly, so the rest of the word glides rather than jumps.
 */
.s {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  /* the slot is always the mark's width; while it shows the letter, the s
     and the rest of the word are slid together with transforms (--gap is the
     difference). Transforms move at sub-pixel precision on the GPU, where
     animating width re-lays out the word every frame and makes it jitter */
  width: var(--sw, 0.72em);
  height: 1em;
}

.name.split .s { width: 0.95em; transform: translateX(calc(var(--gap) / 2)); }
.name.split .rest { transform: translateX(calc(var(--gap) / -2)); }

.sl {
  position: absolute;
  top: 0;
  left: 0;
  line-height: 1;
  color: var(--fg);
}

.mark {
  position: absolute;
  top: 0;
  left: 0;
  width: 1em;
  height: 1em;
  overflow: visible;
}

/* the mark draws itself by sliding a dash along each path. A dash shifted
   fully out of view still leaves a zero-length piece whose round cap shows
   as a dot, so the paths are also faded out whenever they aren't drawn */
.mark path {
  stroke: var(--fg);
  stroke-dasharray: 100 100;
  stroke-dashoffset: 100;
  opacity: 0;
}

.s.loop { animation: s-slot 10s linear infinite; }
.s.loop + .rest { animation: s-rest 10s linear infinite; }
.name .s.loop .sl { animation: s-letter 10s linear infinite; }

/* before the loop starts, the s rises in with the other letters */
.name.split .sl {
  opacity: 0;
  animation: rise 1.3s 0.15s cubic-bezier(.2, .7, .1, 1) forwards;
}
.s.loop .ring { animation: s-ring 10s linear infinite; }
.s.loop .wave { animation: s-wave 10s linear infinite; }

@keyframes s-slot {
  0%, 22% { transform: translateX(calc(var(--gap) / 2)); animation-timing-function: cubic-bezier(.6, 0, .2, 1); }
  32%, 80% { transform: translateX(0); animation-timing-function: cubic-bezier(.6, 0, .2, 1); }
  90%, 100% { transform: translateX(calc(var(--gap) / 2)); }
}

@keyframes s-rest {
  0%, 22% { transform: translateX(calc(var(--gap) / -2)); animation-timing-function: cubic-bezier(.6, 0, .2, 1); }
  32%, 80% { transform: translateX(0); animation-timing-function: cubic-bezier(.6, 0, .2, 1); }
  90%, 100% { transform: translateX(calc(var(--gap) / -2)); }
}

@keyframes s-letter {
  0%, 22% { opacity: 1; transform: none; filter: blur(0); animation-timing-function: cubic-bezier(.5, 0, .75, 0); }
  30% { opacity: 0; transform: translateX(0.1em) scale(0.7) rotate(25deg); filter: blur(6px); }
  82% { opacity: 0; transform: translateX(0.1em) scale(0.7) rotate(-25deg); filter: blur(6px); animation-timing-function: cubic-bezier(.2, .7, .1, 1); }
  92%, 100% { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes s-ring {
  0%, 24% { stroke-dashoffset: 100; opacity: 0; animation-timing-function: cubic-bezier(.6, 0, .2, 1); }
  25% { opacity: 1; }
  34%, 78% { stroke-dashoffset: 0; opacity: 1; animation-timing-function: cubic-bezier(.6, 0, .2, 1); }
  87% { opacity: 1; }
  88%, 100% { stroke-dashoffset: -100; opacity: 0; }
}

@keyframes s-wave {
  0%, 27% { stroke-dashoffset: 100; opacity: 0; animation-timing-function: cubic-bezier(.6, 0, .2, 1); }
  28% { opacity: 1; }
  36%, 74% { stroke-dashoffset: 0; opacity: 1; animation-timing-function: cubic-bezier(.6, 0, .2, 1); }
  83% { opacity: 1; }
  84%, 100% { stroke-dashoffset: -100; opacity: 0; }
}

/* once site.js has split the letters, each one rises in on its own; after
   that the only motion in the name is the s turning into the mark and back */
.name.split { opacity: 1; animation: none; }

.name .l {
  display: inline-block;
  opacity: 0;
  animation: rise 1.3s calc(0.15s + var(--i) * 70ms) cubic-bezier(.2, .7, .1, 1) forwards;
}

.soon {
  display: inline-flex;
  align-items: center;
  gap: 0.75em;
  margin: clamp(1.25rem, 2.6vw, 2rem) 0 0;
  color: var(--muted);
  font-size: clamp(0.8rem, 1.2vw, 0.95rem);
  font-weight: 400;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  /* letter-spacing adds space after the last letter too; balance it on the left */
  padding-left: 0.3em;
  opacity: 0;
  animation: rise 1.4s 0.75s cubic-bezier(.2, .7, .1, 1) forwards;
}

/* the ring is its own circle that scales and fades: an animated box-shadow
   gets clipped by WebKit when the page is zoomed */
.pulse {
  position: relative;
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-soft);
}

.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgb(139 128 255 / 0.55);
  animation: pulse 2s ease-out infinite;
}

/*
 * The GitHub link sits under the tagline as a round button. It opens into a
 * pill showing the repo name and its star count when it gets the .open class
 * (site.js: on hover with a mouse, on the first tap on a touch screen) or
 * keyboard focus: the second grid column grows from 0fr to 1fr, then the text
 * comes in. Closing reverses it: the text goes first, then the pill folds.
 */
.github {
  --ease: cubic-bezier(.2, .8, .2, 1);
  display: inline-grid;
  grid-template-columns: 44px 0fr;
  align-items: center;
  height: 44px;
  margin-top: clamp(1.5rem, 3.2vw, 2.25rem);
  border-radius: 22px;
  color: var(--fg);
  text-decoration: none;
  box-shadow: inset 0 0 0 1px rgb(244 242 255 / 0.16);
  background: rgb(244 242 255 / 0.03);
  opacity: 0;
  animation: fade-to 1.4s 1.3s ease forwards;
  /* closing: wait for the text to leave, then fold up */
  transition:
    grid-template-columns 0.85s 0.3s var(--ease),
    box-shadow 0.6s ease,
    background-color 0.6s ease;
}

.gh-icon { justify-self: center; width: 20px; height: 20px; }

.gh-more { min-width: 0; overflow: hidden; }

.gh-inner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding-right: 1.1rem;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/*
 * The label comes in a piece at a time: each letter of the name, then the
 * star count (site.js splits them and numbers them with --i, and sets --n
 * to the total). Opening, they rise in left to right once the pill has
 * room; closing, they drop out right to left before it folds.
 */
.gc,
.gh-stars {
  opacity: 0;
  transform: translateY(0.45em);
  filter: blur(3px);
  transition:
    opacity 0.22s ease,
    transform 0.3s ease,
    filter 0.22s ease;
  transition-delay: calc((var(--n, 1) - var(--i, 0)) * 28ms);
}

.gc { display: inline-block; }

.github.open .gc,
.github.open .gh-stars,
.github:focus-visible .gc,
.github:focus-visible .gh-stars {
  opacity: 1;
  transform: none;
  filter: blur(0);
  transition:
    opacity 0.4s ease,
    transform 0.6s var(--ease),
    filter 0.4s ease;
  transition-delay: calc(0.28s + var(--i, 0) * 60ms);
}

.gh-stars {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding-left: 0.7rem;
  border-left: 1px solid rgb(244 242 255 / 0.18);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.gh-stars[hidden] { display: none; }

.gh-stars svg { color: #ffd76a; }

.github.open,
.github:focus-visible {
  grid-template-columns: 44px 1fr;
  box-shadow: inset 0 0 0 1px rgb(139 128 255 / 0.55);
  background: rgb(139 128 255 / 0.1);
  /* opening: grow straight away */
  transition:
    grid-template-columns 0.95s 0s var(--ease),
    box-shadow 0.6s ease,
    background-color 0.6s ease;
}

.github:focus-visible {
  outline: 1px solid var(--accent-soft);
  outline-offset: 3px;
}

/* 404 */
.lost .name { font-size: clamp(3rem, 12vw, 8rem); }

.home {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid rgb(244 242 255 / 0.3);
  transition: border-color 0.25s ease;
}

.home:hover, .home:focus-visible { border-color: var(--accent-soft); outline: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(0.35em); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes fade { to { opacity: 1; } }

@keyframes fade-to { to { opacity: 0.85; } }

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  80%, 100% { transform: scale(4.3); opacity: 0; }
}

@media (max-width: 520px) {
  .hero { padding-bottom: 28svh; }
  .soon { letter-spacing: 0.24em; padding-left: 0.24em; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .hero { padding-bottom: 16svh; }
  .name { font-size: clamp(3rem, 18vh, 7rem); }
}

@media (prefers-reduced-motion: reduce) {
  .surface, .name, .name .l, .s, .name.split .sl, .soon, .github { animation: none; opacity: 1; }
  .mark path { animation: none; opacity: 0; }
  .pulse::after { animation: none; opacity: 0; }
  .github, .gc, .gh-stars { transition: none !important; }
}
