/* Fonts: self-hosted latin subsets (SIL OFL, see /fonts).
   Spectral sets everything readable, as a book would; Schibsted Grotesk only for small labels. */
@font-face {
  font-family: "Spectral";
  src: url("/fonts/spectral-300-latin.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("/fonts/spectral-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("/fonts/spectral-400-italic-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("/fonts/schibsted-grotesk-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

/* Metric-matched fallbacks keep line breaks stable while the web fonts load. */
@font-face {
  font-family: "Spectral Fallback";
  src: local("Georgia");
  size-adjust: 100.4%;
  ascent-override: 105.5%;
  descent-override: 46.1%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Schibsted Grotesk Fallback";
  src: local("Arial");
  size-adjust: 105.2%;
  ascent-override: 92.8%;
  descent-override: 24.5%;
  line-gap-override: 0%;
}

:root {
  color-scheme: light;

  /* Families */
  --font-serif: "Spectral", "Spectral Fallback", Georgia, serif;
  --font-label: "Schibsted Grotesk", "Schibsted Grotesk Fallback", Arial, sans-serif;

  /* Type scale: perfect fourth (1.333) from a 1rem base. Body fixed, display fluid. */
  --text-label: 0.6875rem;                                   /* 11px, uppercase only */
  --text-body: 1.125rem;                                     /* 18px */
  --text-heading: 1.777rem;                                  /* 28px */
  --text-display: clamp(2.369rem, 1.4rem + 4.4vw, 5.61rem);  /* 38 → 90px */

  /* Line grid: one body line is the unit of all vertical space. */
  --line: 1.75rem;                 /* 28px */
  --half: calc(var(--line) / 2);   /* 14px */
  --leading-display: 1.04em;
  --leading-heading: 1.15em;

  --tracking-display: -0.022em;
  --tracking-heading: -0.012em;
  --tracking-label: 0.14em;
  --measure: 34em;

  /* Vertical rhythm, in lines */
  --gap-paragraph: var(--half);
  --gap-heading: var(--line);
  --gap-section: clamp(calc(3 * var(--line)), 2rem + 4vw, calc(4 * var(--line)));
  --gap-hero-top: clamp(calc(3 * var(--line)), 1rem + 6vw, calc(5 * var(--line)));
  --gap-hero-bottom: clamp(calc(4 * var(--line)), 2rem + 6vw, calc(6 * var(--line)));

  /* Horizontal */
  --gutter: clamp(1.5rem, 4vw, 2rem);
  --column: 56rem;
  --optical-indent: -0.05em;       /* pulls display type onto the text edge */

  /* Color: ink on warm paper, one ground for the whole page. */
  --paper: oklch(0.972 0.01 85);
  --ink: oklch(0.19 0.012 60);
  --ink-body: oklch(0.29 0.01 60);
  --ink-muted: oklch(0.5 0.01 60);

  font-family: var(--font-serif);
  color: var(--ink-body);
  background: var(--paper);
  font-synthesis: none;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
::selection { background: var(--ink); color: var(--paper); }

body {
  max-width: calc(var(--column) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
  font-size: var(--text-body);
  line-height: var(--line);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; }

a:focus-visible,
main:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 6px;
}

.skip-link {
  position: absolute;
  top: var(--half);
  left: var(--gutter);
  padding: 0.25rem 0.75rem;
  background: var(--paper);
  color: var(--ink);
  transform: translateY(-200%);
}

.skip-link:focus { transform: translateY(0); }

/* Masthead: three lines tall */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--line);
  min-height: calc(3 * var(--line));
  border-bottom: 1px solid var(--ink);
}

.site-header a { text-decoration: none; }
.site-header a,
.email {
  display: inline-block;
  min-height: 2.75rem;
  padding: 0.5rem 0;
}

.wordmark,
.footer-brand {
  font-size: var(--text-heading);
  font-style: italic;
  line-height: var(--line);
  color: var(--ink);
}

.site-header nav a {
  font-family: var(--font-label);
  font-size: var(--text-label);
  font-weight: 500;
  line-height: var(--line);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink);
}
.site-header nav a:hover { text-decoration: underline; text-underline-offset: 0.35em; }

/* Rhythm */
section { margin-top: var(--gap-section); }
.hero { margin-top: var(--gap-hero-top); }
.hero + section { margin-top: var(--gap-hero-bottom); }

/* Headings: line-height snapped to the half-line grid */
h1, h2 {
  margin: 0;
  font-weight: 400;
  color: var(--ink);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-display);
  font-weight: 300;
  line-height: var(--leading-display);
  line-height: round(nearest, var(--leading-display), var(--half));
  letter-spacing: var(--tracking-display);
  margin-inline-start: var(--optical-indent);
  max-width: 13em;
}

h2 {
  font-size: var(--text-heading);
  font-style: italic;
  letter-spacing: var(--tracking-heading);
}

/* Sections: a rule, the heading in the left column, text on the right.
   The heading's first line shares the baseline of the text beside it. */
section:not(.hero) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  column-gap: calc(2 * var(--line));
  border-top: 1px solid var(--ink);
  padding-top: var(--line);
}
section:not(.hero) > * { grid-column: 2; }
section:not(.hero) > h2 {
  grid-column: 1;
  grid-row: 1 / span 20;
  line-height: var(--line);
  padding-top: 0.1em;
}

/* Body text */
p {
  max-width: var(--measure);
  margin: 0 0 var(--gap-paragraph);
  text-wrap: pretty;
  hanging-punctuation: first;
}
p:last-child { margin-bottom: 0; }
strong { font-weight: 400; font-style: italic; color: var(--ink); }

.text-link {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-decoration-color: var(--ink-muted);
  text-underline-offset: 0.25em;
}
.text-link:hover { text-decoration-color: var(--ink); }
a span { display: inline-block; margin-left: 0.3em; }

/* Engineering loop: each stage is one line, separated by one line */
.process {
  --stage-line-height: var(--line);
  --stage-gap: var(--line);
  --stroke: var(--ink-muted);
  margin: calc(1.5 * var(--line)) 0;
  color: var(--ink);
}
.process:last-child { margin-bottom: 0; }
.loop-path {
  --return-top: calc(var(--stage-line-height) + var(--stage-gap) + var(--half));
  position: relative;
  width: fit-content;
  padding-left: calc(1.75 * var(--line));
}

/* Requirements remain above the local loop: return to the second stage, CAD. */
.loop-path::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--return-top);
  bottom: var(--half);
  width: 29px;
  border: 1px solid var(--stroke);
  border-right: 0;
}

.loop-path::after {
  content: "";
  position: absolute;
  left: 23px;
  top: calc(var(--return-top) - 3px);
  width: 7px;
  height: 7px;
  border-top: 1px solid var(--stroke);
  border-right: 1px solid var(--stroke);
  transform: rotate(45deg);
}

.process ol { list-style: none; margin: 0; padding: 0; }
.process li {
  font-family: var(--font-label);
  font-size: var(--text-label);
  font-weight: 500;
  line-height: var(--stage-line-height);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.process li + li { margin-top: var(--stage-gap); position: relative; }
.process li + li::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--stage-gap) + 7px);
  left: 4px;
  height: 12px;
  border-left: 1px solid var(--stroke);
}
.process li + li::after {
  content: "";
  position: absolute;
  top: calc(-1 * var(--stage-gap) + 15px);
  left: 1px;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--stroke);
  border-bottom: 1px solid var(--stroke);
  transform: rotate(45deg);
}

/* Contact and footer */
.contact { padding-bottom: var(--gap-section); }
.contact .email { margin-top: var(--half); }
.email { overflow-wrap: anywhere; }

.site-footer {
  border-top: 1px solid var(--ink);
  padding: var(--line) 0 calc(2 * var(--line));
}
.footer-brand { margin: 0; }

@media (max-width: 720px) {
  :root { --text-body: 1.0625rem; --line: 1.625rem; }
  section:not(.hero) { display: block; }
  section:not(.hero) > h2 {
    line-height: round(nearest, var(--leading-heading), var(--half));
    padding-top: 0;
    margin-bottom: var(--gap-heading);
  }
}
