/* williamklein.dev
   Type: Source Serif 4 (headlines), IBM Plex Sans (text). Both self-hosted, SIL Open Font License. */

@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans.woff2") format("woff2");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f5f8fa;
  --surface: #ffffff;
  --ink: #12202b;
  --muted: #4f5f6b;
  --rule: #d5dde3;
  --accent: #0a6f77;
  --accent-ink: #ffffff;
  --grid: #e3e9ed;
  --trace-ref: #7d8d99;

  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 6px;
  --wrap: 1040px;
  --gutter: clamp(20px, 5vw, 48px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d151b;
  --surface: #131f27;
  --ink: #e7eff3;
  --muted: #9fb0bc;
  --rule: #25343f;
  --accent: #4fc4cb;
  --accent-ink: #0d151b;
  --grid: #1b2a34;
  --trace-ref: #6f818e;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
}

p {
  margin: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

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

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 20;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
}

.skip:focus {
  top: 12px;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}

.bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 60px;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.primary-nav {
  display: flex;
  gap: 1.5rem;
  margin-left: auto;
}

.primary-nav a {
  font-size: 0.95rem;
  color: var(--muted);
  text-decoration: none;
  padding-block: 0.25rem;
  border-bottom: 2px solid transparent;
}

.primary-nav a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--accent);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  padding: 0.7rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  font-size: 0.975rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-small {
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
}

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

.hero {
  padding-block: clamp(48px, 9vw, 104px) clamp(40px, 6vw, 72px);
}

.hero h1 {
  font-size: clamp(3.25rem, 10.5vw, 7rem);
  font-weight: 650;
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.lede {
  max-width: 30ch;
  margin-top: 1.5rem;
  font-size: clamp(1.25rem, 2.6vw, 1.6rem);
  line-height: 1.35;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

/* The scope: a live second-order step response */

.scope {
  margin: clamp(40px, 6vw, 64px) 0 0;
  padding: clamp(14px, 2.5vw, 24px);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.scope figcaption {
  max-width: 62ch;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.scope svg {
  display: block;
  width: 100%;
  height: auto;
}

.scope-grid {
  stroke: var(--grid);
  stroke-width: 1;
}

.scope-axis-text {
  fill: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.scope-ref {
  fill: none;
  stroke: var(--trace-ref);
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
}

.scope-band {
  fill: var(--accent);
  opacity: 0.14;
}

.scope-trace {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.scope-peak {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2.5;
}

.scope-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 2fr;
  gap: 1rem 2rem;
  align-items: end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.scope-slider label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  font-weight: 500;
}

.scope-slider output {
  font-variant-numeric: tabular-nums;
}

.scope-slider input[type="range"] {
  width: 100%;
  height: 28px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.readouts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
}

.readouts dt {
  font-size: 0.85rem;
  color: var(--muted);
}

.readouts dd {
  margin: 0.1rem 0 0;
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

.section {
  padding-block: clamp(48px, 7vw, 88px);
  border-top: 1px solid var(--rule);
}

.section-title {
  font-size: clamp(1.9rem, 3.4vw, 2.5rem);
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.section-note {
  max-width: 60ch;
  margin-top: 0.6rem;
  color: var(--muted);
}

/* About */

.about {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 2rem 3rem;
  align-items: start;
}

.about.no-photo {
  grid-template-columns: minmax(0, 1fr);
}

.about-text {
  max-width: 68ch;
  margin-top: 1rem;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.65;
}

.headshot {
  width: 220px;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
}

/* Projects */

.project-feature {
  margin-top: 2rem;
  padding: clamp(20px, 3.5vw, 32px);
  background: var(--surface);
  border: 1px solid var(--edge, var(--rule));
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
}

.project-feature h3 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.01em;
}

.project-feature p {
  max-width: 64ch;
  margin-top: 0.75rem;
}

.project-sub {
  margin-top: clamp(36px, 5vw, 56px);
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
}

.project-sub-note {
  margin-top: 0.2rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--edge, var(--rule));
  border-radius: var(--radius);
}

.project-card h3 {
  font-size: 1.3rem;
}

.project-card p {
  margin-top: 0.5rem;
  font-size: 0.975rem;
}

.project-card .tags {
  margin-top: auto;
  padding-top: 1rem;
}

.project-list {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}

.project-row {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 0.25rem 1.5rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--rule);
}

.project-row h3 {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
}

.project-row p {
  font-size: 0.975rem;
  color: var(--muted);
}

.project-row .tags {
  grid-column: 2;
  margin-top: 0.5rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.tags li {
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.text-link {
  display: inline-block;
  margin-top: 1rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}

.text-link:hover {
  text-decoration-thickness: 2.5px;
}

.project-row .text-link {
  margin-top: 0;
}

/* Skills */

.skill-groups {
  display: grid;
  gap: 1.5rem;
  margin-top: 2rem;
}

.skill-group h3 {
  margin-bottom: 0.6rem;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
}

.skill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.skill {
  padding: 0.45rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}

.skill:hover {
  border-color: var(--accent);
}

.skill[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.evidence {
  margin-top: 1.75rem;
  padding: 1rem 1.25rem;
  min-height: 5.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.evidence-empty {
  color: var(--muted);
}

.evidence-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.link-btn {
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 0.95rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.evidence-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.evidence-list a {
  display: inline-block;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 0.9rem;
  text-decoration: none;
}

.evidence-list a:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.evidence-kind {
  color: var(--muted);
  font-size: 0.85rem;
}

.evidence-list a:hover .evidence-kind {
  color: inherit;
}

/* Skill filtering on projects, roles and education */

[data-skills] {
  transition: opacity 150ms, border-color 150ms;
}

.is-dim {
  opacity: 0.45;
}

.is-match {
  --edge: var(--accent);
}

.flash {
  animation: flash 1.6s ease-out;
}

@keyframes flash {
  0%,
  35% {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
  }
  100% {
    outline: 3px solid transparent;
    outline-offset: 4px;
  }
}

/* Experience and education timeline */

.timeline {
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

.role {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 0 1.5rem;
  padding-bottom: 2rem;
}

.role:last-child {
  padding-bottom: 0;
}

.role-years {
  padding-top: 0.15rem;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.role-body {
  position: relative;
  padding-left: 1.5rem;
  border-left: 2px solid var(--edge, var(--rule));
}

.role-body::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 0.55rem;
  width: 10px;
  height: 10px;
  background: var(--bg);
  border: 2px solid var(--edge, var(--rule));
  border-radius: 50%;
}

.role h3 {
  font-family: var(--sans);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.35;
}

.role-org {
  color: var(--muted);
}

.role ul {
  margin: 0.6rem 0 0;
  padding-left: 1.1rem;
}

.role li {
  margin-top: 0.3rem;
  max-width: 70ch;
}

.role li[hidden] {
  display: none;
}

.more-btn {
  margin-top: 0.6rem;
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 0.95rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Contact */

.contact-mail {
  display: inline-block;
  margin-top: 1.25rem;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 4.6vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 3px;
  text-underline-offset: 6px;
  overflow-wrap: anywhere;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.site-footer {
  padding-block: 2rem 3rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- Small screens ---------- */

@media (max-width: 820px) {
  .primary-nav {
    display: none;
  }

  .bar-actions {
    margin-left: auto;
  }

  .scope-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .about {
    grid-template-columns: minmax(0, 1fr);
  }

  .headshot {
    order: -1;
    width: 160px;
  }

  .project-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .project-row .tags {
    grid-column: 1;
  }

  .role {
    grid-template-columns: minmax(0, 1fr);
  }

  .role-years {
    margin-bottom: 0.35rem;
    padding-left: 1.5rem;
  }
}

@media (max-width: 620px) {
  /* The plot scales down with the screen, so its labels need to start larger. */
  .scope-axis-text {
    font-size: 22px;
  }

  .scope-trace {
    stroke-width: 4.5;
  }

  .scope-ref {
    stroke-width: 2.5;
  }
}

@media (max-width: 520px) {
  .readouts {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
  }

  .readouts div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .site-header,
  .scope,
  .skill-groups,
  .evidence {
    display: none;
  }
}
