/* John Adamson, oxforddynamics.com/john-adamson/ — "Swiss" style (adopted on main, BRIEF.md D26)
   One grotesk throughout (Hanken Grotesk), black on white, navy as the only colour (links, the
   primary button, focus). A strict grid: on wide screens every section is a two-column spread,
   its heading in a narrow left column that stays in view while you read the right column.
   Heavy black rules open each section; hairlines separate rows. Square corners.
   Dark values are defined twice (system setting, and the switch's explicit choice); change both together. */

@font-face {
  font-family: "Hanken Grotesk";
  src: url("../fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

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

:root {
  color-scheme: light;
  --paper: #ffffff;
  --surface: #ffffff;
  --ink: #0e1116;
  --slate: #555c66;
  --rule: #dfe2e6;
  --rule-heavy: #0e1116;
  --field: #858b94;
  --accent: #0a3a7a;
  --tint: #dbe5f3;
  --button: #0a3a7a;
  --on-button: #ffffff;
  --error: #a3261b;
  --error-bg: #fbf1ef;

  --font: "Hanken Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  --label-col: 15rem;     /* the left column of every wide-screen spread */
  --col-gap: 48px;
  --measure: 42rem;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0d0f12;
    --surface: #15181d;
    --ink: #eef0f3;
    --slate: #a2a9b3;
    --rule: #262a30;
    --rule-heavy: #eef0f3;
    --field: #6e7580;
    --accent: #8fb0e6;
    --tint: #1d2d4a;
    --button: #8fb0e6;
    --on-button: #0d0f12;
    --error: #f2938a;
    --error-bg: #2b1c1a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d0f12;
  --surface: #15181d;
  --ink: #eef0f3;
  --slate: #a2a9b3;
  --rule: #262a30;
  --rule-heavy: #eef0f3;
  --field: #6e7580;
  --accent: #8fb0e6;
  --tint: #1d2d4a;
  --button: #8fb0e6;
  --on-button: #0d0f12;
  --error: #f2938a;
  --error-bg: #2b1c1a;
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 88px;   /* clears the sticky header when jumping to #experience etc. */
  scrollbar-color: var(--field) var(--paper);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  font-kerning: normal;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
  caret-color: var(--accent);
}

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

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

h1, h2, h3 {
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p { text-wrap: pretty; }

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

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

svg { display: block; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 30;
  padding: 10px 14px;
  background: var(--button);
  color: var(--on-button);
}
.skip:focus { top: 12px; }

.wrap {
  width: 100%;
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Header ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 15;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.masthead .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
}

.brand {
  color: var(--ink);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.nav ul { display: flex; align-items: center; gap: 4px; }
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
}
.nav a:hover { color: var(--accent); }
.nav a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.45em; }

/* Three-state theme switch: System, Light, Dark. The icon shows the current setting. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid var(--field);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { border-color: var(--ink); }
.theme-toggle svg { width: 18px; height: 18px; display: none; }
.theme-toggle[data-mode="system"] .i-system,
.theme-toggle[data-mode="light"] .i-light,
.theme-toggle[data-mode="dark"] .i-dark { display: block; }

/* ---------- Buttons and icon links ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--button);
  border-radius: 0;
  background: var(--button);
  color: var(--on-button);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease);
}
.button:hover { text-decoration: none; background: var(--ink); border-color: var(--ink); color: var(--paper); }
.button:disabled { opacity: 0.4; cursor: not-allowed; background: var(--button); border-color: var(--button); color: var(--on-button); }
.button svg { width: 18px; height: 18px; flex: none; }

.button.secondary { background: transparent; color: var(--ink); border-color: var(--ink); }
.button.secondary:hover { background: var(--ink); color: var(--paper); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.icon-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.icon-links a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 44px;
  min-height: 44px;
  color: var(--ink);
}
.icon-links a:hover { color: var(--accent); }
.icon-links .icon { width: 24px; height: 24px; flex: none; }
.icon-links .ext { width: 13px; height: 13px; flex: none; align-self: flex-start; margin: 9px 0 0 -7px; color: var(--slate); }
.icon-links .linkedin { padding: 0 8px; }

/* ---------- Opening: the name across the full width, then the spread ---------- */

.intro { padding: clamp(48px, 9vw, 120px) 0 clamp(48px, 7vw, 88px); }
.intro .wrap { display: grid; }
.intro h1 {
  font-size: clamp(3rem, 1rem + 8.4vw, 7.5rem);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.04em;
  padding-bottom: clamp(28px, 4vw, 48px);
  border-bottom: 3px solid var(--rule-heavy);
}
.intro .roles {
  margin-top: 24px;
  font-weight: 600;
  line-height: 1.4;
}
.intro .roles li { text-wrap: balance; }   /* no single word left on its own line */
.intro .place { margin-top: 6px; color: var(--slate); }
.intro .profile {
  max-width: var(--measure);
  margin-top: 28px;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  line-height: 1.45;
  letter-spacing: -0.005em;
}
.intro .actions { margin-top: 32px; }

.page-intro { padding: clamp(48px, 8vw, 104px) 0 clamp(28px, 4vw, 48px); }
.page-intro h1 {
  font-size: clamp(2.5rem, 1.2rem + 4.6vw, 4.5rem);
  line-height: 0.96;
  letter-spacing: -0.035em;
  padding-bottom: 24px;
  border-bottom: 3px solid var(--rule-heavy);
}
.page-intro .lead {
  max-width: var(--measure);
  margin-top: 24px;
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);
  line-height: 1.45;
  color: var(--slate);
}
.page-intro .actions { margin-top: 32px; }

.section { padding: clamp(48px, 7vw, 88px) 0 clamp(16px, 3vw, 32px); }
.section > .wrap { position: relative; padding-top: 23px; }
/* Heavy rule opening each section, drawn inside the gutters */
.section > .wrap::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--gutter);
  right: var(--gutter);
  height: 3px;
  background: var(--rule-heavy);
}
.section > .wrap > h2, .section-head h2 {
  font-size: clamp(1.5rem, 1.2rem + 1.1vw, 2rem);
  margin-bottom: clamp(24px, 3vw, 36px);
}

/* Heading row with the "Expand all / Collapse all" button, which lines up with the roles' buttons */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(24px, 3vw, 36px);
}
.section-head h2 { margin-bottom: 0 !important; }
.section h3 { font-size: 1.0625rem; letter-spacing: -0.01em; }

/* ---------- Wide screens: every section is a two-column spread ----------
   Heading in the narrow left column (it stays in view while its section scrolls past);
   everything else in the right column. The Expand all button stays in the right column,
   in line with the roles' buttons. */
@media (min-width: 1200px) {
  .intro .wrap, .section > .wrap {
    grid-template-columns: var(--label-col) minmax(0, 1fr);
    column-gap: var(--col-gap);
  }
  .section > .wrap { display: grid; align-content: start; }
  .intro h1 { grid-column: 1 / -1; }
  .intro .roles { grid-column: 1; grid-row: 2; }
  .intro .place { grid-column: 1; grid-row: 3; }
  .intro .profile { grid-column: 2; grid-row: 2 / span 3; margin-top: 22px; }
  .intro .actions { grid-column: 2; grid-row: 5; }

  .section-head { display: contents; }
  .section > .wrap > h2, .section-head h2 {
    grid-column: 1;
    grid-row: 1 / span 6;
    align-self: start;
    position: sticky;
    top: 88px;
    margin: 0 !important;
    font-size: 1.375rem;
  }
  .section > .wrap > :not(h2):not(.section-head) { grid-column: 2; }
  .section-head .toggle-all { grid-column: 2; grid-row: 1; justify-self: end; margin: -6px 0 14px; }
  .section-head ~ .entries { grid-row: 2; }
}

/* ---------- Experience: one collapsible entry per role (<details>) ---------- */

.entries > li { border-top: 1px solid var(--rule); }
.entries > li:last-child { border-bottom: 1px solid var(--rule); }

/* Role lines and education lines share one grid, so their columns line up:
   title | organisation | dates (right) | toggle (education leaves the last column empty).
   Phones: three stacked lines. Tablets: title, then organisation left and dates right.
   Wide screens: all on one line. */
.entry-head, .fact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  grid-template-areas: "title icon" "org icon" "when icon";
  gap: 2px 16px;
  align-items: center;
}
.entry-head { padding: 16px 0; }
@media (min-width: 560px) {
  .entry-head, .fact {
    grid-template-columns: minmax(0, 1fr) auto 44px;
    grid-template-areas: "title title icon" "org when icon";
    align-items: baseline;
  }
}
@media (min-width: 900px) {
  .entry-head, .fact {
    grid-template-columns: 19.5rem minmax(0, 1fr) auto 44px;
    grid-template-areas: "title org when icon";
    column-gap: 24px;
  }
}
summary.entry-head { list-style: none; cursor: pointer; }
summary.entry-head::-webkit-details-marker { display: none; }
.entry-head .when, .fact .when {
  grid-area: when;
  color: var(--slate);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}
@media (min-width: 560px) { .entry-head .when, .fact .when { justify-self: end; } }
.entry-head h3 { grid-area: title; font-size: 1.0625rem; font-weight: 700; }
.entry-head .org, .fact .where { grid-area: org; color: var(--slate); font-size: 0.9375rem; }
.fact .what { grid-area: title; font-weight: 700; letter-spacing: -0.01em; }

/* Square toggles, drawn like the theme switch */
.toggle-icon {
  grid-area: icon;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--field);
  color: var(--ink);
  transition: background-color 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease);
}
.toggle-icon svg { width: 18px; height: 18px; transition: transform 200ms var(--ease); }
.entry[open] > summary .toggle-icon svg { transform: rotate(180deg); }
summary.entry-head:hover .toggle-icon { background: var(--ink); border-color: var(--ink); color: var(--paper); }
summary.entry-head:hover h3 { color: var(--accent); }

.toggle-all {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--slate);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}
.toggle-all[hidden] { display: none; }
.toggle-all:hover { color: var(--ink); }
.toggle-all:hover .toggle-icon { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.toggle-all[data-state="collapse"] .toggle-icon svg { transform: rotate(180deg); }
@media (max-width: 479px) {
  .toggle-all .verb { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

.entry-body { max-width: var(--measure); padding: 0 0 32px; }
.entry-body > :first-child { margin-top: 0; }
.entry-body .summary + .points { margin-top: 14px; }

.points { margin-top: 12px; }
.points li { position: relative; padding-left: 1.25em; }
.points li + li { margin-top: 10px; }
.points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 6px;
  height: 6px;
  background: var(--accent);
}

/* The Cabinet Office note: set apart by space and a hairline */
.aside-note {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  color: var(--slate);
}
.aside-note strong { color: var(--ink); font-weight: 700; }

/* ---------- Education, certifications, skills ---------- */

.facts { display: grid; gap: 36px; }   /* Education above Certifications, full width */
.facts h3 { margin-bottom: 12px; }
.facts li + li { margin-top: 10px; }

.skills { display: grid; gap: 36px 48px; }
.skills h3 { margin-bottom: 4px; }
@media (min-width: 760px) {
  .skills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Call to action ---------- */

.cta p { max-width: var(--measure); color: var(--slate); font-size: 1.125rem; }
.cta .actions { margin-top: 24px; }

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

.contact-layout .wrap { display: grid; gap: 48px 64px; padding-bottom: clamp(48px, 7vw, 96px); }
@media (min-width: 900px) {
  .contact-layout .wrap { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
}

.form { display: grid; gap: 22px; max-width: 40rem; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; }
.req { margin-left: 2px; color: var(--slate); }
.opt { color: var(--slate); font-weight: 400; }

input[type="text"], input[type="email"], textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid var(--field);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: 1.4;
}
textarea { min-height: 168px; resize: vertical; }
input:hover, textarea:hover { border-color: var(--ink); }
input:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--accent); }
[aria-invalid="true"] { border-color: var(--error) !important; }

.check {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  cursor: pointer;
}
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer; }
.check .hint { display: block; color: var(--slate); font-size: 0.9375rem; }
.cv-check { padding: 16px 18px; border: 1px solid var(--field); background: var(--surface); }
.cv-check strong { font-weight: 700; }

.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.field-error { color: var(--error); font-size: 0.9375rem; margin-top: -2px; }
.notice {
  padding: 14px 18px;
  border: 1px solid var(--error);
  background: var(--error-bg);
  color: var(--ink);
  max-width: 40rem;
  margin-bottom: 22px;
}
.notice:focus { outline: none; }

.footnote, .form-status, .form-note { color: var(--slate); font-size: 0.9375rem; }
.send-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }

.direct { border-top: 3px solid var(--rule-heavy); padding-top: 20px; }
.direct h2 { font-size: 1.25rem; margin-bottom: 18px; }
.direct p { color: var(--slate); }
.direct .direct-link { margin-top: 10px; font-weight: 600; }
.direct .based { margin-top: 24px; font-size: 0.875rem; }

/* ---------- Prose (privacy) ---------- */

.prose { max-width: var(--measure); padding-bottom: clamp(48px, 7vw, 96px); }
.prose h2 { font-size: 1.25rem; margin: 36px 0 10px; }
.prose p + p, .prose ul + p, .prose p + ul { margin-top: 12px; }
.prose ul { list-style: disc; padding-left: 1.25em; }
.prose li + li { margin-top: 6px; }
.prose .updated { color: var(--slate); }

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

.colophon {
  margin-top: clamp(32px, 5vw, 64px);
  padding: 0 0 40px;
  color: var(--slate);
  font-size: 0.875rem;
}
.colophon .wrap {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
  padding-top: 20px;
}
.colophon .wrap::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--gutter);
  right: var(--gutter);
  height: 3px;
  background: var(--rule-heavy);
}
.colophon .links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 22px; }
.colophon .links li:has(> [hidden]) { display: none; }
.colophon .links a, .colophon .links button { display: inline-flex; align-items: center; min-height: 44px; color: var(--slate); }
.colophon .links button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  cursor: pointer;
}
.colophon .links a:hover, .colophon .links button:hover { color: var(--ink); }
.colophon .links [hidden] { display: none; }

/* ---------- Cookie consent ---------- */

.consent-banner {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 20;
  width: min(40rem, calc(100% - 32px));
  transform: translateX(-50%);
  padding: 20px 22px;
  border: 1px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 32px rgba(14, 17, 22, 0.16);
  font-size: 0.9375rem;
}
.consent-banner[hidden] { display: none; }
.consent-banner h2 { font-size: 1.0625rem; margin-bottom: 6px; }
.consent-banner .actions { margin-top: 14px; gap: 10px; }
.consent-banner .button { min-height: 44px; flex: 1 1 10rem; }

/* ---------- Narrow screens ---------- */

@media (max-width: 420px) {
  .nav a { padding: 0 8px; }
  .nav .hide-narrow { display: none; }
  .actions .button { flex: 1 1 100%; }
}

/* ---------- Print ---------- */

@media print {
  .masthead nav, .actions, .consent-banner, .colophon .links, .skip, .toggle-all, .toggle-icon { display: none !important; }
  .masthead { position: static; }
  body { background: #fff; color: #000; font-size: 10pt; }
  a { color: inherit; }
  .section > .wrap > h2, .section-head h2 { position: static; }
}

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