/* ==========================================================================
   afairbairn.com — Dr. Andrew J. Fairbairn
   Static site. No frameworks, no external requests, system fonts only.
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */

:root {
  --ink:        #12140f;   /* green-black, not a neutral */
  --ink-soft:   #3a3e37;
  --muted:      #6b6f68;
  --paper:      #fbfaf7;
  --paper-sunk: #f4f3ee;   /* card / inset ground */
  --rule:       #e4e3dd;
  --accent:     #14584a;   /* deep teal-green — 7.6:1 on paper */
  --accent-lit: #1e7a66;
  --accent-wash:#eef3f1;

  --serif: Georgia, "Iowan Old Style", "Times New Roman", Times, serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  --measure: 46rem;   /* ~736px — text column */
  --wide:    68rem;   /* ~1088px — ventures grid */
  --gut:     1.5rem;

  --step: 0.35s cubic-bezier(0.2, 0.8, 0.3, 1);
}

/* --- Reset ---------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--sans);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
}

/* height:auto is load-bearing — without it the HTML height attribute wins
   over aspect-ratio and the portrait renders at full intrinsic height. */
img, svg { display: block; max-width: 100%; height: auto; }

h1, h2, h3, h4, p, ul, ol, dl, figure, blockquote { margin: 0; }

ul, ol { padding: 0; list-style: none; }

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

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

/* --- Layout --------------------------------------------------------------- */

/* One container width for every section, so the left edge never shifts
   between narrow and wide content. Reading measure is constrained on the
   text components themselves (see .measured below), not on the container. */
.wrap  { width: 100%; max-width: var(--wide); margin-inline: auto; padding-inline: var(--gut); }
.wrap--wide { max-width: var(--wide); }

.h-section,
.prose,
.lede,
.pending,
.cv-list,
.pub-group,
.pill-list,
.contact__mail,
.linkrow,
.consulting { max-width: var(--measure); }

.section { padding-block: clamp(3.5rem, 8vw, 6rem); }
.section + .section { padding-top: 0; }
/* Needs .section.section--ruled: a bare .section--ruled (0,1,0) loses to
   .section + .section (0,2,0) above, which zeroed the padding and left the
   eyebrow sitting flush against the rule. */
.section.section--ruled {
  border-top: 1px solid var(--rule);
  padding-top: clamp(3.5rem, 8vw, 6rem);
}

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: var(--paper);
  padding: 0.75rem 1rem; z-index: 100; border-radius: 0 0 4px 0;
}
.skip:focus { left: 0; top: 0; }

/* --- Typography ----------------------------------------------------------- */

.eyebrow {
  font: 500 0.6875rem/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.9rem;
}

.h-section {
  font: 400 clamp(1.65rem, 3.6vw, 2.15rem)/1.2 var(--serif);
  letter-spacing: -0.015em;
  margin-bottom: 1.6rem;
}

.lede  { font-size: 1.1875rem; color: var(--ink-soft); }
.prose p + p { margin-top: 1.15rem; }
.prose { color: var(--ink-soft); }
.prose strong { color: var(--ink); font-weight: 600; }

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

/* --- Nav ------------------------------------------------------------------ */

.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
@supports not (backdrop-filter: blur(1px)) { .nav { background: var(--paper); } }

.nav__inner {
  max-width: var(--wide); margin-inline: auto; padding: 0 var(--gut);
  display: flex; align-items: center; justify-content: space-between;
  min-height: 3.75rem;
}

.nav__brand {
  font: 600 0.9375rem/1 var(--sans);
  letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none;
}
.nav__brand:hover { color: var(--accent); }

.nav__links { display: flex; gap: 1.75rem; align-items: center; }
.nav__links a {
  font-size: 0.9375rem; color: var(--ink-soft); text-decoration: none;
  transition: color var(--step);
}
.nav__links a:hover, .nav__links a[aria-current="page"] { color: var(--accent); }

.nav__toggle {
  display: none;
  background: none; border: 1px solid var(--rule); border-radius: 4px;
  padding: 0.4rem 0.6rem; cursor: pointer; color: var(--ink);
  font: 500 0.8125rem/1 var(--sans);
}

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

.hero { padding-block: clamp(3rem, 9vw, 5.5rem) 0; }
/* Hero with no trace beneath it (CV) needs its own bottom padding, since the
   trace is what separates the hero from the next section on the home page. */
.hero--plain { padding-bottom: clamp(2.5rem, 6vw, 4rem); }

.hero__grid {
  display: grid; gap: clamp(1.75rem, 5vw, 3.25rem);
  grid-template-columns: 1fr;
  max-width: var(--wide); margin-inline: auto; padding-inline: var(--gut);
}
@media (min-width: 56rem) {
  .hero__grid { grid-template-columns: minmax(0, 1fr) 15rem; align-items: start; }
}

.hero__name {
  font: 400 clamp(2.35rem, 6.5vw, 3.5rem)/1.08 var(--serif);
  letter-spacing: -0.028em;
  margin-bottom: 1rem;
}

.hero__roles {
  font: 400 0.8125rem/1.7 var(--mono);
  color: var(--muted);
  margin-bottom: 1.75rem;
  max-width: 40rem;
}
.hero__roles b { color: var(--ink-soft); font-weight: 500; }

.hero__tagline {
  font-size: clamp(1.125rem, 2.4vw, 1.3125rem);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 34rem;
  margin-bottom: 2rem;
}
.hero__tagline em { font-style: normal; color: var(--ink); }

.hero__portrait {
  border-radius: 4px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  width: 100%;
  filter: saturate(0.92);
  border: 1px solid var(--rule);
}
@media (max-width: 55.99rem) {
  .hero__portrait { max-width: 11rem; }
}

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

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

.btn {
  display: inline-block;
  background: var(--accent); color: var(--paper);
  padding: 0.7rem 1.35rem; border-radius: 3px;
  font: 500 0.9375rem/1.3 var(--sans);
  text-decoration: none;
  transition: background var(--step), transform var(--step);
}
.btn:hover { background: var(--accent-lit); color: var(--paper); transform: translateY(-1px); }

.btn--ghost {
  background: none; color: var(--accent);
  border: 1px solid var(--rule);
  padding: 0.7rem 1.35rem;
}
.btn--ghost:hover { background: var(--accent-wash); color: var(--accent); border-color: var(--accent); }

.link-quiet { font-size: 0.9375rem; color: var(--muted); text-decoration: none; }
.link-quiet:hover { color: var(--accent); text-decoration: underline; }

/* --- Acoustic trace (signature) ------------------------------------------- */

.trace {
  display: block;
  width: 100%;
  height: clamp(48px, 7vw, 76px);
  margin-block: clamp(1.75rem, 4vw, 2.75rem) 0;
  /* fades at both ends so it reads as a continuous recording, not a panel */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.trace--rule { height: clamp(30px, 4vw, 42px); opacity: 0.75; margin-block: 0 clamp(2rem, 5vw, 3rem); }

/* --- Ventures ------------------------------------------------------------- */

.cards { display: grid; gap: 1.25rem; }

.card {
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: clamp(1.5rem, 3.5vw, 2.25rem);
  transition: border-color var(--step), background var(--step);
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--rule)); }

/* .card--primary differs by title size only; all cards share one ground. */

.card__head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: 0.5rem 1.5rem;
  margin-bottom: 0.9rem;
}

.card__title {
  font: 400 clamp(1.3rem, 2.6vw, 1.6rem)/1.2 var(--serif);
  letter-spacing: -0.015em;
}
.card--primary .card__title { font-size: clamp(1.5rem, 3.2vw, 1.95rem); }

.card__kicker {
  font: 400 0.75rem/1.4 var(--mono);
  color: var(--muted);
  letter-spacing: 0.02em;
}

.card__body { color: var(--ink-soft); font-size: 1rem; max-width: 44rem; }

.card__foot {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 0.85rem 1.5rem;
  margin-top: 1.35rem;
}

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  font: 400 0.6875rem/1 var(--mono);
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent) 14%, transparent);
  padding: 0.4rem 0.6rem; border-radius: 3px;
  white-space: nowrap;
}

.card__link {
  font: 500 0.9375rem/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
}
.card__link::after { content: " \2192"; transition: none; }
.card__link:hover { text-decoration: underline; }

/* Nature Integrity sits *inside* the AF Labs card — the nesting is the claim */
.card__nested {
  margin-top: 1.75rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.6rem;
  padding-left: 1.25rem;
  border-left: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  margin-left: -0.1rem;
}
.card__nested .card__title { font-size: clamp(1.15rem, 2.3vw, 1.35rem); }

.badge {
  display: inline-block;
  font: 500 0.6875rem/1 var(--mono);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 0.35rem 0.5rem; border-radius: 3px;
}

.consulting {
  margin-top: 1.5rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* --- Highlights ----------------------------------------------------------- */

.highlights {
  display: grid; gap: 1px;
  background: var(--rule);
  border-block: 1px solid var(--rule);
}
@media (min-width: 40rem) { .highlights { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 62rem) { .highlights { grid-template-columns: repeat(4, 1fr); } }

.highlight {
  background: var(--paper);
  padding: 1.5rem 1.35rem;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.highlight__meta {
  font: 400 0.6875rem/1.3 var(--mono);
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent);
}
.highlight__title {
  font: 400 1.0625rem/1.35 var(--serif);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.highlight a { text-decoration: none; }
.highlight a:hover .highlight__title { text-decoration: underline; }

/* --- Contact -------------------------------------------------------------- */

.contact__mail {
  font: 400 clamp(1.15rem, 3vw, 1.5rem)/1.3 var(--serif);
  word-break: break-word;
}

.linkrow { display: flex; flex-wrap: wrap; gap: 0.6rem 1.5rem; margin-top: 1.5rem; }
.linkrow a { font-size: 0.9375rem; text-decoration: none; }
.linkrow a:hover { text-decoration: underline; }

/* --- Footer --------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--rule);
  padding-block: 2.5rem 3rem;
  margin-top: clamp(3rem, 7vw, 5rem);
  font-size: 0.875rem;
  color: var(--muted);
}
.footer__cols {
  display: grid; gap: 1.75rem;
  grid-template-columns: 1fr;
  margin-bottom: 2rem;
}
@media (min-width: 40rem) { .footer__cols { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 56rem) { .footer__cols { grid-template-columns: repeat(3, 1fr); } }

.footer__head {
  font: 500 0.6875rem/1 var(--mono);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.85rem;
}
.footer__list { display: flex; flex-direction: column; gap: 0.5rem; }
.footer__list a { text-decoration: none; color: var(--ink-soft); }
.footer__list a:hover { color: var(--accent); text-decoration: underline; }

.todo {
  font: 400 0.625rem/1 var(--mono);
  color: #9a5b2e; background: #fdf2e7;
  border: 1px solid #f0d9c0; border-radius: 2px;
  padding: 0.2rem 0.35rem; margin-left: 0.4rem;
  letter-spacing: 0.06em;
}

/* --- CV ------------------------------------------------------------------- */

.cv-entry {
  display: grid; gap: 0.25rem 1.75rem;
  grid-template-columns: 1fr;
  padding-block: 1.05rem;
  border-top: 1px solid var(--rule);
}
.cv-list > .cv-entry:first-child { border-top: none; padding-top: 0; }

@media (min-width: 40rem) {
  .cv-entry { grid-template-columns: 8.5rem minmax(0, 1fr); }
}

.cv-entry__when {
  font: 400 0.8125rem/1.6 var(--mono);
  color: var(--muted);
  letter-spacing: -0.01em;
  padding-top: 0.15rem;
}
.cv-entry__what { min-width: 0; }
.cv-entry__role { font-weight: 600; color: var(--ink); }
.cv-entry__where { color: var(--ink-soft); }
.cv-entry__detail { font-size: 0.9375rem; color: var(--muted); margin-top: 0.3rem; }
.cv-entry__detail em { color: var(--accent); font-style: normal; }

.pill-list { display: flex; flex-wrap: wrap; gap: 0.45rem; }

/* Publications */

.pubs { counter-reset: pub; }
.pubs > li {
  counter-increment: pub;
  position: relative;
  padding: 0.95rem 0 0.95rem 2.75rem;   /* hanging indent */
  border-top: 1px solid var(--rule);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.pubs > li:first-child { border-top: none; }
.pubs > li::before {
  content: counter(pub);
  position: absolute; left: 0; top: 1.05rem;
  font: 400 0.75rem/1 var(--mono);
  color: var(--muted);
  width: 2rem; text-align: right;
  font-variant-numeric: tabular-nums;
}
.pubs b { color: var(--ink); font-weight: 700; }   /* Fairbairn */
.pubs cite { font-style: italic; color: var(--ink); }
.pubs .doi {
  display: inline-block;
  font: 400 0.75rem/1.4 var(--mono);
  word-break: break-all;
  margin-top: 0.15rem;
}
.pubs .eq { color: var(--accent); font-weight: 600; }

.footnote {
  margin-top: 1.25rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.pub-group + .pub-group { margin-top: 2.5rem; }
.pub-group__head {
  font: 500 0.6875rem/1 var(--mono);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent);
  padding-bottom: 0.85rem;
  margin-bottom: 0.35rem;
}

.pending {
  background: var(--paper-sunk);
  border: 1px dashed var(--rule);
  border-radius: 4px;
  padding: 1.1rem 1.25rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* --- Mobile nav ----------------------------------------------------------- */

@media (max-width: 46rem) {
  .nav__toggle { display: block; }

  .nav__links {
    position: absolute; inset: 100% 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    padding: 0.5rem var(--gut) 1rem;
    display: none;
  }
  .nav__links[data-open="true"] { display: flex; }
  .nav__links a { padding: 0.75rem 0; border-top: 1px solid var(--rule); }
  .nav__links a:first-child { border-top: none; }
}

/* --- Motion --------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Print (CV) ----------------------------------------------------------- */

@media print {
  .nav, .footer, .trace, .actions, .skip { display: none !important; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .section { padding-block: 0.75rem; }
  a { color: #000; text-decoration: none; }
  .pubs .doi { color: #444; }
  .cv-entry { break-inside: avoid; }
}
