/* ==========================================================================
   Academic personal website — Muhammad Toaha Raza Khan
   Plain CSS, no build step. Colours are defined once as tokens below.
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d232b;
  --muted: #5b6573;
  --rule: #dcd8cf;
  --accent: #8c1d2c;        /* deep academic crimson */
  --accent-soft: #f4e9ea;
  --link: #1f4e79;
  --header-bg: #ffffff;
  --serif: "Source Serif 4", "Georgia", "Times New Roman", serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c;
    --surface: #1b1f26;
    --text: #e4e6ea;
    --muted: #a0a8b4;
    --rule: #2e343d;
    --accent: #e07a86;
    --accent-soft: #2c1d21;
    --link: #8cb8e6;
    --header-bg: #1b1f26;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c;
  --surface: #1b1f26;
  --text: #e4e6ea;
  --muted: #a0a8b4;
  --rule: #2e343d;
  --accent: #e07a86;
  --accent-soft: #2c1d21;
  --link: #8cb8e6;
  --header-bg: #1b1f26;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
}
img { max-width: 100%; display: block; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; color: var(--text); }
h1 { font-size: 2.1rem; margin: 0 0 .25rem; }
h2 {
  font-size: 1.45rem;
  margin: 2.5rem 0 1rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--rule);
}
h2:first-child { margin-top: 0; }
h3 { font-size: 1.1rem; margin: 1.6rem 0 .5rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--header-bg);
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 64px;
}
.brand { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  color: var(--muted); font-size: .92rem; font-weight: 500;
  padding: 8px 12px; border-radius: 4px;
}
.nav a:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); }
.theme-toggle, .nav-toggle {
  background: none; border: 1px solid var(--rule); color: var(--muted);
  border-radius: 4px; width: 36px; height: 36px; cursor: pointer; font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover, .nav-toggle:hover { color: var(--text); }
.nav-toggle { display: none; }

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch;
    background: var(--header-bg); border-bottom: 1px solid var(--rule);
    padding: 8px 16px 16px;
  }
  .nav.open { display: flex; }
  .nav a { padding: 10px 8px; }
  .theme-toggle { align-self: flex-start; margin-top: 6px; }
}

/* ---------- Layout ---------- */
main { padding: 48px 0 64px; }
.layout { display: grid; grid-template-columns: 260px 1fr; gap: 56px; }
@media (max-width: 820px) {
  main { padding: 32px 0 48px; }
  .container { padding: 0 16px; }
  .layout { grid-template-columns: 1fr; gap: 32px; }
}

/* ---------- Profile sidebar ---------- */
.profile { position: sticky; top: 96px; align-self: start; }
.profile img {
  width: 100%; max-width: 220px; aspect-ratio: 413 / 531; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--rule);
}
.profile .name { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; margin: 16px 0 4px; }
.profile .role { color: var(--muted); font-size: .93rem; line-height: 1.5; margin-bottom: 16px; }
.profile ul { list-style: none; padding: 0; margin: 0; font-size: .92rem; }
.profile li { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; }
.profile li svg { flex: 0 0 16px; margin-top: 4px; color: var(--muted); }
.profile li a { word-break: break-word; }
@media (max-width: 820px) {
  .profile { position: static; display: grid; grid-template-columns: 120px 1fr; gap: 0 20px; }
  .profile img { grid-row: span 3; }
  .profile .name { margin-top: 0; }
  .profile ul { grid-column: 1 / -1; margin-top: 16px; }
}

/* ---------- Content blocks ---------- */
.lead { font-size: 1.08rem; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 1rem; padding: 0; list-style: none; }
.tags li {
  font-size: .85rem; padding: 4px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 500;
}
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 1.5rem 0; }
.stat { border: 1px solid var(--rule); background: var(--surface); padding: 14px 16px; border-radius: 4px; }
.stat b { display: block; font-family: var(--serif); font-size: 1.6rem; color: var(--accent); line-height: 1.2; }
.stat span { font-size: .82rem; color: var(--muted); }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.news { list-style: none; padding: 0; margin: 0; }
.news li { display: grid; grid-template-columns: 90px 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--rule); }
.news li:last-child { border-bottom: 0; }
.news time { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }

/* Timeline / CV entries */
.entries { list-style: none; padding: 0; margin: 0; }
.entry { display: grid; grid-template-columns: 130px 1fr; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.entry:last-child { border-bottom: 0; }
.entry .when { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; padding-top: 1px; }
.entry .what b { font-weight: 600; }
.entry .what p, .entry .what ul { margin: 4px 0 0; color: var(--muted); font-size: .94rem; }
.entry .what ul { padding-left: 18px; }
@media (max-width: 560px) { .entry { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- Publications ---------- */
.pub-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 1.5rem; }
.pub-tools input[type="search"] {
  flex: 1 1 240px; padding: 9px 12px; font: inherit; font-size: .93rem;
  border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); color: var(--text);
}
.pub-tools input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.filter { display: inline-flex; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.filter button {
  font: inherit; font-size: .88rem; padding: 8px 14px; border: 0; cursor: pointer;
  background: var(--surface); color: var(--muted);
}
.filter button + button { border-left: 1px solid var(--rule); }
.filter button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.pub-count { font-size: .88rem; color: var(--muted); }

.year-group h3 { font-family: var(--sans); font-size: .95rem; color: var(--accent); letter-spacing: .04em; margin: 1.8rem 0 .4rem; }
.pubs { list-style: none; padding: 0; margin: 0; }
.pub { padding: 12px 0 12px 16px; border-left: 2px solid var(--rule); margin-bottom: 8px; }
.pub:hover { border-left-color: var(--accent); }
.pub .title { font-family: var(--serif); font-size: 1.04rem; font-weight: 600; display: block; }
.pub .authors { font-size: .92rem; }
.pub .authors strong { color: var(--text); }
.pub .venue { font-size: .92rem; color: var(--muted); font-style: italic; }
.pub .meta { margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 3px; border: 1px solid var(--rule); color: var(--muted);
}
.badge.j { color: var(--accent); border-color: var(--accent); }
.badge a { color: inherit; }
.hidden { display: none !important; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { border: 1px solid var(--rule); background: var(--surface); border-radius: 4px; padding: 18px 20px; }
.card h3 { margin-top: 0; font-size: 1.05rem; }
.card p { font-size: .94rem; color: var(--muted); margin: 0; }
.card .amount { display: inline-block; margin-top: 10px; font-size: .85rem; font-weight: 600; color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 4px;
  background: var(--accent); color: #fff; font-weight: 500; font-size: .93rem;
}
.btn:hover { text-decoration: none; opacity: .92; }
.btn.outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 1rem 0 2rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); padding: 24px 0; font-size: .85rem; color: var(--muted); }
.site-footer .container { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

@media print {
  .site-header, .site-footer, .pub-tools, .theme-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .layout { grid-template-columns: 1fr; }
  .profile { position: static; }
}
