/* ==========================================================================
   Arun Viswanathan, academic profile
   Built on Bootstrap 5 utilities; this file supplies the academic theme,
   the minimal nav, and all hover/scroll animations.
   ========================================================================== */

:root {
  --bg: #faf9f6;
  --bg-alt: #f1efe9;
  --text: #22262b;
  --text-muted: #5b6169;
  --accent: #1d3557;
  --accent-soft: #3a5a85;
  --border: #e4e1d8;
  --shadow: 0 10px 30px rgba(29, 53, 87, 0.08);
  --nav-height: 64px;
  --font-body: "Inter", system-ui, sans-serif;
  --font-head: "Lora", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --bg-alt: #1b1f26;
    --text: #e8e6e3;
    --text-muted: #a6adb8;
    --accent: #7fa6d9;
    --accent-soft: #5c85bb;
    --border: #2a2f38;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-head);
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: var(--accent); }

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 8px 0;
  z-index: 2000;
}
.skip-link:focus {
  left: 0;
  top: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

.site-header.scrolled {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom-color: var(--border);
  box-shadow: var(--shadow);
}

.site-nav {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  position: relative;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.35rem 0;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.28s ease;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--text);
}
.nav-link:hover::after,
.nav-link:focus-visible::after,
.nav-link.active::after {
  transform: scaleX(1);
}
.nav-link.active { color: var(--accent); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.nav-toggle .bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] .bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .bar:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] .bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

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

.section {
  max-width: 800px;
  margin: 0 auto;
  padding: 5rem 1.5rem;
  scroll-margin-top: var(--nav-height);
  border-bottom: 1px solid var(--border);
}
.section:last-of-type { border-bottom: none; }

.section h2 {
  font-size: 1.6rem;
  margin-bottom: 1.5rem;
}

.subheading {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 2.25rem 0 1rem;
  font-family: var(--font-body);
  font-weight: 600;
}
.subheading:first-of-type { margin-top: 0; }

/* Scroll-reveal: only hides content once JS (added via the `.js` class on
   <html>, set synchronously by main.js) confirms it will actually reveal it
   again. Without JS, or before it runs, everything stays visible. */
.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.in-view {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  * { animation: none !important; transition-duration: 0.001ms !important; }
}

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

.hero {
  text-align: center;
  padding-top: 4.5rem;
}

.hero-photo-wrap {
  width: 160px;
  height: 160px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border), var(--shadow);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.hero-photo-wrap:hover {
  transform: scale(1.04);
  box-shadow: 0 0 0 1px var(--accent-soft), var(--shadow);
}
.hero-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero h1 {
  font-size: 2.1rem;
  margin: 0 0 0.4rem;
}

.tagline {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.location {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

.bio {
  max-width: 620px;
  margin: 1.75rem auto 0;
  color: var(--text);
  text-align: left;
}

/* ---------- Social icons ---------- */

.social-icons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.social-icons a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.05rem;
  transition: transform 0.25s ease, background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.social-icons a:hover,
.social-icons a:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-3px);
}

/* ---------- Research tags ---------- */

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 0;
}

.tag {
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--accent);
  background: transparent;
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
  cursor: default;
}

.tag:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-2px);
}

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

.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pub-item {
  position: relative;
  display: flex;
  gap: 1.25rem;
  padding: 1rem 0.75rem;
  border-radius: 8px;
  transition: background-color 0.25s ease, transform 0.25s ease;
}

.pub-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.3s ease;
}

.pub-item:hover {
  background: var(--bg-alt);
  transform: translateX(2px);
}
.pub-item:hover::before {
  transform: scaleY(1);
}

.pub-year {
  flex: 0 0 3.2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  padding-top: 0.15rem;
}

.pub-text {
  margin: 0;
  flex: 1;
}

.pub-authors { color: var(--text-muted); }
.pub-title { color: var(--text); font-weight: 500; }
.pub-title a { color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.pub-title a:hover { text-decoration-color: var(--accent); }
.pub-venue { color: var(--text-muted); font-style: italic; }

.pub-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  vertical-align: middle;
}

.pub-note {
  margin: 0.25rem 0 0;
  padding-left: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pub-more {
  margin-top: 1rem;
}
.pub-more a { text-decoration: none; }
.pub-more a:hover { text-decoration: underline; }

.awards-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text);
}
.awards-list li { margin-bottom: 0.5rem; }

/* ---------- CV ---------- */

.btn-cv {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1.25rem 0 3rem;
  padding: 0.7rem 1.5rem;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.btn-cv::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent-soft);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: -1;
}
.btn-cv:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  color: #fff;
}
.btn-cv:hover::before { transform: translateX(0); }

.btn-cv.is-pending {
  background: var(--bg-alt);
  color: var(--text-muted);
  border: 1px dashed var(--border);
  pointer-events: none;
}
.btn-cv.is-pending::before { display: none; }

.timeline-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0 0.85rem 1rem;
  border-left: 2px solid var(--border);
  margin-bottom: 0.25rem;
  transition: border-color 0.25s ease;
}
.timeline li:hover {
  border-left-color: var(--accent);
}

.tl-role { font-weight: 600; }
.tl-org { color: var(--text-muted); font-size: 0.92rem; }
.tl-date { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.15rem; }

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

.contact-emails {
  font-size: 1.05rem;
}
.contact-emails .sep {
  margin: 0 0.6rem;
  color: var(--text-muted);
}
.contact-emails a { text-decoration: none; }
.contact-emails a:hover { text-decoration: underline; }

.contact-address {
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

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

.site-footer {
  text-align: center;
  padding: 2.5rem 1.5rem 3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- Back to top ---------- */

.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.25s ease, color 0.25s ease;
  z-index: 900;
  box-shadow: var(--shadow);
}
.back-to-top.visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--accent);
  color: #fff;
}

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

@media (max-width: 768px) {
  .timeline-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

@media (max-width: 700px) {
  .nav-toggle { display: flex; }

  .nav-links {
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 0.5rem 1.5rem 1rem;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.25s ease;
  }

  .nav-links.open {
    max-height: 320px;
    opacity: 1;
  }

  .nav-links li {
    width: 100%;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
  }
  .nav-links.open li {
    opacity: 1;
    transform: none;
  }
  .nav-links.open li:nth-child(1) { transition-delay: 0.05s; }
  .nav-links.open li:nth-child(2) { transition-delay: 0.1s; }
  .nav-links.open li:nth-child(3) { transition-delay: 0.15s; }
  .nav-links.open li:nth-child(4) { transition-delay: 0.2s; }
  .nav-links.open li:nth-child(5) { transition-delay: 0.25s; }

  .nav-link {
    display: block;
    padding: 0.65rem 0;
  }

  .section { padding: 3.5rem 1.25rem; }
  .hero { padding-top: 3rem; }
  .hero h1 { font-size: 1.7rem; }
}

@media (max-width: 480px) {
  .pub-item { flex-direction: column; gap: 0.25rem; }
  .pub-year { flex: none; }
}
