/* ===== Design tokens ===== */
:root {
  --bg: #fdfaf6; /* Softer, organic off-white canvas */
  --bg-surface: #ffffff; /* For potential cards/overlays */
  --ink: #3b3a37;
  --ink-strong: #1a1a19;
  --ink-muted: #6b6a65;
  --rule: #e6e4de;
  --circle: #dcdad3;
  --link: #2b5bc7;
  --link-hover: #173d94;
  --shadow-portrait: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.08));
  --shadow-slug: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.12));

  --font-body: 'Quicksand', 'Noto Sans Devanagari', 'Noto Sans Bengali', system-ui, sans-serif;

  --max-w: 760px;
  --pad-x: clamp(20px, 5vw, 40px); /* Fluid padding */
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  /* Fluid typography: scales from ~15px on mobile to ~17px on desktop */
  font-size: clamp(0.9375rem, 0.88rem + 0.28vw, 1.0625rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ===== Background topographic shapes ===== */
.bg-shapes {
  position: fixed;
  right: -8vw;
  bottom: -10vh;
  width: 78vw;
  max-width: 980px;
  height: auto;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}
.bg-shapes path {
  fill: none;
  stroke: var(--circle);
  stroke-width: 1;
}

/* ===== Layout shell ===== */
.page {
  position: relative;
  min-height: 100vh;
  z-index: 1;
}

.site-header {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 110px 1fr 110px;
  align-items: start;
  padding: 0 var(--pad-x) 6px;
  max-width: 1200px;
  margin: 0 auto;
}

.avatar-mark {
  width: 70px;
  height: auto;
  transform: rotate(180deg);
  display: block;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.15));
  transition: transform 300ms cubic-bezier(0.3, 0, 0.2, 1);
  cursor: pointer;
  margin-top: -108px; /* Image height is ~216px, half is 108px */
}
.avatar-mark:hover,
.avatar-mark:active {
  /* Local Y is inverted because of 180deg rotation. Translate negative Y to drop DOWN */
  transform: rotate(180deg) translateY(-108px) scale(1.05);
}

.nav {
  justify-self: center;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding-top: 36px;
  white-space: nowrap;
}
.nav a {
  color: var(--ink-strong);
  border-bottom: none;
  margin: 0 8px;
}
.nav a:hover { color: var(--ink-strong); border-bottom: none; }
.nav .dot { color: var(--ink-strong); }

/* underline only on current page */
body.page-home    .nav a[data-nav="home"],
body.page-research .nav a[data-nav="research"],
body.page-teaching .nav a[data-nav="teaching"],
body.page-cv      .nav a[data-nav="cv"] {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
}

/* ===== Main content column ===== */
.content {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 24px auto 80px;
  padding: 0 var(--pad-x);
}
/* Home page gets a wider container so the portrait can breathe */
body.page-home .content {
  max-width: 1180px;
}

.content p { text-align: justify; hyphens: auto; }

h1, h2, h3 { font-weight: 700; color: var(--ink-strong); margin: 0; }

/* ===== Home page ===== */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 460px) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  margin-top: 8px;
  position: relative;
}

.hero-text {
  padding-top: 6px;
  max-width: 460px;
}

.name {
  font-size: 46px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--ink-strong);
  margin: 0 0 14px;
}

.script-line {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-strong);
  margin: 0;
  font-family: 'Noto Sans Bengali', 'Noto Sans Devanagari', var(--font-body);
}

.pronunciation {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink-strong);
  margin: 2px 0 0;
}
.pronunciation a {
  color: inherit;
  border-bottom: 1px dotted var(--ink-muted);
}
.pronunciation a:hover { color: var(--link); border-bottom-color: var(--link); }

.slug-wrap {
  margin: 14px 0 14px;
}
.slug {
  width: 48px;
  height: auto;
  cursor: pointer;
  filter: var(--shadow-slug);
  transform-origin: 50% 100%;
  display: inline-block;
  user-select: none;
  -webkit-user-drag: none;
}
.slug.jumping {
  animation: slug-jump 520ms cubic-bezier(0.3, 0, 0.2, 1);
}
@keyframes slug-jump {
  0%   { transform: translateY(0)    rotate(0deg); }
  20%  { transform: translateY(-26px) rotate(-6deg); }
  45%  { transform: translateY(-32px) rotate(4deg); }
  70%  { transform: translateY(-8px)  rotate(-2deg); }
  100% { transform: translateY(0)    rotate(0deg); }
}

.bio {
  font-size: 15px;
  margin: 6px 0 14px;
}
.bio p { margin: 0 0 10px; }

.socials {
  font-size: 14.5px;
  font-weight: 700;
  margin-top: 8px;
}
.socials a {
  color: var(--ink-strong);
  border-bottom: 1px solid transparent;
}
.socials a:hover { color: var(--link); border-bottom-color: var(--link); }
.socials .sep { color: var(--ink-muted); margin: 0 6px; }

.hero-photo {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  position: relative;
  z-index: 0;
}
.portrait-placeholder {
  width: 100%;
  max-width: 400px;
  height: auto;
  filter: var(--shadow-portrait);
  user-select: none;
  -webkit-user-drag: none;
  border-radius: 16px;
  overflow: hidden;
}
.portrait-placeholder svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ===== Research / Teaching shared blocks ===== */
.section-heading {
  font-size: 24px;
  font-weight: 700;
  margin: 38px 0 14px;
  color: var(--ink-strong);
}

.intro { margin: 6px 0 8px; }

.entry {
  margin: 0 0 22px;
}
.entry .title-line {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-strong);
  margin: 0 0 4px;
}
.entry .title-line .coauthors {
  font-weight: 500;
}

/* ===== Abstract dropdown ===== */
details.abstract {
  margin-top: 4px;
}
details.abstract > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink-strong);
  cursor: pointer;
  user-select: none;
}
details.abstract > summary::-webkit-details-marker { display: none; }
details.abstract > summary .arrow {
  display: inline-block;
  transition: transform 180ms ease;
}
details.abstract[open] > summary .arrow {
  transform: rotate(90deg);
}
details.abstract > summary:hover { color: var(--link); }
details.abstract > .abstract-body {
  margin: 8px 0 0 4px;
  padding: 8px 14px;
  border-left: 2px solid var(--rule);
  font-size: 14.5px;
  color: var(--ink);
  text-align: justify;
}

/* ===== Teaching specific ===== */
.course {
  margin: 0 0 18px;
}
.course .course-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-strong);
  margin: 0 0 4px;
}
.course p {
  font-size: 14.5px;
  margin: 0;
}

/* ===== CV ===== */
.coming-soon {
  margin-top: 12px;
  font-size: 15px;
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .site-header {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 16px;
    padding: 0 16px 8px;
  }
  .avatar-mark {
    width: 64px;
    margin: -99px auto 0; /* Image height is ~197px, half is 99px */
    transform: rotate(180deg);
  }
  
  /* Phase 4: Hop animation on hover/active for the avatar */
  .avatar-mark:hover,
  .avatar-mark:active {
    transform: rotate(180deg) translateY(-99px) scale(1.05);
  }

  .nav {
    padding-top: 0;
    font-size: 16.5px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px; /* Improved touch target spacing */
  }
  .nav a { margin: 0 4px; padding: 6px 0; }

  /* Mobile Hero: Stacked Column */
  body.page-home .content { 
    max-width: 100%; 
    padding: 0 var(--pad-x); 
  }
  
  .hero {
    grid-template-columns: 1fr;
    gap: 32px;
    text-align: center;
  }
  
  .hero-text {
    max-width: 100%;
    margin: 0 auto;
  }
  
  .hero-photo {
    justify-content: center;
    order: -1; /* Move the photo above the text on mobile */
  }
  
  .portrait-placeholder {
    max-width: 260px; /* Scale down slightly on mobile */
  }

  .name { font-size: clamp(32px, 8vw, 46px); }
  
  .hero-text p { text-align: center; } /* Center text on mobile home */
  
  .bio p { text-align: center; }
  
  .bg-shapes { 
    width: 150vw; 
    right: -25vw; 
    bottom: -5vh;
  }
  
  .content { margin-bottom: 56px; }
}

@media (max-width: 420px) {
  .nav {
    gap: 8px; /* Slightly tighter but still accessible */
  }
}
