/* Dark is the default theme; the toggle in index.html sets data-theme="light". */
:root {
  color-scheme: dark;
  --bg: #141210;
  --text: #ece7e0;
  --muted: #a19a90;
  --rule: #2e2a26;
  --accent: #e38d55;
  --accent-hover: #eba06f;
  --on-accent: #141210;
  --ring: #3a352f;          /* edge around the portrait */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, Cambria, "Noto Serif", serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #faf9f7;
  --text: #1b1916;
  --muted: #6b645b;
  --rule: #e4e0da;
  --accent: #a14d17;
  --accent-hover: #8a4113;
  --on-accent: #ffffff;
  --ring: transparent;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.6 var(--sans);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

.page {
  position: relative;
  max-width: 44rem;
  margin: 0 auto;
  padding: 5rem 1.5rem 5rem;
}

h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
p { text-wrap: pretty; }
h1, .title { text-wrap: balance; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
a:hover { text-decoration-color: currentColor; }
a:focus-visible, .theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
a:not(.button):focus-visible { border-radius: 2px; }

abbr[title] { text-decoration: none; }

/* Theme toggle, top right of the page column */
.theme-toggle {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid transparent;   /* shows in forced-colors mode */
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
@media (hover: hover) {   /* a tap on a touch screen would leave the hover ring on */
  .theme-toggle:hover { border-color: var(--rule); color: var(--text); }
}
.theme-toggle[hidden] { display: none; }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Masthead */
.masthead {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.portrait {
  flex: none;
  width: 7.5rem;
  height: 7.5rem;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 0 0 1px var(--ring);
}
/* 500 only changes fallbacks that have a medium weight (e.g. Noto Serif); Charter stays regular */
h1 {
  font: 500 2.75rem/1.05 var(--serif);
  letter-spacing: -0.015em;
}
.title {
  margin-top: 0.6rem;
  font-weight: 500;
}
.place {
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Intro and actions */
.lede {
  margin-top: 3rem;
  font: 400 1.3125rem/1.55 var(--serif);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 1.375rem;
  margin-top: 1.75rem;
  font-size: 0.9375rem;
}
.actions li:first-child { margin-right: 0.25rem; }
.actions a:not(.button) { display: inline-block; padding-block: 0.6rem; }

/* 1.5rem line + padding + border = 44px tap target */
.button {
  display: inline-block;
  padding: 0.5625rem 1.1rem;
  line-height: 1.5rem;
  border: 1px solid var(--accent);   /* also keeps the button visible in forced-colors mode */
  border-radius: 0.375rem;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;   /* lets the address wrap when a phone's text size is enlarged */
}
.button:hover { border-color: var(--accent-hover); background: var(--accent-hover); }

/* Sections */
section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}
h2 {
  margin-bottom: 1.25rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
h3 {
  font-size: inherit;
  font-weight: 600;
}

/* Experience and project: name on the left, details on the right */
.rows > li, .row {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0 1.5rem;
  align-items: baseline;
}
.rows > li + li { margin-top: 0.75rem; }
.rows ul li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  column-gap: 1rem;
}
.years {
  color: var(--muted);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}
/* Current role: years in body colour with a small accent dot */
.current .years { color: var(--text); font-weight: 500; }
.current .years::before {
  content: "";
  display: inline-block;
  width: 0.4375rem;
  height: 0.4375rem;
  margin-right: 0.5em;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.1em;
}

@media (prefers-reduced-motion: no-preference) {
  a, .theme-toggle { transition: color 0.15s, background-color 0.15s, border-color 0.15s, text-decoration-color 0.15s; }
}

@media (max-width: 42rem) {
  .page { padding: 4rem 1.25rem 3rem; }
  .theme-toggle { top: 0.625rem; right: 0.75rem; }
  .masthead { gap: 1.125rem; }
  .portrait { width: 6rem; height: 6rem; }
  h1 { font-size: 2.125rem; }
  .title { margin-top: 0.4rem; font-size: 1rem; line-height: 1.4; }
  .lede { margin-top: 2.5rem; font-size: 1.1875rem; }
  .actions li:first-child { flex-basis: 100%; margin: 0 0 0.25rem; }   /* email button on its own row */
  section { margin-top: 2.75rem; }
  .rows > li, .row { display: block; }
  .rows > li + li { margin-top: 1.25rem; }
  .rows ul li { display: block; }
  .rows ul li + li { margin-top: 0.4rem; }
  .years { display: block; font-size: 0.875rem; line-height: 1.5; }
}

@media (max-width: 22rem) {
  .masthead { flex-direction: column; align-items: flex-start; }
}

@media print {
  :root, :root[data-theme="light"] { color-scheme: light; --bg: #fff; --text: #000; --muted: #444; --rule: #ccc; --accent: #000; }
  .page { padding: 0; max-width: none; }
  .theme-toggle { display: none; }
  .button { padding: 0; border: 0; background: none; color: #000; }
}
