/* ---------- Font ----------
   Geist, hosted on this site (SIL Open Font License, see assets/fonts/OFL.txt).
   One variable file covers weights 400 to 600. The extended Latin file
   only downloads if a page uses one of its characters. */
@font-face {
  font-family: "Geist"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("assets/fonts/geist-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("assets/fonts/geist-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ----------
   One typeface: Geist, everywhere.
   Two text colours per mode: --ink (primary) and --muted (secondary).
   --subtle, --rule and --surface are for lines and fills only, never text. */
:root {
  --bg: #ffffff;
  --ink: #171717;
  --muted: #6b6b6b;
  --subtle: #a3a3a3;
  --rule: #e5e5e5;
  --surface: #f5f5f5;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --toggle-x: 0px; --toggle-track: #e5e5e5; --toggle-thumb: #ffffff;
  --toggle-sun: var(--ink); --toggle-moon: var(--muted);
  --grain-opacity: 0.07;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --ink: #ededed; --muted: #a1a1a1;
    --subtle: #525252; --rule: #262626; --surface: #171717;
    --toggle-x: 16px; --toggle-track: #3a3a3a; --toggle-thumb: #ededed;
    --toggle-sun: var(--muted); --toggle-moon: var(--ink);
    --grain-opacity: 0.08;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --ink: #ededed; --muted: #a1a1a1;
  --subtle: #525252; --rule: #262626; --surface: #171717;
  --toggle-x: 16px; --toggle-track: #3a3a3a; --toggle-thumb: #ededed;
  --toggle-sun: var(--muted); --toggle-moon: var(--ink);
  --grain-opacity: 0.08;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* Film grain: a fixed noise layer behind the content. Strength is --grain-opacity. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 1.6 -0.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}
.page {
  max-width: 44rem;            /* 704px */
  margin: 32px 16px 0;
  padding-bottom: 64px;
}
@media (min-width: 1024px) { .page { margin-left: auto; margin-right: auto; } }

a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; color: var(--ink); }
p { margin: 0; }

/* ---------- Nav ---------- */
.nav { display: flex; justify-content: space-between; align-items: center; margin: 0 0 56px -8px; }
.nav-links { display: flex; flex-wrap: wrap; gap: 0 16px; }
.nav a { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); text-decoration: none; padding: 4px 8px; }
.nav a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--subtle); }
/* Links that open another site get the same arrow as LinkedIn, before the text */
.nav a.external::before {
  content: ""; width: 13px; height: 13px; flex: 0 0 auto; background: currentColor;
  -webkit-mask: var(--icon-arrow) center / contain no-repeat;
          mask: var(--icon-arrow) center / contain no-repeat;
}
.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 0; padding: 4px 0; cursor: pointer; color: var(--muted);
}
.theme-toggle .ti { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; transition: color .2s; }
.theme-toggle .track {
  position: relative; width: 38px; height: 22px; border-radius: 999px;
  background: var(--toggle-track); border: 1px solid var(--rule);
  transition: background .2s;
}
.theme-toggle .thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--toggle-thumb); box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transform: translateX(var(--toggle-x)); transition: transform .2s ease;
}
.theme-toggle .ti-sun { color: var(--toggle-sun); }
.theme-toggle .ti-moon { color: var(--toggle-moon); }
.theme-toggle:hover .track { border-color: var(--subtle); }
.theme-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 6px; }

/* ---------- Home ---------- */
.home h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.05em; line-height: 1.3; margin-bottom: 24px; }
.home .intro { color: var(--ink); margin-bottom: 40px; }

.section-title { font-size: 16px; font-weight: 500; color: var(--muted); margin: 0 0 16px; }

.work { list-style: none; margin: 0 0 48px; padding: 0; }
.work li { margin-bottom: 24px; }
.work li:last-child { margin-bottom: 0; }
/* Row: year, title, reading time. Phones: year and reading time on one line, title below. */
.work .row { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "meta pill" "title title"; align-items: center; gap: 4px 12px; }
.work .meta { grid-area: meta; }
.work .title { grid-area: title; }
.work .pill { grid-area: pill; justify-self: start; }
@media (min-width: 640px) {
  .work .row { grid-template-columns: 52px auto 1fr; grid-template-areas: "meta title pill"; align-items: start; gap: 0 8px; }
  .work .pill { margin-left: 4px; }
}
.work .meta { color: var(--muted); font-variant-numeric: tabular-nums; }
.work .desc { margin: 4px 0 0; color: var(--muted); }
/* Reading time pill, 12px after the title */
.pill { display: inline-block; padding: 0 8px; border: 1px solid var(--rule); border-radius: 999px; font-size: 14px; line-height: 22px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; vertical-align: 1px; }
@media (min-width: 640px) { .work .desc { margin-left: 60px; } }
.work .title { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); letter-spacing: -0.01em; }
.work a.title-text { color: var(--ink); text-decoration: none; }
.work a.title-text:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--subtle); }

/* ---------- Footer ---------- */
.footer { margin-top: 64px; }
.footer .section-title { margin: 0 0 12px; }
.footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 48px; }
.footer li { display: flex; }
/* Footer links match the project-title links: primary colour, underline on hover */
.footer a { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.footer a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--subtle); }
.footer a::before {
  content: ""; width: 13px; height: 13px; flex: 0 0 auto; background: currentColor;
  -webkit-mask: var(--icon-arrow) center / contain no-repeat;
          mask: var(--icon-arrow) center / contain no-repeat;
}

/* Copy-email tooltip */
.copy-email { position: relative; cursor: copy; }
.footer .copy-email::before {
  content: ""; width: 13px; height: 13px; background: currentColor;
  -webkit-mask: var(--icon-copy) center / contain no-repeat;
          mask: var(--icon-copy) center / contain no-repeat;
}
.footer .copy-email.copied::before {
  -webkit-mask-image: var(--icon-check);
          mask-image: var(--icon-check);
}
:root {
  --icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linejoin='round'%3E%3Crect x='5.5' y='5.5' width='9' height='9' rx='1.5'/%3E%3Cpath d='M10.5 5.5V3a1.5 1.5 0 0 0-1.5-1.5H3A1.5 1.5 0 0 0 1.5 3v6A1.5 1.5 0 0 0 3 10.5h2.5'/%3E%3C/svg%3E");
  --icon-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 11.5l7-7M5.5 4.5h6v6'/%3E%3C/svg%3E");
  --icon-pin: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 14.5s-4.5-4.2-4.5-7.7a4.5 4.5 0 0 1 9 0c0 3.5-4.5 7.7-4.5 7.7z'/%3E%3Ccircle cx='8' cy='6.8' r='1.6'/%3E%3C/svg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 8.5l3.5 3.5 7.5-8'/%3E%3C/svg%3E");
}
.copy-email::after {
  content: attr(data-tooltip);
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 1;
  transform: translateY(4px);
  white-space: nowrap; pointer-events: none;
  padding: 4px 8px; border-radius: 6px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule);
  font-size: 12px; line-height: 1.4;
  opacity: 0; transition: opacity .15s, transform .15s;
}
.copy-email:hover::after, .copy-email:focus-visible::after, .copy-email.copied::after {
  opacity: 1; transform: translateY(0);
}
/* Location: secondary text, pushed to the right end of the contact row */
.footer .place-location { align-items: center; gap: 8px; color: var(--muted); }
@media (min-width: 640px) { .footer .place-location { margin-left: auto; } }
.place-location::before {
  content: ""; width: 13px; height: 13px; flex: 0 0 auto; background: currentColor;
  -webkit-mask: var(--icon-pin) center / contain no-repeat;
          mask: var(--icon-pin) center / contain no-repeat;
}

/* ---------- Case study ---------- */
.cs-hero h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.05em; line-height: 1.3; margin: 0 0 24px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 20px 0; margin: 0 0 16px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.stat strong { display: block; font-size: 16px; font-weight: 500; letter-spacing: -0.01em; color: var(--ink); }
.stat span { display: block; font-size: 16px; line-height: 1.4; color: var(--muted); margin-top: 2px; }

.cs-section { margin-top: 40px; scroll-margin-top: 24px; }
.cs-section > .label { display: block; font-size: 16px; font-weight: 400; letter-spacing: normal; color: var(--muted); margin-bottom: 4px; }
.cs-section h2 { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.5; margin-bottom: 8px; }
.cs-section h3 { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.5; margin: 24px 0 8px; }
.cs-section p, .cs-section li { color: var(--ink); }
.cs-section p { margin: 16px 0; }
.cs-section strong { color: var(--ink); font-weight: 500; }
.cs-section ul { padding-left: 20px; margin: 16px 0; }
.cs-section li { margin-bottom: 8px; padding-left: 2px; }

.decision { margin-top: 32px; }
/* A section label always sits 16px above whatever comes first, subheading or decision included */
.cs-section > .label + h3, .cs-section > .label + .decision { margin-top: 16px; }
/* Captions sit closer to their image (8px) than to the next block (16px) */
.cs-image:has(+ .caption) { margin-bottom: 8px; }
.cs-image + .caption { margin-top: 8px; }
.compare figcaption { margin-top: 8px; }
.decision h3 { margin-top: 2px; }

.ui-copy {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 16px;
  color: var(--ink);
}

.table-wrap { overflow-x: auto; margin: 16px 0; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; color: var(--ink); }
th { font-weight: 500; color: var(--muted); }

.placeholder {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  background: var(--surface);
  border: 1px dashed var(--subtle);
  border-radius: 8px;
  color: var(--muted);
  font-size: 16px;
  margin: 16px 0;
  text-align: center;
  padding: 16px;
}
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compare figure { margin: 0; }
.compare .cs-image { margin-bottom: 0; }
.cs-image { display: block; width: 100%; height: auto; margin: 16px 0; border-radius: 8px; border: 1px solid var(--rule); }
.caption { font-style: italic; }

.feedback { margin-top: 16px; }
.feedback blockquote { margin: 0 0 16px; padding-left: 16px; border-left: 2px solid var(--rule); color: var(--ink); font-style: italic; }
.feedback cite { display: block; font-style: normal; font-size: 16px; color: var(--muted); margin-top: 4px; }

.next-cs { display: block; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--rule); text-decoration: none; }
.next-cs .label { display: block; font-size: 16px; color: var(--muted); }
.next-cs h2 { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.5; margin-top: 2px; }
.next-cs h2::before { content: "→" / ""; display: inline-block; margin-right: 6px; }
.next-cs:hover h2 { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--subtle); }

@media (max-width: 480px) {
  .compare { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; gap: 12px; }
}

/* ---------- Secondary text: muted ---------- */
.work .meta, .section-title,
.cs-section > .label,
th, .stat span, .feedback cite, .next-cs .label,
.placeholder, .cs-section p.placeholder, .copy-email::after {
  color: var(--muted);
}
.section-title, th { font-weight: 400; }

/* ---------- Accessibility ---------- */
/* Text for screen readers only */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* Skip link: hidden until a keyboard user tabs to it */
.skip-link {
  position: absolute; left: 16px; top: 8px; z-index: 10;
  padding: 4px 8px; border-radius: 6px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--rule);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
/* One clear focus ring for every link and button */
a:focus-visible, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
