/* metacrystal.com
   Editorial and calm: warm paper, ink text, one deep teal accent kept for actions.
   Newsreader (headings) + Radio Canada (body), both self-hosted under the SIL Open Font License. */

@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-latin.woff2") format("woff2");
  font-weight: 500 600; /* instanced: opsz pinned at 36, weights 500-600 only */
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Radio Canada";
  src: url("/assets/fonts/radio-canada-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Color (all text pairs meet WCAG AA on both paper tones) */
  --paper: #f7f4ee;
  --paper-2: #eee8dd;
  --ink: #1c2226;
  --ink-2: #4b5560;
  --ink-3: #5f6872;
  --rule: #d8d0c2;
  --accent: #1f5a52;
  --accent-dark: #174640;
  --field: #fffdf9;
  --field-border: #857f75;
  --error: #9b2c22;

  /* Type */
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Radio Canada", system-ui, -apple-system, "Segoe UI", sans-serif;
  --text-sm: 0.9375rem;
  --text-body: 1.0625rem;
  --text-lead: clamp(1.1875rem, 1.6vw, 1.3125rem);
  --text-h3: 1.3125rem;
  --text-h2: clamp(1.75rem, 3.2vw, 2.25rem);
  --text-display: clamp(2.75rem, 7vw, 4.5rem);

  /* Space */
  --s1: 0.5rem;
  --s2: 0.75rem;
  --s3: 1rem;
  --s4: 1.5rem;
  --s5: 2.5rem;
  --s6: clamp(3rem, 6vw, 4.5rem);
  --s7: clamp(4rem, 9vw, 7rem);

  --wrap: 1080px;
  --measure: 68ch;
  --gutter: clamp(16px, 4vw, 40px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--text-body);
  line-height: 1.65;
  font-kerning: normal;
}

img { display: block; max-width: 100%; height: auto; }
main { flex: 1 0 auto; }
[id] { scroll-margin-top: var(--s4); }

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a { transition: color 150ms cubic-bezier(0.25, 1, 0.5, 1); }
a:hover { color: var(--accent-dark); text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  color: var(--ink);
}
h1, h2, h3, .dek, .record-lead, .pull p { text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
h1 { font-size: var(--text-display); letter-spacing: -0.02em; line-height: 1.02; }
h2 { font-size: var(--text-h2); }
h3 { font-size: var(--text-h3); }
p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }
strong { font-weight: 600; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.measure { max-width: var(--measure); }
.lede { font-size: var(--text-lead); line-height: 1.55; color: var(--ink); }
.muted { color: var(--ink-2); }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--paper); padding: 8px 14px; z-index: 10;
}
.skip:focus { left: 8px; top: 8px; }

/* Header and footer */
.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap; padding-top: 20px; padding-bottom: 18px;
}
.brand { font-family: var(--serif); font-size: 1.375rem; font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand:hover { color: var(--ink); }
.nav { display: flex; gap: clamp(16px, 3vw, 32px); margin: 0; padding: 0; list-style: none; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.site-footer { border-top: 1px solid var(--rule); padding: var(--s5) 0; color: var(--ink-2); font-size: var(--text-sm); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: var(--s2) var(--s4); flex-wrap: wrap; }
.site-footer a { color: var(--ink-2); }
.footer-nav { display: flex; gap: var(--s4); flex-wrap: wrap; }

/* Sections: rhythm comes from varied spacing, not alternating bands */
.section { padding: var(--s6) 0; }
.section + .section { border-top: 1px solid var(--rule); }
.section.tint { background: var(--paper-2); border-top: 0; }
.section.tint + .section { border-top: 0; }
.kicker {
  font-family: var(--sans); font-size: 0.8125rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
  margin: 0 0 var(--s3);
}

/* Buttons */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); margin-top: var(--s4); }
.button {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--paper);
  border: 1px solid var(--accent); border-radius: 3px; padding: 12px 24px; min-height: 44px;
}
.button { transition: background-color 150ms cubic-bezier(0.25, 1, 0.5, 1), border-color 150ms cubic-bezier(0.25, 1, 0.5, 1); }
.button:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: var(--paper); }
.button:active { background: var(--ink); border-color: var(--ink); }
.button[disabled] { opacity: 0.65; cursor: progress; }
.text-link { font-weight: 600; }

/* Home: hero */
.hero { padding: var(--s7) 0 var(--s6); }
.hero-grid { display: grid; gap: var(--s4); grid-template-columns: 1fr; align-items: start; }
@media (min-width: 760px) {
  .hero-grid { grid-template-columns: 1fr 200px; gap: var(--s6); }
}
.hero h1 { margin-bottom: 0.25em; }
.dek {
  font-family: var(--serif); font-size: clamp(1.375rem, 2.6vw, 1.875rem);
  line-height: 1.3; color: var(--ink); margin: 0 0 var(--s4); max-width: 30ch;
}
.hero .lede { max-width: 58ch; color: var(--ink-2); }
.portrait { margin: 0; }
.portrait img { border-radius: 50%; width: 96px; height: 96px; object-fit: cover; }
@media (min-width: 760px) {
  .portrait { order: 2; padding-top: 0.6rem; }
  .portrait img { width: 200px; height: 200px; }
}

/* Home: record */
.record-lead {
  font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2.125rem); line-height: 1.3;
  max-width: 34ch; margin: 0 0 var(--s5);
}
.facts { list-style: none; margin: 0; padding: 0; max-width: 820px; border-top: 1px solid var(--rule); }
.facts li { padding: var(--s3) 0; border-bottom: 1px solid var(--rule); color: var(--ink-2); }
.facts strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Areas: ruled definition rows, not cards */
.areas { margin: 0; max-width: 920px; border-top: 1px solid var(--rule); }
.areas > div { display: grid; gap: var(--s1) var(--s5); padding: var(--s4) 0; border-bottom: 1px solid var(--rule); }
@media (min-width: 760px) { .areas > div { grid-template-columns: 15rem 1fr; } }
.areas dt { font-family: var(--serif); font-size: var(--text-h3); line-height: 1.25; }
.areas dd { margin: 0; color: var(--ink-2); }

/* Home: risk */
.split { display: grid; gap: var(--s5); grid-template-columns: 1fr; align-items: center; }
@media (min-width: 860px) { .split { grid-template-columns: 1.2fr 1fr; gap: var(--s6); } }
.pull { margin: 0; padding-left: var(--s4); border-left: 3px solid var(--accent); }
.pull p { font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2.125rem); line-height: 1.25; margin: 0; }

/* Closing call to action */
.closing h2 { max-width: 24ch; }

/* About */

.timeline { list-style: none; margin: 0; padding: 0; max-width: var(--measure); }
.timeline li { position: relative; padding: 0 0 var(--s5) var(--s4); border-left: 1px solid var(--rule); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 0.55em;
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
}
.timeline h3 { margin-bottom: 0.15em; }
.timeline .when { color: var(--ink-3); font-size: var(--text-sm); margin-bottom: var(--s2); }

.groups { display: grid; gap: var(--s5); grid-template-columns: 1fr; }
@media (min-width: 560px) { .groups { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .groups { grid-template-columns: repeat(4, 1fr); } }
.groups h3 { font-family: var(--sans); font-size: var(--text-sm); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--s2); }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.plain li:last-child { border-bottom: 0; }

.outside { display: grid; gap: var(--s5); grid-template-columns: 1fr; align-items: center; }
@media (min-width: 760px) { .outside { grid-template-columns: 1fr 240px; } }
.snapshot { margin: 0; }
.snapshot img { border-radius: 4px; aspect-ratio: 3 / 4; object-fit: cover; width: 100%; max-width: 240px; }

/* Projects: on-this-page links */
.jump { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin-top: var(--s4); font-weight: 600; }
.jump a { padding: 6px 0; }

/* Projects: full entries */
.project { display: grid; gap: var(--s4) var(--s5); grid-template-columns: 1fr; }
@media (min-width: 820px) { .project { grid-template-columns: 2fr 3fr; align-items: start; } }
.project + .project { margin-top: var(--s6); padding-top: var(--s6); border-top: 1px solid var(--rule); }
.project h3 { font-size: clamp(1.375rem, 2.4vw, 1.75rem); }
.figure { margin: 0; padding: var(--s1); border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); }
.figure img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 2px; }
.compact .figure { padding: 4px; }
.section-label { margin-bottom: var(--s5); }
.project-meta { color: var(--ink-3); font-size: var(--text-sm); margin: -0.2em 0 var(--s3); }
.links { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-weight: 600; }

/* A typeset patent "figure" instead of a stock picture */
.patent-card {
  aspect-ratio: 4 / 3; border-radius: 2px; display: flex; flex-direction: column; justify-content: space-between;
  padding: var(--s4); background: var(--paper); color: var(--ink);
}
@media (max-width: 819px) { .patent-card { aspect-ratio: auto; gap: var(--s4); } }
.patent-card .kicker { margin: 0; }
.patent-card .number { font-family: var(--serif); font-size: clamp(1.625rem, 3.2vw, 2.375rem); line-height: 1; margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.patent-card .title { font-family: var(--serif); font-size: 1.0625rem; line-height: 1.35; margin: 0; color: var(--ink-2); }

/* Projects: compact entries, same language at a smaller size */
.compact { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.compact > li { display: grid; gap: var(--s3) var(--s4); grid-template-columns: 96px 1fr; align-items: start; padding: var(--s4) 0; border-bottom: 1px solid var(--rule); }
@media (min-width: 640px) { .compact > li { grid-template-columns: 168px 1fr; } }
.compact h3 { font-size: 1.1875rem; margin-bottom: 0.2em; }
.compact .project-meta { margin: 0 0 var(--s1); }
.compact p { margin-bottom: var(--s1); }

/* Contact form */
.form { display: grid; gap: var(--s4); max-width: 620px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field input:hover, .field textarea:hover { border-color: var(--ink-2); }
.form-note { margin: 0; color: var(--ink-2); font-size: var(--text-sm); }
.field input, .field textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--field);
  border: 1px solid var(--field-border); border-radius: 3px; padding: 11px 14px; min-height: 44px;
}
.field textarea { min-height: 170px; resize: vertical; }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--error); border-width: 2px; }
.req { color: var(--ink-3); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form .button { justify-self: start; }
.form-status { min-height: 1.6em; margin: 0; }
.form-status.error { color: var(--error); }

/* Privacy and Terms */
.prose { max-width: var(--measure); }
.prose h2 { font-size: 1.5rem; margin-top: 1.8em; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
