/* Faizal Karim — site styles
   Palette: navy ink from the portrait's tie, pale sky from the sweater,
   teal for links, saffron for the "electrons" in the QCA motif. */

:root {
  --paper: #f5f7f9;
  --surface: #ffffff;
  --sky: #e3edf6;
  --ink: #15213b;
  --muted: #56627a;
  --line: #d5dce5;
  --teal: #0e7c86;
  --teal-strong: #0a5f67;
  --electron: #e0a526;
  --cell: #ffffff;
  --cell-line: #9fb0c4;

  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --measure: 38rem;
  --wide: 72rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1626;
    --surface: #152036;
    --sky: #1a2942;
    --ink: #e6ecf4;
    --muted: #a3b0c4;
    --line: #2a3a55;
    --teal: #4fc1cb;
    --teal-strong: #7fd8df;
    --electron: #f0bc45;
    --cell: #152036;
    --cell-line: #4a5f80;
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--sans);
  font-feature-settings: "kern", "liga";
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--teal); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--teal-strong); text-decoration-thickness: 2px; }

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

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--ink); color: var(--paper); padding: .5rem 1rem;
}
.skip:focus { left: 1rem; top: 1rem; z-index: 10; }

.wrap { max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Type ---------- */
h1, h2, h3 { margin: 0; color: var(--ink); }
h1, h2 { font-family: var(--serif); font-weight: 300; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.5rem, 5.6vw, 4.5rem); line-height: 1.05; }
h2 { font-size: clamp(1.75rem, 3vw, 2.25rem); line-height: 1.15; margin-bottom: 1.25rem; }
h3 { font-size: 1.125rem; line-height: 1.35; font-weight: 600; }
p { margin: 0 0 1em; max-width: var(--measure); }
.lede { font-family: var(--serif); font-size: clamp(1.2rem, 2vw, 1.4rem); line-height: 1.55; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: .9375rem; }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--line); }
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 4.5rem; flex-wrap: wrap;
}
.brand {
  font-family: var(--serif); font-size: 1.375rem; font-weight: 400;
  color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: .6rem;
}
.brand:hover { color: var(--ink); }
.brand-cell { width: 1.35rem; height: 1.35rem; }

.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: clamp(.9rem, 2.5vw, 2rem); flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 500; padding: .35rem 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--electron); }

/* ---------- Sections ---------- */
main section { padding: clamp(3rem, 7vw, 5.5rem) 0; }
main section + section { border-top: 1px solid var(--line); }

.split { display: grid; gap: clamp(2rem, 5vw, 4rem); grid-template-columns: 1fr; }
@media (min-width: 52rem) {
  .split { grid-template-columns: 14rem 1fr; }
  .split > h2 { margin-top: .2rem; }
}

/* ---------- Hero ---------- */
.hero { padding-top: clamp(2.5rem, 6vw, 4.5rem); }
.hero-grid { display: grid; gap: clamp(2rem, 5vw, 4rem); align-items: end; }
@media (min-width: 56rem) { .hero-grid { grid-template-columns: 1.35fr 1fr; } }
.hero h1 { margin-bottom: 1.25rem; }
.hero .role { font-size: 1.125rem; font-weight: 600; color: var(--muted); margin-bottom: 1.5rem; }
.hero-photo {
  margin: 0; background: var(--sky); border-radius: 2px 2px 2px 2px;
  overflow: hidden; aspect-ratio: 4 / 5; max-width: 26rem; justify-self: end; width: 100%;
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; }

.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .7rem 1.2rem; border-radius: 999px; font-weight: 600; text-decoration: none;
  border: 1.5px solid var(--ink); color: var(--ink); background: transparent; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--teal-strong); border-color: var(--teal-strong); color: #fff; }

/* ---------- QCA wire ---------- */
.wire-band { background: var(--sky); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.wire-band .wrap { padding-top: 2rem; padding-bottom: 2rem; }
.wire-row { display: flex; align-items: center; gap: 1rem; }
.wire {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  gap: 6px; flex: 1 1 0; min-width: 0;
}
.qca {
  aspect-ratio: 1; background: var(--cell); border: 1.5px solid var(--cell-line); border-radius: 4px;
  position: relative; min-width: 0; max-width: 3.5rem;
}
.qca.driver { border-color: var(--ink); border-width: 2px; }
.qca .dot {
  position: absolute; width: 28%; height: 28%; border-radius: 50%;
  border: 1.5px solid var(--cell-line); background: transparent;
  transition: background-color .18s ease, border-color .18s ease;
}
.qca .dot:nth-child(1) { top: 12%; left: 12%; }
.qca .dot:nth-child(2) { top: 12%; right: 12%; }
.qca .dot:nth-child(3) { bottom: 12%; left: 12%; }
.qca .dot:nth-child(4) { bottom: 12%; right: 12%; }
/* P = +1: top-right and bottom-left occupied. P = -1: top-left and bottom-right. */
.qca.p1 .dot:nth-child(2), .qca.p1 .dot:nth-child(3),
.qca.p0 .dot:nth-child(1), .qca.p0 .dot:nth-child(4) { background: var(--electron); border-color: var(--electron); }
.wire .qca:nth-child(n+11) { display: none; }
@media (min-width: 40rem) { .wire .qca:nth-child(n+11) { display: block; } }
@media (min-width: 40rem) { .wire .qca:nth-child(n+15) { display: none; } }
@media (min-width: 64rem) { .wire .qca:nth-child(n+15) { display: block; } }

.bit-out {
  font-family: var(--serif); font-size: 2rem; min-width: 1.5ch; text-align: center; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.wire-caption { margin-top: 1.25rem; display: grid; gap: 1rem; align-items: start; }
@media (min-width: 52rem) { .wire-caption { grid-template-columns: 1fr auto; } }
.wire-caption p { margin: 0; color: var(--muted); font-size: .9375rem; max-width: 46rem; }

/* ---------- Outcomes list ---------- */
.outcomes { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.outcomes li { padding: 1.1rem 0; border-bottom: 1px solid var(--line); display: grid; gap: .25rem; }
.outcomes li:first-child { border-top: 1px solid var(--line); }
@media (min-width: 44rem) { .outcomes li { grid-template-columns: 11rem 1fr; gap: 2rem; } }
.outcomes strong { font-family: var(--serif); font-weight: 400; font-size: 1.35rem; line-height: 1.3; }
.outcomes span { max-width: var(--measure); }

.clients { font-family: var(--serif); font-size: 1.2rem; line-height: 1.7; max-width: 46rem; }

.doorways { display: grid; gap: 1.5rem; }
@media (min-width: 44rem) { .doorways { grid-template-columns: 1fr 1fr; } }
.doorway {
  display: block; padding: 1.75rem; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--teal);
}
.doorway:hover { color: var(--ink); border-color: var(--teal); }
.doorway h3 { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; margin-bottom: .5rem; }
.doorway p { margin: 0; color: var(--muted); }

/* ---------- CV ---------- */
.page-head { padding: clamp(2.5rem, 6vw, 4rem) 0 clamp(2.5rem, 5vw, 3.5rem); }
.page-head h1 { font-size: clamp(2.25rem, 4.5vw, 3.5rem); margin-bottom: 1rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.org { padding-bottom: 2.5rem; margin-bottom: 2.5rem; border-bottom: 1px solid var(--line); }
.org:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.org-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1.5rem; align-items: baseline; margin-bottom: .75rem; }
.org-head h3 { font-family: var(--serif); font-size: 1.6rem; font-weight: 400; }
.org-head .where { color: var(--muted); }
.org > p { color: var(--muted); }
.roles { list-style: none; margin: 1.5rem 0 0; padding: 0 0 0 1.25rem; border-left: 2px solid var(--line); }
.role-item { position: relative; padding: 0 0 1.5rem; }
.role-item:last-child { padding-bottom: 0; }
.role-item::before {
  content: ""; position: absolute; left: calc(-1.25rem - 6px); top: .45rem;
  width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--teal);
}
.role-item:first-child::before { background: var(--electron); border-color: var(--electron); }
.role-item h4 { margin: 0; font-size: 1.0625rem; font-weight: 600; }
.role-item .dates { color: var(--muted); font-size: .9375rem; font-variant-numeric: tabular-nums; }
.role-item ul { margin: .5rem 0 0; padding-left: 1.1rem; max-width: var(--measure); }
.role-item li { margin-bottom: .35rem; }

.facts { display: grid; gap: 1.5rem; }
@media (min-width: 44rem) { .facts { grid-template-columns: repeat(3, 1fr); } }
.facts h3 { margin-bottom: .5rem; }
.facts p { margin: 0; }

.plain-list { margin: 0; padding-left: 1.1rem; max-width: var(--measure); }
.plain-list li { margin-bottom: .5rem; }

/* ---------- Research ---------- */
.figure-pair { display: grid; gap: 1.5rem; margin-top: 2rem; }
@media (min-width: 48rem) { .figure-pair { grid-template-columns: 1.4fr 1fr; align-items: start; } }
figure { margin: 0; }
figure img { border: 1px solid var(--line); background: var(--surface); }
figcaption { margin-top: .6rem; font-size: .875rem; color: var(--muted); max-width: 30rem; }
.fig-qca img { image-rendering: auto; width: 100%; }
.fig-lab img { max-width: 18rem; }

.pubs-group + .pubs-group { margin-top: 2.5rem; }
.pubs-group h3 { margin-bottom: 1rem; color: var(--muted); font-weight: 600; }
.pubs { list-style: none; margin: 0; padding: 0; }
.pub { padding: 1rem 0; border-top: 1px solid var(--line); }
.pub-title { font-family: var(--serif); font-size: 1.2rem; line-height: 1.35; margin: 0 0 .25rem; max-width: 44rem; }
.pub-authors { color: var(--muted); font-size: .9375rem; margin: 0 0 .4rem; }
.pub-links { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .9375rem; font-weight: 600; }
.pub-links a { text-decoration: none; }
.pub-links a:hover { text-decoration: underline; }
.me { color: var(--ink); font-weight: 600; }

/* ---------- About ---------- */
.logos { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1.5rem; align-items: center; }
.logos img { width: 4.5rem; height: 4.5rem; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: .35rem; }

.contact-grid { display: grid; gap: 2.5rem; }
@media (min-width: 52rem) { .contact-grid { grid-template-columns: 1fr 1.2fr; } }
form { display: grid; gap: 1rem; max-width: 34rem; }
label { font-weight: 600; font-size: .9375rem; display: grid; gap: .35rem; }
input, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 4px; padding: .7rem .8rem; width: 100%;
}
input:focus, textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 25%, transparent); }
textarea { min-height: 9rem; resize: vertical; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-status { min-height: 1.5em; margin: 0; font-weight: 500; }
.form-status.ok { color: var(--teal); }
.form-status.err { color: #b3261e; }
@media (prefers-color-scheme: dark) { .form-status.err { color: #ff8a80; } }

.contact-links { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.contact-links a { font-weight: 600; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 2.5rem 0 3rem; color: var(--muted); font-size: .9375rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: center; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 1.5rem; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--ink); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}

/* ---------- Print (CV page prints cleanly) ---------- */
@media print {
  .site-header, .site-footer, .actions, .wire-band { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  main section { padding: 1rem 0; }
  a { color: #000; text-decoration: none; }
}

.h1-sub { display: block; color: var(--muted); font-style: italic; font-weight: 300; }
.wire-caption .btn { justify-self: start; }

/* ---------- Teaching ---------- */
.doorways { grid-template-columns: 1fr; }
@media (min-width: 44rem) { .doorways { grid-template-columns: repeat(3, 1fr); } }

.areas { display: grid; gap: 1.5rem 2rem; margin-top: 1.5rem; }
@media (min-width: 40rem) { .areas { grid-template-columns: 1fr 1fr; } }
@media (min-width: 64rem) { .areas { grid-template-columns: repeat(3, 1fr); } }
.areas > div { border-top: 2px solid var(--electron); padding-top: .75rem; }
.areas h3 { margin-bottom: .35rem; }
.areas p { margin: 0; font-size: .9375rem; }

.courses { list-style: none; margin: 1rem 0 0; padding: 0; }
.course { display: grid; gap: .25rem 1.5rem; padding: 1.25rem 0; border-top: 1px solid var(--line); }
.course:last-child { border-bottom: 1px solid var(--line); }
@media (min-width: 44rem) { .course { grid-template-columns: 7.5rem 1fr 8rem; } }
.course-code { font-family: var(--serif); font-size: 1.2rem; white-space: nowrap; }
.course h3 { margin-bottom: .1rem; }
.course p { margin: 0 0 .35rem; }
.course-terms { color: var(--muted); font-size: .9375rem; font-variant-numeric: tabular-nums; line-height: 1.6; }
@media (min-width: 44rem) { .course-terms { text-align: right; } }

.videos { display: grid; gap: 2rem; }
@media (min-width: 56rem) { .videos { grid-template-columns: 1fr 1fr; } }
.video { position: relative; aspect-ratio: 16 / 9; background: var(--sky); border: 1px solid var(--line); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.students { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 1.5rem 2rem; }
@media (min-width: 44rem) { .students { grid-template-columns: 1fr 1fr; } }
.students li { border-left: 2px solid var(--teal); padding-left: 1rem; }
.students h3 { font-family: var(--serif); font-weight: 400; font-size: 1.25rem; }
.students p { margin: 0 0 .25rem; }

.two-col { display: grid; gap: 2rem; }
@media (min-width: 56rem) { .two-col { grid-template-columns: 1.3fr 1fr; } }
.two-col h3 { margin-bottom: .75rem; }
.ta-list { list-style: none; margin: 0; padding: 0; }
.ta-list li { padding: .55rem 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 7.5rem 1fr; gap: 0 1rem; }
.ta-code { font-weight: 600; grid-row: span 2; white-space: nowrap; }
.ta-terms { grid-column: 2; color: var(--muted); font-size: .875rem; }

#main h3 + p.muted.small { margin-top: 0; }

/* Publications with years */
.pub { display: grid; grid-template-columns: 1fr; gap: .1rem 1.25rem; }
@media (min-width: 40rem) { .pub { grid-template-columns: 3.5rem 1fr; } }
.pub-year { font-family: var(--serif); font-size: 1.1rem; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: .1rem; }
.pub-venue { margin: 0 0 .4rem; font-size: .9375rem; max-width: 44rem; }
