:root {
  --paper: #f3efe6;
  --ink: #161412;
  --soft: #6b645a;
  --rule: #d8d1c3;
  --orange: #ff4f1f;
  --cobalt: #2340ff;
  --on-cobalt: #f3efe6;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

/* Light is the default; dark only when the visitor picks it. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #151412;
  --ink: #ece7dc;
  --soft: #9a9286;
  --rule: #2f2c27;
  --cobalt: #3d57ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; width: 100%; }

.wrap {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 32px;
}

a { color: inherit; }

/* ---------- header ---------- */
.top {
  position: relative;
  overflow: hidden;
  background: var(--orange);
  color: #161412;
  padding: 20px 0 40px;
}
.contours {
  position: absolute;
  right: -80px;
  top: -20px;
  width: min(820px, 110vw);
  opacity: 0.32;
  pointer-events: none;
}
.bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--mono);
  font-size: 13px;
}
.bar-links { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px 20px; }
.bar-links > * { white-space: nowrap; }
.bar a { text-decoration: none; border-bottom: 1.5px solid currentColor; }
.bar a:hover { background: #161412; color: var(--orange); }
.intro a { text-underline-offset: 4px; }
.intro a:hover { color: var(--orange); }
.fine a { color: inherit; }
.theme-toggle {
  font: inherit;
  color: inherit;
  background: none;
  border: 1.5px solid currentColor;
  padding: 0 8px;
  cursor: pointer;
}
.theme-toggle:hover { background: #161412; color: var(--orange); }

.top h1 {
  margin: 72px 0 0;
  font-weight: 500;
  font-size: clamp(48px, 9vw, 104px);
  line-height: 0.88;
  letter-spacing: -0.04em;
}
.role {
  margin: 16px 0 0;
  font-style: italic;
  font-size: clamp(19px, 2vw, 24px);
}
.amp { font-family: var(--serif); font-style: italic; }

/* ---------- about ---------- */
section { margin-top: 64px; }

.about {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
}
.label {
  margin: 5px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--soft);
}
.intro {
  margin: 0;
  font-size: clamp(19px, 1.8vw, 22px);
  line-height: 1.45;
  max-width: 40ch;
}
.intro em {
  font-style: italic;
  background: linear-gradient(transparent 62%, color-mix(in srgb, var(--orange) 40%, transparent) 62%);
}

/* ---------- lists ---------- */
.block h2 {
  margin: 0 0 8px;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(30px, 3.4vw, 40px);
  letter-spacing: -0.02em;
  line-height: 1;
}
.research h2 { color: var(--cobalt); }
.projects h2 { color: var(--orange); }
.chess h2 { color: var(--ink); }
.chess .list a:hover { background: var(--ink); color: var(--paper); }
.languages h2 { color: var(--orange); }
.reading h2 { color: var(--cobalt); }
.native { margin-left: 10px; font-weight: 400; color: var(--soft); }
.native[lang="ur"], .native[lang="pnb"] {
  font-family: "Noto Nastaliq Urdu", serif;
  font-size: 0.9em;
  line-height: 1;
}
.native[lang="hi"] { font-family: "Noto Serif Devanagari", serif; }
.prose { margin: 20px 0 0; max-width: 40ch; font-size: 19px; line-height: 1.5; }

.list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.list li { border-bottom: 1px solid var(--rule); }
.list a,
.list .row {
  display: grid;
  grid-template-columns: 140px 1fr 32px;
  gap: 24px;
  align-items: baseline;
  padding: 16px 12px;
  margin: 0 -12px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.when {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--soft);
}
.body { display: flex; flex-direction: column; gap: 4px; }
.title { font-size: 20px; font-weight: 500; letter-spacing: -0.015em; line-height: 1.2; }
.desc { color: var(--soft); font-size: 16px; }
.arrow {
  justify-self: end;
  font-size: 18px;
  transition: transform 0.15s;
}

.research .list a:hover { background: var(--cobalt); color: var(--on-cobalt); }
.projects .list a:hover { background: var(--orange); color: #161412; }
.list a:hover .when,
.list a:hover .desc { color: inherit; }
.list a:hover .arrow { transform: translate(3px, -3px); }

.more { margin: 20px 0 0; font-size: 16px; }
.more a { text-underline-offset: 4px; }
.more a:hover { color: var(--orange); }

/* ---------- footer ---------- */
.foot {
  margin-top: 88px;
  background: var(--cobalt);
  color: var(--on-cobalt);
  padding: 56px 0 28px;
}
.say {
  margin: 0;
  max-width: 26ch;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.say a {
  font-style: italic;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}
.say a:hover { color: var(--orange); }
.fine {
  margin: 48px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0.75;
}

/* ---------- small screens ---------- */
@media (max-width: 700px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .bar .site { display: none; }
  .bar:has(.site) { justify-content: flex-end; }
  .bar-links { gap: 8px 14px; }
  .top h1 { margin-top: 56px; }
  .contours { right: -260px; width: 900px; }
  section { margin-top: 48px; }
  .about { grid-template-columns: 1fr; gap: 12px; }
  .list a, .list .row { grid-template-columns: 1fr 24px; gap: 2px 12px; padding: 14px 8px; margin: 0 -8px; }
  .when { grid-column: 1 / -1; }
  .title { font-size: 19px; }
  .foot { margin-top: 64px; padding-top: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Plain (non-link) rows line up with the text, not the hover area */
.list li.row { margin: 0; padding-left: 0; padding-right: 0; }

/* Reading: sub-groups per language */
:lang(ur), :lang(pnb) { font-family: "Noto Nastaliq Urdu", serif; line-height: 1.9; }
:lang(hi) { font-family: "Noto Serif Devanagari", serif; }
.native:lang(ur), .native:lang(pnb) { line-height: 1; }
cite { font-style: italic; }
.sub {
  margin: 44px 0 0;
  padding-bottom: 8px;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cobalt);
}
.sub-note { margin: 0 0 4px; color: var(--soft); font-size: 16px; max-width: 52ch; }
.reading .list { border-top-width: 1px; }
.verse {
  margin: 12px 0 10px;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--orange);
  font-style: italic;
  font-size: 18px;
  line-height: 1.45;
}
.gloss {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 15px;
  color: var(--soft);
}

/* Reading lists: the work is the headline, the author sits in the left column */
.works .title cite { font-style: italic; }
.works .when { color: var(--ink); }
.works .native:not([lang]) { display: block; margin: 2px 0 0; font-size: 16px; }
.works .title cite:lang(ur) { font-style: normal; font-size: 1.15em; }

/* Urdu reading list: right-to-left, Urdu first, English as quieter support */
.urdu .when { font-size: 17px; color: var(--ink); line-height: 1.9; }
.urdu [lang="en"] { font-family: var(--serif); line-height: 1.5; text-align: right; }
.urdu .translit {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--soft);
}
.urdu .native { display: block; margin: 2px 0 0; font-size: 16px; }
.urdu .title cite { font-style: normal; font-size: 1.15em; }

/* "In Urdu" heading: right-to-left, Urdu first */
.sub-ur {
  font-family: "Noto Nastaliq Urdu", serif;
  font-size: 18px;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.9;
  padding-bottom: 0;
}
.sub-ur .translit {
  margin-right: 10px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--soft);
}
.sub-note-ur { text-align: right; margin-left: auto; }

/* Fiction / Non-fiction split inside a reading group */
.minor {
  margin: 20px 0 6px;
  font-weight: 400;
  font-style: italic;
  font-size: 18px;
  color: var(--soft);
}

/* Urdu verse: bar on the right, upright Nastaliq */
.urdu .verse {
  border-left: 0;
  border-right: 3px solid var(--orange);
  padding: 2px 16px 2px 0;
  font-style: normal;
  font-size: 20px;
  line-height: 2.3;
}
.urdu .verse .gloss { line-height: 1.5; }
.urdu .translit-verse { font-style: italic; }

/* Nastaliq looks much bigger than Latin text at the same font-size, so the
   Urdu sizes below are tuned by eye to match their English/German counterparts. */
.sub-ur { font-size: 13px; line-height: 2.2; }
.urdu .when { font-size: 13px; line-height: 2.1; }
.urdu .title cite { font-size: 17px; }
.urdu .title { line-height: 2.1; }
.urdu .verse { font-size: 16px; line-height: 2.4; }
.works.urdu .title cite:lang(ur) { font-size: 16px; }

/* Smaller quotations throughout */
.verse { font-size: 16px; }
.urdu .verse { font-size: 14px; line-height: 2.3; }
.verse .gloss { font-size: 14px; }

/* Publication year beside each work */
.year {
  margin-inline-start: 8px;
  font-family: var(--serif);
  font-style: normal;
  font-size: 15px;
  color: var(--soft);
}
.urdu .year { line-height: 1; }
.urdu .year { margin-left: 0; margin-right: 8px; }
.urdu .year:lang(ur) { font-family: "Noto Nastaliq Urdu", serif; font-size: 14px; }

/* Main page: link through to the hobbies page */
.hobbies h2 { color: var(--ink); }
.hobbies .list a:hover { background: var(--ink); color: var(--paper); }
.hobbies .list a:hover .arrow { transform: translateX(4px); }

/* Hobbies hub: one row per hobby, each in its own colour on hover */
.hub .title { font-size: 26px; }
.hub .to-languages a:hover { background: var(--orange); color: #161412; }
.hub .to-reading a:hover { background: var(--cobalt); color: var(--on-cobalt); }
.hub .to-chess a:hover { background: var(--ink); color: var(--paper); }
.hub .list a:hover .arrow { transform: translateX(4px); }
/* A hobby subpage's single section needs no heading gap above it */
.solo > .prose:first-child, .solo > .list:first-child { margin-top: 0; }

/* Reading page: jump links to each language */
.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}
.jump a {
  padding: 4px 14px;
  border: 1.5px solid var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  text-decoration: none;
}
.jump a:lang(ur) { font-family: "Noto Nastaliq Urdu", serif; font-size: 13px; line-height: 1.6; padding: 0 14px; }
.jump a:hover { background: var(--cobalt); border-color: var(--cobalt); color: var(--on-cobalt); }
.sub[id] { scroll-margin-top: 24px; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.jump a { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; }
.jump a:lang(ur) { font-size: 16px; line-height: 1; padding: 0 14px 4px; }

/* 404 page */
.missing.path { font-family: var(--mono); font-style: normal; font-size: 0.8em; overflow-wrap: anywhere; }
.lost .list a:hover { background: var(--orange); color: #161412; }
.lost .list a:hover .arrow { transform: translateX(4px); }
