:root {
  /* Whites, creams and blues */
  --white: #ffffff;
  --cream: #f7f1e5;
  --cream-dark: #ece3d0;
  --navy: #1c3557;
  --blue: #3a6ea5;
  --blue-soft: #dbe6f3;
  --sidebar-bg: #edf3f9;
  --sidebar-line: #cddbea;
  --text: #22303f;
  --muted: #6a7686;
  --font: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --font-accent: "EB Garamond", Garamond, "Garamond Premier Pro", Georgia, serif;
  /* Panel slide: quick start, soft landing */
  --slide: .55s cubic-bezier(.22, 1, .36, 1);
  --panel-gap: 64px;
  /* Theme-dependent extras */
  --logo-bg: #ffffff;
  --glow: rgba(28, 53, 87, .22);
  --banner: rgba(255, 255, 255, .82);
  --banner-open: rgba(255, 255, 255, .94);
}
/* Dark mode: same roles, night palette. Logo nodes stay light so the logos remain legible. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --white: #0f1722;
  --cream: #182331;
  --cream-dark: #26344a;
  --navy: #e4ebf4;
  --blue: #7fa9da;
  --blue-soft: #20324a;
  --sidebar-bg: #131d2a;
  --sidebar-line: #2a3b51;
  --text: #cfd8e3;
  --muted: #8b97a7;
  --logo-bg: #e9eef4;
  --glow: rgba(0, 0, 0, .45);
  --banner: rgba(15, 23, 34, .82);
  --banner-open: rgba(15, 23, 34, .94);
}
/* Colours fade only while switching themes, not on page load */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after { transition: background-color .3s, border-color .3s, color .3s, box-shadow .3s !important; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-gutter: stable; }
body { margin: 0; font-family: var(--font); font-size: 16px; background: var(--white); color: var(--text); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-weight: 600; }

/* Sidebar */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 360px; padding: 48px 36px; background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-line); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--sidebar-line) transparent; }
/* Photo runs right up to a 2px blue ring; 104px + 2px ring = 108px footprint */
.avatar { display: block; width: 104px; height: 104px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--blue); margin: 2px 0 22px 2px; }
.sidebar h1 { margin: 0; font-size: 34px; color: var(--navy); line-height: 1.15; }
.role { margin: 4px 0 0; color: var(--blue); font-family: var(--font-accent); font-size: 18px; line-height: 1.3; }
/* Spoken languages: small muted line under the role, outline globe icon */
.languages { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; font-size: 13px; line-height: 1.3; letter-spacing: .08em; color: #8f9aa8; }
.languages svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.languages abbr { text-decoration: none; cursor: default; }
/* Tighter gap from the header to the first section */
.languages + .block { margin-top: 22px; }

.block { margin-top: 32px; }
.block h2 { margin: 0 0 12px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--navy); border-bottom: 1px solid var(--sidebar-line); padding-bottom: 6px; }
.bio { margin: 0 0 14px; }
/* Interest tags styled like the timeline nodes: white, 2px border, rounded-square corners (scaled down for the smaller size) */
.skills span { display: inline-block; font-size: 13px; background: var(--white); color: var(--navy); border: 2px solid var(--sidebar-line); border-radius: 7px; padding: 3px 10px; margin: 0 6px 8px 0; }

/* Education timeline */
.edu-timeline { list-style: none; margin: 0; padding: 0 0 0 56px; }
.edu-timeline li { position: relative; padding-bottom: 22px; min-height: 40px; }
.edu-timeline li:last-child { padding-bottom: 0; }
/* Connector line from each node down to the next one */
.edu-timeline li:not(:last-child)::after { content: ""; position: absolute; left: -37px; top: 50px; bottom: -10px; width: 2px; background: var(--sidebar-line); }
/* Rounded-square node holding the school's icon */
/* top: 10px centres the square on the first line of the title (date line is ~19px, title line ~22px) */
.edu-timeline .node { position: absolute; left: -56px; top: 10px; width: 40px; height: 40px; padding: 7px; border-radius: 10px; background: var(--logo-bg); border: 2px solid var(--sidebar-line); }
.edu-timeline a.node { transition: border-color .2s, box-shadow .2s; }
.edu-timeline a.node:hover { border-color: var(--blue); }
.edu-timeline .node img { display: block; width: 100%; height: 100%; object-fit: contain; }
.edu-timeline .node.crest { padding: 3px; }
/* Current entry: blue border, soft ring and a small even shadow on all sides */
.edu-timeline li.current .node { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft), 0 0 10px 2px var(--glow); }
.edu-timeline time { display: block; line-height: 1.6; font-size: 12px; color: var(--muted); letter-spacing: .03em; }
.edu-timeline h3 { margin: 0; font-size: 17px; color: var(--navy); line-height: 1.3; }
.edu-timeline .org { margin: 0; font-family: var(--font-accent); color: var(--blue); }
.edu-timeline .org a:hover, .entry .org a:hover { text-decoration: underline; text-underline-offset: 3px; }
.edu-timeline p { margin: 2px 0 0; font-size: 14px; }

.contact .location { margin: 0 0 12px; color: var(--muted); }
/* Link boxes styled like the timeline nodes: white, 2px border, 10px radius, blue on hover */
.contact-links { display: flex; gap: 12px; }
.contact-box { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--white); border: 2px solid var(--sidebar-line); color: var(--navy); font-weight: 600; font-size: 15px; transition: border-color .2s, box-shadow .2s; }
.contact-box:hover { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.contact-box svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

/* Dark/light toggle: a small, faint icon in the sidebar's top-right corner (moon in light mode, sun in dark) */
.theme-toggle { position: absolute; top: 16px; right: 16px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--muted); opacity: .55; cursor: pointer; transition: opacity .2s, color .2s; }
.theme-toggle:hover { opacity: 1; color: var(--blue); }
.theme-toggle:focus-visible { opacity: 1; outline: 2px solid var(--blue); outline-offset: 2px; }
.theme-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-toggle .sun { display: none; }
.theme-toggle .moon { fill: currentColor; stroke: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* Main content */
main { margin-left: 360px; padding: 40px 64px 120px; }
/* Section tabs: big enough to double as the section titles */
.topnav { position: sticky; top: 0; display: flex; gap: 36px; padding: 18px 0 14px; background: var(--white); border-bottom: 1px solid var(--blue-soft); z-index: 5; }
.topnav a { font-size: 30px; font-weight: 600; line-height: 1.2; color: var(--muted); transition: color .3s; }
.topnav a:hover, .topnav a.active { color: var(--navy); }
.topnav a:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; border-radius: 4px; }
/* Underline under the active tab; the script slides it along with the panels */
.tab-indicator { position: absolute; left: 0; bottom: -1px; width: 1px; height: 3px; background: var(--blue); transform-origin: 0 0; transform: translateX(var(--ind-x, 0)) scaleX(var(--ind-w, 0)); transition: transform var(--slide); }

/* Slider: the panels sit side by side and the track moves one panel width per step */
.slider { overflow: hidden; overflow: clip; touch-action: pan-y pinch-zoom; transition: height var(--slide); }
.slider-track { display: flex; align-items: flex-start; gap: var(--panel-gap); transform: translateX(calc(var(--pos, 0) * (-100% - var(--panel-gap)))); transition: transform var(--slide); will-change: transform; }
.panel { flex: 0 0 100%; min-width: 0; padding-top: 12px; scroll-margin-top: 80px; }
/* While swiping (and on first load) the content follows instantly */
.no-anim .slider, .no-anim .slider-track, .no-anim .tab-indicator { transition: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .slider, .slider-track, .tab-indicator { transition: none; }
}

main h3 { margin: 0; font-size: 19px; color: var(--navy); }
.org { margin: 0 0 6px; color: var(--blue); font-family: var(--font-accent); }
.entry { display: grid; grid-template-columns: 120px 1fr; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--blue-soft); }
.entry p, .entry ul { margin: 4px 0; }
.when { font-size: 14px; color: var(--muted); padding-top: 4px; }
.when .duration { display: block; margin-top: 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.when .location { margin-top: 2px; font-size: 12px; line-height: 1.4; }
/* Projects: 3 equal columns across the full content width; extra cards wrap into new rows */
.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
/* Card: cover image with a translucent white banner (title + date) along the bottom.
   On hover the banner slides up to cover the whole card and the bullet points fade in. */
.project { --banner-h: 76px; position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; background: var(--cream); border: 1px solid var(--cream-dark); border-radius: 10px; transition: border-color .2s; }
.project:hover, .project:has(> .project-link:focus-visible) { border-color: var(--blue); }
.project:has(> .project-link:focus-visible) { outline: 2px solid var(--blue); outline-offset: 3px; }
.project-cover { display: block; width: 100%; height: 100%; object-fit: cover; }
/* Logo placeholder: shown whole and centred in the space above the banner */
.project-cover.placeholder { object-fit: contain; padding: 20px 20px calc(var(--banner-h) + 20px); }
.project-banner { position: absolute; inset: 0; background: var(--banner); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transform: translateY(calc(100% - var(--banner-h))); transition: transform var(--slide), background-color .3s; }
.project:hover .project-banner, .project:has(> .project-link:focus-visible) .project-banner { transform: none; background: var(--banner-open); }
.project-head { height: var(--banner-h); display: flex; flex-direction: column; justify-content: center; padding: 0 20px; }
.project-head h3 { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; line-height: 1.3; }
.project-head time { font-size: 13px; color: var(--muted); letter-spacing: .03em; }
.project-details { margin: 0; padding: 0 20px 0 38px; font-size: 14px; line-height: 1.5; opacity: 0; transition: opacity .2s; }
.project-details li + li { margin-top: 4px; }
/* Keywords below the title, in the blue Garamond of the organisation names, dot-separated; revealed with the details on hover.
   Each dot sits in the gap before its keyword; the one starting a wrapped line falls left of the box and is clipped. */
.project-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; list-style: none; margin: 0 20px 12px; padding: 0; overflow: hidden; font-family: var(--font-accent); font-size: 16px; line-height: 1.4; color: var(--blue); opacity: 0; transition: opacity .2s; }
.project-tags li { display: inline-flex; align-items: center; }
.project-tags li::before { content: "·"; width: 18px; margin-left: -18px; text-align: center; }
.project-tags img { display: block; height: 16px; width: auto; }
.project:hover .project-details, .project:has(> .project-link:focus-visible) .project-details,
.project:hover .project-tags, .project:has(> .project-link:focus-visible) .project-tags { opacity: 1; transition: opacity .3s .15s; }
/* The card's link is an empty overlay covering the whole card (links can't nest, so this lets other links sit above it) */
.project-link { position: absolute; inset: 0; z-index: 1; }
/* Image credit: small frosted label in the cover's top-right corner, above the card link */
.credit { position: absolute; top: 8px; right: 8px; z-index: 2; padding: 2px 7px; border-radius: 5px; font-size: 11px; line-height: 1.4; color: var(--muted); background: var(--banner); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.credit:hover, .credit:focus-visible { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.entry, .project { scroll-margin-top: 90px; }

@media (max-width: 1200px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { position: relative; width: auto; padding: 36px 24px; border-right: 0; border-bottom: 1px solid var(--sidebar-line); }
  main { margin-left: 0; padding: 0 24px 80px; }
  .entry { grid-template-columns: 1fr; gap: 2px; }
  .topnav { gap: 28px; }
  .topnav a { font-size: 26px; }
  :root { --panel-gap: 24px; }
}
@media (max-width: 600px) {
  .project-grid { grid-template-columns: 1fr; }
}
