/* Bricolage Grotesque, SIL Open Font License 1.1 (fonts/OFL.txt). */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --paper: #f4f5f7;
  --surface: #ffffff;
  --ink: #14171c;
  --muted: #5b6270;
  --rule: #dde1e7;
  --link: #1f4f99;
  /* The dark bars at the top and bottom of every page. */
  --band: #101318;
  --band-plate: #181c23;
  --band-rule: #262b34;
  --band-ink: #eef0f3;
  --band-muted: #a0a7b3;
  /* The bit lamps in the hero and the mark. */
  --lamp: #ffb020;
  --lamp-top: #ffd27a;
  --lamp-glow: rgb(255 176 32 / 0.4);
  --lamp-off: #232831;
  --lamp-side: #b8730a;
  /* Each project's accent on a dark screen: Lepticons from its demo site, BitFort from the
     dark theme of bitfort.dev. */
  --lepticons: #3b82f6;
  --bitfort: #7d6bff;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1014;
    --surface: #151920;
    --ink: #e9ecf0;
    --muted: #98a1ae;
    --rule: #262b34;
    --link: #93b4ef;
    --band: #07090c;
    --band-plate: #11151b;
    --band-rule: #1f242c;
    --lamp-off: #1d2129;
  }
}

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

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--sans);
}

main {
  flex: 1;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--display);
  letter-spacing: -0.02em;
}

h2 {
  font-size: 2rem;
  font-weight: 650;
  line-height: 1.1;
}

h3 {
  font-size: 1.75rem;
  font-weight: 650;
  line-height: 1.2;
}

p + p {
  margin-top: 0.75rem;
}

/* Keeps a hyphenated word on one line. */
.nowrap {
  white-space: nowrap;
}

/* Text for screen readers and translation tools only, such as the name of an icon link. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

a {
  color: var(--link);
  text-underline-offset: 0.15em;
}

a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: 3px;
}

.container {
  width: 100%;
  max-width: 70rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--band);
  border-bottom: 1px solid var(--band-rule);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--band-ink);
  font: 700 1.375rem/1 var(--display);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
}

.topbar nav,
.bottombar nav {
  display: flex;
  gap: 1.5rem;
}

.topbar nav a,
.bottombar nav a {
  color: var(--band-muted);
  font-size: 0.9375rem;
  text-decoration: none;
}

.topbar nav a:hover,
.bottombar nav a:hover {
  color: var(--band-ink);
}

/* Hero */

.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(40rem 26rem at 78% 50%, rgb(255 176 32 / 0.12), transparent 70%),
    var(--band);
  color: var(--band-ink);
}

/* A faint dot grid that fades out around the lamp panel. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(rgb(255 255 255 / 0.1) 1px, transparent 1.5px) 0 0 / 1.5rem 1.5rem;
  mask-image: radial-gradient(48rem 30rem at 78% 50%, #000, transparent 70%);
}

.hero-inner {
  position: relative;
  display: grid;
  align-items: center;
  gap: 3rem;
  padding-top: 5rem;
  padding-bottom: 5.5rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 1.5rem + 4.6vw, 5rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.hero p {
  max-width: 32rem;
  margin-top: 1.5rem;
  font-size: 1.1875rem;
  color: var(--band-muted);
}

/* A tilted 3D slab: the hero's lamp panel and each project's emblem panel. Under the pointer, it
   turns toward the visitor. */
.stage {
  perspective: 75rem;
}

.slab {
  position: relative;
  padding: 0.875rem;
  background: var(--band-plate);
  border: 1px solid var(--band-rule);
  border-radius: 1.25rem;
  box-shadow: -2.5rem 3rem 4rem rgb(0 0 0 / 0.55);
  transform: rotateX(24deg) rotateY(-28deg) rotateZ(6deg);
  transform-style: preserve-3d;
}

/* The slab's thickness: a darker copy of the panel, set back in 3D space. */
.slab::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: #05060a;
  transform: translateZ(-1.25rem);
}

/* The hero's slab holds the 9bits mark as nine lamps that stand up like keys. */
.lamps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
  width: 13rem;
}

.lamps span {
  aspect-ratio: 1;
  border-radius: 0.5rem;
  background: var(--lamp-off);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.04),
    0 0.25rem 0 #0b0d11;
  transform: translateZ(0.5rem);
}

.lamps .on {
  background: linear-gradient(to bottom, var(--lamp-top), var(--lamp));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.5),
    0 0.3rem 0 var(--lamp-side),
    0 0 1.75rem var(--lamp-glow);
}

@media (prefers-reduced-motion: no-preference) {
  /* On load, the lit lamps switch on one after another, in reading order. */
  .lamps .on {
    animation: lamp-on 0.35s ease-out both;
    animation-delay: calc(0.25s + var(--i) * 0.11s);
  }

  .slab {
    transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  .stage:hover .slab,
  .project:hover .slab {
    transform: rotateX(12deg) rotateY(-14deg) rotateZ(3deg);
  }
}

@keyframes lamp-on {
  from {
    background: var(--lamp-off);
    box-shadow:
      inset 0 1px 0 rgb(255 255 255 / 0.04),
      0 0.25rem 0 #0b0d11;
  }
}

@media (min-width: 52rem) {
  .hero-inner {
    grid-template-columns: 1fr auto;
    gap: 4rem;
    padding-top: 7rem;
    padding-bottom: 7.5rem;
  }

  .lamps {
    width: 19rem;
    padding: 1.25rem;
    gap: 0.875rem;
  }
}

/* Sections */

.section {
  padding: 5rem 0;
  scroll-margin-top: 4rem;
}

.section h2 {
  margin-bottom: 2rem;
}

.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.25rem;
  padding: 0;
  list-style: none;
}

.project {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 1rem;
}

/* A dark screen that shows the project's pixel emblem in its accent color. */
.screen {
  display: grid;
  place-items: center;
  overflow: hidden;
  height: 12.5rem;
  background:
    radial-gradient(12rem 8rem at 50% 50%, color-mix(in srgb, var(--bit) 24%, transparent), transparent 70%),
    radial-gradient(rgb(255 255 255 / 0.08) 1px, transparent 1.5px) 0 0 / 1.25rem 1.25rem,
    var(--band);
}

/* A gentler tilt than the hero's, so the small pixel emblem stays easy to read. */
.screen .slab {
  padding: 0.75rem;
  border-radius: 1rem;
  box-shadow: -1.5rem 2rem 2.5rem rgb(0 0 0 / 0.5);
  transform: rotateX(16deg) rotateY(-18deg) rotateZ(3deg);
}

/* Each lit pixel has a darker copy drawn just below it, so it stands up like a lamp key. */
.emblem {
  display: block;
  width: 7rem;
  filter: drop-shadow(0 0 0.5rem color-mix(in srgb, var(--bit) 60%, transparent));
  transform: translateZ(0.25rem);
}

.emblem .off {
  fill: var(--lamp-off);
}

.emblem .on-side {
  fill: color-mix(in srgb, var(--bit) 55%, #000);
}

.emblem .on {
  fill: var(--bit);
}

.project-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.75rem 2rem 2rem;
}

.project p {
  color: var(--muted);
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  margin-top: auto;
  padding-top: 0.75rem;
}

/* The GitHub mark as a link to the source code. GitHub's brand rules allow the mark only in grey,
   black, or white: --muted is grey, and --ink is near black or near white. */
.repo-link {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  color: var(--muted);
}

.repo-link:hover {
  color: var(--ink);
}

.repo-link svg {
  width: 1.375rem;
  height: 1.375rem;
  fill: currentColor;
}

.project-links span {
  color: var(--muted);
}

/* Not-found page */

.doc {
  max-width: 42rem;
  padding-top: 4.5rem;
  padding-bottom: 5rem;
}

.doc h1 {
  font-size: clamp(2.25rem, 1.6rem + 2.5vw, 3.25rem);
  font-weight: 700;
  line-height: 1.05;
}

.doc .lead {
  margin-top: 1rem;
  font-size: 1.125rem;
  color: var(--muted);
}

/* Bottom bar */

.bottombar {
  background: var(--band);
  color: var(--band-muted);
  font-size: 0.9375rem;
}

.bottombar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}
