/* ---------------------------------------------------------------------------
   Animesh Karnewar — personal homepage
   Layout and visual design adapted, with gratitude, from Oliver Wang's
   homepage (https://www.oliverwang.info/).
   --------------------------------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-title: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --border-color: #e2e8f0;

  --accent: #2563eb;
  --accent-light: #eff6ff;
  --accent-hover: #1d4ed8;

  --badge-highlight-bg: #fef3c7;
  --badge-highlight-text: #d97706;
  --badge-oral-bg: #dcfce7;
  --badge-oral-text: #15803d;
  --badge-award-bg: #fee2e2;
  --badge-award-text: #b91c1c;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

/* Global resets & typography */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
  background-color: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

/* Page container: Grid layout */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 4rem;
}

/* Sidebar Styling */
.sidebar {
  position: sticky;
  top: 3rem;
  height: fit-content;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.profile-avatar-container {
  width: 160px;
  height: 160px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--accent-light);
  box-shadow: var(--shadow-sm);
  background: #f1f5f9;
}

/* Starts blurred; JS sharpens it as the page is scrolled. */
.profile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(12px);
  transition: transform 0.5s ease, filter 0.1s ease-out;
  will-change: filter;
}

.profile-card:hover .profile-avatar {
  transform: scale(1.05);
}

.profile-name {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.profile-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.profile-affiliation {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

.profile-links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid transparent;
}

.btn-secondary:hover {
  background: #dbeafe;
}

/* Secondary "elsewhere" links, kept compact under the buttons */
.profile-extra-links {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 2;
}

.profile-extra-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}

.profile-extra-links a:hover {
  color: var(--accent);
}

/* Nav quick scroll links */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 0.5rem;
  border-left: 2px solid var(--border-color);
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  padding: 0.25rem 0;
}

.nav-link:hover {
  color: var(--accent);
  padding-left: 4px;
}

.nav-link.active {
  color: var(--accent);
  font-weight: 600;
}

/* Main Content Area Styling */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

/* Section Header Styling */
section h2 {
  font-family: var(--font-title);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 2rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Bio intro — lifted out of an inline style attribute once it grew to
   several paragraphs. */
.bio {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bio p {
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.7;
  color: var(--text-muted);
}

.bio a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.bio a:hover {
  text-decoration: underline;
}

/* Instagram handle, rendered as an inline chip with the brand glyph */
.bio .ig-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.5rem 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  /* Instagram's own gradient, always on */
  background: linear-gradient(45deg, #f09433, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888);
  color: #fff;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.bio .ig-link svg {
  width: 1em;
  height: 1em;
  fill: currentColor;
  flex-shrink: 0;
}

.bio .ig-link:hover {
  color: #fff;
  text-decoration: none;
  filter: saturate(1.15) brightness(1.08);
  box-shadow: 0 2px 8px -2px rgba(188, 24, 136, 0.5);
}

/* Shipped Products Section */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: row;
  transition: all 0.25s ease;
  height: 120px;
}

.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.feature-image-box {
  position: relative;
  width: 120px;
  height: 120px;
  background: #f8fafc;
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
  overflow: hidden;
}

.feature-image-box img,
.feature-image-box video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.feature-card:hover .feature-image-box img {
  transform: scale(1.05);
}

.feature-details {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.feature-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.feature-title a {
  color: var(--text-main);
  text-decoration: none;
  transition: color 0.15s ease;
}

.feature-title a:hover {
  color: var(--accent);
}

.feature-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.feature-subtitle {
  font-size: 0.75rem;
  color: var(--text-light);
  font-style: italic;
  margin-bottom: 0.1rem;
  margin-top: 0.15rem;
}

/* Publications Section with Filter */
.pub-header-wrapper {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.pub-header-wrapper h2 {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.search-container {
  position: relative;
  width: 320px;
  max-width: 100%;
}

.search-input {
  width: 100%;
  padding: 0.5rem 1rem 0.5rem 2.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  background: var(--bg-card);
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.9rem;
  pointer-events: none;
}

/* Publication Entry Row */
.publications-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.pub-entry {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: row;
  transition: all 0.2s ease;
}

.pub-entry:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.pub-image-box {
  position: relative;
  width: 140px;
  min-height: 110px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
  overflow: hidden;
}

.pub-image-box img,
.pub-image-box video {
  position: absolute;
  inset: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  object-fit: contain;
  border-radius: 4px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.pub-entry:hover .pub-image-box img {
  transform: scale(1.03);
}

/* Teaser video sits on top of the still and fades in on hover.
   Videos are preload="none" and only played on hover (see script). */
.pub-image-box video,
.feature-image-box video {
  opacity: 0;
  pointer-events: none;
}

.pub-entry:hover .pub-image-box video,
.feature-card:hover .feature-image-box video {
  opacity: 1;
}

.pub-details {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-grow: 1;
}

.pub-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  line-height: 1.35;
}

.pub-title a {
  color: var(--text-main);
  text-decoration: none;
  transition: color 0.15s ease;
}

.pub-title a:hover {
  color: var(--accent);
}

.pub-authors {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.pub-authors a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--border-color);
}

.pub-authors a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.pub-venue-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-light);
}

.pub-venue {
  font-style: italic;
  font-weight: 500;
}

.pub-abstract {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 0.6rem;
}

/* Badges styling */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-highlight {
  background: var(--badge-highlight-bg);
  color: var(--badge-highlight-text);
}

.badge-oral {
  background: var(--badge-oral-bg);
  color: var(--badge-oral-text);
}

.badge-award {
  background: var(--badge-award-bg);
  color: var(--badge-award-text);
}

.pub-links {
  margin-top: 0.5rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.pub-links a {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.pub-links a:hover {
  text-decoration: underline;
}

/* Professional Services / Awards Style */
.services-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.service-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  transition: all 0.2s ease;
}

.service-pill:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}

.service-name {
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
}

.service-name:hover {
  color: var(--accent);
}

.service-role {
  font-size: 0.8rem;
  color: var(--text-light);
  background: #f1f5f9;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}

/* Small secondary link inside a pill, e.g. a local copy of a paywalled article */
.pill-extra {
  font-size: 0.75rem;
  color: var(--text-light);
  text-decoration: none;
  margin-left: 0.4rem;
  white-space: nowrap;
}

.pill-extra::before {
  content: '[';
}

.pill-extra::after {
  content: ']';
}

.pill-extra:hover {
  color: var(--accent);
}

/* Mentors Section */
.mentors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.5rem;
}

.mentor-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  text-align: center;
}

.mentor-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.mentor-photo {
  width: 110px;
  height: 110px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent-light);
  background: #f1f5f9;
}

.mentor-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.mentor-card:hover .mentor-photo img {
  transform: scale(1.06);
}

.mentor-name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.mentor-name a {
  color: var(--text-main);
  text-decoration: none;
}

.mentor-name a:hover {
  color: var(--accent);
}

.mentor-role {
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.45;
}

/* Collaborators Section */
.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.student-name {
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  text-align: center;
  color: var(--text-muted);
  font-weight: 500;
}

/* Timelines (Education & Employment) */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
  padding-left: 1.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: calc(-1.5rem - 4px);
  top: 0.5rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-page);
  transition: transform 0.2s ease;
}

.timeline-item:hover::before {
  transform: scale(1.3);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.timeline-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.timeline-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.timeline-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 500;
}

.timeline-details {
  font-size: 0.85rem;
  color: var(--text-light);
}

.timeline-group-title {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text-main);
}

.timeline-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 3rem;
}

/* Footer Styling */
footer {
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}

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

/* Fade in Scroll Animations */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-on-scroll.appear {
  opacity: 1;
  transform: translateY(0);
}

/* Search results empty state */
.search-empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
}

.publications-list.searching .pub-entry {
  display: none !important;
}

.publications-list.searching .pub-entry.search-match {
  display: flex !important;
}

/* Mobile & Tablet responsiveness */
@media (max-width: 900px) {
  .page-container {
    grid-template-columns: 1fr;
    gap: 3rem;
    padding: 2rem 1rem;
  }

  .sidebar {
    position: relative;
    top: 0;
  }

  .profile-card {
    max-width: 450px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .pub-entry {
    flex-direction: column;
  }

  .pub-image-box {
    width: 100%;
    height: 160px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .search-container {
    width: 100%;
  }
}

/* Respect users who prefer reduced motion: no fade-in, no avatar blur. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .animate-on-scroll {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .profile-avatar {
    filter: none !important;
  }
}
