/* ---------------------------------------------------------------- tokens */

:root {
  --bg: #ffffff;
  --surface: #f5f7f9;
  --text: #1c1e21;
  --muted: #5b6470;
  --hairline: #e6e8eb;
  --accent: #1a5fb4;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 42rem;
  --shell: 70rem;
  --rail: 17.5rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.75rem;
  --space-xl: 2.75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101418;
    --surface: #161b21;
    --text: #e6e9ec;
    --muted: #98a1ab;
    --hairline: #232a31;
    --accent: #6ca0e8;
  }
}

/* ------------------------------------------------------------------ base */

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

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

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  transition: background-color 150ms linear, color 150ms linear;
}

p {
  margin: 0;
}

/* ---------------------------------------------------------------- layout */

.page {
  max-width: var(--shell);
  margin-inline: auto;
  padding: var(--gutter);
}

/* mobile first: one column, sections divided by hairlines */
main > section + section {
  margin-top: var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--hairline);
}

main,
footer {
  margin-top: var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--hairline);
}

/* -------------------------------------------------------- language switch */

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-lg);
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.2rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.lang-switch > * {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

/* the active language is plain text, not a link */
.lang-current {
  background-color: var(--surface);
  color: var(--text);
  font-weight: 600;
}

.lang-switch a {
  color: var(--muted);
  text-decoration: none;
  transition: color 150ms linear, background-color 150ms linear;
}

.lang-switch a:hover,
.lang-switch a:focus-visible {
  color: var(--accent);
  background-color: var(--surface);
  text-decoration: none;
}

/* ------------------------------------------------------------- typography */

h1 {
  margin: 0 0 var(--space-sm);
  font-size: clamp(2rem, 1.6rem + 1.4vw, 2.6rem);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* h2 reads as a quiet section label, not a competing headline */
h2 {
  margin: 0 0 var(--space-md);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 150ms linear;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

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

/* -------------------------------------------------------------- identity */

.identity .role {
  font-size: 1.0625rem;
}

.identity .availability {
  margin-top: var(--space-xs);
  color: var(--muted);
  text-wrap: pretty;
}

.identity .languages {
  margin-top: var(--space-sm);
  color: var(--muted);
  font-size: 0.9375rem;
}

.identity .languages span {
  padding-inline: 0.2rem;
}

.identity-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  margin-top: var(--space-md);
  font-size: 0.9375rem;
}

.identity-links a {
  overflow-wrap: anywhere;
}

/* sits directly under the email, closing the identity block */
.identity .location {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: var(--space-sm);
  color: var(--muted);
  font-size: 0.9375rem;
}

.pin {
  flex: none;
  width: 0.95em;
  height: 0.95em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------- selected work rows */

.about p,
.work-item > p,
.work-more {
  max-width: var(--measure);
  text-wrap: pretty;
}

.work-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.work-item {
  border-radius: 10px;
  transition: background-color 150ms linear;
}

.work-item + .work-item {
  margin-top: var(--space-lg);
}

/* project names are the only bold links on the page */
.work-item > a {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.work-item > p {
  margin-top: var(--space-xs);
  color: var(--muted);
}

.work-more {
  margin-top: var(--space-lg);
  color: var(--muted);
}

/* ---------------------------------------------------------------- skills */

.skill-groups {
  margin: 0;
  max-width: var(--measure);
}

.skill-group + .skill-group {
  margin-top: var(--space-md);
}

.skill-group dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.skill-group dd {
  margin: var(--space-xs) 0 0;
}

/* ---------------------------------------- education and experience */

.history-list {
  margin: 0;
  padding: 0;
  max-width: var(--measure);
  list-style: none;
}

.history-list li + li {
  margin-top: var(--space-md);
}

/* ---------------------------------------------------------------- footer */

/* one centred line closing the page; the flex row went with the footer email */
footer {
  color: var(--muted);
  font-size: 0.9375rem;
  text-align: center;
}

/* <small> carries the legal small print semantics; the size is set here */
.copyright small {
  font-size: inherit;
}

/* -------------------------------------------- desktop: two column shell */

@media (min-width: 62rem) {
  .layout {
    display: grid;
    grid-template-columns: var(--rail) minmax(0, 1fr);
    gap: clamp(3rem, 6vw, 5.5rem);
    align-items: start;
  }

  /* the identity rail stays in view while the work scrolls past it */
  .identity {
    position: sticky;
    top: var(--gutter);
  }

  .identity-links {
    flex-direction: column;
    gap: var(--space-sm);
  }

  /* the rail already separates the columns, so main needs no top rule */
  main {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  /* hover affordance on work rows, bled into the column gutter */
  .work-list {
    margin-inline: -1rem;
  }

  .work-item {
    padding: 0.85rem 1rem;
  }

  .work-item + .work-item {
    margin-top: var(--space-md);
  }

  .work-item:hover {
    background-color: var(--surface);
  }

  .work-more {
    margin-top: var(--space-md);
  }
}

/* ------------------------------------------------------------ a11y prefs */

@media (prefers-reduced-motion: reduce) {
  body,
  a,
  .work-item,
  .lang-switch a {
    transition: none;
  }
}

/* ----------------------------------------------------------------- print */

@media print {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --text: #000000;
    --muted: #000000;
    --hairline: #bbbbbb;
    --accent: #000000;
  }

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

  .page {
    max-width: none;
    padding: 0;
  }

  /* the switch is navigation, and navigation does not print */
  .topbar {
    display: none;
  }

  .layout {
    display: block;
  }

  .identity {
    position: static;
  }

  a,
  a:hover {
    text-decoration: none;
  }

  main,
  main > section + section,
  footer {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
  }

  .work-list {
    margin-inline: 0;
  }

  .work-item,
  .skill-group,
  .history-list li {
    padding: 0;
    break-inside: avoid;
  }
}
