:root {
  --bg: #fff;
  --text: #111;
  --muted: #555;
  --rule: #e5e5e5;
  --link: #0645ad;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --bg: #111; --text: #e6e6e6; --muted: #9a9a9a; --rule: #2a2a2a; --link: #8ab4f8; }
}
:root[data-theme="light"] { --bg: #fff; --text: #111; --muted: #555; --rule: #e5e5e5; --link: #0645ad; color-scheme: light; }
:root[data-theme="dark"] { --bg: #111; --text: #e6e6e6; --muted: #9a9a9a; --rule: #2a2a2a; --link: #8ab4f8; color-scheme: dark; }
:root[data-theme="contrast"] { --bg: #000; --text: #fff; --muted: #fff; --rule: #fff; --link: #ffef5c; color-scheme: dark; }
:root[data-theme="contrast"] a { text-decoration-thickness: 2px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-wrap: break-word;
  font: 1.0625rem/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
main, header, footer { max-width: 680px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 480px) { main, header, footer { padding: 0 16px; } body { font-size: 1rem; } }

a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

header { padding-top: 56px; }
header h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 6px; font-weight: 700; }
header h1 a { color: inherit; text-decoration: none; }
header p { margin: 0; color: var(--muted); }
nav { margin-top: 10px; }
nav a { margin-right: 14px; display: inline-block; }

h2 { font-size: 1.1875rem; margin: 44px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.0625rem; margin: 0; }
p { margin: 0 0 14px; }
ul { margin: 0 0 14px; padding-left: 20px; }
li { margin: 4px 0; }

.muted { color: var(--muted); }

/* Work / project entries */
.entry { margin: 0 0 22px; }
.when { color: var(--muted); font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.entry p, .entry ul { margin: 4px 0 0; }
details { margin-top: 6px; }
summary { cursor: pointer; color: var(--link); font-size: 0.9375rem; }
details h4 { font-size: 1rem; margin: 12px 0 2px; }

/* Date | text rows */
.rows { list-style: none; padding: 0; }
.rows li { display: grid; grid-template-columns: 9.5rem 1fr; gap: 0.75rem; margin: 0.5rem 0; align-items: baseline; }
.rows .when { white-space: nowrap; }
@media (max-width: 480px) { .rows li { grid-template-columns: 1fr; gap: 0; margin: 10px 0; } }

/* Certifications page */
.search { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 4px; background: var(--bg); color: var(--text); margin: 4px 0 6px; }
.certs h3 { font-size: 1rem; color: var(--muted); margin: 26px 0 4px; }
.certs ul { list-style: none; padding: 0; margin: 0; }
.certs li { margin: 6px 0; }

footer { margin-top: 56px; padding-top: 16px; padding-bottom: 48px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.9375rem; }
footer p { margin: 0; }

/* Accessibility: text size and high contrast (footer controls), skip link */
html[data-text-size="1"] { font-size: 112.5%; }
html[data-text-size="2"] { font-size: 125%; }
html[data-text-size="3"] { font-size: 150%; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }
.skip { position: absolute; left: 8px; top: -48px; padding: 8px 12px; background: var(--bg); color: var(--link); border: 2px solid var(--link); z-index: 10; }
.skip:focus { top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.display button { font: inherit; color: var(--text); background: none; border: 1px solid var(--rule); border-radius: 4px; padding: 0 6px; min-width: 28px; min-height: 28px; cursor: pointer; }
.display button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.display { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; }
.display[hidden] { display: none; }
.display .group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.display .label { margin-right: 2px; }
.a11y-info summary { cursor: pointer; color: var(--link); width: fit-content; }
.a11y-info ul { margin: 6px 0 0; }

/* Dyslexia-friendly font (only downloaded when switched on) */
@font-face { font-family: "OpenDyslexic"; src: url("/assets/fonts/opendyslexic-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "OpenDyslexic"; src: url("/assets/fonts/opendyslexic-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
html[data-font="dyslexic"] body, html[data-font="dyslexic"] button, html[data-font="dyslexic"] input { font-family: "OpenDyslexic", sans-serif; }
html[data-font="dyslexic"] body { line-height: 1.75; }

/* Text being read aloud */
.reading { outline: 2px dashed var(--link); outline-offset: 4px; }
.display button:disabled { opacity: .4; cursor: default; }

/* Read aloud player (only shown while reading) */
.tts-bar {
  position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; max-width: calc(100% - 24px);
  padding: 8px 12px; background: var(--bg); color: var(--text); border: 1px solid var(--muted); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18); font-size: 0.9375rem;
}
.tts-bar button, .tts-bar select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--rule); border-radius: 4px; min-height: 30px; padding: 0 8px; }
.tts-bar button { cursor: pointer; }
.tts-bar select { max-width: 13rem; }
.tts-bar label[hidden] { display: none; }
@media (max-width: 600px) {
  .tts-bar { left: 8px; right: 8px; bottom: 8px; transform: none; max-width: none; justify-content: center; }
  .tts-bar select { max-width: 11rem; }
}

/* Expandable extras (skills, leadership, memberships) */
main details { margin: 10px 0 0; }
main details > summary { cursor: pointer; color: var(--link); width: fit-content; }
main details[open] > summary { margin-bottom: 4px; }

/* Phones: keep the header links on one line ("Download CV" shows as "CV"; screen readers still hear the full name) */
@media (max-width: 480px) {
  nav a { margin-right: 12px; font-size: 0.95rem; }
  nav a:last-child { margin-right: 0; }
  nav .wide-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 370px) {
  nav a { margin-right: 9px; font-size: 0.875rem; }
}
