/* ==========================================================================
   Portfolio stylesheet
   1. Fonts   2. Theme colours   3. Base   4. Layout   5. Header and footer
   6. Hero   7. Projects   8. Diagrams   9. Lists and prose   10. Project page
   ========================================================================== */

/* 1. Fonts (self-hosted, SIL Open Font License) --------------------------- */

@font-face {
  font-family: "Besley";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/assets/fonts/besley-latin-wght.woff2") format("woff2");
}

@font-face {
  font-family: "Libre Franklin";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/libre-franklin-latin-wght.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-mono-latin-400.woff2") format("woff2");
}

/* 2. Theme colours --------------------------------------------------------
   Light is paper; dark is topsoil. The dark values appear twice on purpose:
   once for visitors whose system is set to dark, once for the toggle. */

:root {
  --paper: #fbfbf9;
  --surface: #ffffff;
  --ink: #1d1b16;
  --muted: #5f5b52;
  --rule: #dddad0;
  --rule-strong: #b9b5a8;
  --accent: #1f6a43;
  --ochre: #a8772a;
  --group: #f4f4ef;
  --code: #f0efe9;

  --font-display: "Besley", Rockwell, "Roboto Slab", Georgia, serif;
  --font-body: "Libre Franklin", "Franklin Gothic Medium", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --measure: 39rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1815;
    --surface: #23201b;
    --ink: #ece7dd;
    --muted: #aba394;
    --rule: #3a342d;
    --rule-strong: #5b5348;
    --accent: #8ccb9f;
    --ochre: #d9a657;
    --group: #1f1c18;
    --code: #2c2721;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #1b1815;
  --surface: #23201b;
  --ink: #ece7dd;
  --muted: #aba394;
  --rule: #3a342d;
  --rule-strong: #5b5348;
  --accent: #8ccb9f;
  --ochre: #d9a657;
  --group: #1f1c18;
  --code: #2c2721;
  color-scheme: dark;
}

/* 3. Base ------------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 1.5rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  text-wrap: balance;
}

p,
ul,
ol,
dl,
figure {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

::selection {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code);
  padding: 0.12em 0.36em;
  border-radius: 3px;
  overflow-wrap: anywhere;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
}

.skip-link:focus {
  top: 1rem;
}

/* 4. Layout -----------------------------------------------------------------
   One left-hand margin column for section names, one wide column for content.
   Everything on the site hangs from the same vertical line. */

.wrap {
  max-width: 72rem;
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 5vw, 3rem);
}

.ledger {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  column-gap: 3rem;
}

.ledger > :not(.section__label, .hero__links, .page-head__back) {
  grid-column: 2;
}

.section {
  padding-bottom: clamp(2.5rem, 6vw, 4rem);
}

/* the rule above each section, kept inside the page margins */
.section::before {
  content: "";
  grid-column: 1 / -1;
  height: 1px;
  margin-bottom: clamp(2.5rem, 6vw, 4rem);
  background: var(--rule);
}

.section__label {
  grid-column: 1;
  align-self: start;
  position: sticky;
  top: 1.5rem;
  font-size: 1.1875rem;
  line-height: 1.3;
}

.section__body > * + * {
  margin-top: 1.5rem;
}

.prose {
  max-width: var(--measure);
}

.prose > * + * {
  margin-top: 1rem;
}

@media (max-width: 54rem) {
  .ledger {
    grid-template-columns: minmax(0, 1fr);
  }

  .ledger > :not(.section__label, .hero__links, .page-head__back) {
    grid-column: 1;
  }

  .section__label {
    position: static;
    margin-bottom: 1.25rem;
    font-size: 1.375rem;
  }
}

/* 5. Header and footer ------------------------------------------------------- */

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding-block: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-right: auto;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  text-decoration: none;
}

.brand__mark {
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9375rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.theme-toggle[hidden] {
  display: none;
}

.theme-toggle:hover {
  border-color: var(--rule-strong);
}

@media (max-width: 34rem) {
  .site-nav {
    order: 3;
    width: 100%;
    gap: 1.25rem;
  }
}

.site-footer {
  color: var(--muted);
  font-size: 0.9375rem;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: 2rem;
  border-top: 1px solid var(--rule);
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  padding: 0;
  list-style: none;
}

/* 6. Hero --------------------------------------------------------------------- */

.hero {
  padding-block: clamp(2.5rem, 9vw, 6.5rem) clamp(3rem, 9vw, 6rem);
  row-gap: 2rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 1.5rem + 4.6vw, 4.5rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.hero__statement {
  max-width: 24em;
  margin-top: 1.5rem;
  font-size: clamp(1.3125rem, 1.1rem + 1vw, 1.75rem);
  line-height: 1.3;
  text-wrap: balance;
}

.hero__intro {
  max-width: var(--measure);
  margin-top: 1.25rem;
  color: var(--muted);
}

.hero .button-row {
  margin-top: 2rem;
}

.hero__links {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  display: grid;
  gap: 0.35rem;
  padding: 0;
  /* line the first link up with the cap height of the name */
  padding-top: clamp(0.5rem, 0.2rem + 1vw, 1rem);
  list-style: none;
}

@media (max-width: 54rem) {
  .hero__links {
    grid-row: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.5rem;
    padding-top: 0;
  }
}

/* 7. Projects ----------------------------------------------------------------- */

.projects > * + * {
  margin-top: 1.5rem;
}

.project {
  position: relative;
  padding: clamp(1.25rem, 3vw, 1.75rem);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.project > * + * {
  margin-top: 1rem;
}

.project:hover {
  border-color: var(--rule-strong);
}

.project:has(.project__title a:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.project__title {
  font-size: 1.375rem;
}

.project--featured .project__title {
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
}

.project__title a {
  color: var(--ink);
  text-decoration: none;
}

/* the title link covers the whole card */
.project__title a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
}

.project__title a:focus-visible {
  outline: none;
}

.project__summary {
  max-width: var(--measure);
}

.project__highlights {
  max-width: var(--measure);
  padding-left: 1.15rem;
}

.project__highlights li + li {
  margin-top: 0.3rem;
}

.project__highlights li::marker {
  color: var(--ochre);
}

.project__stack {
  color: var(--muted);
  font-size: 0.9375rem;
}

.project__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  font-size: 0.9375rem;
}

.project__cta {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.project:hover .project__cta {
  text-decoration-thickness: 2px;
}

/* keep the real links and the scrollable figure above the card-wide link */
.project__links a,
.project .figure {
  position: relative;
  z-index: 1;
}

/* 8. Diagrams (the SVG comes from generator/diagram.py) -------------------- */

.figure__scroll {
  overflow-x: auto;
  padding-block: 0.25rem;
}

.diagram {
  display: block;
  max-width: 100%;
  height: auto;
}

.figure__hint {
  display: none;
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

@media (max-width: 44rem) {
  /* keep the labels legible on phones: the figure scrolls sideways instead */
  .diagram {
    max-width: none;
    width: 41rem;
  }

  .figure__hint {
    display: block;
  }

  /* on the home page the card stays short; the diagram is on the project page */
  .project .figure {
    display: none;
  }
}

figcaption {
  max-width: var(--measure);
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.d-group {
  fill: var(--group);
  stroke: var(--rule);
}

.d-group-label {
  fill: var(--muted);
  font: 600 11.5px var(--font-body);
}

.d-node {
  fill: var(--surface);
  stroke: var(--ink);
  stroke-width: 1.25;
}

.d-node--external {
  stroke: var(--muted);
  stroke-dasharray: 4 3;
}

.d-node-label {
  fill: var(--ink);
  font: 600 13px var(--font-body);
}

.d-node-sub {
  fill: var(--muted);
  font: 400 11.5px var(--font-body);
}

.d-edge {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
}

.d-edge--accent {
  stroke: var(--accent);
}

.d-head {
  fill: var(--muted);
}

.d-head--accent {
  fill: var(--accent);
}

.d-edge-label {
  fill: var(--muted);
  font: 500 11px var(--font-body);
}

.d-edge-label--accent {
  fill: var(--accent);
}

/* 9. Lists and prose ----------------------------------------------------------- */

.spec__row {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  column-gap: 2rem;
  padding-block: 0.7rem;
  border-top: 1px solid var(--rule);
}

.spec__row:first-child {
  padding-top: 0;
  border-top: 0;
}

.spec dt {
  font-weight: 600;
}

.spec dd {
  margin: 0;
}

@media (max-width: 34rem) {
  .spec__row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.checklist {
  padding-left: 1.15rem;
}

.checklist li + li {
  margin-top: 0.6rem;
}

.checklist li::marker {
  color: var(--ochre);
}

.contact__email {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1rem + 1.4vw, 1.75rem);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: 4px;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}

.button:hover {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.button--primary {
  background: var(--ink);
  color: var(--paper);
}

.button--primary:hover {
  background: color-mix(in srgb, var(--ink) 86%, var(--paper));
}

/* 10. Project page ------------------------------------------------------------- */

.page-head {
  padding-block: clamp(2rem, 7vw, 4.5rem) clamp(2.5rem, 7vw, 4.5rem);
  row-gap: 1.25rem;
}

.page-head__back {
  grid-column: 1;
  align-self: start;
  padding-top: clamp(0.3rem, 0.1rem + 0.8vw, 0.8rem);
  font-size: 0.9375rem;
}

.page-head h1 {
  font-size: clamp(2.125rem, 1.4rem + 3.2vw, 3.5rem);
  line-height: 1.06;
  letter-spacing: -0.015em;
}

.page-head__lede {
  max-width: 30em;
  margin-top: 1.25rem;
  font-size: clamp(1.1875rem, 1.05rem + 0.6vw, 1.4375rem);
  line-height: 1.35;
  text-wrap: balance;
}

.page-head .button-row {
  margin-top: 1.75rem;
}

.subhead {
  margin-top: 2.5rem;
  font-size: 1.1875rem;
}

.flow {
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.flow li {
  position: relative;
  padding-left: 2.5rem;
  counter-increment: step;
}

.flow li + li {
  margin-top: 0.8rem;
}

.flow li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -0.05em;
  width: 1.6rem;
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 600;
  text-align: right;
}

.decisions > * + * {
  margin-top: 2.25rem;
}

.decision h3 {
  font-size: 1.1875rem;
  line-height: 1.3;
}

.decision > h3 + p {
  margin-top: 0.6rem;
}

.decision__tradeoff {
  padding-left: 1rem;
  border-left: 2px solid var(--ochre);
  color: var(--muted);
}

.decision__tradeoff strong {
  color: var(--ink);
}

.link-list {
  padding: 0;
  list-style: none;
}

.link-list li + li {
  margin-top: 0.5rem;
}

.next {
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.next span {
  display: block;
  color: var(--muted);
  font-size: 0.9375rem;
}

.next a {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 600;
}

@media print {
  .site-nav,
  .theme-toggle,
  .skip-link {
    display: none;
  }

  .section__label {
    position: static;
  }
}
