:root {
  --bg: #f8f9fd;
  --surface: #ffffff;
  --text: #131535;
  --muted: #555c82;
  --border: #dfe2f1;
  --accent: #3d52d9;
  --accent-text: #ffffff;
  --radius: 14px;
  --max: 1000px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131535;
    --surface: #1c1e45;
    --text: #edf0fb;
    --muted: #a0a8cc;
    --border: #2f3365;
    --accent: #9db4ff;
    --accent-text: #131535;
  }
}
:root[data-theme="dark"] {
  --bg: #131535;
  --surface: #1c1e45;
  --text: #edf0fb;
  --muted: #a0a8cc;
  --border: #2f3365;
  --accent: #9db4ff;
  --accent-text: #131535;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Lato, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
}
a { color: inherit; }
main, .nav, footer { max-width: var(--max); margin: 0 auto; padding-left: 20px; padding-right: 20px; }
section { padding: 72px 0; border-top: 1px solid var(--border); }
section.hero { border-top: 0; padding: 110px 0 90px; }
h1 { font-size: clamp(2.4rem, 7vw, 4.4rem); line-height: 1.08; margin: 0 0 20px; letter-spacing: -0.015em; }
h2 { font-size: 1.7rem; margin: 0 0 28px; letter-spacing: -0.01em; }
.accent { color: var(--accent); }
.eyebrow { color: var(--muted); margin: 0 0 10px; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 560px; }
.tagline { font-size: clamp(1.15rem, 3vw, 1.4rem); font-weight: 500; max-width: 640px; }
.tagline span { white-space: nowrap; }

/* Navigation */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; max-width: none;
  padding: 0 max(20px, calc((100% - var(--max)) / 2 + 20px));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.logo { font-weight: 700; text-decoration: none; font-size: 1.15rem; }
.logo span { color: var(--accent); }
.nav nav { display: flex; align-items: center; gap: 22px; }
.nav nav a { text-decoration: none; color: var(--muted); font-size: .95rem; }
.nav nav a:hover { color: var(--text); }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--text);
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 1rem;
}
.icon-btn:hover { border-color: var(--accent); }

/* Buttons */
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.btn {
  display: inline-block; padding: 11px 22px; border-radius: 999px;
  border: 1px solid var(--border); text-decoration: none; font-weight: 600;
  transition: transform .15s, border-color .15s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Projects */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform .2s, border-color .2s;
}
.card:hover { transform: translateY(-4px); border-color: var(--accent); }
a.card { text-decoration: none; color: inherit; }
a.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.card .actions span { color: var(--accent); }
.card .thumb {
  aspect-ratio: 16 / 9; display: grid; place-items: center;
  font-size: 2.2rem; font-weight: 700; color: var(--accent-text);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #b455ff));
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card h3 { margin: 0; font-size: 1.1rem; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { font-size: .75rem; padding: 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.card .actions { display: flex; gap: 16px; font-size: .9rem; font-weight: 600; }
.card .actions a { color: var(--accent); text-decoration: none; }
.card .actions a:hover { text-decoration: underline; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.filter {
  font: inherit; font-size: .9rem; cursor: pointer; padding: 6px 16px; border-radius: 999px;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
}
.filter:hover { border-color: var(--accent); color: var(--text); }
.filter.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Research */
.research-card {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.rc-body { padding: 28px 30px; display: flex; flex-direction: column; gap: 14px; }
.rc-kicker { margin: 0; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.rc-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.rc-org { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: .75rem; text-decoration: none; }
.rc-org:hover { color: var(--accent); }
.rc-org:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
/* The logo is a transparent PNG used as a mask, so it takes the current text colour in both themes */
.rc-logo {
  display: block; width: 92px; aspect-ratio: 520 / 94; background-color: currentColor;
  -webkit-mask: url("img/mitacs-logo.png") center / contain no-repeat;
          mask: url("img/mitacs-logo.png") center / contain no-repeat;
}
.rc-org:not(:hover) .rc-logo { background-color: var(--text); }
.research-card h3 { margin: 0; font-size: 1.3rem; line-height: 1.25; letter-spacing: -.01em; }
.rc-summary { margin: 0; color: var(--muted); }
.rc-stats { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.rc-stats li { border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; background: var(--bg); }
.rc-stats b { display: block; color: var(--accent); font-size: 1.05rem; }
.rc-stats span { font-size: .78rem; color: var(--muted); }
.research-card .cta { margin-top: 6px; }
.rc-visual { position: relative; min-height: 320px; border-left: 1px solid var(--border); background: #d9a400; }
.rc-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 60% 40%; display: block; }
.rc-visual p {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 28px 16px 12px;
  font-size: .82rem; font-weight: 600; color: #fff; text-align: left;
  background: linear-gradient(to top, rgba(0,0,0,.65), rgba(0,0,0,0));
}

/* Contact */
.contact p { color: var(--muted); }
.links { display: flex; gap: 20px; margin-top: 22px; }
.links a { color: var(--muted); }
.links a:hover { color: var(--accent); }

footer { padding-top: 30px; padding-bottom: 40px; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--border); }

@media (max-width: 720px) {
  .research-card { grid-template-columns: minmax(0, 1fr); }
  .rc-visual { border-left: 0; border-top: 1px solid var(--border); order: -1; min-height: 0; aspect-ratio: 4 / 3; }
  .rc-visual img { object-position: 55% 35%; }
  .rc-body { padding: 22px 20px; }
  .nav nav { gap: 14px; }
  .nav nav a { font-size: .85rem; }
  section { padding: 52px 0; }
  section.hero { padding: 70px 0 60px; }
}
@media (max-width: 480px) {
  .nav nav { gap: 12px; }
}
