/* ---------------------------------------------------------
   Prof. Syed Hamid Hasan — academic site
   Clean academic, light. Navy + brass accent.
   --------------------------------------------------------- */

:root {
  --paper: #FFFFFF;
  --paper-tint: #F4F6F8;
  --ink: #1F2328;
  --navy: #1F3864;
  --navy-hover: #15274a;
  --brass: #9C7A3C;
  --muted: #5A6573;
  --line: #DADDE1;
  --header-bg: rgba(255, 255, 255, 0.95);
  --btn-text-on-dark: #FFFFFF;
  --shadow-cover: rgba(31, 35, 40, 0.12);
  --row-stripe: #F4F6F8;
  --card-bg: #FFFFFF;

  --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --container: 1080px;
  --measure: 68ch;

  color-scheme: light;
}

html[data-theme="dark"] {
  --paper: #0f141c;
  --paper-tint: #161c26;
  --ink: #e6e9ef;
  --navy: #93b4ea;
  --navy-hover: #b6cdf4;
  --brass: #c99a51;
  --muted: #9aa3b2;
  --line: #272e3a;
  --header-bg: rgba(15, 20, 28, 0.92);
  --btn-text-on-dark: #0f141c;
  --shadow-cover: rgba(0, 0, 0, 0.5);
  --row-stripe: #141a24;
  --card-bg: #1b2230;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) {
    --paper: #0f141c;
    --paper-tint: #161c26;
    --ink: #e6e9ef;
    --navy: #93b4ea;
    --navy-hover: #b6cdf4;
    --brass: #c99a51;
    --muted: #9aa3b2;
    --line: #272e3a;
    --header-bg: rgba(15, 20, 28, 0.92);
    --btn-text-on-dark: #0f141c;
    --shadow-cover: rgba(0, 0, 0, 0.5);
    --row-stripe: #141a24;
    color-scheme: dark;
  }
}

/* ---------- Reset / base ---------- */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--navy);
  line-height: 1.15;
  margin: 0 0 0.5em;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 { font-size: 34px; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }

p { margin: 0 0 1em; max-width: var(--measure); }

a {
  color: var(--navy);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease, color 120ms ease;
}
a:hover, a:focus-visible { border-bottom-color: var(--brass); color: var(--navy-hover); }

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

ul { padding-left: 1.1em; margin: 0 0 1em; max-width: var(--measure); }
li { margin-bottom: 0.35em; }

small, .small { font-size: 14.5px; color: var(--muted); }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

/* ---------- Layout ---------- */

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

main { display: block; }

section { padding: 56px 0; }
section + section { border-top: 1px solid var(--line); }
section.tint { background: var(--paper-tint); }

.section-head { margin-bottom: 1.75rem; }
.section-head h2 { margin-bottom: 0.25rem; }
.section-head .lede { color: var(--muted); max-width: var(--measure); margin: 0; }

/* ---------- Header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(1.2) blur(6px);
  -webkit-backdrop-filter: saturate(1.2) blur(6px);
  border-bottom: 1px solid var(--line);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 24px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.wordmark-name {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.01em;
  border: 0;
}
.wordmark-name:hover,
.wordmark-name:focus-visible { color: var(--navy-hover); border: 0; }
.kau-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  padding: 2px;
  transition: transform 160ms ease;
}
.kau-link:hover,
.kau-link:focus-visible {
  border: 0;
  transform: scale(1.06);
}
.kau-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}
html[data-theme="dark"] .kau-logo {
  filter: brightness(1.08) contrast(1.02);
}

.nav {
  display: flex;
  align-items: center;
  gap: 28px;
}
.nav a {
  font-size: 15.5px;
  color: var(--ink);
  padding: 6px 0;
  border-bottom: 1.5px solid transparent;
}
.nav a:hover, .nav a:focus-visible {
  color: var(--navy);
  border-bottom-color: var(--brass);
}
.nav a[aria-current="page"] {
  color: var(--navy);
  font-weight: 600;
  border-bottom-color: var(--brass);
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--line);
  width: 36px;
  height: 36px;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
  margin-left: 4px;
}
.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--brass);
  color: var(--navy);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  width: 40px; height: 40px;
  border-radius: 4px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.nav-toggle span {
  display: block;
  width: 18px; height: 2px;
  background: var(--navy);
  position: relative;
}
.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px; height: 2px;
  background: var(--navy);
}
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after  { top:  6px; }

/* ---------- Hero ---------- */

.hero {
  padding: 80px 0 56px;
  position: relative;
}
.hero .name {
  font-size: 44px;
  margin-bottom: 0.2em;
  line-height: 1.1;
}
.hero .title {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 400;
  color: var(--muted);
  margin: 0 0 0.75em;
  letter-spacing: 0;
}
.hero .one-liner {
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  color: var(--ink);
  max-width: var(--measure);
  margin: 0 0 2rem;
}

.hero-fade { opacity: 0; animation: heroFade 420ms ease-out 60ms forwards; }
@keyframes heroFade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.brass-rule {
  width: 72px;
  height: 2px;
  background: var(--brass);
  border: 0;
  margin: 2rem 0 2.25rem;
}

/* ---------- Stat group (3 stacked value/label pairs) ---------- */

.stats {
  display: flex;
  gap: 0;
  margin: 0 0 2.25rem;
  max-width: 540px;
}
.stats .stat {
  flex: 1;
  padding: 0 20px;
  border-left: 1px solid var(--line);
}
.stats .stat:first-child { padding-left: 0; border-left: 0; }
.stats .stat .value {
  font-family: var(--serif);
  font-size: 32px;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 6px;
  font-weight: 600;
}
.stats .stat .label {
  font-size: 13.5px;
  color: var(--muted);
}

.stats.wide { max-width: 760px; }
.stats.wide .stat .value { font-size: 26px; }

/* ---------- Buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.btn {
  display: inline-block;
  padding: 10px 18px;
  font-size: 15.5px;
  font-family: var(--sans);
  color: var(--navy);
  background: var(--paper);
  border: 1px solid var(--navy);
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}
.btn:hover, .btn:focus-visible {
  background: var(--navy);
  color: var(--btn-text-on-dark);
  border-bottom: 1px solid var(--navy);
}
.btn.primary {
  background: var(--navy);
  color: var(--btn-text-on-dark);
}
.btn.primary:hover, .btn.primary:focus-visible {
  background: var(--navy-hover);
  border-color: var(--navy-hover);
  color: var(--btn-text-on-dark);
}

/* ---------- Research focus grid ---------- */

.focus-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 48px;
  max-width: 820px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.focus-grid li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 16px;
  margin: 0;
}

.focus-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: none;
}
.focus-card {
  padding: 24px 22px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  margin: 0;
}
.focus-card:hover {
  border-color: var(--brass);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--shadow-cover);
}
.focus-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--paper-tint);
  color: var(--navy);
  margin-bottom: 14px;
  transition: background 160ms ease, color 160ms ease;
}
.focus-card:hover .focus-icon {
  background: var(--navy);
  color: var(--brass);
}
.focus-icon svg { width: 26px; height: 26px; }
.focus-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--navy);
}
.focus-card p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  max-width: none;
}

@media (max-width: 820px) {
  .focus-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .focus-cards { grid-template-columns: 1fr; }
}

.focus-list { max-width: var(--measure); }
.focus-list dt {
  font-family: var(--serif);
  font-style: italic;
  color: var(--navy);
  margin-top: 1.1em;
  margin-bottom: 0.2em;
}
.focus-list dt:first-child { margin-top: 0; }
.focus-list dd { margin: 0 0 0.4em; color: var(--ink); }

/* ---------- Lists for appointments / supervision / accreditation ---------- */

.plain-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1em;
  max-width: var(--measure);
}
.plain-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.plain-list li:last-child { border-bottom: 0; }

/* ---------- Funding table ---------- */

.funding-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  margin: 0.5em 0 1em;
  border: 1px solid var(--line);
}
.funding-table th,
.funding-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.funding-table thead th {
  background: var(--navy);
  color: var(--btn-text-on-dark);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--navy);
}
.funding-table tbody tr:nth-child(even) { background: var(--row-stripe); }
.funding-table td.num { white-space: nowrap; }

.table-wrap { overflow-x: auto; }

/* ---------- Publications ---------- */

.pub-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5em;
  counter-reset: pub;
}
.pub-list.numbered li { counter-increment: pub; }
.pub-list li {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  max-width: 820px;
}
.pub-list li:last-child { border-bottom: 0; }
.pub-list .cite {
  display: block;
  color: var(--muted);
  font-size: 14.5px;
  margin-top: 4px;
}
.pub-title { font-weight: 600; color: var(--ink); }
.pub-title a { color: var(--ink); }
.pub-title a:hover { color: var(--navy); }

/* ---------- Timeline (Appointments & leadership) ---------- */

.timeline {
  position: relative;
  margin: 1rem 0 0;
  padding: 10px 0 10px 72px;
  max-width: 820px;
}
.timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: none;
}
.timeline-rail {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 23px;
  width: 2px;
  background: var(--line);
  overflow: hidden;
  border-radius: 2px;
}
.timeline-progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to bottom, var(--navy), var(--brass));
  transition: height 140ms linear;
  will-change: height;
}
.timeline-item {
  position: relative;
  padding: 0 0 36px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 420ms ease, transform 420ms ease;
}
.timeline-item.is-visible {
  opacity: 1;
  transform: none;
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-badge {
  position: absolute;
  left: -72px;
  top: 2px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--line);
  box-shadow: 0 0 0 4px var(--paper-tint);
  display: grid;
  place-items: center;
  overflow: hidden;
  z-index: 1;
  text-decoration: none;
  transition: border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}
a.timeline-badge:hover,
a.timeline-badge:focus-visible {
  border-color: var(--brass);
  transform: scale(1.08);
}
.timeline-badge img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
}
.timeline-item.is-active .timeline-badge {
  border-color: var(--brass);
  transform: scale(1.05);
  box-shadow: 0 0 0 4px var(--paper-tint), 0 6px 18px var(--shadow-cover);
}

.timeline-card {
  padding: 14px 18px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 2px;
  transition: border-left-color 220ms ease;
}
.timeline-item.is-active .timeline-card { border-left-color: var(--brass); }

.timeline-when {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
.timeline-card h3 {
  margin: 0 0 4px;
  font-size: 20px;
  color: var(--navy);
}
.timeline-role {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink);
  font-size: 16px;
  max-width: none;
}
.timeline-card p {
  color: var(--ink);
  max-width: none;
  font-size: 15.5px;
  margin: 0 0 0.75em;
}
.timeline-card > :last-child { margin-bottom: 0; }

.timeline-bullets {
  margin: 0 0 0.75em;
  padding-left: 1.1em;
  max-width: none;
}
.timeline-bullets li {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  margin-bottom: 6px;
}

.timeline-skills {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 13.5px;
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 560px) {
  .timeline { padding-left: 56px; }
  .timeline-rail { left: 18px; }
  .timeline-badge { left: -56px; width: 40px; height: 40px; }
  .timeline-badge img { width: 28px; height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .timeline-item { opacity: 1; transform: none; transition: none; }
  .timeline-progress { transition: none; }
}

/* ---------- Email chooser popover ---------- */

.email-chooser {
  position: relative;
  display: inline-flex;
}
.email-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  min-width: 240px;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 10px 28px rgba(31, 35, 40, 0.14);
  max-width: 100%;
}
.email-menu[hidden] { display: none; }
.email-menu li { margin: 0; }
.email-menu a,
.email-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.email-menu a:hover,
.email-menu a:focus-visible,
.email-menu button:hover,
.email-menu button:focus-visible {
  background: var(--paper-tint);
  color: var(--navy);
  border-bottom-color: var(--brass);
  outline: none;
}
.email-copied-toast {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  padding: 8px 14px;
  background: var(--navy);
  color: var(--paper);
  font-size: 13.5px;
  border-radius: 3px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.email-copied-toast.show {
  opacity: 1;
  transform: none;
}

/* ---------- Books ---------- */

.books-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 48px;
  max-width: 820px;
  margin: 0.5em 0 1em;
}
.book {
  margin: 0;
}
.book-cover {
  display: block;
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--paper-tint);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: 0 1px 2px var(--shadow-cover);
  transition: box-shadow 180ms ease, transform 180ms ease;
}
.book-cover img,
.book-cover svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.book-cover::after {
  content: "View on Amazon";
  position: absolute;
  inset: auto 0 0 0;
  padding: 10px 14px;
  background: var(--navy);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.02em;
  text-align: center;
  transform: translateY(100%);
  transition: transform 180ms ease;
}
.book-cover:hover,
.book-cover:focus-visible {
  box-shadow: 0 6px 18px var(--shadow-cover);
  transform: translateY(-2px);
  border-color: var(--brass);
  border-bottom: 1px solid var(--brass);
}
.book-cover:hover::after,
.book-cover:focus-visible::after {
  transform: translateY(0);
}
.book-cover::after {
  color: var(--btn-text-on-dark);
}
.book-meta {
  margin: 14px 0 0;
}
.book-meta .book-title {
  display: block;
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 4px;
}
.book-meta .book-sub {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 2px;
}
.book-meta .book-isbn {
  display: block;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.chapters {
  margin-top: 3rem;
}

@media (max-width: 720px) {
  .books-grid {
    grid-template-columns: 1fr;
    gap: 32px;
    max-width: 320px;
  }
}

/* ---------- Contact ---------- */

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  max-width: 820px;
}
.contact-grid dt {
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 1rem;
}
.contact-grid dt:first-child { margin-top: 0; }
.contact-grid dd {
  margin: 2px 0 0;
  font-size: 16.5px;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 48px;
  padding: 32px 0 40px;
  border-top: 1px solid var(--line);
  background: var(--paper-tint);
  font-size: 14.5px;
  color: var(--muted);
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  align-items: baseline;
  justify-content: space-between;
}
.site-footer .profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}
.site-footer .profile-links a {
  color: var(--muted);
  font-size: 14.5px;
}
.site-footer .profile-links a:hover,
.site-footer .profile-links a:focus-visible {
  color: var(--navy);
}

/* ---------- 404 ---------- */

.error-page {
  text-align: left;
  padding: 100px 0;
}
.error-page .code {
  font-family: var(--serif);
  font-size: 72px;
  color: var(--navy);
  line-height: 1;
  margin: 0 0 0.25em;
}

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .focus-grid { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  h1 { font-size: 28px; }
  .hero { padding: 56px 0 40px; }
  .hero .name { font-size: 34px; }
  .hero .one-liner { font-size: 18px; }
  section { padding: 40px 0; }

  .nav-toggle { display: inline-flex; }
  .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 24px 16px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav.open { display: flex; }
  .nav a {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  .nav a:last-child { border-bottom: 0; }
  .nav a[aria-current="page"] { border-bottom-color: var(--line); }

  .stats { flex-wrap: wrap; }
  .stats .stat { padding: 0 14px; }
}

@media (max-width: 480px) {
  .stats {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px 0;
  }
  .stats .stat {
    flex: 1 1 33%;
    padding: 0 10px;
  }
  .stats .stat:nth-child(1) { padding-left: 0; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .hero-fade { opacity: 1; transform: none; }
}
