/* eliasmueller.dev
   One motif: structure resolving out of noise, as in a diffusion model.
   The portrait denoises on load; below it a vessel tree branches to every
   heading and denoises as you scroll (tree.js). */

/* Source Serif 4 for reading, Source Sans 3 for names, dates and labels:
   the same superfamily as the PDF CV. */
@font-face {
  font-family: "Source Serif 4";
  src: url("assets/fonts/source-serif-4-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("assets/fonts/source-serif-4-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("assets/fonts/source-sans-3-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Sans 3";
  src: url("assets/fonts/source-sans-3-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

:root {
  /* Dark, as in an MR angiogram: bright vessels on a blue-black ground. */
  --paper: #12181C;
  --ink: #E2E8EA;
  --muted: #8F9CA4;
  --accent: #8BC4CB;     /* links only */
  --line: #34414A;
  --tint: #1E282E;
  --vessel: #C8D3D8;     /* the tree: a little below the text, like contrast in a vessel */

  --serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --sans: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;

  --col: 360px;          /* portrait above, tree below */
  --gap: 48px;
  --main: 560px;

  color-scheme: dark;
}

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

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

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

::selection { background: color-mix(in srgb, var(--accent) 38%, var(--paper)); color: #fff; }

h1, h2, h3, h4, p, figure { margin: 0; }
p { text-wrap: pretty; }

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 2px;
  transition: text-decoration-color 120ms, background-color 120ms;
}
a:hover {
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  background-color: var(--tint);
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

strong { font-weight: 600; }

/* ---------- Page frame ---------- */

.page {
  position: relative;
  max-width: calc(var(--col) + var(--gap) + var(--main));
  margin: 0 auto;
  padding: 0 32px 64px;
  box-sizing: content-box;
}

/* Sized and drawn by tree.js. */
#tree {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 0;
}

.top,
.hero,
.body { position: relative; z-index: 1; }

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

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 24px;
  padding: 24px 0 8px;
}

/* Contact: icons. Fixed at the top left where there is room beside the
   page; otherwise at the start of the top bar. Labels show on hover and focus. */
.contact {
  display: flex;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.contact a {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  transition: color 120ms, background-color 120ms;
}
.contact a:hover,
.contact a:focus-visible {
  color: var(--ink);
  background-color: var(--tint);
}
.contact svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.contact svg.solid {
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: none;
}
.contact .label {
  position: absolute;
  top: 50%;
  left: calc(100% + 8px);
  transform: translate(-4px, -50%);
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--tint);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms, transform 120ms;
}
.contact a:hover .label,
.contact a:focus-visible .label {
  opacity: 1;
  transform: translate(0, -50%);
}
/* Below the icons in the top bar, labels would run into the nav: show them underneath. */
@media (max-width: 1199px) {
  .contact .label {
    top: calc(100% + 6px);
    left: 0;
    transform: translate(0, -4px);
  }
  .contact a:hover .label,
  .contact a:focus-visible .label { transform: translate(0, 0); }
}
@media (min-width: 1200px) {
  .contact {
    position: fixed;
    top: 24px;
    left: 24px;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
  }
  .top { justify-content: flex-end; }
}
.top nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  font-size: 0.9375rem;
}

/* ---------- Hero ---------- */

.hero,
.body {
  display: grid;
  grid-template-columns: var(--col) minmax(0, 1fr);
  column-gap: var(--gap);
}
.hero {
  align-items: start;
  padding-top: 8px;
}

.portrait {
  position: relative;
  margin-top: 12px;
  width: var(--col);
  aspect-ratio: 800 / 913;
}
.portrait img {
  display: block;
  width: 100%;
  height: auto;
}
/* The bust ends softly rather than in a hard crop. */
.portrait img,
.portrait-noise {
  -webkit-mask-image: linear-gradient(to bottom, #000 86%, transparent 99%);
  mask-image: linear-gradient(to bottom, #000 86%, transparent 99%);
}
/* The seed of the tree: a tile of noise under the portrait, with its number.
   The trunk begins below it (tree.js reads its position). Pressing it
   samples another tree. */
.seed {
  position: absolute;
  top: calc(100% + 6px);
  left: calc(50% - 14px);
  display: flex;
  align-items: center;
  gap: 10px;
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font-family: var(--sans);
  font-size: 0.8125rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  border-radius: 2px;
}
.seed canvas {
  display: block;
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}
.seed:hover, .seed:focus-visible { color: var(--ink); }
.seed:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
html:not(.tree) .seed { display: none; }

/* The portrait is sampled from noise on load (tree.js draws it here). When
   it is done the photo appears underneath and this fades away. */
.portrait-noise {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity 500ms ease-out;
}
.js .portrait img { opacity: 0; }
.js.shown .portrait img { opacity: 1; }
.js.denoising .portrait-noise { opacity: 1; transition: none; }

h1, h2, h3, h4, .when, .top, .detail, .facts dt {
  font-family: var(--sans);
}

h1 {
  font-size: clamp(2rem, 1.6rem + 1.4vw, 2.625rem);
  line-height: 1.02;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.lede {
  margin-top: 16px;
  font-size: 1.25rem;
  line-height: 1.4;
}

.intro > p + p { margin-top: 14px; }
.intro > .lede + p { margin-top: 20px; }

/* ---------- Body ---------- */

.body { margin-top: 88px; }
.main-col {
  grid-column: 2;
  min-width: 0;
  position: relative;
}

/* Short or full CV. Everything marked .full-only is left out of the short one. */
.js:not(.full) .full-only { display: none; }
.detail { font-family: var(--sans); font-size: 0.9375rem; }
.detail-top {
  position: absolute;
  top: 5px;
  right: 0;
}
.detail-end { margin-top: 48px; }
.no-js .detail { display: none; }
.detail button {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 2px;
}
.detail button:hover { text-decoration-color: var(--accent); text-decoration-thickness: 2px; background-color: var(--tint); }
.detail button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.section { scroll-margin-top: 24px; }
.section + .section { margin-top: 64px; }

h2 {
  font-size: 1.3125rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

/* ---------- Entries ---------- */

.entry { scroll-margin-top: 24px; }
.entry + .entry { margin-top: 26px; }

.entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 24px;
}
h3, h4 {
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 600;
}
.when {
  flex: none;
  font-size: 0.875rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.sub {
  margin-top: 1px;
  font-size: 0.9375rem;
  font-style: italic;
  color: var(--muted);
}
.entry > p:not(.sub) { margin-top: 6px; }
.entry > .sub + p { margin-top: 6px; }
.entry a { white-space: nowrap; }

/* Projects within a role, one step down the tree. */
.sub-entry { margin-left: 28px; }
.entry > .sub-entry { margin-top: 18px; }
.entry > .entry-head + .sub-entry { margin-top: 12px; }
.entry > .sub-entry:not(:has(> p:not(.sub))) + .sub-entry:not(:has(> p:not(.sub))) { margin-top: 12px; }

/* ---------- Skills and memberships ---------- */

.facts { margin: 0; }
.facts > div {
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
  column-gap: 24px;
}
.facts > div + div { margin-top: 8px; }
.facts dt { font-weight: 600; font-size: 1rem; line-height: 1.6; }
.facts dd { margin: 0; text-wrap: pretty; }

/* Without the script (or if it fails): a plain line marks the column. */
html:not(.tree) .main-col {
  border-left: 1px solid var(--line);
  padding-left: 24px;
  margin-left: -25px;
}

/* ---------- Narrower screens ---------- */

@media (max-width: 1100px) {
  :root { --col: 300px; --gap: 40px; }
}

@media (max-width: 899px) {
  :root { --col: 240px; --gap: 32px; }
  .lede { font-size: 1.1875rem; }
  .facts > div { grid-template-columns: 1fr; }
}

@media (max-width: 719px) {
  /* The portrait stacks above the text; the tree runs in a narrow gutter. */
  :root { --col: 52px; --gap: 0px; }
  .page { padding-inline: 16px; }
  .top { padding-top: 16px; }
  .top nav { gap: 4px 16px; font-size: 0.875rem; }
  .contact { gap: 4px; }
  .hero {
    grid-template-columns: 1fr;
    row-gap: 28px;
  }
  .portrait { width: min(320px, 80vw); }
  .seed { left: 14px; }
  .seed canvas { width: 21px; height: 21px; }
  .seed-n { display: none; }
  .intro { padding-left: var(--col); }
  .body { margin-top: 56px; }
  .section + .section { margin-top: 52px; }
  .detail-top { top: 3px; }
  h2 { font-size: 1.25rem; }
  .entry-head { flex-direction: column; gap: 0; }
  .when { order: 2; }
  .sub-entry { margin-left: 20px; }
}

/* On phones the icons are enough up top: the section links would not fit beside them. */
@media (max-width: 479px) {
  .top nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .js .portrait img { opacity: 1; transition: none; }
  .portrait-noise { display: none; }
}

@media print {
  #tree, .top nav, .portrait-noise, .detail, .contact svg, .contact li:has(a[download]), .seed { display: none; }
  .top { padding: 0 0 8px; justify-content: flex-start; }
  .contact { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px 16px; }
  .contact a { display: inline; width: auto; height: auto; }
  .contact .label { position: static; opacity: 1; transform: none; padding: 0; background: none; }
  .js .portrait img { opacity: 1; }
  :root {
    --paper: #fff; --ink: #1D2730; --muted: #56616B; --accent: #0E5A66; --line: #C9D3D6; --tint: #E6EEF0;
    color-scheme: light;
  }
  body { background: #fff; font-size: 10.5pt; }
  .page { padding: 0; max-width: none; }
  html:not(.tree) .main-col, .main-col { border: 0; padding: 0; margin: 0; }
  .hero { grid-template-columns: 120px 1fr; column-gap: 24px; align-items: start; }
  .portrait { width: 120px; }
  .body { grid-template-columns: 0 1fr; column-gap: 0; margin-top: 24px; }
  .section + .section { margin-top: 24px; }
  h2, h3, h4, .entry-head { break-after: avoid; }
  .entry-head, .sub-entry, .facts > div { break-inside: avoid; }
  a { color: var(--ink); }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
  .contact a { color: var(--ink); }
}
