/* Anand Mathew, personal academic site.
   Palette: deep indigo for links and a turmeric mark for the current page. */

:root {
  --paper: #fafaf8;
  --ink: #1c2230;
  --muted: #5e6573;
  --rule: #dcdfe4;
  --indigo: #2e4a8c;
  --turmeric: #c8901e;
  --link: #2e4a8c;
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Mukta", "Segoe UI", Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --paper: #161a22;
  --ink: #e4e6ea;
  --muted: #a3a9b5;
  --rule: #2c323d;
  --indigo: #7d9be0;
  --turmeric: #d9a441;
  --link: #9db4ea;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.68;
  font-weight: 400;
}

a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); }
a:hover { text-decoration-color: var(--link); }
a:focus-visible, summary:focus-visible { outline: 2px solid var(--indigo); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* Header */

header.site .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 28px;
  padding-top: 26px;
  padding-bottom: 10px;
}

header.site.home .wrap { justify-content: flex-end; }

.site-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}

nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 22px;
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  font-size: 16px;
}
nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--ink); }
nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--turmeric); }

main { padding: 36px 0 72px; }

/* Home: name block */

.hero {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 36px;
  align-items: center;
}

.hero h1 {
  font-size: clamp(42px, 7vw, 58px);
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}

.hero .lede { font-size: 20px; line-height: 1.55; margin: 0; max-width: 36em; }

.hero img {
  width: 240px;
  height: 300px;
  object-fit: cover;
  object-position: 50% 15%;
  display: block;
  border-radius: 3px;
}

.market {
  font-family: var(--sans);
  font-size: 17px;
  margin: 18px 0 0;
}
.market a { margin-left: 4px; }

/* Sections */

h2 {
  font-size: 15px;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 56px 0 14px;
}

main .wrap > h2:first-child { margin-top: 8px; }

p { margin: 0 0 14px; }

.facts { display: grid; grid-template-columns: 112px 1fr; gap: 8px 22px; margin: 0; }
.facts dt { font-family: var(--sans); color: var(--muted); font-size: 15.5px; padding-top: 3px; }
.facts dd { margin: 0; }

.refs { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px 32px; font-size: 16.5px; line-height: 1.5; }
.refs .who { font-weight: 500; display: block; }
.refs .what { color: var(--muted); display: block; }

/* Papers */

.paper { margin: 0 0 40px; }
.paper h3 { font-size: 23px; font-weight: 500; line-height: 1.3; margin: 0 0 4px; }
.paper h3 a { color: var(--ink); text-decoration: none; }
.paper h3 a:hover { text-decoration: underline; text-decoration-color: var(--turmeric); }
.paper .with { font-family: var(--sans); color: var(--muted); margin: 0 0 12px; font-size: 16px; }
.paper .abstract { font-size: 17px; }
.paper .links { font-family: var(--sans); font-size: 16px; margin: 6px 0 0; }
.paper .links a + a { margin-left: 18px; }
.paper .talks { font-family: var(--sans); color: var(--muted); font-size: 15px; line-height: 1.5; margin: 10px 0 0; }

details.abs summary {
  font-family: var(--sans);
  font-size: 16px;
  color: var(--link);
  cursor: pointer;
  list-style: none;
  display: inline-block;
}
details.abs summary::-webkit-details-marker { display: none; }
details.abs summary::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-3px) rotate(-45deg);
  transition: transform 200ms ease;
}
details.abs[open] summary::before { transform: translateY(-5px) rotate(45deg); }
details.abs .abstract { margin-top: 10px; }
details.abs[open] .abstract { animation: open 260ms ease-out; }
@keyframes open { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Teaching */

.course { margin: 0 0 18px; }
.course h3 { font-size: 18.5px; font-weight: 500; margin: 0; }
.course .when { font-family: var(--sans); color: var(--muted); font-size: 15.5px; margin: 0; }
.course p.desc { margin-top: 8px; font-size: 17px; }

/* Teaching animations */

.demos-intro { font-size: 17px; margin-bottom: 22px; }

.demos { list-style: none; padding: 0; margin: 0 0 8px; }
.demos li {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 22px;
  align-items: start;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
}
.demos li:last-child { border-bottom: 1px solid var(--rule); }
.demos .thumb { display: block; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; line-height: 0; }
.demos .thumb img { width: 100%; height: auto; aspect-ratio: 8 / 5; object-fit: cover; transition: transform 300ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.demos .thumb:hover img, .demos .thumb:focus-visible img { transform: scale(1.03); }
.demos h3 { font-size: 19px; font-weight: 500; margin: 0; line-height: 1.3; }
.demos h3 a { color: var(--ink); text-decoration: none; }
.demos h3 a:hover { text-decoration: underline; text-decoration-color: var(--turmeric); }
.demos .when { font-family: var(--sans); color: var(--muted); font-size: 15px; margin: 2px 0 8px; }
.demos p:last-child { font-size: 16.5px; margin: 0; }

@media (max-width: 640px) {
  .demos li { grid-template-columns: 1fr; gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .demos .thumb img { transition: none; }
}

footer .wrap {
  font-family: var(--sans);
  color: var(--muted);
  font-size: 14px;
  padding-top: 18px;
  padding-bottom: 36px;
  border-top: 1px solid var(--rule);
}

@media (max-width: 640px) {
  body { font-size: 17px; }
  main { padding-top: 24px; }
  .hero { grid-template-columns: 1fr; gap: 22px; }
  .hero img { width: 200px; height: 250px; order: -1; }
  .hero .lede { font-size: 18px; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  details.abs[open] .abstract { animation: none; }
  details.abs summary::before { transition: none; }
}

/* Theme switch, last item in the nav. Shows a moon in light mode, a sun in dark. */

nav ul { align-items: center; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-left: 2px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease;
}
.theme-toggle:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.theme-toggle:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; transition: transform 300ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
.theme-toggle:active svg { transform: rotate(-30deg) scale(0.9); }

body { transition: background-color 200ms ease, color 200ms ease; }

/* Motion: smooth scrolling (Lenis) and a soft cross-fade between pages.
   The header stays put and the current-page mark slides to the new tab. */

html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

@view-transition { navigation: auto; }

header.site { view-transition-name: site-header; }
nav a[aria-current="page"] { view-transition-name: current-tab; }

::view-transition-old(root) { animation: 180ms ease-in both page-out; }
::view-transition-new(root) { animation: 320ms cubic-bezier(0.2, 0.7, 0.2, 1) 60ms both page-in; }
::view-transition-group(current-tab) { animation-duration: 320ms; animation-timing-function: cubic-bezier(0.2, 0.7, 0.2, 1); }

@keyframes page-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  body, .theme-toggle, .theme-toggle svg { transition: none; }
}
