/* ------------------------------------------------------------------
   The page is a small instrument: one device with a dot-matrix LCD
   up top, smaller LCD modules for research and projects, and quiet
   type around them.

   Colour has two jobs. The hero screen is dark indigo with lit
   dots: the one loud block on the page. Purple, the alien's colour, marks
   what matters everywhere else: the key detail in each screen,
   links, bullets, the main action, and the footer base. The rest
   stays light grey and near-black text.

   Doto is for display sizes only (22px and up). Everything people
   need to read at small sizes is Archivo; its wide cut (font-stretch
   112%) labels keys and navigation, like print on a front panel.
   ------------------------------------------------------------------ */

:root {
  --font-display: "Doto", ui-monospace, "SF Mono", Menlo, monospace;
  --font-text: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bar-h: 64px;
  --step: 6px;

  color-scheme: light;
  --bg: #FBFBFB;
  --ink: #111111;
  --muted: #555555;
  --line: #D6D6D6;
  --hover: #F1F1F1;

  /* the housing around the display */
  --case: #EDEDED;
  --case-hi: #FFFFFF;
  --case-lo: #CFCFCF;

  /* one light grey for every screen and every key face */
  --panel: #E4E4E4;
  --panel-hi: #F5F5F5;
  --panel-lo: #BBBBBB;
  --panel-hover: #DDDDDD;
  --panel-pressed: #D8D8D8;

  /* screens read like a pale LCD: crisp dark dots, faint unlit ones */
  --led-off: #D7D7D7;
  --led-dim: #9E9E9E;
  --led-on: #141414;
  --led-hot: #000000;
  --led-glow: #B4B4B4;

  /* the accent: the alien's purple */
  --alien: #7B3FE4;
  --accent: #7B3FE4;
  --accent-hi: #A07AF2;
  --accent-lo: #5424B8;
  --accent-hover: #6C31D9;
  --accent-soft: rgba(123, 63, 228, 0.45);
  --led-alien: #6E36DE;
  --led-accent: #7B3FE4;

  /* the hero screen: dark indigo, dots that light up */
  --night: #2B2160;
  --night-hi: #4A3D8A;
  --night-lo: #170F38;
}

::selection { background: #DCD0FF; color: var(--ink); }

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

canvas { display: block; }
a { color: inherit; }
h1, h2, h3 { font-weight: inherit; }

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

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

.skip {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  font: 600 15px/1 var(--font-text);
  text-decoration: none;
}
.skip:focus { top: 12px; }

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
}

/* Square corners with a two-step pixel notch. */
.device,
.screen--small,
.screen--strip,
.key {
  --n: var(--step);
  clip-path: polygon(
    0 calc(var(--n) * 2), var(--n) calc(var(--n) * 2), var(--n) var(--n), calc(var(--n) * 2) var(--n), calc(var(--n) * 2) 0,
    calc(100% - var(--n) * 2) 0, calc(100% - var(--n) * 2) var(--n), calc(100% - var(--n)) var(--n), calc(100% - var(--n)) calc(var(--n) * 2), 100% calc(var(--n) * 2),
    100% calc(100% - var(--n) * 2), calc(100% - var(--n)) calc(100% - var(--n) * 2), calc(100% - var(--n)) calc(100% - var(--n)), calc(100% - var(--n) * 2) calc(100% - var(--n)), calc(100% - var(--n) * 2) 100%,
    calc(var(--n) * 2) 100%, calc(var(--n) * 2) calc(100% - var(--n)), var(--n) calc(100% - var(--n)), var(--n) calc(100% - var(--n) * 2), 0 calc(100% - var(--n) * 2)
  );
}

/* A dashed rule made of square pixels. */
.facts dl > div {
  background-image: linear-gradient(to right, var(--line) 50%, transparent 0);
  background-size: 8px 2px;
  background-repeat: repeat-x;
  background-position: 0 0;
}

/* ---------- Bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}
.bar.is-scrolled { box-shadow: 0 2px 0 0 var(--line); }

.bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--bar-h);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 900 24px/1 var(--font-display);
  text-decoration: none;
}
.logo-alien {
  width: 28px;
  height: 20px;
  color: var(--alien);
  flex: none;
}

.nav ul {
  display: flex;
  gap: 32px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.nav a {
  font: 550 15px/1 var(--font-text);
  font-stretch: 112%;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 7px;
  text-decoration-color: transparent;
  padding: 8px 0;
}
.nav a:hover,
.nav a:focus-visible { text-decoration-color: var(--accent); }

/* ---------- Device (hero) ---------- */

.hero { padding-top: 24px; }

.device {
  padding: 20px 20px 18px;
  background: var(--case);
  box-shadow:
    inset 0 3px 0 0 var(--case-hi),
    inset 0 -5px 0 0 var(--case-lo);
}

/* An LCD window, sitting recessed: dark edge top and left, light
   edge bottom and right. */
.screen {
  background: var(--panel);
  box-shadow:
    inset 3px 3px 0 0 var(--panel-lo),
    inset -3px -3px 0 0 var(--panel-hi);
}
/* the hero screen is dark: dots light up near-white, the alien in
   a light purple that holds up on indigo */
.screen--hero {
  padding: 18px 15px 15px 18px;
  background: var(--night);
  box-shadow:
    inset 3px 3px 0 0 var(--night-lo),
    inset -3px -3px 0 0 var(--night-hi);
  --led-off: #382D72;
  --led-dim: #7A6BBB;
  --led-on: #F4F0FF;
  --led-hot: #FFFFFF;
  --led-glow: #9A8BE0;
  --led-alien: #AC85FF;
}
#matrix { width: 100%; height: 200px; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
  padding-top: 18px;
}
.keys {
  display: flex;
  gap: 10px;
}

/* A key: light face, white top edge, a dark lip that presses in.
   A small square LED shows which mode is on. */
.key {
  --n: 3px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 13px 18px 15px 16px;
  border: 0;
  background: var(--panel);
  color: var(--ink);
  font: 600 15px/1 var(--font-text);
  font-stretch: 112%;
  cursor: pointer;
  box-shadow:
    inset 0 3px 0 0 var(--panel-hi),
    inset 0 -4px 0 0 var(--panel-lo);
  -webkit-tap-highlight-color: transparent;
}
.key:hover { background: var(--panel-hover); }
.key:active,
.key[aria-pressed="true"] {
  background: var(--panel-pressed);
  transform: translateY(2px);
  box-shadow: inset 0 3px 0 0 var(--panel-lo);
}
/* clip-path would cut an outside ring, so the focus ring sits inside */
.key:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -8px;
}
.key-led {
  width: 6px;
  height: 6px;
  background: var(--panel-lo);
  flex: none;
}
.key[aria-pressed="true"] .key-led { background: var(--accent); }

/* the main action on the page gets the accent */
.key--solo {
  background: var(--accent);
  color: #FFFFFF;
  box-shadow:
    inset 0 3px 0 0 var(--accent-hi),
    inset 0 -4px 0 0 var(--accent-lo);
}
.key--solo:hover { background: var(--accent-hover); }
.key--solo:active {
  background: var(--accent-hover);
  box-shadow: inset 0 3px 0 0 var(--accent-lo);
}
.key--solo:focus-visible { outline-color: #FFFFFF; }

.readout {
  margin: 0;
  color: var(--muted);
  font: 500 15px/1.3 var(--font-text);
  font-stretch: 112%;
}

.writer input {
  width: 280px;
  max-width: 100%;
  margin: 0;
  padding: 11px 14px 10px;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
  font: 500 16px/1.2 var(--font-text);
  box-shadow:
    inset 3px 3px 0 0 var(--panel-lo),
    inset -3px -3px 0 0 var(--panel-hi);
}
.writer input::placeholder { color: #666; }
.writer input:focus-visible { outline-offset: 2px; }

.lede {
  max-width: 26em;
  margin: 44px 0 0;
  font-size: 27px;
  font-weight: 450;
  line-height: 1.42;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

/* ---------- Sections ---------- */

.section {
  padding-top: 136px;
  /* land with the title a little below the bar, not 136px down */
  scroll-margin-top: -40px;
}
.section-title {
  margin: 0 0 48px;
  font: 900 clamp(44px, 5.4vw, 68px)/1 var(--font-display);
}

.section a:not(.mail-addr) {
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
  text-decoration-color: var(--accent-soft);
}
.section a:not(.mail-addr):hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

/* Research: a wide strip showing a live event stream, then the work */

.screen--strip {
  --n: 4px;
  aspect-ratio: 6 / 1;
  padding: 14px 12px 12px 14px;
}
.screen--strip canvas { width: 100%; height: 100%; }

.research-body {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 32px 72px;
  margin-top: 40px;
}
.research h3 {
  margin: 0;
  font: 900 34px/1.1 var(--font-display);
}
.research-role {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}
.research-summary {
  margin: 20px 0 0;
  font-size: 19px;
  line-height: 1.55;
  text-wrap: pretty;
}
/* a status line with a lit LED, like the keys */
.status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 24px 0 0;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.5;
  font-stretch: 112%;
}
.status::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: 0.5em;
  background: var(--accent);
  flex: none;
}

.research-work {
  margin: 0;
  padding: 0;
  list-style: none;
}
.research-work li {
  position: relative;
  padding-left: 24px;
  text-wrap: pretty;
}
.research-work li + li { margin-top: 16px; }
.research-work li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 6px;
  height: 6px;
  background: var(--accent);
}
.research-work a { font-weight: 600; white-space: nowrap; }

/* Projects: a small LCD module for each one */

.projects {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 64px 40px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.screen--small {
  --n: 4px;
  aspect-ratio: 2 / 1;
  padding: 14px 12px 12px 14px;
}
.screen--small canvas { width: 100%; height: 100%; }

.project h3 {
  margin: 24px 0 0;
  font: 900 28px/1.1 var(--font-display);
}
.project p {
  max-width: 36em;
  margin: 12px 0 0;
  font-size: 16px;
  line-height: 1.6;
}
.project .project-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
}
.project .project-facts { font-size: 15px; }
.project .project-stack {
  color: var(--muted);
  font-size: 15px;
}
.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  font-weight: 600;
}
.project .project-links { margin-top: 14px; font-size: 15px; }

/* About: a short statement, then education and skills as a fact sheet */

.about {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 40px 72px;
  align-items: start;
}
.about-big {
  max-width: 20em;
  margin: 0;
  font-size: 27px;
  font-weight: 450;
  line-height: 1.42;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
.facts h3 {
  margin: 0 0 12px;
  font: 600 15px/1.2 var(--font-text);
  font-stretch: 112%;
}
.facts dl { margin: 0 0 40px; }
.facts dl:last-child { margin-bottom: 0; }
.facts dl > div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 20px;
  padding: 12px 0 13px;
}
.facts dt {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}
.facts dd {
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
}

/* Contact */

.section--contact { padding-bottom: 152px; }
.contact-note {
  max-width: 32em;
  margin: 0;
  font-size: 19px;
}
.mail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 36px;
  margin: 28px 0 36px;
}
.mail-addr {
  font: 900 clamp(22px, 5vw, 64px)/1.1 var(--font-display);
  text-decoration: underline;
  text-decoration-thickness: 4px;
  text-underline-offset: 12px;
  text-decoration-color: transparent;
  overflow-wrap: anywhere;
}
.mail-addr:hover { text-decoration-color: var(--accent); }

.elsewhere {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 600;
  font-stretch: 112%;
  font-size: 15px;
}

/* Footer: the page settles onto a purple base through a dither */

.foot {
  position: relative;
  margin-top: 48px;
  background: var(--accent);
  color: #FFFFFF;
}
.foot::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 48px;
  background: url("../img/dither.svg") repeat-x 0 0;
}
.foot-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding-top: 28px;
  padding-bottom: 36px;
  font-size: 15px;
}
.foot p {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
}
.foot-alien {
  width: 21px;
  height: 15px;
  color: #FFFFFF;
  flex: none;
}
.foot a {
  font-weight: 600;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
  text-decoration-color: rgba(255, 255, 255, 0.5);
}
.foot a:hover { text-decoration-color: currentColor; }
.foot :focus-visible { outline-color: #FFFFFF; }

/* ---------- Smaller screens ---------- */

@media (max-width: 1000px) {
  .research-body { grid-template-columns: 1fr; gap: 36px; }
  .research-intro { max-width: 40em; }

  /* each project becomes a row: screen left, words right */
  .projects { grid-template-columns: 1fr; gap: 56px; }
  .project {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    column-gap: 32px;
    align-content: start;
  }
  .project > .screen { grid-row: 1 / span 8; align-self: start; }
  .project > :not(.screen) { grid-column: 2; }
  .project h3 { margin-top: 0; }

  .about { grid-template-columns: 1fr; }
  .about-big { max-width: 24em; }
}

@media (max-width: 760px) {
  .section { padding-top: 104px; }
  .lede,
  .about-big { font-size: 23px; }
  .screen--strip { aspect-ratio: 4 / 1; }
}

@media (max-width: 600px) {
  .project { display: block; }
  .project h3 { margin-top: 22px; }
}

@media (max-width: 560px) {
  :root { --step: 4px; }
  /* left and right only: a shorthand here would wipe the sections' top padding */
  .wrap { padding-left: 16px; padding-right: 16px; }
  .bar { position: static; }
  .bar-inner {
    flex-wrap: wrap;
    height: auto;
    padding-top: 14px;
    padding-bottom: 12px;
    gap: 12px;
  }
  .nav { width: 100%; }
  .nav ul { justify-content: space-between; gap: 8px; }
  .section { scroll-margin-top: -72px; }

  .hero { padding-top: 8px; }
  .device { padding: 10px 10px 12px; }
  .screen--hero { padding: 12px 9px 9px 12px; }
  .controls { padding-top: 12px; }
  .keys { width: 100%; }
  .keys .key { flex: 1; justify-content: center; padding-left: 8px; padding-right: 8px; }
  .writer { width: 100%; }
  .writer input { width: 100%; }
  .readout { font-size: 14px; }
  .lede { margin-top: 32px; font-size: 20px; }

  .section-title { margin-bottom: 32px; }
  .screen--strip { aspect-ratio: 3 / 1; }
  .research h3 { font-size: 28px; }
  .research-summary { font-size: 17px; }
  .about-big { font-size: 21px; }
  .facts dl > div { grid-template-columns: 1fr; gap: 2px; }
  .contact-note { font-size: 17px; }
}
