/* =================================================================
   Matthew D. Webb — portfolio & engineering notebook
   Editorial serif · FT-style · light + dark · print-ready
   ================================================================= */

/* ---- Design tokens ------------------------------------------- */
:root {
  /* Type — newspaper editorial pairing (FT-style news serif) */
  --font-display:
    "Newsreader", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-body:
    "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  /* Mono — the "data" voice: dates, tags, datelines, section kickers */
  --font-mono:
    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    "Roboto Mono", monospace;

  /* Fluid type scale (min … max across 22rem–62rem viewport) */
  --step--1: clamp(0.78rem, 0.75rem + 0.12vw, 0.84rem);
  --step-0: clamp(0.92rem, 0.88rem + 0.16vw, 1rem);
  --step-1: clamp(1.02rem, 0.96rem + 0.24vw, 1.15rem);
  --step-2: clamp(1.85rem, 1.45rem + 1.9vw, 3.1rem);

  /* Spacing scale — condensed */
  --space-2xs: 0.2rem;
  --space-xs: 0.3rem;
  --space-s: 0.45rem;
  --space-m: 0.58rem;
  --space-l: 0.9rem;
  --space-xl: 1.4rem;
  --space-2xl: 2.25rem;

  /* Measure — full width with gutters */
  --measure: none;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);

  /* Colour — light · "FT Pink" salmon paper, warm ink, claret accent */
  --ink: #33302e;
  --ink-soft: #66605c;
  --paper: #fff1e5;
  --rule: #e6d9ce;
  --accent: #990f3d;
  --teal: #0d7680;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #ece4d9;
    --ink-soft: #a59d92;
    --paper: #1f1b17;
    --rule: #3a342d;
    --accent: #f4a3b8;
    --teal: #4cb3a9;
  }
}

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

img {
  max-width: 100%;
  height: auto;
}

/* Keep long words / URLs / headlines from forcing horizontal scroll */
.nameplate,
.article__headline,
.teaser__headline,
.article__dek,
.teaser__dek,
.entry__role,
.prose {
  overflow-wrap: break-word;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.3;
  font-weight: 400;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "liga", "onum";
}

/* ---- Layout -------------------------------------------------- */
.masthead,
#main,
.colophon {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.masthead {
  padding-top: var(--space-2xl);
}

#main {
  padding-block: var(--space-2xl) var(--space-xl);
}

.colophon {
  padding-block: var(--space-m) var(--space-xl);
  color: var(--ink-soft);
  font-size: var(--step--1);
  font-family: var(--font-mono);
}

section + section {
  margin-top: var(--space-xl);
}

/* ---- Market-data top banner (FT-style ticker) --------------- */
.ticker {
  background: #1a1a1a;
  color: #fff;
}

.ticker__bar {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding: var(--space-s) var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-l);
}

.ticker__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-l);
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

.ticker__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.ticker__label,
.ticker__cta {
  color: #fff;
  border: none;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.ticker__label:hover,
.ticker__cta:hover {
  color: #fff;
  border: none;
  opacity: 0.72;
}

.ticker__cta {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.ticker__chip {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 0.08em 0.4em;
  border-radius: 2px;
  color: #fff;
}

.ticker__chip.is-up {
  background: #1a7f3d;
}

.ticker__chip.is-down {
  background: #b3093c;
}

/* ---- Masthead nameplate (FT-style) --------------------------- */
.masthead__bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-m);
}

.nameplate {
  justify-self: center;
  text-align: center;
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: clamp(1.6rem, 0.7rem + 4vw, 3.6rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.015em;
  padding-block: var(--space-m) var(--space-s);
}

.nameplate a {
  color: inherit;
  border: none;
}

.nameplate a:hover {
  color: inherit;
}

.edition {
  justify-self: start;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.5;
  color: var(--ink-soft);
}

.strapline {
  margin-top: var(--space-m);
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-wrap: balance;
}

/* ---- Section nav --------------------------------------------- */
.nav {
  margin-top: var(--space-xl);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(1.4rem, 0.6rem + 3vw, 3rem);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Links fill the bar height so the underline sits flush with the bottom rule */
.nav a {
  display: inline-block;
  padding-block: var(--space-m);
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  color: var(--ink);
}

.nav a:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.nav a.is-active {
  color: var(--teal);
  border-color: var(--teal);
}

/* ---- Links --------------------------------------------------- */
a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition:
    border-color 0.18s ease,
    color 0.18s ease;
}

a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- Headings (section kickers) ------------------------------ */
h2 {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: var(--space-m);
}

h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* ---- Lede / professional summary ---------------------------- */
.lede p {
  max-width: 60ch;
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.5;
  text-wrap: pretty;
}

.lede p + p {
  margin-top: var(--space-s);
}

/* ---- Experience entries ------------------------------------- */
.entry {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: var(--space-m);
  padding-block: var(--space-m);
  border-top: 1px solid var(--rule);
}

.entry:first-of-type {
  border-top: none;
  padding-top: 0;
}

.entry__period {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-soft);
  font-variant-numeric: lining-nums tabular-nums;
  line-height: 1.5;
  letter-spacing: -0.02em;
}

.entry__role {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.005em;
}

.entry__org {
  margin-top: 0.1rem;
  margin-bottom: var(--space-xs);
  color: var(--ink-soft);
  font-size: var(--step--1);
}

.entry__body p:last-child {
  text-wrap: pretty;
}

em {
  font-style: italic;
}

/* ---- Focus tags ---------------------------------------------- */
.tags {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs) 0;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.tags li:not(:last-child)::after {
  content: "/";
  margin-inline: var(--space-s);
  color: var(--rule);
}

/* ---- Blog listing (teasers) --------------------------------- */
.teaser {
  max-width: 46rem;
  padding-block: var(--space-l);
  border-top: 1px solid var(--rule);
}

.teaser:first-of-type {
  border-top: none;
  padding-top: 0;
}

.teaser__kicker,
.article__kicker {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.teaser__headline {
  margin-top: var(--space-2xs);
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.9rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.teaser__headline a {
  border: none;
  color: inherit;
}

.teaser__headline a:hover {
  color: var(--accent);
}

.teaser__dek {
  margin-top: var(--space-xs);
  max-width: 54ch;
  font-size: var(--step-1);
  line-height: 1.4;
  color: var(--ink);
  text-wrap: pretty;
}

.teaser__byline {
  margin-top: var(--space-s);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-variant-numeric: lining-nums tabular-nums;
}

/* ---- Article (single post) ---------------------------------- */
.article {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 40rem);
  column-gap: var(--space-l);
  justify-content: center;
}

.article__head {
  grid-column: 2;
  padding-bottom: var(--space-m);
  margin-bottom: var(--space-l);
  border-bottom: 1px solid var(--rule);
}

.article__headline {
  margin-top: var(--space-xs);
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: clamp(2rem, 1.3rem + 3vw, 3.3rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.018em;
}

.article__dek {
  margin-top: var(--space-s);
  max-width: 46ch;
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.4rem);
  line-height: 1.4;
  color: var(--ink);
  text-wrap: pretty;
}

.article__byline {
  margin-top: var(--space-m);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-variant-numeric: lining-nums tabular-nums;
}

/* Vertical share rail (hangs in the left column) */
.article__share {
  grid-column: 1;
  grid-row: 1 / -1;
  align-self: start;
  position: sticky;
  top: var(--space-l);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.share-btn {
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--ink);
}

.share-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.share-btn svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
}

/* Optional hero image */
.article__hero {
  grid-column: 2;
  margin-bottom: var(--space-l);
}

.article__hero img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
}

.article__hero figcaption {
  margin-top: var(--space-2xs);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.prose {
  grid-column: 2;
}

.article__back {
  grid-column: 2;
  margin-top: var(--space-xl);
  padding-top: var(--space-m);
  border-top: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---- Prose (article body) ----------------------------------- */
.prose {
  font-size: var(--step-1);
  line-height: 1.6;
}

.prose > * + * {
  margin-top: 1.05em;
}

.prose h2 {
  display: block;
  margin-top: 1.9em;
  margin-bottom: 0;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1.1rem + 0.7vw, 1.6rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--ink);
}

.prose h2::after {
  content: none;
}

.prose h3 {
  margin-top: 1.6em;
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
}

.prose a {
  color: var(--accent);
}

.prose ul,
.prose ol {
  padding-left: 1.3em;
}

.prose li + li {
  margin-top: var(--space-2xs);
}

.prose li::marker {
  color: var(--ink-soft);
}

.prose blockquote {
  padding-left: var(--space-m);
  border-left: 3px solid var(--accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  line-height: 1.35;
  color: var(--ink);
}

.prose blockquote p {
  margin: 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.prose pre {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  line-height: 1.55;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: var(--space-m);
  overflow-x: auto;
}

.prose pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin-block: var(--space-l);
}

.prose img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
}

/* Wide tables scroll inside the column instead of the whole page */
.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

/* ---- Accessibility ------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: var(--space-2xs) var(--space-s);
  background: var(--ink);
  color: var(--paper);
  border: none;
}

.skip-link:focus {
  left: var(--space-s);
  top: var(--space-s);
  z-index: 10;
}

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

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

/* ---- Narrow viewports ---------------------------------------- */
@media (max-width: 52rem) {
  .article {
    grid-template-columns: minmax(0, 1fr);
  }

  .article__head,
  .article__hero,
  .prose,
  .article__back {
    grid-column: 1;
  }

  .article__share {
    grid-column: 1;
    grid-row: auto;
    position: static;
    flex-direction: row;
    gap: var(--space-s);
    margin-bottom: var(--space-l);
  }

  .share-btn {
    width: 2.75rem;
    height: 2.75rem;
  }
}

@media (max-width: 44rem) {
  /* FT-style mobile masthead: ticker banner → nameplate → centred menu */
  .ticker__bar {
    justify-content: center;
  }

  .ticker__cta {
    display: none;
  }

  .masthead {
    padding: 0;
  }

  .masthead__bar {
    grid-template-columns: 1fr;
    grid-template-areas: "name";
    align-items: center;
    gap: 0;
  }

  .nameplate {
    grid-area: name;
    font-size: clamp(1.25rem, 0.9rem + 1.8vw, 1.7rem);
    padding-block: var(--space-s);
  }

  .edition,
  .strapline {
    display: none;
  }

  /* Three sections sit centred under the nameplate — no hamburger */
  .nav {
    margin-top: 0;
  }

  .nav ul {
    justify-content: center;
  }
}

@media (max-width: 32rem) {
  .entry {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }

  .entry__period {
    order: -1;
  }
}

/* ---- Print --------------------------------------------------- */
@media print {
  :root {
    --ink: #000;
    --ink-soft: #333;
    --paper: #fff;
    --rule: #ccc;
  }

  body {
    font-size: 10.5pt;
    line-height: 1.4;
  }

  .masthead {
    padding-top: 0;
  }

  .skip-link,
  .ticker,
  .nav {
    display: none;
  }

  a {
    border: none;
  }

  .entry,
  h2 {
    break-inside: avoid;
  }

  #main {
    padding-block: 1rem;
  }

  .colophon {
    display: none;
  }
}
