/* ==========================================================================
   zakknudsen.com
   Plain CSS. No build step.
   Light and dark themes follow the visitor's system setting until they
   choose one with the theme toggle.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --color-bg: light-dark(#ffffff, #111418);
  --color-surface: light-dark(#f5f6f8, #1a1f26);
  --color-text: light-dark(#1b1f24, #e8ebef);
  --color-text-muted: light-dark(#4a5360, #a9b2bf);
  --color-border: light-dark(#d5d9e0, #333b46);
  --color-accent: light-dark(#0b5cad, #7ab7ff);
  --color-accent-contrast: light-dark(#ffffff, #111418);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 70ch;
  --gutter: 1rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --space-6: 4rem;
  --radius: 4px;
}

/* A saved choice (set by js/theme-toggle.js) overrides the system setting. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: var(--space-5) 0 var(--space-3);
}

h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  margin-top: 0;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.15rem;
}

p,
ul,
ol,
dl,
table,
figure {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--color-accent);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

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

code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* --------------------------------------------------------------------------
   3. Layout
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  padding: var(--space-2) var(--space-3);
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  z-index: 10;
}

.skip-link:focus {
  top: var(--space-2);
}

.site-header,
main,
.site-footer {
  width: 100%;
  max-width: 60rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.site-title {
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}

.site-header-end {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Optically align the icon with the header rule's right edge. */
.site-header-end theme-toggle {
  margin-right: -0.625rem;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  color: var(--color-text);
}

.site-nav a[aria-current="page"] {
  font-weight: 700;
  color: var(--color-accent);
}

main {
  padding-block: var(--space-5) var(--space-6);
}

.site-footer {
  padding-block: var(--space-4);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  list-style: none;
  margin: 0 0 var(--space-2);
  padding: 0;
}

/* Reading width for prose. */
main p,
main blockquote,
.prose > ul,
.prose > ol {
  max-width: var(--measure);
}

/* --------------------------------------------------------------------------
   4. Components
   -------------------------------------------------------------------------- */

.lede {
  font-size: 1.25rem;
  color: var(--color-text-muted);
  max-width: var(--measure);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 var(--space-2);
}

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-3);
  padding: var(--space-3);
  margin: var(--space-4) 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.meta dt {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.meta dd {
  margin: 0;
}

.proof-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-3);
  list-style: none;
  padding: 0;
}

.proof-strip li {
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius);
}

.proof-strip strong {
  display: block;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: var(--space-3) 0;
}

.chips li {
  padding: 0.1rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
}

.card {
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.card h2,
.card h3 {
  margin-top: 0;
}

.card .role {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.status {
  display: inline-block;
  padding: 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  color: var(--color-accent);
}

.diagram {
  margin: var(--space-4) 0;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

/* Wide diagrams scroll inside their own box. The page never scrolls sideways. */
.diagram-scroll {
  overflow-x: auto;
}

.diagram-scroll img {
  min-width: 42rem;
}

.diagram figcaption {
  margin-top: var(--space-2);
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.diagram details {
  margin-top: var(--space-2);
  font-size: 0.9rem;
}

.diagram summary {
  cursor: pointer;
  color: var(--color-accent);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

td:first-child {
  white-space: nowrap;
}

.timeline-list {
  list-style: none;
  padding: 0;
}

.timeline-list li {
  padding: var(--space-2) 0 var(--space-2) var(--space-3);
  border-left: 3px solid var(--color-border);
}

.timeline-list time {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   5. Small screens and print
   -------------------------------------------------------------------------- */

@media (max-width: 40rem) {
  body {
    font-size: 1rem;
  }

  .site-footer .footer-links {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Pull the icon row left so the first icon lines up with the text above. */
  .site-footer .footer-external {
    margin-left: -0.625rem;
  }

  td:first-child {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-nav,
  .skip-link {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}

.credly-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1rem 0;
}

.credly-badge {
  margin: 0;
  max-width: 12rem;
  font-size: 0.9rem;
}

.credly-badge iframe {
  display: block;
}

.credly-badge figcaption {
  margin-top: 0.5rem;
}

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

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-4);
  margin-bottom: var(--space-2);
}

.footer-links ul {
  align-items: center;
  margin: 0;
}

.footer-external {
  gap: 0;
}

.footer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.social-link a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
}

.social-link .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent);
  cursor: pointer;
}

.theme-toggle[aria-pressed="true"] {
  --moon-fill: currentColor;
}

.theme-toggle .icon {
  width: 1.5rem;
  height: 1.5rem;
}

/* --------------------------------------------------------------------------
   Timeline (generated by the private CMS)
   Every year is the same height. Positions are set in years by custom
   properties: --top is the offset from the top, --span the height.
   -------------------------------------------------------------------------- */

.timeline-scroll {
  overflow-x: auto;
}

.timeline {
  --year: 3rem;
  --bar: 0.5rem;
  --place-color: light-dark(#8a94a3, #6b7684);
  /* Residency bars take a colour from the flag of the country: US blue, Hong Kong red, Spain yellow. */
  --flag-us: light-dark(#3c3b6e, #7c7bd1);
  --flag-hk: light-dark(#de2910, #ff6a57);
  --flag-es: #f1bf00;
  /* Where I lived and the axis fit their content; Work takes the rest. */
  display: grid;
  grid-template-columns: max-content max-content 1fr;
  min-width: 38rem;
  font-size: 0.875rem;
}

.tl-heads,
.tl-plot,
.tl-origin {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
}

.tl-heads {
  padding-bottom: var(--space-2);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tl-heads span:first-child {
  text-align: right;
}

.tl-plot {
  height: calc(var(--years) * var(--year));
}

/* Year lines run from the axis to the right edge, one at the top of every year. */
.tl-plot::before {
  content: "";
  grid-column: 2 / -1;
  grid-row: 1;
  background-image: repeating-linear-gradient(to bottom, var(--color-border) 0 1px, transparent 1px var(--year));
}

.tl-places,
.tl-roles,
.tl-threads {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Residencies share one grid cell, so the column is as wide as the widest label. */
.tl-places {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  align-content: start;
}

.tl-axis {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  padding-inline: 0.5rem 1.1rem;
}

.tl-axis-sizer {
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.tl-threads,
.tl-roles {
  grid-column: 3;
  grid-row: 1;
}

/* Centre line, with a tick for every month. */
.tl-axis::before {
  content: "";
  position: absolute;
  inset-block: 0;
  left: calc(100% - 0.6rem - 1px);
  border-left: 2px solid var(--color-border);
}

.tl-axis::after {
  content: "";
  position: absolute;
  inset-block: 0;
  left: calc(100% - 0.9rem);
  width: 0.6rem;
  background-image: repeating-linear-gradient(to bottom, var(--color-border) 0 1px, transparent 1px calc(var(--year) / 12));
}

.tl-year {
  position: absolute;
  top: calc(var(--top) * var(--year));
  right: 1.1rem;
  padding-top: 0.2rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.tl-block {
  position: absolute;
  top: calc(var(--top) * var(--year));
  height: calc(var(--span) * var(--year));
}

.tl-bar {
  position: absolute;
  width: var(--bar);
  border-radius: 2px;
  box-shadow: inset 0 2px 0 var(--color-bg); /* a small break where one stint hands over to the next */
  top: calc(var(--b-top, 0) * var(--year));
  height: calc(var(--b-span, var(--span)) * var(--year));
}

.tl-label p {
  margin: 0;
  line-height: 1.3;
}

.tl-label {
  position: relative; /* the label may run past a short bar */
  padding-top: 0.1rem;
}

.tl-name {
  font-weight: 700;
}

.tl-role {
  font-weight: 600;
}

.tl-dates,
.tl-clients,
.tl-note {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.tl-note {
  font-style: italic;
}

/* Residencies: bar beside the axis, text to its left. */
.tl-place {
  grid-area: 1 / 1;
  position: relative;
  top: auto;
  margin-top: calc(var(--top) * var(--year));
  padding-right: calc(var(--bar) + 0.6rem);
  text-align: right;
}

.tl-place .tl-bar {
  right: 0;
  top: calc(var(--b-top, 0) * var(--year));
  height: calc(var(--b-span, var(--span)) * var(--year));
  background: var(--place-color);
}

/* Roles: one lane per overlapping company, bar beside the axis, text to its right. */
.tl-role-block {
  left: calc(var(--lane) * 100% / var(--lanes));
  width: calc(100% / var(--lanes));
  padding-left: calc(var(--bar) + 0.6rem);
}

.tl-role-block .tl-bar {
  left: 0;
  background: var(--color-accent);
}

.tl-thread {
  position: absolute;
  top: calc(var(--top) * var(--year));
  height: calc(var(--span) * var(--year));
  left: calc(var(--lane) * 100% / var(--lanes) + var(--bar) / 2 - 1px);
  border-left: 2px dotted var(--color-text-muted);
}

/* The one month before the first role, then the year of birth. */
.tl-origin-line {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  margin-right: calc(0.6rem - 1px);
  height: calc(var(--year) / 12);
  border-left: 2px dotted var(--color-text-muted);
}

.tl-origin p {
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
  transform: translateX(calc(50% - 0.6rem)); /* centred under the axis line */
  margin: 0.25rem 0 0;
  white-space: nowrap;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

/* A short stay gets its name and dates on one line so it cannot run into the next label. */
.tl-compact .tl-label {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0 0.5rem;
}

/* Education and time away are not work: shaded bands behind the roles. */
.tl-edu {
  grid-column: 3;
  grid-row: 1;
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tl-edu-band {
  position: absolute;
  inset-inline: 0;
  top: calc(var(--top) * var(--year));
  height: calc(var(--span) * var(--year));
  border-block: 1px dashed var(--color-text-muted);
  background-image: repeating-linear-gradient(
    135deg,
    color-mix(in srgb, var(--color-accent) 16%, transparent) 0 0.35rem,
    color-mix(in srgb, var(--color-accent) 6%, transparent) 0.35rem 0.7rem
  );
}

/* One short line, centred on the band so it never spills past it. */
.tl-edu-band .tl-label {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  padding: 0 0.4rem;
}

.tl-label .tl-edu-name {
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.tl-place[data-country="US"] .tl-bar { background: var(--flag-us); }
.tl-place[data-country="HK"] .tl-bar { background: var(--flag-hk); }
.tl-place[data-country="ES"] .tl-bar {
  background: var(--flag-es);
  outline: 1px solid light-dark(rgb(0 0 0 / 0.35), transparent); /* yellow alone is faint on white */
}

/* A small "i" next to a renamed company; hover or focus shows the new name. */
.tl-info {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-left: 0.25rem;
  padding: 0;
  border: 1px solid var(--color-text-muted);
  border-radius: 50%;
  background: none;
  color: var(--color-text-muted);
  font: italic 700 0.65rem/1 Georgia, serif;
  vertical-align: middle;
  cursor: help;
}

.tl-info::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 0.4rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: var(--color-text);
  color: var(--color-bg);
  font: normal 600 0.75rem/1.2 var(--font-sans);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

.tl-info:hover::after,
.tl-info:focus::after {
  opacity: 1;
}

/* Time away inside a stay: a dotted line. Its label is a shaded band in the Work column. */
.tl-place-thread {
  position: absolute;
  right: calc(var(--bar) / 2 - 1px);
  top: calc(var(--b-top) * var(--year));
  height: calc(var(--b-span) * var(--year));
  border-right: 2px dotted var(--color-text-muted);
}

