/* ============================================================
   Rajarshi Haldar — personal homepage
   Design tokens → base → layout → components
   ============================================================ */

/* ------------------------------------------------ tokens -- */
:root {
  --bg:            #ffffff;
  --bg-alt:        #f7f7f9;
  --surface:       #ffffff;
  --surface-hover: #fbfbfd;
  --border:        #e6e6ec;
  --border-strong: #d4d4de;
  --text:          #15151a;
  --text-soft:     #4b4b57;
  --text-muted:    #737382;
  --accent:        #4f46e5;
  --accent-hover:  #4338ca;
  --accent-soft:   rgba(79, 70, 229, 0.08);
  --accent-ring:   rgba(79, 70, 229, 0.35);
  --shadow-sm:     0 1px 2px rgba(16, 16, 24, 0.04);
  --shadow-md:     0 10px 30px -12px rgba(16, 16, 24, 0.16);

  --radius:    14px;
  --radius-sm: 9px;
  --wrap:      1080px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono",
          Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg:            #0b0b0f;
  --bg-alt:        #101015;
  --surface:       #131319;
  --surface-hover: #181820;
  --border:        #26262f;
  --border-strong: #35353f;
  --text:          #ececeF;
  --text-soft:     #b6b6c2;
  --text-muted:    #8b8b99;
  --accent:        #8b8cf7;
  --accent-hover:  #a3a4ff;
  --accent-soft:   rgba(139, 140, 247, 0.12);
  --accent-ring:   rgba(139, 140, 247, 0.4);
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:     0 10px 30px -12px rgba(0, 0, 0, 0.7);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.021em;
  font-weight: 650;
}

p { margin: 0 0 1em; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-hover); }

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

img { max-width: 100%; display: block; }

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mono { font-family: var(--mono); font-size: 0.82em; letter-spacing: -0.01em; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 24px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 12px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
}
.skip-link:focus { left: 16px; color: #fff; }

/* ------------------------------------------------ topbar -- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, background-color 0.25s ease;
}
.topbar.is-scrolled { border-bottom-color: var(--border); }

.topbar__inner {
  max-width: var(--wrap);
  margin-inline: auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-right: auto;
}
.wordmark__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.wordmark__text { font-size: 15px; }

.nav { display: flex; gap: 4px; }
.nav a {
  position: relative;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s ease, background-color 0.15s ease;
}
.nav a:hover { color: var(--text); background: var(--accent-soft); }
.nav a.is-active { color: var(--accent); background: var(--accent-soft); }

.theme-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; }

:root[data-theme="light"] .icon-moon,
:root[data-theme="dark"]  .icon-sun { display: none; }

/* -------------------------------------------------- hero -- */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(56px, 9vw, 104px) 0 clamp(48px, 7vw, 80px);
  border-bottom: 1px solid var(--border);
}

.hero__glow {
  position: absolute;
  inset: -40% 0 auto 50%;
  width: min(900px, 120%);
  aspect-ratio: 1;
  transform: translateX(-50%);
  background: radial-gradient(circle at 50% 50%,
              var(--accent-soft) 0%, transparent 62%);
  pointer-events: none;
}

.hero__inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(28px, 5vw, 56px);
}

.avatar {
  position: relative;
  flex: none;
  width: 150px;
  height: 150px;
  border-radius: 22px;
  overflow: hidden;
  background: var(--accent);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--border);
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 1;
}
.avatar__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #12b3a8));
}
.avatar.is-fallback img { display: none; }

.eyebrow {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  font-size: clamp(2.3rem, 5.6vw, 3.4rem);
  letter-spacing: -0.035em;
  font-weight: 700;
}

.hero__affil {
  margin: 10px 0 0;
  font-size: clamp(1rem, 1.7vw, 1.12rem);
  color: var(--text-soft);
}

.hero__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
}
.hero__tags span {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

/* ------------------------------------------------- chips -- */
.linkrow {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 24px;
}

/* Zero-height full-width flex item: forces the button row to wrap at a chosen
   point on wide screens. Removed on narrow screens so the row wraps naturally
   rather than being pinned into two awkward groups. */
.linkrow__break {
  flex-basis: 100%;
  height: 0;
  margin: 0;
}
@media (max-width: 720px) {
  .linkrow__break { display: none; }
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, background-color 0.15s ease;
}
.chip svg { width: 15px; height: 15px; flex: none; }
.chip:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

/* Icon-only variant: a square target with the label in title/aria-label. */
.chip--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
}
.chip--icon svg { width: 17px; height: 17px; }

.chip--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px -4px var(--accent-ring);
}
.chip--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.chip--lg { padding: 12px 22px; font-size: 15.5px; }

/* ---------------------------------------------- sections -- */
.section { padding: clamp(56px, 8vw, 92px) 0; }
.section--alt {
  background: var(--bg-alt);
  border-block: 1px solid var(--border);
}

.section__title {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  margin-bottom: 10px;
}
.section__num {
  font-family: var(--mono);
  font-size: 0.72em;
  font-weight: 500;
  color: var(--accent);
  opacity: 0.75;
}

.section__lede {
  max-width: 68ch;
  margin: 0 0 32px;
  color: var(--text-muted);
  font-size: 15px;
}

.prose {
  max-width: 72ch;
  margin-top: 26px;
  color: var(--text-soft);
  font-size: 16.5px;
}
.prose strong { color: var(--text); font-weight: 600; }
.prose a { font-weight: 500; }
.prose p:last-child { margin-bottom: 0; }

/* ------------------------------------------------- cards -- */
.grid { display: grid; gap: 18px; margin-top: 32px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid--quad { grid-template-columns: repeat(2, 1fr); }

.card {
  position: relative;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

/* research-interest cards */
.card--interest .card__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.card--interest .card__icon svg { width: 19px; height: 19px; }
.card--interest h3 { font-size: 1.06rem; margin-bottom: 8px; }
.card--interest p {
  margin: 0;
  font-size: 14.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* publication cards */
.card--pub { display: flex; flex-direction: column; }

.card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge--journal {
  background: color-mix(in srgb, #12b3a8 12%, transparent);
  color: #0d9488;
}
:root[data-theme="dark"] .badge--journal { color: #2dd4bf; }

.year {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-muted);
}

.pub__title {
  font-size: 1.02rem;
  line-height: 1.4;
  margin-bottom: 8px;
}

.pub__authors {
  margin: 0 0 4px;
  font-size: 13.8px;
  color: var(--text-muted);
  line-height: 1.55;
}
.pub__authors b,
.pub__authors strong { color: var(--text); font-weight: 600; }

.pub__venue {
  margin: 0 0 16px;
  font-size: 13.3px;
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.85;
}

.pub__links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: auto;
}
.pub__links a {
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.pub__links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ----------------------------------------------- patents -- */
.patents {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.card--patent {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 24px;
  align-items: start;
}

.patent__id {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}
.patent__id .mono {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}
.patent__date { font-size: 12.5px; color: var(--text-muted); }

.patent__body h3 { font-size: 1.02rem; line-height: 1.4; margin-bottom: 7px; }
.patent__body .pub__authors { margin-bottom: 12px; }

/* ---------------------------------------------- timeline -- */
.timeline {
  list-style: none;
  margin: 34px 0 0;
  padding: 0 0 0 22px;
  border-left: 2px solid var(--border);
  display: grid;
  gap: 36px;
}

.timeline__item { position: relative; }
.timeline__item::before {
  content: "";
  position: absolute;
  left: -29px;
  top: 7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2.5px solid var(--accent);
}
.section--alt .timeline__item::before { background: var(--bg-alt); }

.timeline__when {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.timeline__body h3 { font-size: 1.05rem; margin-bottom: 3px; }
.timeline__org {
  margin: 0 0 8px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--accent);
}
.timeline__place {
  font-weight: 400;
  color: var(--text-muted);
}
.timeline__detail {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.timeline__points {
  margin: 8px 0 0;
  padding-left: 17px;
  max-width: 68ch;
}
.timeline__points li {
  font-size: 14.5px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 5px;
}
.timeline__points li::marker { color: var(--accent); }

.timeline__body p:last-child {
  margin: 0;
  font-size: 14.5px;
  color: var(--text-muted);
  max-width: 66ch;
}

/* ----------------------------------------------- contact -- */
.section--contact {
  text-align: center;
  border-top: 1px solid var(--border);
  background:
    radial-gradient(ellipse 70% 100% at 50% 100%, var(--accent-soft), transparent 70%);
}
.contact h2 {
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  margin-bottom: 10px;
}
.contact p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ------------------------------------------------ footer -- */
.footer {
  border-top: 1px solid var(--border);
  padding: 26px 0;
  font-size: 13.5px;
  color: var(--text-muted);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}
.footer p { margin: 0; }
.footer__links { display: flex; flex-wrap: wrap; gap: 16px; }
.footer__links a { color: var(--text-muted); font-weight: 500; }
.footer__links a:hover { color: var(--accent); }

/* ---------------------------------------------- motion  -- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* -------------------------------------------- responsive -- */
@media (max-width: 860px) {
  .nav { display: none; }
  .card--patent { grid-template-columns: 1fr; gap: 12px; }
  .patent__id { flex-direction: row; align-items: baseline; gap: 12px; }
}

@media (max-width: 640px) {
  .hero__inner { flex-direction: column; align-items: flex-start; }
  .avatar { width: 110px; height: 110px; border-radius: 18px; }
  .avatar__fallback { font-size: 34px; }
  .wrap { padding-inline: 20px; }
  .grid--2, .grid--3, .grid--quad { grid-template-columns: 1fr; }
  .footer__inner { flex-direction: column; align-items: flex-start; }
}

/* ------------------------------------------------- print -- */
@media print {
  .topbar, .theme-toggle, .hero__glow, .section--contact { display: none; }
  .card { break-inside: avoid; box-shadow: none; }
  body { background: #fff; color: #000; }
}
