/* lancekeay.com — engineer's notebook */
:root {
  --paper: #F4F6F9;
  --paper-2: #E6ECF4;
  --white: #FFFFFF;
  --ink: #182233;
  --ink-2: #485468;
  --blue: #38629F;
  --blue-deep: #26497C;
  --rule: #C8D1DD;
  --ochre: #C9802E;

  --sans: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --serif: "Literata", Georgia, "Times New Roman", serif;

  --margin-col: 12.5rem;
  --main-col: 41rem;
  --gap: 3rem;
  --page: 76rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
  font-optical-sizing: auto;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--blue-deep); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- Page frame: margin column + main column ---------- */
.frame {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, var(--main-col)) minmax(0, 1fr);
  column-gap: var(--gap);
}
.frame > * { grid-column: 2; }
.frame > .margin { grid-column: 1; }
.frame > .wide { grid-column: 1 / -1; }
.frame > .main-wide { grid-column: 2 / -1; }

/* The blue margin rule — the notebook's red line, in Keay blue */
.ruled { position: relative; }
.ruled::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: calc(max(0px, (100% - var(--page)) / 2) + 2rem + var(--margin-col) + var(--gap) / 2);
  width: 1px;
  background: var(--blue);
  opacity: .45;
  transform-origin: top;
  transform: scaleY(var(--rule-scale, 1));
  pointer-events: none;
}

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--rule); background: var(--paper); }
.site-header .frame { align-items: center; padding-top: 1.1rem; padding-bottom: 1.1rem; }
.wordmark {
  grid-column: 1;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark:hover { color: var(--blue); }
.nav { grid-column: 2 / -1; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1.75rem; }
.nav a {
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink-2);
  text-decoration: none;
  padding: .25rem 0;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--blue); }

/* ---------- Type ---------- */
h1, h2, h3, h4 { font-family: var(--sans); color: var(--ink); line-height: 1.12; margin: 0; letter-spacing: -0.015em; }
h1 { font-size: clamp(2.6rem, 6vw, 4.75rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.02; }
h2 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); font-weight: 600; }
h3 { font-size: 1.3rem; font-weight: 600; }
p { margin: 0 0 1em; }
.lede { font-size: 1.3rem; line-height: 1.55; color: var(--ink); max-width: 36em; }
.small { font-size: .95rem; color: var(--ink-2); }
.sans { font-family: var(--sans); }
.tnum { font-variant-numeric: tabular-nums lining-nums; }

/* margin notes: small sans in blue ink, aligned to the first line of the content next to them */
.note {
  font-family: var(--sans);
  font-size: .95rem;
  line-height: 1.4;
  color: var(--blue-deep);
}
.note strong { display: block; font-weight: 600; color: var(--ink); }

/* ---------- Sections ---------- */
.section { padding-top: 4.5rem; padding-bottom: 4.5rem; }
.section + .section { border-top: 1px solid var(--rule); }
.section-head { margin-bottom: 2rem; }
.section-head p { margin: .5rem 0 0; color: var(--ink-2); }

/* ---------- Home hero ---------- */
.hero { padding-top: 5.5rem; padding-bottom: 4.5rem; }
.hero .margin { padding-top: 1.1rem; }
.hero h1 { margin-bottom: 1.5rem; }
.hero-line { display: block; overflow: hidden; padding-bottom: .06em; }
.hero-line > span { display: inline-block; }
.hero .intro { font-size: clamp(1.2rem, 1.8vw, 1.45rem); line-height: 1.5; max-width: 34em; margin: 0; }
.hero .intro + .intro { margin-top: .75rem; color: var(--ink-2); }
.hero-actions { margin-top: 2.25rem; display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--sans); font-size: 1.02rem; font-weight: 600;
  padding: .75rem 1.25rem;
  border: 1.5px solid var(--blue);
  border-radius: 3px;
  background: var(--blue); color: #fff;
  text-decoration: none;
  transition: background-color .15s, color .15s;
}
.btn:hover { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--blue-deep); }
.btn.ghost:hover { background: var(--white); color: var(--blue-deep); }
.btn svg { width: 1.05em; height: 1.05em; flex: none; }
.textlink { font-family: var(--sans); font-weight: 600; }

/* ---------- Verdict marks (Harvey balls) ---------- */
.verdict {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--sans); font-size: .95rem; font-weight: 600; color: var(--ink);
  white-space: nowrap;
}
.ball { width: 1.05rem; height: 1.05rem; flex: none; }
.ball circle { fill: none; stroke: var(--blue); stroke-width: 1.6; }
.ball .fill { fill: var(--blue); }

/* ---------- Post list ---------- */
.posts { list-style: none; margin: 0; padding: 0; }
.post-row {
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, 1fr);
  column-gap: var(--gap);
  padding: 1.6rem 0;
  border-top: 1px solid var(--rule);
}
.post-row:last-child { border-bottom: 1px solid var(--rule); }
.post-row .meta { font-family: var(--sans); font-size: .95rem; color: var(--ink-2); line-height: 1.5; }
.post-row .meta time { display: block; color: var(--ink); }
.post-row h3 { font-size: 1.4rem; margin-bottom: .45rem; max-width: 30em; }
.post-row h3 a { color: var(--ink); text-decoration: none; }
.post-row h3 a:hover { color: var(--blue); text-decoration: underline; text-decoration-thickness: 2px; }
.post-row .says { margin: .35rem 0 0; max-width: 38em; }
.post-row .says .verdict { margin-right: .4rem; }
.tags { display: inline; }
.tag { color: var(--ink-2); }

/* posts on home sit in the main+wide area */
.frame > .posts { grid-column: 1 / -1; }

/* ---------- Filter ---------- */
.filter { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 2rem; padding: 0; border: 0; }
.filter legend { font-family: var(--sans); font-size: .95rem; color: var(--ink-2); margin-bottom: .6rem; padding: 0; }
.filter button {
  font-family: var(--sans); font-size: 1rem;
  padding: .45rem 1rem;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: var(--white); color: var(--ink);
  cursor: pointer;
  transition: border-color .15s, background-color .15s, color .15s;
}
.filter button:hover { border-color: var(--blue); }
.filter button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.filter-status { font-family: var(--sans); font-size: .95rem; color: var(--ink-2); margin: 0 0 1rem; }

/* ---------- Chart ---------- */
.chart-block { background: var(--white); border: 1px solid var(--rule); border-radius: 4px; padding: 1.75rem 1.75rem 1.25rem; }
.chart-block h3 { font-size: 1.2rem; margin-bottom: .25rem; }
.chart-block .sub { font-family: var(--sans); font-size: .95rem; color: var(--ink-2); margin: 0 0 1rem; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; font-family: var(--sans); font-size: .95rem; color: var(--ink-2); margin: 0 0 .75rem; padding: 0; list-style: none; }
.legend li { display: inline-flex; align-items: center; gap: .45rem; }
.legend .key { width: .85rem; height: .85rem; border-radius: 2px; display: inline-block; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--sans); fill: var(--ink-2); font-size: 13px; }
.chart .cat { fill: var(--ink); font-size: 14px; }
.chart .val { fill: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .base { stroke: var(--ink-2); stroke-width: 1; }
.chart .bar { transform-box: fill-box; transform-origin: left center; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:focus { outline: none; }
.chart .hit:focus-visible + .bar, .chart g.is-hot .bar { filter: brightness(1.12); }
.tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--ink); color: #fff;
  font-family: var(--sans); font-size: .9rem; line-height: 1.35;
  padding: .45rem .65rem; border-radius: 3px;
  white-space: nowrap; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s;
}
.tip.on { opacity: 1; transform: none; }
.chart-foot { font-family: var(--sans); font-size: .9rem; color: var(--ink-2); margin: .75rem 0 0; }
details.data { margin-top: .75rem; font-family: var(--sans); font-size: .95rem; }
details.data summary { cursor: pointer; color: var(--blue-deep); }

/* ---------- Tables ---------- */
.table-wrap, .chart-block, .verdict-panel, .post-row { position: relative; }
.table-wrap {
  overflow-x: auto;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin: 1.5rem 0 .5rem;
  -webkit-overflow-scrolling: touch;
}
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 1rem; line-height: 1.4; }
caption { text-align: left; padding: 1rem 1.25rem .75rem; font-weight: 600; color: var(--ink); caption-side: top; }
caption span { display: block; font-weight: 400; color: var(--ink-2); font-size: .92rem; margin-top: .2rem; }
th, td { padding: .7rem 1.25rem; text-align: left; vertical-align: top; border-top: 1px solid var(--rule); }
thead th { background: var(--paper-2); font-weight: 600; color: var(--ink); border-top: 0; white-space: nowrap; }
tbody th { font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
tbody tr:hover { background: #F7F9FC; }
tr.pick th, tr.pick td { background: #EEF3FA; }
.table-note { font-family: var(--sans); font-size: .9rem; color: var(--ink-2); margin: 0 0 1.5rem; }

/* ---------- Hire strip ---------- */
.hire { background: var(--blue); color: #fff; }
.hire .frame { padding-top: 3.5rem; padding-bottom: 3.5rem; align-items: start; }
.hire h2 { color: #fff; grid-column: 1; font-size: 1.6rem; }
.hire .hire-body { grid-column: 2 / -1; }
.hire p { font-size: 1.2rem; max-width: 36em; margin-bottom: 1.5rem; }
.hire .btn { background: #fff; color: var(--blue-deep); border-color: #fff; }
.hire .btn:hover { background: var(--paper-2); border-color: var(--paper-2); color: var(--blue-deep); }
.hire .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.7); }
.hire .btn.ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.hire :focus-visible { outline-color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem 1rem; }

/* ---------- Article ---------- */
.article-head { padding-top: 4.5rem; padding-bottom: 2.5rem; }
.article-head h1 { font-size: clamp(2.2rem, 4.6vw, 3.6rem); margin-bottom: 1.25rem; }
.article-head .margin { padding-top: .6rem; }
.factsheet { margin: 0; display: grid; gap: 1.1rem; }
.factsheet div { border-top: 1px solid var(--rule); padding-top: .55rem; }
.factsheet dt { font-family: var(--sans); font-size: .9rem; color: var(--ink-2); }
.factsheet dd { margin: .1rem 0 0; font-family: var(--sans); font-size: 1rem; line-height: 1.4; color: var(--ink); }
.prose h2 { font-size: 1.6rem; margin: 2.75rem 0 1rem; }
.prose h3 { margin: 2rem 0 .6rem; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1.1em; }
.prose li { margin-bottom: .45em; }
.prose code { font-size: .88em; background: var(--paper-2); padding: .1em .35em; border-radius: 3px; }
.verdict-panel {
  border-left: 3px solid var(--blue);
  background: var(--white);
  padding: 1.25rem 1.5rem;
  margin: 0 0 2.5rem;
}
.verdict-panel .verdict { font-size: 1.1rem; margin-bottom: .5rem; }
.verdict-panel p { margin: 0; }
.sample-flag {
  font-family: var(--sans); font-size: .9rem; color: var(--ink-2);
  border: 1px dashed var(--rule); border-radius: 3px; padding: .5rem .75rem; margin: 0 0 2rem;
  background: rgba(255,255,255,.5);
}

/* ---------- CV ---------- */
.skills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem 2.5rem; margin: 0; }
.skills dt { font-family: var(--sans); font-weight: 600; margin-bottom: .35rem; }
.skills dd { margin: 0; font-size: 1.05rem; color: var(--ink-2); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 1.5rem; padding: 1.25rem 0; border-top: 1px solid var(--rule); }
.timeline .when { font-family: var(--sans); font-size: .98rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.timeline h3 { font-size: 1.15rem; margin-bottom: .3rem; }
.timeline p { margin: 0; font-size: 1.05rem; }
.download { display: flex; flex-wrap: wrap; gap: .75rem 1rem; margin: 1.5rem 0 .75rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); padding: 2.5rem 0 3rem; font-family: var(--sans); font-size: .95rem; color: var(--ink-2); }
.site-footer .frame { row-gap: .5rem; }
.site-footer p { margin: 0; }
.site-footer .wordmark { font-size: 1.05rem; }

/* ---------- Motion pre-states (only while JS + motion are active) ---------- */
.pre-anim .hero-line > span { transform: translateY(105%); }
.pre-anim .hero .intro, .pre-anim .hero .margin, .pre-anim .hero-actions { opacity: 0; }
.pre-anim .ruled { --rule-scale: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  :root { --margin-col: 10rem; --gap: 2rem; }
}
@media (max-width: 760px) {
  body { font-size: 1.0625rem; }
  .frame { grid-template-columns: minmax(0, 1fr); padding: 0 1.25rem; }
  .frame > *, .frame > .margin, .frame > .wide, .frame > .main-wide, .frame > .posts { grid-column: 1; }
  .ruled::before { display: none; }
  .site-header .frame { row-gap: .5rem; }
  .nav { grid-column: 1; }
  .nav ul { gap: .1rem 1.25rem; }
  .hero { padding-top: 3rem; padding-bottom: 3rem; }
  .hero .margin { padding-top: 0; margin-bottom: 1.25rem; order: -1; }
  .section { padding-top: 3.25rem; padding-bottom: 3.25rem; }
  .post-row { grid-template-columns: minmax(0, 1fr); row-gap: .5rem; }
  .post-row .meta time { display: inline; margin-right: .6rem; }
  .hire h2, .hire .hire-body { grid-column: 1; }
  .hire h2 { margin-bottom: 1rem; }
  .article-head { padding-top: 2.75rem; padding-bottom: 1.5rem; }
  .article-head .margin { order: 2; margin-top: 1.5rem; }
  .factsheet { grid-template-columns: 1fr 1fr; gap: .9rem 1.25rem; }
  .skills { grid-template-columns: minmax(0, 1fr); gap: 1.4rem; }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: .3rem; }
  .chart-block { padding: 1.25rem 1rem 1rem; }
  th, td { padding: .6rem .9rem; }
  .margin.note { margin-bottom: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* fixes after review */
.prose .chart-block h3 { margin-top: 0; }
tbody th { min-width: 13rem; }
@media (max-width: 760px) { tbody th { min-width: 10rem; } }
.chart .cat { paint-order: stroke; stroke: var(--white); stroke-width: 5px; stroke-linejoin: round; }
[hidden] { display: none !important; }
