/* Colour, type and scale come from joy-tokens.css (@montionugera/joy-tokens). No colour
   literals here: both themes follow the --joy-* semantic roles. */
:root {
  color-scheme: light dark;
  --page: min(100% - 2.5rem, 72rem);
  --gap: clamp(var(--joy-space-12), 9vw, var(--joy-space-24));
  --row: clamp(var(--joy-space-5), 3vw, var(--joy-space-8));
  --col: clamp(var(--joy-space-4), 3vw, var(--joy-space-10));
  /* Career strip steps: the inverse surface mixed into the canvas. */
  --strip-1: color-mix(
    in oklab,
    var(--joy-surface-inverse) 14%,
    var(--joy-surface-canvas)
  );
  --strip-2: color-mix(
    in oklab,
    var(--joy-surface-inverse) 48%,
    var(--joy-surface-canvas)
  );
  --strip-3: var(--joy-surface-inverse);
}

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

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

body {
  margin: 0;
  background: var(--joy-surface-canvas);
  color: var(--joy-text-primary);
  font-family: var(--joy-font-family-sans);
  font-size: clamp(var(--joy-font-size-md), 0.96rem + 0.2vw, 1.125rem);
  line-height: var(--joy-line-height-normal);
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

h1,
h2,
.builds h3,
.masthead .name,
.scale b {
  font-family: var(--joy-font-family-display);
  font-weight: var(--joy-font-weight-semibold);
  letter-spacing: var(--joy-letter-spacing-tight);
  font-variant-numeric: lining-nums;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color var(--joy-duration-fast) var(--joy-ease-out);
}

a:hover {
  color: var(--joy-text-link);
}

:focus-visible {
  outline: var(--joy-focus-ring);
  outline-offset: 3px;
  border-radius: var(--joy-radius-sm);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

.wrap {
  width: var(--page);
  margin-inline: auto;
}

.skip {
  position: absolute;
  left: -100vw;
}

.skip:focus {
  left: var(--joy-space-4);
  top: var(--joy-space-4);
  background: var(--joy-surface-card);
  padding: var(--joy-space-2) var(--joy-space-3);
}

/* Masthead: sticky, so the section links stay one tap away on a long page. */
.top {
  position: sticky;
  top: 0;
  z-index: var(--joy-z-sticky);
  background: var(--joy-surface-canvas);
  border-bottom: 1px solid var(--joy-border-subtle);
}

section,
#top,
#contact {
  scroll-margin-top: calc(var(--joy-space-16) + var(--joy-space-10));
}

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--joy-space-4);
  padding-block: var(--joy-space-3);
}

.masthead a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  text-decoration: none;
  white-space: nowrap;
}

.masthead .name {
  font-size: var(--joy-font-size-xl);
}

.masthead nav ul {
  display: flex;
  gap: clamp(var(--joy-space-2), 3vw, var(--joy-space-8));
}

/* Hero */
.hero {
  padding-block: clamp(var(--joy-space-10), 4vw, var(--joy-space-12)) var(--gap);
}

.hero h1 {
  /* The one place type goes past the display tokens: boldness is spent here once. */
  font-size: clamp(2.75rem, 1.3rem + 5.6vw, 5rem);
  line-height: 0.98;
  text-wrap: balance;
}

.hero h1 em {
  font-style: normal;
  color: var(--joy-accent-text);
}

.hero .lede {
  max-width: 58ch;
  margin-top: clamp(var(--joy-space-6), 3vw, var(--joy-space-10));
  font-size: var(--joy-font-size-lg);
  line-height: var(--joy-line-height-snug);
  text-wrap: pretty;
}

.hero .now {
  margin-top: var(--joy-space-4);
  color: var(--joy-text-secondary);
}

.hero .actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 var(--joy-space-8);
  margin-top: var(--joy-space-4);
  font-weight: var(--joy-font-weight-semibold);
}

.hero .actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* The one primary action on the page. */
.hero .actions a:first-child {
  padding-inline: var(--joy-space-5);
  border-radius: var(--joy-radius-control);
  background: var(--joy-surface-inverse);
  color: var(--joy-text-inverse);
  text-decoration: none;
}

.hero .actions a:first-child:hover {
  text-decoration: underline;
}

/* Career strip: segment widths are months of tenure, so the bar is the data. */
.strip {
  margin-top: clamp(var(--joy-space-8), 4vw, var(--joy-space-10));
}

.strip figcaption {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--joy-space-2);
  font-weight: var(--joy-font-weight-semibold);
}

.strip ol {
  display: flex;
  gap: var(--joy-space-0-5);
  height: clamp(var(--joy-space-10), 4vw, var(--joy-space-12));
}

/* The lightest tint is 1.3:1 on the canvas, so every segment and swatch also carries an outline. */
.strip li,
.strip .key span::before {
  box-shadow: inset 0 0 0 1px var(--joy-border-default);
}

.strip li {
  flex: var(--m) 1 0;
  min-width: 3px;
  background: var(--strip-1);
  transform-origin: left;
}

.strip li.lead {
  background: var(--strip-2);
}

.strip li.current {
  background: var(--strip-3);
}

.strip .key {
  display: flex;
  flex-wrap: wrap;
  gap: var(--joy-space-1) var(--joy-space-6);
  margin-bottom: var(--joy-space-3);
  color: var(--joy-text-secondary);
  font-size: var(--joy-font-size-sm);
}

.strip .key span::before {
  content: "";
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin-right: 0.45em;
  background: var(--c);
}

/* Sections */
section {
  padding-block: 0 var(--gap);
}

section > h2 {
  padding-top: var(--joy-space-3);
  margin-bottom: clamp(var(--joy-space-6), 4vw, var(--joy-space-12));
  border-top: 2px solid var(--joy-text-primary);
  font-size: clamp(
    var(--joy-font-size-3xl),
    1.4rem + 2vw,
    var(--joy-font-size-5xl)
  );
  line-height: var(--joy-line-height-tight);
}

/* Ledger: when | who and what | how big */
.ledger > li {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr) minmax(9rem, 13rem);
  gap: var(--joy-space-2) var(--col);
  padding-block: var(--row);
  border-bottom: 1px solid var(--joy-border-subtle);
}

.ledger > li:first-child {
  padding-top: 0;
}

/* Employer marks are fixed-colour art, so their chip stays light in both themes (hence a primitive). */
.ledger .when {
  display: flex;
  font-weight: var(--joy-font-weight-semibold);
  white-space: nowrap;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--joy-space-3);
}

.logo {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: var(--joy-space-1);
  border-radius: var(--joy-radius-control);
  background: var(--joy-color-cream-50);
  box-shadow: 0 0 0 1px var(--joy-border-subtle);
  object-fit: contain;
  color: var(--joy-color-ink-500);
  font-size: var(--joy-font-size-xs);
  font-weight: var(--joy-font-weight-bold);
}

.ledger h3 {
  font-size: var(--joy-font-size-xl);
  font-weight: var(--joy-font-weight-bold);
  line-height: var(--joy-line-height-tight);
  letter-spacing: var(--joy-letter-spacing-tight);
}

.ledger .role {
  margin-top: var(--joy-space-1);
  color: var(--joy-text-secondary);
}

.ledger .what {
  max-width: 62ch;
  margin-top: var(--joy-space-3);
}

.ledger .what li {
  position: relative;
  padding-left: 1.1em;
  text-wrap: pretty;
}

.ledger .what li + li {
  margin-top: var(--joy-space-2);
}

.ledger .what li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 0.45em;
  height: 1px;
  background: currentColor;
}

.stack {
  margin-top: var(--joy-space-3);
  color: var(--joy-text-muted);
  font-size: var(--joy-font-size-sm);
}

.ledger .scale {
  text-align: right;
  line-height: var(--joy-line-height-tight);
}

.ledger .scale b {
  display: block;
  font-size: clamp(var(--joy-font-size-4xl), 1.6rem + 2.2vw, 3.5rem);
  line-height: 0.95;
  color: var(--joy-accent-text);
}

.ledger .scale span {
  color: var(--joy-text-secondary);
  font-size: var(--joy-font-size-sm);
}

.earlier {
  margin-top: var(--joy-space-5);
  color: var(--joy-text-secondary);
}

/* Builds */
.builds > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: var(--joy-space-2) clamp(var(--joy-space-4), 4vw, var(--joy-space-16));
  padding-block: var(--row);
  border-bottom: 1px solid var(--joy-border-subtle);
}

.builds > li:first-child {
  padding-top: 0;
}

.builds h3 {
  font-size: clamp(
    var(--joy-font-size-3xl),
    1.4rem + 2vw,
    var(--joy-font-size-5xl)
  );
  line-height: 1;
}

.builds .kind {
  margin-top: var(--joy-space-2);
  color: var(--joy-text-secondary);
}

.builds p {
  max-width: 62ch;
  text-wrap: pretty;
}

.builds p + p {
  margin-top: var(--joy-space-3);
}

/* Toolbox + education */
.kv {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: var(--joy-space-3) var(--col);
}

.kv dt {
  font-weight: var(--joy-font-weight-bold);
}

.kv dd {
  max-width: 68ch;
}

/* Contact: the one inverse surface */
.contact {
  background: var(--joy-surface-inverse);
  color: var(--joy-text-inverse);
  padding-block: clamp(var(--joy-space-16), 9vw, 7rem);
}

.contact h2 {
  max-width: 18ch;
  font-size: clamp(2.5rem, 1.3rem + 4.8vw, 4.5rem);
  line-height: 1;
  text-wrap: balance;
}

.contact .mail {
  display: inline-block;
  margin-top: clamp(var(--joy-space-6), 4vw, var(--joy-space-10));
  padding-block: var(--joy-space-2);
  font-size: clamp(
    var(--joy-font-size-lg),
    0.8rem + 1.8vw,
    var(--joy-font-size-3xl)
  );
  font-weight: var(--joy-font-weight-semibold);
  overflow-wrap: anywhere;
}

.contact ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--joy-space-8);
  margin-top: var(--joy-space-5);
}

.contact ul a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* On the inverse surface the link and focus roles lose contrast, so stay on text-inverse. */
.contact a:hover {
  color: inherit;
  text-decoration-thickness: 2px;
}

.contact :focus-visible {
  outline: 2px solid var(--joy-text-inverse);
}

.contact small {
  display: block;
  margin-top: clamp(var(--joy-space-10), 6vw, var(--joy-space-16));
  font-size: var(--joy-font-size-sm);
  opacity: 0.8;
}

.print-only {
  display: none;
}

/* One moment of motion: the headline settles, then the career bar draws left to right. */
/* screen only: an entrance animation restarting at print time would print at opacity 0 */
@media screen and (prefers-reduced-motion: no-preference) {
  .hero h1,
  .hero .lede,
  .hero .now,
  .hero .actions {
    animation: settle var(--joy-duration-slow) var(--joy-ease-out-quint) both;
  }

  .hero .lede {
    animation-delay: 0.08s;
  }

  .hero .now,
  .hero .actions {
    animation-delay: 0.16s;
  }

  .strip li {
    animation: draw var(--joy-duration-slow) var(--joy-ease-out-quint) both;
    animation-delay: calc(0.35s + var(--i) * 0.07s);
  }
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(0.6rem);
  }
}

@keyframes draw {
  from {
    transform: scaleX(0);
  }
}

/* Scroll effects. Progress is tied to scroll position, not time, so each one enhances content
   that is already visible: without scroll-timeline support (or with reduced motion) nothing moves. */
@media screen and (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    /* reading progress along the bottom of the sticky header */
    .top::after {
      content: "";
      position: absolute;
      inset: auto 0 -1px;
      height: 2px;
      background: var(--joy-text-primary);
      transform-origin: left;
      animation: grow linear both;
      animation-timeline: scroll(root);
    }

    /* each section's top rule draws itself as the heading arrives */
    section > h2 {
      position: relative;
      border-top-color: transparent;
    }

    section > h2::before {
      content: "";
      position: absolute;
      inset: -2px 0 auto;
      height: 2px;
      background: var(--joy-text-primary);
      transform-origin: left;
      animation: draw linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 14rem;
    }

    /* rows rise into place; a fixed distance so tall phone rows are readable early */
    .ledger > li,
    .builds > li,
    .kv,
    .contact h2 {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 16rem;
    }

    /* the scale figure lands a beat after its row: the evidence arriving beside the claim */
    .ledger .scale b {
      animation: arrive linear both;
      animation-timeline: view();
      animation-range: entry 4rem entry 20rem;
    }
  }
}

@keyframes grow {
  from {
    transform: scaleX(0);
  }
}

@keyframes rise {
  from {
    opacity: 0.1;
    transform: translateY(2.5rem);
  }
}

@keyframes arrive {
  from {
    opacity: 0;
    transform: translateX(1.25rem);
  }
}

@media (max-width: 46rem) {
  .ledger > li {
    grid-template-columns: minmax(0, 1fr);
  }

  .ledger .when {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    color: var(--joy-text-secondary);
  }

  .ledger .scale {
    grid-row: 2;
    text-align: left;
  }

  .ledger .scale b {
    display: inline;
    margin-right: 0.25em;
  }

  .builds > li,
  .kv {
    grid-template-columns: minmax(0, 1fr);
  }

  .kv dd + dt {
    margin-top: var(--joy-space-2);
  }
}

/* Print = the downloadable CV. Same content, two A4 pages. */
@media print {
  @page {
    size: A4;
    margin: 14mm 15mm;
  }

  :root {
    --page: 100%;
    --gap: 5mm;
    --row: 2.2mm;
    --col: 5mm;
  }

  body {
    background: none;
    font-size: 9pt;
    line-height: 1.38;
  }

  .top,
  .strip,
  .skip,
  .screen-only {
    display: none !important;
  }

  .print-only {
    display: block;
  }

  .hero {
    padding-block: 0 var(--gap);
  }

  .hero h1 {
    max-width: none;
    font-size: 22pt;
  }

  .hero .lede {
    max-width: none;
    margin-top: 2mm;
    font-size: 1em;
  }

  .hero .now {
    margin-top: 1.5mm;
  }

  section > h2 {
    padding-top: 1mm;
    margin-bottom: 2.5mm;
    border-top-width: 1pt;
    font-size: 15pt;
    break-after: avoid;
  }

  .ledger > li,
  .builds > li {
    gap: 1mm 5mm;
    break-inside: avoid;
  }

  .ledger > li {
    grid-template-columns: 19mm minmax(0, 1fr) 38mm;
  }

  .ledger h3 {
    font-size: 1.15em;
  }

  .ledger .role {
    margin-top: 0;
  }

  .ledger .what,
  .stack {
    max-width: none;
    margin-top: 1mm;
    font-size: 1em;
  }

  .ledger .what li + li {
    margin-top: 0.4mm;
  }

  .ledger .scale b,
  .builds h3 {
    font-size: 16pt;
  }

  .ledger .scale span,
  .builds .kind {
    font-size: 1em;
    margin-top: 1mm;
  }

  .builds p {
    max-width: none;
  }

  .builds p + p {
    margin-top: 0.8mm;
  }

  .kv {
    grid-template-columns: 32mm minmax(0, 1fr);
    gap: 1mm 5mm;
  }

  .kv dd {
    max-width: none;
  }

  a {
    text-decoration: none;
  }
}
