:root {
  --paper: #F5F6F4;
  --ink: #1A2230;
  --band: #0F1526;
  --graphite: #5B6472;
  --rule: #C9CED6;
  --todo: #FFE9A8;

  /* Site-level accent is neutral ink so the three project colors own the color on the page.
     Project accents: each is 4.5:1+ with white text and as text on --paper. */
  --accent: #1A2230;
  --accent-purple: #8F3577; /* formazan purple sampled from the MTT plate photo (hue ~316) */
  --accent-blue: #1E56A0;
  --accent-rust: #A64510;

  /* Duotone shadows. Every channel is <= its accent's, so no duotone pixel is lighter
     than the accent and white text on a band keeps at least the accent's contrast. */
  --shadow-purple: #3D1532;
  --shadow-blue: #0B1E3D;
  --shadow-rust: #3A1706;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Source Serif 4", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.65 var(--body);
}
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
img { max-width: 100%; display: block; }
::selection { background: var(--ink); color: #fff; }

/* Keyboard users can jump past the nav. Appears on focus, instantly (no animation on keyboard actions). */
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 10;
  padding: .6rem 1rem; background: #fff; color: var(--ink);
  font: 600 .9375rem var(--display);
}
.skip-link:focus { top: .5rem; }

/* Placeholders: highlighted so nothing unfinished gets submitted. Ink text so it reads on any background. */
.todo { background: var(--todo); color: var(--ink); padding: 0 .2em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

.wrap { max-width: 68rem; margin: 0 auto; padding: 0 1.5rem; }

/* Dark header band. Nav text is --paper on --band (~17:1). */
.site-header { background: var(--band); color: var(--paper); }
.site-nav {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0 1.5rem;
  padding-top: .5rem; padding-bottom: .5rem;
  font-family: var(--display);
}
/* 44px tall hit areas for every nav link, whatever the text size. */
.site-nav a { display: inline-flex; align-items: center; min-height: 44px; }
.site-nav .home { font-weight: 700; color: #fff; text-decoration: none; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.site-nav ul a { color: var(--paper); text-decoration: none; }
.site-nav a[aria-current="page"] { color: #fff; font-weight: 600; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.site-header a:focus-visible { outline-color: var(--paper); }
@media (hover: hover) and (pointer: fine) {
  .site-nav ul a:hover { text-decoration: underline; text-underline-offset: 6px; }
}

h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; }
h1 {
  font-size: clamp(3rem, 9vw, 6.5rem);
  font-stretch: 75%; font-weight: 800; letter-spacing: -.01em;
  margin: 3.5rem 0 1rem;
}
.lede { font-size: 1.25rem; max-width: 38rem; color: var(--graphite); margin: 0 0 2.5rem; }

/* ---------- Home: split hero ---------- */
.hero { background: #fff; overflow: hidden; }
.hero-inner { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.hero-panel {
  position: relative; background: var(--ink); color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: clamp(2.5rem, 5vw, 3.5rem) 3rem clamp(2rem, 4vw, 3rem) 0;
}
/* Bleed the panel color to the viewport edge while its text stays aligned with the nav. */
.hero-panel::before {
  content: ""; position: absolute; top: 0; bottom: 0; right: calc(100% - 1px);
  width: 100vw; background: var(--ink);
}
.hero-name {
  font-size: clamp(3.25rem, 7.5vw, 6.5rem); font-stretch: 62%; font-weight: 800;
  line-height: .9; letter-spacing: -.015em; margin: 0 0 1.25rem;
  overflow-wrap: anywhere;
}
.hero .lede { color: #fff; font-size: clamp(1.125rem, 1.5vw, 1.3rem); max-width: 30rem; margin: 0; }
.hero-facts { display: flex; align-items: center; padding: 2rem 0 2rem clamp(2rem, 4vw, 3.5rem); }

/* Title block: a 2x2 grid of ruled cells, like the title block on an engineering drawing. */
.title-block { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; margin: 0; border-top: 3px solid var(--ink); }
.title-block div { padding: .75rem 0 .85rem; border-bottom: 1px solid var(--rule); }
.title-block div:nth-child(odd) { padding-right: 1rem; border-right: 1px solid var(--rule); }
.title-block div:nth-child(even) { padding-left: 1rem; }
.title-block dt { margin-bottom: .3rem; font: 600 .75rem var(--display); letter-spacing: .08em; text-transform: uppercase; color: var(--graphite); }
.title-block dd { margin: 0; font: 600 1.0625rem/1.3 var(--display); }

.about { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; padding: 4rem 0; }
.about--intro { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: clamp(2rem, 4vw, 3rem); padding-bottom: 0; }
.contact-line { margin: 0; padding: 3rem 0; font: 500 1.0625rem/1.6 var(--display); }
.contact-line strong { font-weight: 700; }
.about h2 { font-size: 1.25rem; margin-bottom: .75rem; }
.about section { max-width: 36rem; }
.about ul { padding-left: 1.1rem; margin: 0; }

/* Home intro: pure CSS, so it needs no JS and never leaves content hidden. Ends at 840ms. */
@keyframes intro-rise {
  from { opacity: 0; transform: translateY(14px); }
}
.home-intro .hero-name { animation: intro-rise 560ms var(--ease-out) both; }
.home-intro .hero .lede { animation: intro-rise 560ms var(--ease-out) 80ms both; }
.home-intro .title-block > div { animation: intro-rise 560ms var(--ease-out) both; }
.home-intro .title-block > div:nth-child(1) { animation-delay: 160ms; }
.home-intro .title-block > div:nth-child(2) { animation-delay: 200ms; }
.home-intro .title-block > div:nth-child(3) { animation-delay: 240ms; }
.home-intro .title-block > div:nth-child(4) { animation-delay: 280ms; }

/* ---------- Projects ---------- */
.page-title { margin-bottom: 2.5rem; }

.project, .entry { --proj-accent: var(--accent); --proj-shadow: var(--band); }
.project { --overlap: 6rem; margin-bottom: 5rem; }
[data-accent="purple"] { --proj-accent: var(--accent-purple); --proj-shadow: var(--shadow-purple); }
body[data-accent="purple"] { --accent: var(--accent-purple); }
/* Aim the plate photo at the formazan-filled wells, not the empty top row. */
[data-accent="purple"] .band-media { object-position: 40% 58%; }
[data-accent="blue"] { --proj-accent: var(--accent-blue); --proj-shadow: var(--shadow-blue); }
[data-accent="rust"] { --proj-accent: var(--accent-rust); --proj-shadow: var(--shadow-rust); }

/* Full-bleed duotone band: accent ground, grayscale photo multiplied in (black..accent),
   then the shadow color lightened over it (shadow..accent). A missing photo leaves a solid accent. */
.band {
  position: relative; isolation: isolate; overflow: hidden;
  background: var(--proj-accent);
  min-height: calc(clamp(13rem, 26vw, 20rem) + var(--overlap));
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 calc(var(--overlap) + 2rem);
}
.band-media {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: grayscale(1) contrast(1.15) brightness(1.05);
  mix-blend-mode: multiply;
}
.band::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: var(--proj-shadow); mix-blend-mode: lighten;
}
.band-inner { position: relative; z-index: 1; }
.band :is(h1, h2) {
  color: #fff; max-width: 16ch; margin: 0;
  font-size: clamp(2.5rem, 7vw, 5.25rem); font-stretch: 65%; font-weight: 800;
  line-height: .92; letter-spacing: -.01em;
}

/* Illustrated band: drawn directly in the accent's palette, so no blend layers. */
.band--art { background: var(--proj-shadow); min-height: 0; }
.band--art::after { content: none; }
.band--art .band-inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 2rem 3rem; align-items: start; }
.band-art { width: 100%; height: auto; max-width: 34rem; justify-self: end; }
.band-art text { font-family: var(--display); }
.band-art .flow { stroke-dasharray: 6 6; }
@keyframes flow { to { stroke-dashoffset: -24; } }
.band.in-view .flow, .entry.in-view .flow { animation: flow 1.2s linear 3; }

/* Body text always sits on this solid panel, never on the image. */
.card {
  position: relative; z-index: 1; margin-top: calc(-1 * var(--overlap));
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 2.5rem;
  background: #fff; padding: clamp(1.25rem, 3vw, 2.5rem);
  border-top: 4px solid var(--proj-accent);
  box-shadow: 0 24px 48px -28px rgb(15 21 38 / .45);
}
.project figure { margin: 0; }
.project figure img { border: 1.5px solid var(--proj-accent); background: #fff; width: 100%; }
.project figcaption { font-size: .875rem; color: var(--graphite); margin-top: .5rem; }
.bottom-line, .project .bottom-line {
  border: 1.5px solid var(--ink); border-left: 6px solid var(--proj-accent);
  padding: .75rem 1rem; margin: 0 0 1.5rem; max-width: 40rem;
  font: 600 1.0625rem/1.4 var(--display);
}
.project p { margin: 0; max-width: 36rem; }

/* Detail pages: visuals on the left, the rubric sections in order on the right */
.detail-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); align-items: start; }
.detail .band { min-height: calc(clamp(8rem, 16vw, 12rem) + var(--overlap)); }
/* The visual column runs the full height of the text so its section links can stay in view. */
.visuals { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; align-self: stretch; gap: 2rem; }
.toc { position: sticky; top: 1.5rem; font-family: var(--display); }
.toc-title { margin: 0 0 .5rem; font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--graphite); }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc a { display: block; padding: .35rem 0 .35rem .9rem; font-size: .9375rem; font-weight: 500; color: var(--graphite); text-decoration: none; }
.toc a:focus-visible { outline-offset: 0; }
@media (hover: hover) and (pointer: fine) {
  .toc a { transition: color 150ms ease; }
  .toc a:hover { color: var(--ink); }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
.sections > section { scroll-margin-top: 1.5rem; }

/* End of every project page: the next project and a way to get in touch. */
.project-end {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1.25rem 2rem;
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--rule);
}
.next-project { font: 700 clamp(1.25rem, 2.5vw, 1.625rem)/1.2 var(--display); color: var(--ink); text-decoration: none; }
.next-project span { display: block; margin-bottom: .3rem; font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--graphite); }
.next-project::after { content: "\00a0→"; content: "\00a0→" / ""; }
.project-end .contact-line { padding: 0; }
.diagram svg { display: block; width: 100%; height: auto; }
.diagram text { font-family: var(--display); }
.sections .meta { margin: -.75rem 0 1.5rem; font-size: .875rem; line-height: 1.5; color: var(--graphite); }
.sections section + section { margin-top: 1.5rem; }
.sections h2 { font-size: 1.3rem; margin: 0 0 .45rem; }
.sections h3 { font-size: 1.0625rem; margin: 1rem 0 .2rem; color: var(--proj-accent); }
.sections p + p { margin-top: .6rem; }
.sections ul:not(.tools), .sections ol { margin: .4rem 0 0; padding-left: 1.2rem; max-width: 36rem; }
.sections li + li { margin-top: .35rem; }
.sections section > .tools { margin-top: .4rem; }
.project code { font: .875em ui-monospace, "Cascadia Mono", Consolas, monospace; }
.wide-figure { grid-column: 1 / -1; min-width: 0; margin: 0; }
.wide-figure figcaption { max-width: 65ch; }
.wide-figure img { height: auto; }
.scroll-x { overflow-x: auto; }
.scroll-hint { display: none; margin: .5rem 0 0; font: 500 .8125rem var(--display); color: var(--graphite); }
.formula-figure { margin: 0; }
.formula {
  margin: 0; padding: .9rem 1rem; overflow-x: auto;
  background: var(--paper); border-left: 4px solid var(--proj-accent);
  font: .8125rem/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink);
}
.formula code { font: inherit; }

/* Home: project overview */
.overview { padding: clamp(2rem, 4vw, 3rem) 0 1rem; }
.section-title { font-size: clamp(1.75rem, 3.5vw, 2.25rem); font-stretch: 68%; font-weight: 800; margin-bottom: 1.25rem; }
.entries { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
.entry {
  position: relative; display: flex; flex-direction: column; background: #fff;
  border-top: 4px solid var(--proj-accent);
  box-shadow: 0 24px 48px -28px rgb(15 21 38 / .45);
}
/* The whole card is the link: the "Read about" link's hit area stretches over the card. */
.more::before { content: ""; position: absolute; inset: 0; }
@supports selector(:has(*)) {
  .more:focus-visible { outline: none; }
  .entry:has(.more:focus-visible) { outline: 2px solid var(--proj-accent); outline-offset: 4px; }
}
/* Every thumbnail is the same object: a framed plate on its project's deep color. */
.thumb {
  overflow: hidden; aspect-ratio: 16 / 9; padding: .75rem;
  display: grid; place-items: center; background: var(--proj-shadow);
}
.thumb .band-art { width: 100%; height: 100%; max-width: none; }
.thumb--photo .band-media { position: static; width: 100%; height: 100%; object-fit: cover; filter: none; mix-blend-mode: normal; }
.thumb-diagram { width: 100%; height: 100%; }
.thumb-diagram text { font-family: var(--display); }
.entry-body { flex: 1; display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem 1.25rem 1.5rem; }
.entry h3 { font-size: 1.5rem; font-stretch: 80%; }
.entry .bottom-line { margin: 0; font-size: 1rem; }
.entry p { margin: 0; }
.more { margin-top: auto; font: 600 1rem var(--display); color: var(--proj-accent); }
.more::after { content: "\00a0→"; content: "\00a0→" / ""; }
.tools { list-style: none; padding: 0; margin: .75rem 0 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.tools li { font: 500 .875rem var(--display); border: 1px solid var(--proj-accent); color: var(--proj-accent); padding: .15rem .6rem; }
.project .credit {
  margin-top: 1.5rem; padding-top: .75rem; border-top: 1px solid var(--rule);
  font-size: .8125rem; line-height: 1.5; color: var(--graphite);
}

/* Image trigger for the lightbox */
.img-trigger {
  display: block; width: 100%; padding: 0; margin: 0;
  border: 0; background: none; cursor: zoom-in;
}
.img-trigger:focus-visible { outline: 3px solid var(--proj-accent); outline-offset: 3px; }
.img-trigger img { transition: transform 160ms var(--ease-out); }
.img-trigger:active img { transform: scale(0.985); }

/* Reveal on scroll: only hidden once JS has added .js-reveal */
.js-reveal .band .band-media { transform: scale(1.04); transition: transform 500ms var(--ease-out); }
.js-reveal .entry {
  opacity: 0; transform: translateY(20px);
  transition: opacity 480ms var(--ease-out), transform 480ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.js-reveal .entry:nth-child(2) { transition-delay: 60ms; }
.js-reveal .entry:nth-child(3) { transition-delay: 120ms; }
.js-reveal .entry.in-view { opacity: 1; transform: none; }
.js-reveal .band-inner {
  opacity: 0; transform: translateY(18px);
  transition: opacity 480ms var(--ease-out), transform 480ms var(--ease-out);
}
.js-reveal .card {
  opacity: 0; transform: translateY(24px);
  transition: opacity 480ms var(--ease-out) 60ms, transform 480ms var(--ease-out) 60ms;
}
.js-reveal .band.in-view .band-media,
.js-reveal .band.in-view .band-inner,
.js-reveal .card.in-view { opacity: 1; transform: none; }

@media (hover: hover) and (pointer: fine) {
  .project figure img { transition: transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out); }
  .img-trigger:hover img {
    transform: translateY(-3px);
    box-shadow: 0 14px 28px -16px var(--proj-accent);
  }
  .entry { transition: box-shadow 200ms var(--ease-out); }
  .entry:hover { box-shadow: 0 28px 52px -24px rgb(15 21 38 / .6); }
  .more { text-decoration-color: transparent; transition: text-decoration-color 150ms ease; }
  .entry:hover .more { text-decoration-color: currentColor; }
}

/* Lightbox (native <dialog>) */
.lightbox {
  border: 0; padding: 0; background: transparent;
  max-width: min(94vw, 72rem); max-height: 94vh;
  opacity: 1; transform: scale(1);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
@starting-style {
  .lightbox[open] { opacity: 0; transform: scale(0.96); }
}
.lightbox::backdrop { background: rgb(15 21 38 / .82); }
.lightbox-inner {
  position: relative; background: #fff;
  padding: 3rem .75rem .75rem; border-top: 4px solid var(--band);
}
.lightbox-inner img { max-height: calc(94vh - 4rem); width: auto; margin: 0 auto; }
.lightbox-close {
  position: absolute; top: .5rem; right: .5rem;
  display: grid; place-items: center;
  width: 2.25rem; height: 2.25rem; padding: 0;
  font: 400 1.5rem/1 var(--display); color: var(--paper);
  background: var(--band); border: 0; border-radius: 50%;
  cursor: pointer; transition: transform 120ms var(--ease-out);
}
.lightbox-close:active { transform: scale(0.94); }
.lightbox-close:focus-visible { outline: 2px solid var(--band); outline-offset: 2px; }

footer { border-top: 1px solid var(--rule); padding: 1.5rem 0 2.5rem; color: var(--graphite); font-size: .9rem; }

@media (max-width: 760px) {
  .wrap { padding-left: 1.25rem; padding-right: 1.25rem; }
  .hero-inner { grid-template-columns: 1fr; min-height: 0; }
  .hero-panel { padding: 2.5rem 0 2rem; }
  .hero-panel::after {
    content: ""; position: absolute; top: 0; bottom: 0; left: calc(100% - 1px);
    width: 100vw; background: var(--ink);
  }
  .hero-facts { padding: 1.5rem 0 2rem; }
  .about { grid-template-columns: 1fr; gap: 2rem; padding: 3rem 0; }
  .about--intro { padding-top: 2rem; padding-bottom: 0; }
  /* Phones: About, then Projects, then Top skills and Interests. Desktop and the DOM keep
     the chosen order; the moved sections hold no links, so tab order is unchanged. */
  main:has(.intro-wrap) { display: flex; flex-direction: column; }
  .intro-wrap, .intro-wrap .about--intro { display: contents; }
  .about--intro > section { padding-inline: 1.25rem; }
  .about--intro > section:nth-child(1) { order: 1; padding-top: 2rem; }
  main:has(.intro-wrap) .overview { order: 2; }
  .about--intro > section:nth-child(2) { order: 3; padding-top: 2.5rem; }
  .about--intro > section:nth-child(3) { order: 4; padding-top: 2rem; }
  .contact-wrap { order: 5; }
  h1 { margin-top: 2.5rem; }

  .project { --overlap: 2.5rem; margin-bottom: 3.5rem; }
  .card { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .band--art .band-inner { grid-template-columns: 1fr; }
  .toc { display: none; }
  /* A visual column holding only the (hidden) section links would leave an empty grid gap. */
  .visuals:not(:has(figure)) { display: none; }
  .scroll-hint { display: block; }
  .entries { grid-template-columns: 1fr; }
  /* The protocol matrix is 960 units wide; keep its 15px text readable by scrolling instead of shrinking. */
  .scroll-x .img-trigger { min-width: 680px; }
  .overview { padding-top: 3rem; }
  /* One swipeable row instead of a wrapping, two-line header; the fade hints there's more. */
  .site-nav ul {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    width: calc(100% + 2.5rem); margin-inline: -1.25rem; padding-inline: 1.25rem 2.5rem; gap: 1.25rem;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
  }
  .site-nav ul::-webkit-scrollbar { display: none; }
  .site-nav li { flex: none; }
  .band-art { justify-self: stretch; max-width: none; width: calc(100% + 1.5rem); margin-inline: -.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .home-intro .hero-name, .home-intro .hero .lede, .home-intro .title-block > div { animation: none; }
  .js-reveal .band .band-media, .js-reveal .band-inner, .js-reveal .card, .js-reveal .entry { opacity: 1; transform: none; transition: none; }
  .band.in-view .flow, .entry.in-view .flow { animation: none; }
  .lightbox { transition: opacity 150ms ease; transform: none; }
  @starting-style { .lightbox[open] { transform: none; } }
  .img-trigger:hover img, .img-trigger:active img { transform: none; }
}
