/* The Measured Sheet. Tokens and rules are documented in DESIGN.md. */

:root {
  color-scheme: light;

  /* Light: stone ground, white sheets, solid ink close. */
  --ground: #f6f6f4;
  --surface: #ffffff;
  --surface-raised: #fbfbf9;
  --line: #e2e2de;
  --line-strong: #c9c9c4;
  --ink: #101113;
  --ink-2: #4f5257;
  --ink-3: #66696e;
  --accent: #0a6b4a;
  --meter: #85888d;
  --segment: #e2e2de;
  --on-ink: #ffffff;
  --close-ground: #101113;
  --close-ink: #f4f4f2;
  --close-ink-2: #aeb1b6;
  --close-line: #2a2c30;
  --display-weight: 560;

  /* Type scale: ratio 1.25 from 16px. */
  --t-label: .8rem;
  --t-body: 1rem;
  --t-lead: 1.25rem;
  --t-title: 1.563rem;
  --t-heading: clamp(1.953rem, 1.6rem + 1.2vw, 2.441rem);
  --t-figure: clamp(2.441rem, 2rem + 1.4vw, 3.052rem);
  --t-headline: clamp(2.441rem, 1.7rem + 3vw, 3.815rem);
  --t-display: clamp(2.75rem, .9rem + 7.2vw, 5.96rem);

  /* Spacing scale: 4px base. */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;
  --s-24: 96px;
  --s-32: 128px;
  --s-40: 160px;

  --r-sm: 2px;
  --r: 4px;

  --page: 80rem;
  --gutter: clamp(var(--s-5), 4vw, var(--s-10));
  --section: clamp(var(--s-24), 11vw, var(--s-40));
  --measure: 34rem; /* about 72 characters of Geist at 16px; ch is too wide a unit in this face */

  --sans: "Geist", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, Consolas, Menlo, monospace;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

/* Dark: carbon ground, panels lifted by tone, lighter display weight.
   Declared twice on purpose: the media block is what makes System work without JS. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0a0b0c;
    --surface: #111315;
    --surface-raised: #16181b;
    --line: #232529;
    --line-strong: #383b40;
    --ink: #edeef0;
    --ink-2: #a6a9af;
    --ink-3: #8e9299;
    --accent: #3fcf8e;
    --meter: #6e7177;
    --segment: #2a2d31;
    --on-ink: #0a0b0c;
    --close-ground: #15171a;
    --close-ink: #edeef0;
    --close-ink-2: #a6a9af;
    --close-line: #2b2e33;
    --display-weight: 500;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0a0b0c;
  --surface: #111315;
  --surface-raised: #16181b;
  --line: #232529;
  --line-strong: #383b40;
  --ink: #edeef0;
  --ink-2: #a6a9af;
  --ink-3: #8e9299;
  --accent: #3fcf8e;
  --meter: #6e7177;
  --segment: #2a2d31;
  --on-ink: #0a0b0c;
  --close-ground: #15171a;
  --close-ink: #edeef0;
  --close-ink-2: #a6a9af;
  --close-line: #2b2e33;
  --display-weight: 500;
}

/* Base */

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

html {
  scroll-behavior: smooth;
  scrollbar-color: var(--line-strong) var(--ground);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 var(--t-body)/1.6 var(--sans);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, p, ol, ul, dl, dd, figure, fieldset { margin: 0; padding: 0; }
ol, ul { list-style: none; }
small { font-size: inherit; }
strong { font-weight: 600; }
fieldset { border: 0; }

h1, h2 {
  font-weight: var(--display-weight);
  text-wrap: balance;
}

h1 { margin-left: -.03em; font-size: var(--t-display); line-height: 1; letter-spacing: -.04em; }
h2 { margin-left: -.03em; font-size: var(--t-headline); line-height: 1.05; letter-spacing: -.035em; }
h3 { font-size: var(--t-lead); font-weight: 500; line-height: 1.3; letter-spacing: -.01em; text-wrap: balance; }

p { max-width: var(--measure); text-wrap: pretty; }

a { color: inherit; }

::selection { background: var(--ink); color: var(--ground); }

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: var(--r-sm);
}


.wrap {
  width: min(100%, var(--page));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.sprite { position: absolute; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.ext {
  width: .65em;
  height: .65em;
  margin-left: .3em;
  vertical-align: baseline;
  color: var(--ink-3);
}

.skip {
  position: absolute;
  left: var(--s-4);
  top: calc(var(--s-16) * -1);
  z-index: 20;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r);
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 500;
}
.skip:focus { top: var(--s-3); }

/* Header */

.topbar {
  position: relative;
  z-index: 10;
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}

.topbar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0 var(--s-4);
  padding-block: var(--s-2) 0;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 44px;
  width: fit-content;
  font-size: var(--t-body);
  font-weight: 500;
  letter-spacing: -.01em;
  text-decoration: none;
}

.mark-box {
  display: grid;
  place-items: center;
  width: var(--s-6);
  height: var(--s-6);
  border-radius: var(--r);
  background: var(--ink);
  color: var(--on-ink);
  font: 500 .64rem/1 var(--mono);
}

.topbar nav {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 var(--s-3);
  font-size: var(--t-label);
}

.topbar nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-2);
  text-decoration: none;
  transition: color .15s;
}
.topbar nav a:hover { color: var(--ink); }

/* Theme switcher. Without JS the page follows the system by itself, so the control is hidden. */

.theme {
  display: none;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: var(--t-label);
  line-height: 1;
}
.js .theme { display: inline-flex; }

.theme label { position: relative; display: block; }

.theme input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.theme span {
  display: flex;
  align-items: center;
  min-height: var(--s-8);
  padding-inline: var(--s-2);
  border-radius: var(--r-sm);
  color: var(--ink-3);
  transition: color .15s;
}
.theme label:hover span { color: var(--ink); }
.theme input:checked + span { background: var(--segment); color: var(--ink); }
.theme input:focus-visible + span {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

/* Hero */

.hero-inner { padding-block: clamp(var(--s-20), 9vw, var(--s-32)) clamp(var(--s-20), 8vw, var(--s-24)); }

h1 span { display: block; animation: settle .9s var(--ease) both; }
h1 span:nth-child(2) { animation-delay: .08s; }

.hero-grid {
  display: grid;
  gap: var(--s-16);
  margin-top: clamp(var(--s-12), 6vw, var(--s-20));
}

.lede {
  max-width: 34rem;
  color: var(--ink-2);
  font-size: var(--t-lead);
  line-height: 1.5;
  letter-spacing: -.01em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-top: var(--s-10);
}

.btn {
  display: inline-flex;
  align-items: center;
  min-height: var(--s-12);
  padding-inline: var(--s-6);
  border: 1px solid var(--ink);
  border-radius: var(--r);
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 500;
  letter-spacing: -.005em;
  text-decoration: none;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--ink-2); border-color: var(--ink-2); }

.btn-ghost {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink);
}
.btn-ghost:hover { background: var(--surface); border-color: var(--line-strong); }

.textlink {
  display: inline-block;
  padding-block: var(--s-3);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: .3em;
  transition: text-decoration-color .15s;
}
.textlink:hover { text-decoration-color: currentColor; }

/* Summary panel */

.panel {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
}

.panel-head {
  max-width: none;
  padding: var(--s-4) var(--s-6);
  text-wrap: balance;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
  letter-spacing: -.005em;
}

.panel dl > div {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: var(--s-4);
  padding: var(--s-3) var(--s-6);
}
.panel dl > div + div { border-top: 1px solid var(--line); }

.panel dt,
.tally dt,
.log-key,
.tag,
.meter-key,
.rate-price small {
  font: 400 var(--t-label)/1.4 var(--mono);
}

.panel dt { padding-top: .2rem; color: var(--ink-3); }

/* Scale of past work */

.tally { border-top: 1px solid var(--line); }
.tally .wrap { padding-inline: 0; }

.tally-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
}

.tally-row > div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  padding: var(--s-8) var(--gutter);
  background: var(--ground);
}

.tally dt { margin-top: var(--s-3); color: var(--ink-3); }

.tally dd {
  font-size: var(--t-heading);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.tally small {
  margin-left: var(--s-1);
  color: var(--ink-3);
  font: 400 var(--t-label)/1.4 var(--mono);
  letter-spacing: 0;
}

/* Sections */

.section { border-top: 1px solid var(--line); }
.section > .wrap { padding-block: var(--section); }
.section-flush > .wrap { padding-bottom: 0; }

.note { margin-top: var(--s-6); color: var(--ink-2); }

.split { display: grid; gap: var(--s-12); }
.split-link { margin-top: var(--s-4); }

.top-head { display: grid; gap: 0 var(--s-16); padding-bottom: clamp(var(--s-16), 7vw, var(--s-24)); }

/* Rate card */

.rates > li {
  display: grid;
  gap: var(--s-4);
  padding-block: var(--s-8);
  border-top: 1px solid var(--line);
}
.rates > li:last-child { padding-bottom: 0; }

.rates li div p { margin-top: var(--s-2); color: var(--ink-2); }

.rate-price {
  font-size: var(--t-title);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rate-price small {
  margin-right: var(--s-2);
  color: var(--ink-3);
  letter-spacing: 0;
}

/* Work: a ruled grid that bleeds to the page edges. */

.cases,
.terms {
  display: grid;
  gap: 1px;
  margin-inline: calc(var(--gutter) * -1);
  border-top: 1px solid var(--line);
  background: var(--line);
}

.case {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: clamp(var(--s-8), 4vw, var(--s-12)) var(--gutter);
  background: var(--surface);
  transition: background-color .15s;
}
.case:hover { background: var(--surface-raised); }

.case-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-2) var(--s-6);
  margin-bottom: var(--s-4);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.case-wide h3 { font-size: var(--t-title); line-height: 1.2; letter-spacing: -.02em; }

.case h3 a { text-decoration: none; }
.case h3 a::after { content: ""; position: absolute; inset: 0; }
.case h3 a:focus-visible { outline: none; }
.case h3 a:focus-visible::after { outline: 2px solid var(--ink); outline-offset: -4px; border-radius: var(--r-sm); }
.case:hover h3 a { text-decoration: underline; text-decoration-color: var(--line-strong); text-decoration-thickness: 1px; text-underline-offset: .25em; }

.case p:not(.tag):not(.bigfig):not(.result):not(.case-extra) { color: var(--ink-2); }

.result { margin-top: var(--s-4); color: var(--ink-2); }
.result strong { color: var(--ink); font-weight: 500; }

.bigfig {
  margin-top: auto;
  padding-top: var(--s-12);
  font-size: var(--t-figure);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}

.bigfig small {
  display: block;
  margin-top: var(--s-2);
  color: var(--ink-3);
  font: 400 var(--t-label)/1.4 var(--mono);
  letter-spacing: 0;
}

.case-extra { position: relative; z-index: 1; width: fit-content; margin-top: var(--s-2); }

.case-proof { margin-top: var(--s-10); }
.case-proof .bigfig { padding-top: 0; }

/* Measurement */

.meter + .meter { margin-top: var(--s-10); }

.meter figcaption { margin-bottom: var(--s-4); font-size: var(--t-body); font-weight: 500; letter-spacing: -.005em; }

.meter-row {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) 4.5rem;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--s-6);
}

.meter-key { color: var(--ink-3); }

.meter-val {
  text-align: right;
  font: 400 var(--t-label)/1 var(--mono);
  font-variant-numeric: tabular-nums;
}

.meter-track { display: block; height: var(--s-2); }
.meter-track i { display: block; height: 100%; min-width: 2px; }
.meter-before { background: var(--meter); }
.meter-after { background: var(--accent); transition: width .9s var(--ease); }
@media screen { .arm .meter-after { width: 100% !important; } }

/* Experience */

.log > li {
  display: grid;
  gap: var(--s-1);
  padding-block: var(--s-6);
  border-top: 1px solid var(--line);
}
.log > li:last-child { padding-bottom: 0; }

.log-key { padding-top: .25rem; color: var(--ink-3); }

/* How I work */

.terms > li {
  padding: clamp(var(--s-8), 4vw, var(--s-12)) var(--gutter);
  background: var(--ground);
}
.terms h3 { margin-bottom: var(--s-3); }
.terms p { color: var(--ink-2); }

/* Close. Light ends on solid ink, dark on a raised carbon band. */

.contact {
  border-top: 1px solid var(--line);
  background: var(--close-ground);
  color: var(--close-ink);
}

.contact-inner { padding-block: var(--section); }

.contact h2 {
  max-width: 14em;
  margin-left: 0;
  font-size: var(--t-display);
  line-height: 1;
  letter-spacing: -.04em;
}

.contact-note {
  max-width: 34rem;
  margin-top: var(--s-8);
  color: var(--close-ink-2);
  font-size: var(--t-lead);
  line-height: 1.5;
  letter-spacing: -.01em;
}

.contact-mail {
  display: inline-block;
  margin-top: clamp(var(--s-12), 6vw, var(--s-20));
  font-size: clamp(1.75rem, 9vw, 3.815rem);
  font-weight: var(--display-weight);
  line-height: 1.05;
  letter-spacing: -.035em;
  text-decoration: underline;
  text-decoration-color: var(--close-ink-2);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  transition: text-decoration-color .15s;
}
.contact-mail:hover { text-decoration-color: currentColor; }

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s-6);
  margin-top: var(--s-6);
  font-size: var(--t-label);
  line-height: 1;
}

.contact-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}
.contact-links a:hover { text-decoration: underline; text-underline-offset: .3em; }
.contact-links .ext { color: currentColor; }

.footer { border-top: 1px solid var(--line); }

.footer p {
  padding-block: var(--s-8);
  color: var(--ink-3);
  font-size: var(--t-label);
}

/* Wider layouts */

@media (min-width: 40rem) {
  .tally-row { grid-template-columns: repeat(4, 1fr); }

  .rates > li { grid-template-columns: minmax(0, 1fr) 11rem; gap: var(--s-8); align-items: baseline; }
  .rate-price { text-align: right; }
  .rate-price small { display: block; margin: 0 0 var(--s-1); }

  .log > li { grid-template-columns: 8rem minmax(0, 1fr); gap: var(--s-4); }

  .terms { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 39.99rem) {
  .actions .btn { flex: 1 1 auto; justify-content: center; }
}

@media (min-width: 48rem) {
  section[id] { scroll-margin-top: 60px; } /* the sticky header's height, so the previous section never peeks out */

  .topbar { position: sticky; top: 0; }

  .topbar-row {
    grid-template-columns: 1fr auto auto;
    gap: var(--s-8);
    padding-block: var(--s-2);
  }

  .topbar nav {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
    gap: 0 var(--s-6);
  }
}

@media (min-width: 64rem) {
  /* The panel fills the last five of twelve sheet columns and joins the rail and the tally. */
  .hero-inner { padding-block: var(--s-24) 0; }
  .hero-grid {
    grid-template-columns: minmax(0, 1fr) calc((100% + 2 * var(--gutter)) * 5 / 12 - var(--gutter));
    gap: 0;
    margin-top: var(--s-16);
  }
  .hero-copy { padding-bottom: var(--s-16); padding-right: var(--s-16); }
  .panel {
    align-self: stretch;
    margin-right: calc(var(--gutter) * -1);
    border-width: 1px 0 0 1px;
    border-radius: 0;
  }
  .panel-head, .panel dl > div { padding-inline: var(--s-8) var(--gutter); }

  .split {
    grid-template-columns: 4fr 8fr;
    gap: var(--s-16);
    align-items: start;
  }
  .split-head { position: sticky; top: var(--s-24); }

  .top-head { grid-template-columns: 4fr 8fr; align-items: end; }
  .top-head .note { margin-top: 0; }

  .cases { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .case-wide {
    grid-column: span 12;
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: var(--s-16);
    align-items: start;
  }
  .case-7 { grid-column: span 7; }
  .case-5 { grid-column: span 5; }
  .case-proof { margin-top: 0; }

  /* Neighbouring cells share rows and columns, so figures and text line up across the sheet. */
  @supports (grid-template-rows: subgrid) {
    .case-5, .case-7 {
      display: grid;
      grid-row: span 4;
      grid-template-rows: subgrid;
      row-gap: 0;
    }
    .bigfig { margin-top: 0; }
    .case-wide { grid-template-columns: subgrid; gap: 0; }
    .case-copy { grid-column: 1 / span 5; padding-right: var(--s-8); }
    .case-proof { grid-column: 6 / -1; padding-left: var(--gutter); }
  }
}

/* Rails: once the sheet is narrower than the window, its edges are drawn. */
@media (min-width: 81rem) {
  .wrap { border-inline: 1px solid var(--line); }
  .contact .wrap { border-color: var(--close-line); }
}

/* Motion: the statement settles on load. Each After bar shrinks to its measured value once, when first seen (see .arm). */

@keyframes settle {
  from { opacity: 0; transform: translateY(.16em); }
}

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

@media (pointer: coarse) {
  .theme span { min-height: 44px; }
}

@media (forced-colors: active) {
  .meter-track i, .tag::before { background: CanvasText; }
  .theme input:checked + span { background: Highlight; color: HighlightText; forced-color-adjust: none; }
}

.inline-link { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 0.2em; }
.inline-link:hover { text-decoration-color: currentColor; }

/* Demo thumbnails: whole image links to the live demo, sits above the card's GitHub overlay link */
.case-shot {
  position: relative;
  z-index: 1;
  display: block;
  margin: var(--s-2) 0 var(--s-6);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--ground);
  transition: border-color .15s;
}
.case-shot img { display: block; width: 100%; height: auto; aspect-ratio: 8 / 5; }
.case-shot:hover { border-color: var(--line-strong); }
.case-shot:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.shot-dark { display: none !important; }
:root[data-theme="dark"] .shot-light { display: none !important; }
:root[data-theme="dark"] .shot-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shot-light { display: none !important; }
  :root:not([data-theme="light"]) .shot-dark { display: block !important; }
}
