/* ------------------------------------------------------------
   Muhammad bin Javaid: academic homepage
   Edit colors and fonts in the :root blocks below.
   ------------------------------------------------------------ */

:root {
  --bg: #f6f8fb;
  --surface: #e9eef5;
  --text: #18232f;
  --muted: #5a6877;
  --rule: #d5dde7;
  --accent: #2c46c9;
  --accent-soft: #dfe5fb;
  --tea: #c05a0c;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --measure: 44rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1822;
    --surface: #182534;
    --text: #e4ebf2;
    --muted: #9aa9b8;
    --rule: #253546;
    --accent: #8ea2ff;
    --accent-soft: #1f2c52;
    --tea: #f2a35c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1822;
  --surface: #182534;
  --text: #e4ebf2;
  --muted: #9aa9b8;
  --rule: #253546;
  --accent: #8ea2ff;
  --accent-soft: #1f2c52;
  --tea: #f2a35c;
  color-scheme: dark;
}

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--accent);
  color: var(--bg);
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  z-index: 10;
}

.skip:focus {
  top: 1rem;
}

/* ---------- Page layout ---------- */

.page {
  display: grid;
  grid-template-columns: 17.5rem minmax(0, 1fr);
  gap: 4.5rem;
  max-width: 70rem;
  margin: 0 auto;
  padding: 4.5rem 2rem 3rem;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky;
  top: 3rem;
  align-self: start;
}

.portrait {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 14px;
  background: var(--surface);
}

.sidebar h1 {
  margin: 1.5rem 0 0.25rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.9rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.role {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
}

.role a {
  color: inherit;
}

.contact {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 0.45rem;
  font-size: 0.95rem;
}

.contact a {
  overflow-wrap: anywhere;
}

.cv-button {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.55rem 1.1rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.98rem;
  text-decoration: none;
}

.cv-button:hover {
  filter: brightness(1.1);
  text-decoration: none;
}

/* ---------- Main column ---------- */

main {
  min-width: 0;
  max-width: var(--measure);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16rem;
  gap: 2.5rem;
  align-items: start;
}

.intro p {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-size: 1.32rem;
  line-height: 1.55;
}

.intro p:last-child {
  margin-bottom: 0;
}

.molecule-figure {
  display: block;
  width: 100%;
  margin: 0.2rem 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.molecule {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.molecule .bond {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: butt;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  animation: draw 0.9s cubic-bezier(0.3, 0.6, 0.3, 1) var(--d) forwards;
}

/* The benzotropolone core is the part that colours black tea:
   it grows in blue like the rest, then steeps to tea-amber. */
.molecule .bond.core {
  animation:
    draw 0.9s cubic-bezier(0.3, 0.6, 0.3, 1) var(--d) forwards,
    steep 1.8s ease-in-out var(--steep) forwards;
}

.molecule .atom-bg {
  fill: var(--bg);
}

.molecule .node {
  fill: var(--accent);
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: pop 0.5s ease-out var(--d) forwards;
}

.molecule .atom-label {
  fill: var(--accent);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 9.5px;
  text-anchor: middle;
  dominant-baseline: central;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: pop 0.5s ease-out var(--d) forwards;
}

.molecule .node.core {
  animation:
    pop 0.5s ease-out var(--d) forwards,
    steep-fill 1.8s ease-in-out var(--steep) forwards;
}

.molecule .atom-label.core {
  animation:
    pop 0.5s ease-out var(--d) forwards,
    steep-fill 1.8s ease-in-out var(--steep) forwards;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  60% {
    opacity: 1;
    transform: scale(1.25);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes steep {
  to {
    stroke: var(--tea);
  }
}

@keyframes steep-fill {
  to {
    fill: var(--tea);
  }
}

section {
  margin-top: 4rem;
}

section h2 {
  margin: 0 0 1.5rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.7rem;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

/* Rows with a date or label column on the left */
.row {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr);
  gap: 0.5rem 1.5rem;
  margin-bottom: 1.6rem;
}

.row:last-child {
  margin-bottom: 0;
}

.when {
  color: var(--muted);
  font-size: 0.93rem;
  padding-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.row h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1.35;
}

.row .where {
  margin: 0.1rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.97rem;
}

.row ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

.row li {
  margin-bottom: 0.3rem;
}

.row p {
  margin: 0;
}

/* Publications */
.pub h3 {
  font-size: 1.12rem;
}

.pub .authors {
  margin: 0.25rem 0 0;
  font-size: 0.98rem;
}

.pub .authors strong {
  font-weight: 700;
}

.pub .venue {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.97rem;
}

.pub .note {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.pub .links {
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  font-size: 0.95rem;
}


footer {
  margin-top: 5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Tablet and mobile ---------- */

@media (max-width: 62rem) {
  .page {
    grid-template-columns: 1fr;
    gap: 2.5rem;
    padding: 2.5rem 1.5rem 2.5rem;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 11rem minmax(0, 1fr);
    column-gap: 2rem;
    align-items: start;
  }

  .sidebar .portrait {
    grid-row: 1 / span 3;
  }

  .sidebar h1 {
    margin-top: 0;
  }

  .contact {
    grid-column: 2;
  }

  .cv-button {
    justify-self: start;
    grid-column: 2;
  }

  main {
    max-width: none;
  }
}

@media (max-width: 40rem) {
  body {
    font-size: 1rem;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .sidebar .portrait {
    grid-row: auto;
    max-width: 12rem;
  }

  .sidebar h1 {
    margin-top: 1.25rem;
  }

  .contact,
  .cv-button {
    grid-column: 1;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .intro p {
    font-size: 1.18rem;
  }

  .molecule-figure {
    max-width: 14rem;
    order: -1;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .when {
    padding-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .molecule .bond,
  .molecule .bond.core {
    animation: none;
    stroke-dashoffset: 0;
  }

  .molecule .node,
  .molecule .atom-label,
  .molecule .node.core,
  .molecule .atom-label.core {
    animation: none;
    opacity: 1;
  }

  .molecule .bond.core {
    stroke: var(--tea);
  }

  .molecule .node.core,
  .molecule .atom-label.core {
    fill: var(--tea);
  }
}

@media print {
  .sidebar {
    position: static;
  }

  .molecule-figure {
    display: none;
  }
}
