/* tylerbanks.net
 * Palette borrowed from a stained slide: hematoxylin ink, eosin for the trace.
 * Archivo carries the résumé facts; STIX Two Text (the typeface scientific
 * journals are set in) carries prose and citations.
 */

@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-latin-standard-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "STIX Two Text";
  src: url("fonts/stix-two-text-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "STIX Two Text";
  src: url("fonts/stix-two-text-latin-wght-italic.woff2") format("woff2");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #f7f6fb;
  --paper-raised: #ffffff;
  --ink: #1b1838;
  --ink-soft: #57537c;
  --rule: #dcd8ec;
  --stain: #4a3aa7;
  --eosin: #d6336c;

  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --serif: "STIX Two Text", "Iowan Old Style", "Palatino Linotype", Georgia, serif;

  --page: 70rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --rail: 11rem;
  --when: 8.5rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14122a;
    --paper-raised: #1c1938;
    --ink: #eceaf8;
    --ink-soft: #a9a4cb;
    --rule: #2f2b54;
    --stain: #b6aaff;
    --eosin: #ff6fa3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #14122a;
  --paper-raised: #1c1938;
  --ink: #eceaf8;
  --ink-soft: #a9a4cb;
  --rule: #2f2b54;
  --stain: #b6aaff;
  --eosin: #ff6fa3;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.5;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}
ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: var(--stain);
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
}
a:hover {
  text-decoration-thickness: 0.12em;
}
:focus-visible {
  outline: 2px solid var(--eosin);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 20;
  padding: 0.5rem 0.9rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
}
.skip:focus {
  top: 0.6rem;
}

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------------------------------------------------------------- nav */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.site-nav .wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 3.5rem;
}
.site-nav a {
  color: inherit;
  text-decoration: none;
}
.nav-home {
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.nav-links {
  display: flex;
  gap: 1.35rem;
  margin-left: auto;
  font-size: 0.9375rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar {
  display: none;
}
.nav-links a {
  padding-block: 0.35rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.nav-links a:hover,
.nav-links a[aria-current="true"] {
  color: var(--ink);
}
.nav-links a[aria-current="true"] {
  box-shadow: inset 0 -2px 0 var(--eosin);
}
.theme-toggle {
  flex: none;
  font: inherit;
  font-size: 0.875rem;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
}
.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}

/* --------------------------------------------------------------- hero */

.hero {
  padding-top: clamp(3rem, 9vw, 7rem);
}
.hero h1 {
  font-size: clamp(2.9rem, 10.5vw, 8.25rem);
  font-weight: 800;
  font-stretch: 122%;
  line-height: 0.92;
  letter-spacing: -0.035em;
  margin-left: -0.045em; /* optical: pull the T's bar to the margin */
}
.hero .lede {
  max-width: 35em;
  margin-top: clamp(1.5rem, 3vw, 2.5rem);
  font-family: var(--serif);
  font-size: clamp(1.2rem, 1.1rem + 0.6vw, 1.5rem);
  line-height: 1.5;
  text-wrap: pretty;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 2rem;
}
.button {
  display: inline-block;
  padding: 0.7rem 1.35rem;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
  border-radius: 999px;
}
.button:hover {
  background: var(--stain);
}

.trace {
  margin-top: clamp(2rem, 5vw, 3.5rem);
}
.trace canvas {
  display: block;
  width: 100%;
  height: clamp(11rem, 24vw, 16rem);
  font-family: var(--sans);
  cursor: pointer;
  touch-action: pan-y;
}
.trace figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: 0.9rem 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.trace figcaption p {
  max-width: 44em;
}
.trace-controls {
  display: flex;
  gap: 0.5rem;
}
.trace-controls button {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  cursor: pointer;
}
.trace-controls button:hover {
  border-color: var(--ink-soft);
}
.trace-controls button[aria-pressed="true"] {
  background: var(--eosin);
  border-color: var(--eosin);
  color: #fff;
}
:root[data-theme="dark"] .trace-controls button[aria-pressed="true"] {
  color: #14122a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .trace-controls button[aria-pressed="true"] {
    color: #14122a;
  }
}

/* ------------------------------------------------------------ sections */

main {
  padding-bottom: 5rem;
}
.section {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  column-gap: 2rem;
  margin-top: clamp(3.5rem, 8vw, 6rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.section > h2 {
  align-self: start;
  position: sticky;
  top: 5rem;
  font-size: 1.375rem;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.section-note {
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.55;
  max-width: 38em;
  margin-bottom: 2.25rem;
  text-wrap: pretty;
}

.entry {
  display: grid;
  grid-template-columns: var(--when) minmax(0, 1fr);
  column-gap: 1.5rem;
}
.entry + .entry {
  margin-top: 2.25rem;
}
.entry-when {
  padding-top: 0.2em;
  color: var(--ink-soft);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}
.entry h3 {
  font-size: 1.1875rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.005em;
}
.entry-where {
  margin-top: 0.15rem;
  color: var(--ink-soft);
}
.entry-where b {
  color: var(--ink);
  font-weight: 550;
}
.entry-body > p:not(.entry-where),
.entry-body > ul {
  max-width: 43em;
}
.entry-body > p:not(.entry-where) {
  margin-top: 0.6rem;
}
.points {
  margin-top: 0.7rem;
}
.points li {
  position: relative;
  padding-left: 1.1rem;
}
.points li + li {
  margin-top: 0.45rem;
}
.points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.68em;
  width: 0.4rem;
  height: 1.5px;
  background: var(--eosin);
}

/* -------------------------------------------------------- publications */

.pubs-group + .pubs-group {
  margin-top: 3.25rem;
}
.pubs-group > h3 {
  margin-bottom: 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.pub + .pub {
  margin-top: 1.6rem;
}
.pub-title {
  font-family: var(--serif);
  font-size: 1.1875rem;
  font-weight: 500;
  line-height: 1.35;
  max-width: 36em;
  text-wrap: pretty;
}
.pub-authors,
.pub-venue {
  max-width: 44em;
  font-size: 0.9688rem;
}
.pub-authors {
  margin-top: 0.3rem;
}
.pub-authors b {
  font-weight: 700;
}
.pub-venue {
  color: var(--ink-soft);
}
.pub-venue i {
  font-family: var(--serif);
  font-size: 1.04em;
}
.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.1rem;
  margin-top: 0.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
}
.footnote {
  margin-top: 2rem;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

/* -------------------------------------------------------------- skills */

.facts {
  display: grid;
  grid-template-columns: var(--when) minmax(0, 1fr);
  gap: 1.6rem 1.5rem;
}
.facts dt {
  padding-top: 0.1em;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.facts dd {
  max-width: 43em;
}
.facts dd + dd {
  grid-column: 2;
  margin-top: -1.1rem;
}

/* -------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: 2.5rem 3.5rem;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 2rem;
}
.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
}

/* ------------------------------------------------- earlier-work archive */

.page-head {
  padding-top: clamp(2.5rem, 7vw, 5rem);
}
.page-head h1 {
  font-size: clamp(2.25rem, 6vw, 4.25rem);
  font-weight: 800;
  font-stretch: 118%;
  line-height: 1;
  letter-spacing: -0.03em;
}
.page-head p {
  max-width: 36em;
  margin-top: 1.25rem;
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.5;
}
.shots {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.1rem;
}
.shots img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.shots.phones img {
  width: 9.5rem;
}
.entry-body code {
  font-size: 0.92em;
  padding: 0.1em 0.4em;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.entry[id] {
  scroll-margin-top: 5rem;
}

/* -------------------------------------------------------------- narrow */

@media (max-width: 60rem) {
  .section {
    display: block;
  }
  .section > h2 {
    position: static;
    margin-bottom: 1.75rem;
    font-size: 1.5rem;
  }
  .theme-toggle {
    margin-left: 0;
  }
}
@media (max-width: 44rem) {
  .nav-home {
    display: none;
  }
  .nav-links {
    margin-left: 0;
    flex: 1;
    gap: 1.15rem;
    /* fade the edge so it reads as scrollable */
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 1.5rem), transparent);
    padding-right: 1.25rem;
  }
}
@media (max-width: 36rem) {
  .entry,
  .facts {
    display: block;
  }
  .entry-when,
  .facts dt {
    margin-bottom: 0.2rem;
    padding-top: 0;
  }
  .facts dd + dt {
    margin-top: 1.5rem;
  }
  .facts dd + dd {
    margin-top: 0.4rem;
  }
  .entry + .entry {
    margin-top: 2rem;
  }
}

/* --------------------------------------------------------------- print */

@media print {
  :root,
  :root[data-theme="dark"] {
    --paper: #fff;
    --paper-raised: #fff;
    --ink: #000;
    --ink-soft: #333;
    --rule: #bbb;
    --stain: #000;
    --eosin: #000;
    color-scheme: light;
  }
  @page {
    margin: 16mm 15mm;
  }
  body {
    font-size: 10pt;
  }
  .site-nav,
  .trace,
  .actions .button,
  .skip,
  .site-footer ul {
    display: none;
  }
  .hero {
    padding-top: 0;
  }
  .hero h1 {
    font-size: 30pt;
  }
  .hero .lede {
    font-size: 11.5pt;
    margin-top: 8pt;
  }
  .actions {
    margin-top: 8pt;
  }
  .section {
    display: block;
    margin-top: 18pt;
    padding-top: 8pt;
  }
  .section > h2 {
    position: static;
    font-size: 13pt;
    margin-bottom: 8pt;
  }
  .section-note {
    font-size: 10.5pt;
    margin-bottom: 10pt;
  }
  .entry + .entry,
  .pub + .pub {
    margin-top: 10pt;
  }
  .entry h3,
  .pub-title {
    font-size: 11pt;
  }
  .entry,
  .pub {
    break-inside: avoid;
  }
  h2,
  h3 {
    break-after: avoid;
  }
  a {
    text-decoration: none;
  }
  main {
    padding-bottom: 0;
  }
}

/* Entries with no date column (the projects archive). */
.entry.plain {
  display: block;
}
.entry.plain .pub-links {
  margin-top: 0.6rem;
}

/* Citation lines sit closer together than résumé paragraphs. */
.pub .entry-body > .pub-title {
  margin-top: 0;
}
.pub .entry-body > .pub-authors {
  margin-top: 0.35rem;
}
.pub .entry-body > .pub-venue {
  margin-top: 0.1rem;
}
.pub .entry-body > .pub-links {
  margin-top: 0.35rem;
}

/* ------------------------------------------ tissue segmentation figure */

/* The tissue is an alpha mask filled with the page's stain colour, so it
   follows the theme; the outline is drawn over it as a dash that runs out. */
.slide {
  max-width: 27rem;
  margin-top: 1.75rem;
}
.slide-frame {
  position: relative;
  aspect-ratio: 830 / 812;
}
.slide-tissue {
  position: absolute;
  inset: 0;
  background: var(--stain);
  -webkit-mask: url("tissue-mask.webp") center / 100% 100% no-repeat;
  mask: url("tissue-mask.webp") center / 100% 100% no-repeat;
}
.slide-outline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.slide-outline use {
  fill: none;
  stroke: var(--eosin);
  stroke-width: 3.2;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.slide.is-armed .slide-outline use {
  stroke-dashoffset: 1;
}
.slide.is-armed.is-traced .slide-outline use {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 3.2s cubic-bezier(0.45, 0, 0.2, 1);
}
.slide figcaption {
  margin-top: 0.75rem;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.link-button {
  padding: 0;
  font: inherit;
  color: var(--stain);
  background: none;
  border: 0;
  text-decoration: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.18em;
  cursor: pointer;
}
@media print {
  .slide {
    display: none;
  }
}

/* ------------------------------------------------------ neuron controls */

.trace figcaption {
  display: grid;
  gap: 0.9rem;
  justify-content: stretch;
}
.trace-controls {
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem 1.1rem;
}
.dial {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
}
.dial input {
  width: 8.5rem;
  margin: 0;
  accent-color: var(--eosin);
}
.dial output {
  min-width: 4.4em;
  color: var(--ink-soft);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.trace-controls .trace-rate {
  margin-right: auto;
  font-size: 0.875rem;
}
.trace-rate output {
  display: inline-block;
  min-width: 1.9em;
  text-align: right;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------- entry links */

/* Arriving at an entry from a link to it: a brief wash so the eye finds it. */
.entry:target {
  animation: entry-arrive 1.8s ease-out;
}
@keyframes entry-arrive {
  from {
    background: color-mix(in srgb, var(--eosin) 16%, transparent);
    box-shadow: 0 0 0 0.6rem color-mix(in srgb, var(--eosin) 16%, transparent);
  }
  to {
    background: transparent;
    box-shadow: 0 0 0 0.6rem transparent;
  }
}
@media (prefers-reduced-motion: reduce) {
  .entry:target {
    animation: none;
  }
}
@media (max-width: 36rem) {
  .dial input {
    width: 7rem;
  }
}
