/* ============================================================
   "First day of class"
   A chalkboard in Eagles midnight green. The room starts with the
   lights off; switch them on and the wall is lo-fi technical paper.
   Pixel type: Departure Mono (sizes in multiples of 11px so every
   font pixel lands on a whole screen pixel). Reading text: Geist.
   The board is the only loud thing on the page.
   ============================================================ */

@font-face {
  font-family: "Departure Mono";
  src: url(../vendor/fonts/departure-mono-1.500.woff2) format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;     /* scrollbars and other browser-drawn parts follow the room */

  /* lights off is how the room starts: a dark wall and a lit board */
  --plaster:   #0b1112;   /* the wall */
  --ink:       #dfe6e2;
  --graphite:  #98a6a2;   /* secondary text */
  --rule:      #2b3634;
  --line:      #000000;   /* hard outlines */
  --link:      #8fd0c9;
  --marker:    #11474d;   /* highlighter */

  --midnight:      #004c54;   /* the board */
  --midnight-deep: #023b42;
  --midnight-lift: #0b5a63;
  --chalk:   #eef2ea;
  --chalk-2: #c9dad4;
  --chalk-3: #a3c0bb;
  --chalk-4: #7da6a3;
  --yellow:  #f0dc82;         /* the second stick of chalk */

  --alu:    #5a6362;          /* board frame */
  --alu-hi: #747d7c;
  --alu-lo: #3a4241;

  --pixel: "Departure Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --text:  "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;

  --page:    76.25rem;
  --gutter:  clamp(1rem, 4vw, 3rem);
  --rail:    12.5rem;
  --measure: 35rem;
}

/* lights on: plaster wall, ink text. The board looks the same either way. */
html[data-lights="on"] {
  color-scheme: light;
  --plaster:  #eceeea;
  --ink:      #1b211f;
  --graphite: #59635f;
  --rule:     #bfc6c2;
  --line:     #1b211f;
  --link:     #004c54;
  --marker:   #cfe2d5;
  --alu:      #aab1b1;
  --alu-hi:   #d3d8d7;
  --alu-lo:   #7c8484;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--plaster);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, canvas, video { display: block; max-width: 100%; }

a {
  color: var(--link);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
a:hover { background: var(--marker); }            /* a swipe of highlighter */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
::selection { background: var(--midnight); color: var(--chalk); }

.skip {
  position: absolute; left: var(--gutter); top: -4rem;
  font: 16.5px/22px var(--pixel);
  background: var(--ink); color: var(--plaster);
  padding: 0.4rem 0.7rem;
}
.skip:focus { top: 0.5rem; }

/* ============================================================
   TOP LINE
   ============================================================ */
.top {
  max-width: var(--page);
  margin: 0 auto;
  padding: 1rem var(--gutter) 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  flex-wrap: wrap;
  font: 16.5px/22px var(--pixel);
}
.top nav { display: flex; flex-wrap: wrap; gap: 0 1.6rem; }
.top nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.5rem 0;
}
.top nav a:hover { background: none; text-decoration: underline; text-decoration-thickness: 2px; }
.lights {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--ink);
  padding: 0.2rem 0.65rem;
  cursor: pointer;
}
.lights:hover { background: var(--ink); color: var(--plaster); }

/* ============================================================
   THE BOARD
   ============================================================ */
.classroom {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.board {
  position: relative;
  padding: 8px 8px 0;
  background: var(--alu);
  box-shadow:
    inset 2px 2px 0 var(--alu-hi),
    inset -2px -2px 0 var(--alu-lo),
    0 0 0 2px var(--line);
}

.board-surface {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--midnight);
  color: var(--chalk);
  box-shadow: 0 0 0 2px var(--alu-lo);
  font-family: var(--pixel);
  padding: 26px 36px 28px;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  column-gap: 44px;
}

/* eraser smudges, painted once by chalk.js */
.dust {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  image-rendering: pixelated;
  pointer-events: none;
}

/* chalk skips: a few board pixels knocked out of every stroke (mask built by chalk.js) */
.name, .role, .math, .dne {
  -webkit-mask-image: var(--grain);
  mask-image: var(--grain);
  -webkit-mask-size: 128px 128px;
  mask-size: 128px 128px;
}

/* the name, the way a teacher writes it on day one.
   Line box is 14 font-pixels tall: caps run from pixel 3 to pixel 11, so the
   four bands below each cover exactly two rows of the letters.
   The h1's own text is invisible and only casts the hard shadow; the lettering
   itself is a copy laid on top, so the shadow can never paint over it. */
.name {
  grid-column: 1 / -1;
  justify-self: start;
  position: relative;
  margin: 0;
  font: 400 77px/calc(14em / 11) var(--pixel);
  text-transform: uppercase;
  white-space: nowrap;
  color: transparent;
  text-shadow: calc(1em / 11) calc(1em / 11) 0 var(--midnight-deep);   /* one font-pixel of depth */
}
.name::before {
  content: attr(data-text);
  content: attr(data-text) / "";      /* decorative copy: keep it out of the accessibility tree */
  position: absolute;
  left: 0;
  top: 0;
  color: var(--chalk);
  text-shadow: none;
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .name::before {
    background: linear-gradient(180deg,
      var(--chalk)   0 calc(5em / 11),
      var(--chalk-2) 0 calc(7em / 11),
      var(--chalk-3) 0 calc(9em / 11),
      var(--chalk-4) 0);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
}
@media (forced-colors: active) {      /* high-contrast mode: one plain copy of the name */
  .name { color: CanvasText; text-shadow: none; }
  .name::before { content: none; }
}
.name::after {                      /* underlined twice */
  content: "";
  display: block;
  height: 2px;
  background: var(--chalk-2);
  box-shadow: 0 6px 0 var(--chalk-4);
  margin-bottom: 8px;
}

.role {
  grid-column: 1 / -1;
  margin: 12px 0 28px;
  max-width: 68ch;
  font-size: 22px;
  line-height: 32px;
}

.dne {
  position: absolute;
  top: 30px;
  right: 34px;
  margin: 0;
  padding: 6px 10px 4px;
  border: 2px solid var(--yellow);
  color: var(--yellow);
  font-size: 11px;
  line-height: 14px;
}

/* ---- equations ---- */
.math {
  grid-column: 1;
  display: grid;
  align-content: start;
  row-gap: 20px;
  font-size: 22px;
  line-height: 32px;
}
.eq {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 16px;
  row-gap: 2px;
}
.eq .expr { white-space: nowrap; }
.eq sub,
.eq sup {
  position: relative;
  font-size: 11px;
  line-height: 0;
  vertical-align: baseline;
}
.eq sup { top: -12px; }
.eq sub { top: 6px; }
.frac {
  display: inline-grid;
  text-align: center;
  vertical-align: middle;
  margin: 0 4px;
}
.frac > span { padding: 0 6px; }
.frac > span:first-child { border-bottom: 2px solid currentColor; }
.eq .note {
  color: var(--yellow);
  font-size: 11px;
  line-height: 16px;
}

/* ---- the plot ---- */
.plot {
  grid-column: 2;
  position: relative;
  margin: 0;
  min-width: 0;
}
.plot canvas {
  image-rendering: pixelated;
  cursor: crosshair;
  touch-action: manipulation;
}
.plot-label {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  font-size: 11px;
  line-height: 14px;
  color: var(--chalk-2);
}
.replay {                           /* keyboard twin of clicking the board; shows only when focused */
  position: absolute;
  right: 0;
  top: 0;
  font: 11px/14px var(--pixel);
  color: var(--midnight-deep);
  background: var(--yellow);
  border: 0;
  padding: 5px 8px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}
.replay:focus-visible {
  opacity: 1;
  pointer-events: auto;
  outline: 2px solid var(--chalk);
  outline-offset: 2px;
}
.readout {
  margin: 8px 0 0;
  min-height: 16px;
  font-size: 11px;
  line-height: 16px;
  color: var(--yellow);
  white-space: pre;
}

/* ---- chalk tray ---- */
.tray {
  position: relative;
  height: 18px;
  margin: 8px -14px 0;
  background: var(--alu);
  box-shadow:
    inset 0 2px 0 var(--alu-hi),
    inset 0 -4px 0 var(--alu-lo),
    0 0 0 2px var(--line);
}
.tray::before {                     /* a stick of chalk */
  content: "";
  position: absolute;
  left: 11%;
  top: -6px;
  width: 36px;
  height: 6px;
  background: var(--chalk);
  box-shadow: inset 0 -2px 0 var(--chalk-3);
}
.tray::after {                      /* the eraser: wood on top, felt below */
  content: "";
  position: absolute;
  right: 8%;
  top: -14px;
  width: 58px;
  height: 14px;
  background: linear-gradient(180deg, #8a6a4d 0 6px, #262b2a 6px);
}

.figcap {
  margin: 1.5rem 0 0;
  max-width: 44rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--graphite);
}
.figcap b {
  font: 400 16.5px/1 var(--pixel);
  color: var(--ink);
  margin-right: 0.5em;
}

/* without the script there is no plot, so don't promise one */
html:not(.js) .plot,
html:not(.js) .lights,
html:not(.js) .classroom > .figcap { display: none; }

/* ============================================================
   THE REST: quiet technical paper
   Section name sits in the left rail; content in one column.
   ============================================================ */
.sheet {
  max-width: var(--page);
  margin: 0 auto;
  padding: clamp(3.5rem, 9vh, 5.75rem) var(--gutter) 0;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  column-gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
}
.sheet > h2 {
  margin: 0;
  padding-top: 0.3rem;
  font: 400 16.5px/22px var(--pixel);
  color: var(--graphite);
}
.col > p { margin: 0 0 1.05rem; max-width: var(--measure); }
.col > p:last-child { margin-bottom: 0; }

.lead {
  font: 400 33px/42px var(--pixel);
  color: var(--ink);
  margin-bottom: 1.5rem;
}
mark {
  background: var(--marker);
  color: inherit;
  padding: 0.1em 0.12em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ---- about ---- */
.about-col {
  display: grid;
  grid-template-columns: minmax(0, var(--measure)) 15rem;
  column-gap: 2.5rem;
  align-items: start;
}
.about-col > .lead { grid-column: 1 / -1; }
.about-text > p { margin: 0 0 1.05rem; }
.about-text > p:last-child { margin-bottom: 0; }

.portrait { position: relative; margin: 0; }
.portrait-frame {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 2px solid var(--line);
  background: #f4f6f2;                /* the paper the one-bit version is printed on */
  overflow: hidden;
}
.is-dithered .portrait-frame { cursor: pointer; }
.portrait-frame img { width: 100%; height: auto; object-fit: cover; }
.portrait-frame canvas {              /* the one-bit version waits on top of the photo */
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  visibility: hidden;
}
.is-pixel .portrait-frame canvas { visibility: visible; }
.is-pixel .portrait-frame img { visibility: hidden; }   /* still holds the frame open */
.portrait figcaption {
  margin-top: 0.6rem;
  font: 11px/16px var(--pixel);
  color: var(--graphite);
}

/* ---- what I work in ---- */
.kit { margin: 0; }
.kit > div {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  column-gap: 2rem;
  padding: 0.95rem 0;
  border-top: 2px dotted var(--rule);
}
.kit > div:first-child { border-top: 0; padding-top: 0; }
.kit dt { font: 400 16.5px/26px var(--pixel); }
.kit dd { margin: 0; max-width: 30rem; }

/* ---- path ---- */
.path { list-style: none; margin: 0; padding: 0; }
.path > li {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  column-gap: 2rem;
  padding: 1.35rem 0;
  border-top: 2px dotted var(--rule);
}
.path > li:first-child { border-top: 0; padding-top: 0; }
.era { font: 400 16.5px/30px var(--pixel); color: var(--graphite); }
.path h3 { margin: 0 0 0.2rem; font: 400 22px/30px var(--pixel); }
.path p { margin: 0; max-width: 32rem; }
.logos { display: flex; align-items: center; gap: 1.2rem; margin-top: 0.8rem; min-height: 26px; }
.logos img { height: 24px; width: auto; filter: brightness(0) invert(0.85); opacity: 0.72; }
.logos img.seal { height: 38px; filter: grayscale(1) brightness(1.7) contrast(1.05); opacity: 0.9; }
html[data-lights="on"] .logos img { filter: brightness(0); }
html[data-lights="on"] .logos img.seal { filter: grayscale(1) contrast(1.15); }

/* ---- work ---- */
.proj { padding: 1.6rem 0; border-top: 2px dotted var(--rule); }
.proj:first-child { border-top: 0; padding-top: 0; }
.proj h3 { margin: 0 0 0.5rem; font: 400 22px/30px var(--pixel); }
.proj > p { margin: 0 0 1.05rem; max-width: var(--measure); }
.proj .stack {
  margin: 0 0 0.5rem;
  font: 11px/16px var(--pixel);
  color: var(--graphite);
}
.proj .repo { margin: 0; font: 16.5px/24px var(--pixel); }
.proj .repo a,
.elsewhere a { display: inline-block; padding: 4px 0; }   /* a taller target for fingers */

/* the demo sits in an old-school window */
.demo { margin: 0; }
.demo + p { margin-top: 1.6rem; }   /* text that picks up after a figure */
.window {
  margin: 1.6rem 6px 6px 0;
  max-width: 46rem;
  border: 2px solid var(--line);
  box-shadow: 6px 6px 0 var(--line);
  background: #07090a;
}
.window-bar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 8px;
  background: var(--line);
  color: #eceeea;
  font: 11px/22px var(--pixel);
  border-bottom: 2px solid var(--line);
}
.window video { width: 100%; height: auto; }
.window + .figcap { margin-top: 1.1rem; }

/* ---- contact ---- */
.mail {
  display: inline-block;
  font: 400 33px/42px var(--pixel);
  overflow-wrap: anywhere;
}
.elsewhere {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.8rem;
  margin: 1.6rem 0 0;
  padding: 0;
  list-style: none;
  font: 16.5px/24px var(--pixel);
}

.colophon {
  max-width: var(--page);
  margin: 0 auto;
  padding: 1.3rem var(--gutter) 2.4rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem 2rem;
  font: 11px/16px var(--pixel);
  color: var(--graphite);
}
.colophon p { margin: 0; }
.colophon-rule {
  max-width: var(--page);
  margin: clamp(4rem, 10vh, 6rem) auto 0;
  padding: 0 var(--gutter);
}
.colophon-rule::before { content: ""; display: block; border-top: 2px dotted var(--rule); }

/* ============================================================
   NARROWER SCREENS
   ============================================================ */
@media (max-width: 1100px) {
  .board-surface { grid-template-columns: minmax(0, 1fr); padding: 24px 28px 26px; }
  .math, .plot { grid-column: 1; }
  .math { margin-bottom: 30px; }
  .name { font-size: 55px; }
  .about-col { grid-template-columns: minmax(0, 1fr) 13rem; }
}

@media (max-width: 860px) {
  .sheet { grid-template-columns: minmax(0, 1fr); row-gap: 1.1rem; }
  .sheet > h2 { padding-top: 0; }
  .about-col { grid-template-columns: minmax(0, 1fr); row-gap: 1.8rem; }
  .portrait { max-width: 15rem; }
  .kit > div { grid-template-columns: minmax(0, 1fr); row-gap: 0.1rem; }
}

@media (max-width: 620px) {
  .top { font-size: 11px; line-height: 16px; padding-top: 0.6rem; padding-bottom: 0.6rem; }
  .top nav { gap: 0 1.15rem; }
  .top nav a { padding: 0.75rem 0; }
  .lights { padding: 0.5rem 0.6rem; }

  .board { padding: 6px 6px 0; }
  .board-surface { padding: 16px 14px 18px; }
  .tray { margin: 6px -8px 0; }
  .name { font-size: 33px; }
  .dne { position: static; order: 9; justify-self: end; margin: 16px 0 0; }
  .role { font-size: 16.5px; line-height: 24px; margin: 10px 0 22px; }
  .math { font-size: 16.5px; line-height: 24px; row-gap: 16px; }
  .eq sup { top: -9px; }
  .eq sub { top: 4px; }

  .lead { font-size: 22px; line-height: 30px; }
  .path > li { grid-template-columns: minmax(0, 1fr); row-gap: 0.1rem; }
  .era { line-height: 22px; }
  .mail { font-size: 16.5px; line-height: 24px; }
  .window { box-shadow: 4px 4px 0 var(--line); }
}
