/* Bhargava Systems Research — site styles */
:root {
  --accent: #c0392b;
  --accent-dark: #a93226;
  --ink: #111111;
  --body: #333333;
  --muted: #666666;
  --line: #e2e2e2;
  --bg: #ffffff;
  --bg-muted: #f7f7f5;
  --radius: 8px;
  --wrap: 1100px;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", Arial, Helvetica, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--body);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.site-footer { margin-top: auto; }       /* pin footer to bottom on short pages */
.hero { flex: 1 0 auto; }                 /* home: hero fills the gap, no white strip */

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }
img { max-width: 100%; display: block; }

h1, h2, h3 { font-family: var(--serif); color: var(--ink); line-height: 1.2; }

.container { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border-radius: 5px;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: background .2s, color .2s, border-color .2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-ghost { border-color: #cfcfcf; color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Header / nav */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: saturate(180%) blur(6px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-logo { height: 34px; width: auto; object-fit: contain; }
.brand-text { font-family: var(--serif); font-weight: 700; font-size: 1rem; white-space: nowrap; }
.site-nav { display: flex; gap: 0.25rem; }
.site-nav a {
  color: var(--body); font-size: 0.86rem; font-weight: 500;
  padding: 0.45rem 0.75rem; border-radius: 5px;
}
.site-nav a:hover { color: var(--ink); background: var(--bg-muted); }
.site-nav a.active { color: var(--accent); }

.nav-toggle {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: 0; cursor: pointer; padding: 6px;
}
.nav-toggle span { width: 24px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .2s, opacity .2s; }

/* Home banner */
.home-banner { display: block; }
.home-banner img { display: block; width: 100%; height: auto; }
@media (max-height: 660px) { body:has(.hero-grid) .home-banner { display: none; } }  /* no room for it on very short screens */

/* Hero (home) */
.hero { position: relative; overflow: hidden; background: var(--bg-muted); display: flex; align-items: stretch; }
.hero-bg {
  position: absolute; inset: 0;
  background: radial-gradient(900px 400px at 80% -10%, rgba(192,57,43,0.14), transparent 60%),
              radial-gradient(700px 500px at 0% 120%, rgba(17,17,17,0.05), transparent 55%);
}
.hero .container { position: relative; padding-top: 5.5rem; padding-bottom: 5.5rem; max-width: 820px; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.3rem); margin-bottom: 1.25rem; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 640px; margin-bottom: 2rem; }
.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

/* Page header (subpages) */
.page-header { background: var(--bg-muted); border-bottom: 1px solid var(--line); }
.page-header .container { padding-top: 3.5rem; padding-bottom: 3.5rem; }
.page-header h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin-bottom: 0.9rem; }

/* Generic sections */
.section { padding: 4.5rem 0; }
.section-muted { background: var(--bg-muted); }
.section h2 { font-size: 1.7rem; margin-bottom: 0.9rem; }
.section p { color: var(--body); margin-bottom: 0.9rem; }
.section-title { font-size: 1.7rem; margin-bottom: 2rem; }

/* Research topics — alternating image / text rows */
.methods { display: flex; flex-direction: column; gap: 0; }
.method { display: flex; align-items: center; gap: 2.5rem; }
.method:nth-child(even) { flex-direction: row-reverse; }
.method-figure {
  flex: 0 0 44%; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}
.method-figure img { width: 100%; height: 100%; object-fit: cover; display: block; }
.method-body { flex: 1; }
.method h2 { font-size: 1.4rem; margin-bottom: 0.6rem; }
.method-projects { list-style: none; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.method-projects li { position: relative; padding-left: 1.1rem; font-size: 0.92rem; line-height: 1.5; }
.method-projects li::before { content: "→"; position: absolute; left: 0; color: var(--accent); }
.method-projects a { color: var(--body); }
.method-projects a:hover { color: var(--accent); }
@media (max-width: 720px) {
  .method, .method:nth-child(even) { flex-direction: column; }
  .method-figure { width: 100%; flex: 0 0 auto; }
}

/* People */
.people-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.75rem; }
.person { text-align: center; }
.avatar {
  width: 90px; height: 90px; border-radius: 50%;
  margin: 0 auto 1rem; background: var(--bg-muted);
  border: 1px solid var(--line); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.person h3 { font-size: 1.05rem; margin-bottom: 0.2rem; }
.person-role { color: var(--accent); font-size: 0.82rem; font-weight: 600; margin-bottom: 0.2rem; }
.person-tenure { font-size: 0.78rem; color: var(--muted); }
.person-links { display: flex; gap: 0.7rem; justify-content: center; margin-top: 0.5rem; }

/* Former members: text-only list, no photos */
.alumni { list-style: none; display: grid; gap: 1.5rem; max-width: 40rem; }
.alumni h3 { font-size: 1.05rem; margin-bottom: 0.2rem; }
.alumni .person-tenure { margin-bottom: 0.35rem; }

/* Lead mentor (PI) card */
.pi-card {
  display: grid; grid-template-columns: 180px 1fr; gap: 1.5rem; align-items: center;
  background: var(--bg-muted); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 2.25rem;
}
.pi-card img { width: 180px; height: 180px; border-radius: var(--radius); object-fit: cover; object-position: top; border: 1px solid var(--line); }
.pi-info h2 { font-size: 1.5rem; margin-bottom: 0.2rem; }
.pi-role { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); margin-bottom: 0.9rem; }
.pi-bio { color: var(--body); font-size: 0.95rem; line-height: 1.8; margin: 0; }
.pi-card + .pi-card { margin-top: 3rem; }
.pi-links { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 1.1rem; }
.pi-links .icon-link svg { width: 24px; height: 24px; }
.icon-link { color: var(--muted); display: inline-flex; }
.icon-link:hover { color: var(--accent); }
.icon-link svg { width: 20px; height: 20px; fill: currentColor; display: block; }
@media (max-width: 640px) { .pi-card { grid-template-columns: 1fr; text-align: center; gap: 1.5rem; } .pi-card img { margin: 0 auto; } }

/* Publications */
.pubs { max-width: 820px; }
.pub-year { margin-bottom: 2.5rem; }
.pub-year h2 { font-size: 1.3rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--accent); margin-bottom: 1.25rem; }
.pub-list { list-style: none; }
.pub { padding: 1rem 0; border-bottom: 1px solid var(--line); }
.pub-title { font-weight: 600; color: var(--ink); margin-bottom: 0.2rem; }
.pub-title a { color: var(--ink); }
.pub-title a:hover { color: var(--accent); }
.pub-authors { font-size: 0.9rem; color: var(--body); margin-bottom: 0.1rem; }
.pub-venue { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.3rem; }
.pub-type {
  display: inline-block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.15rem 0.55rem; border-radius: 999px; margin-bottom: 0.45rem;
}
.pub-type-preprint { background: var(--accent); color: #fff; }
.pub-type-oral { background: #f7ddd9; color: var(--accent-dark); border: 1px solid #edc0b9; }
.pub-type-poster { background: var(--bg-muted); color: var(--muted); border: 1px solid var(--line); }

/* Publications dialog (members page): whole card is the click target */
.person-linked { cursor: pointer; }
.person-name-btn { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.pub-icon {
  width: 0.72em; height: 0.72em; margin-left: 0.3em; vertical-align: 0.05em;
  fill: none; stroke: var(--muted); stroke-width: 1.8; opacity: 0.55;
}
.person-linked:hover .person-name-btn { color: var(--accent); }
.person-linked:hover .pub-icon { stroke: var(--accent); opacity: 1; }
.person-linked:hover .avatar { border-color: var(--accent); }
.pub-dialog {
  margin: auto;                      /* the global margin:0 reset kills the UA centering */
  width: min(680px, calc(100vw - 2rem)); max-height: 82vh; overflow: auto;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.75rem; color: var(--body); background: var(--bg);
}
.pub-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.pub-dialog h2 { font-size: 1.35rem; margin-bottom: 0.15rem; padding-right: 2rem; }
.pub-dialog-sub {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted); margin-bottom: 1.4rem;
}
.cite-list { list-style: none; }
.cite {
  font-size: 0.92rem; line-height: 1.7; color: var(--body);
  text-indent: -1.5rem; padding: 0 0 0 1.5rem;   /* hanging indent, like a reference list */
}
.cite + .cite { margin-top: 0.9rem; }
.cite strong { color: var(--ink); font-weight: 700; }
.cite a { color: var(--accent); word-break: break-word; }
.cite-venue { color: var(--muted); font-style: italic; }
.cite a.cite-venue { color: var(--accent); font-style: italic; }
.pub-dialog-close {
  position: absolute; top: 0.9rem; right: 1.1rem;
  font-size: 1.5rem; line-height: 1; color: var(--muted);
  background: none; border: 0; cursor: pointer;
}
.pub-dialog-close:hover { color: var(--accent); }
.pub-dialog-more { margin-top: 1rem; font-size: 0.88rem; }

/* Footer */
.site-footer { background: var(--bg-muted); border-top: 1px solid var(--line); padding: 1.6rem 0 1rem; }
.footer-inner { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 1.5rem; }
.footer-brand { font-family: var(--serif); font-weight: 700; color: var(--ink); }
.footer-meta { font-size: 0.85rem; color: var(--muted); }
.footer-links { display: flex; flex-direction: column; gap: 0.35rem; text-align: right; }
.footer-links a { font-size: 0.88rem; color: var(--body); }
.footer-links a:hover { color: var(--accent); }
.footer-bottom { margin-top: 1.1rem; padding-top: 0.85rem; border-top: 1px solid var(--line); }
.footer-bottom small { font-size: 0.78rem; color: var(--muted); }

/* Responsive */
@media (max-width: 1000px) {
  .people-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-toggle { display: flex; }
  .site-nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; gap: 0; background: #fff;
    border-bottom: 1px solid var(--line); padding: 0.5rem 1.5rem 1rem;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 0.6rem 0.25rem; }
  .site-header { position: relative; }
}
@media (max-width: 520px) {
  .people-grid { grid-template-columns: 1fr; }
}

/* Tools group in the primary nav (PaperAtlas / PocketScope) */
.nav-tools-label {
  align-self: center;
  margin-left: 0.4rem;
  padding-left: 0.85rem;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.site-nav { align-items: center; }
.site-nav a.tool-link {
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.28rem 0.64rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
}
.site-nav a.tool-link:hover { background: var(--accent); color: #fff; }
/* The tool you are currently inside, e.g. anywhere under /paperatlas. */
.site-nav a.tool-link.active {
  background: var(--accent); color: #fff;
  font-weight: 700; font-style: italic;
}
.site-nav a.tool-link.active:hover { background: var(--accent); color: #fff; }
@media (max-width: 1000px) {
  .nav-tools-label { border-left: 0; padding-left: 0.25rem; margin: 0.5rem 0 0.1rem; }
  .site-nav a.tool-link { display: inline-block; margin: 0.15rem 0; }
}

/* Home: shuffling deck of manuscript pages / graphical abstracts, beside the hero copy */
/* Sized in vh so banner + hero + footer clear a 16:9 screen without scrolling */
.hero .container.hero-grid {
  max-width: min(1320px, 100%);
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: clamp(2rem, 3vw, 3.5rem);
  align-items: stretch; align-content: stretch;
  padding-top: clamp(1rem, 2vh, 3rem); padding-bottom: clamp(1rem, 2vh, 3rem);
}
.hero-grid h1 { font-size: clamp(1.8rem, 2.2vw, 2.6rem); margin-bottom: clamp(0.5rem, 1.3vh, 1rem); }
.hero-copy { align-self: center; }
.hero-copy .lede { font-size: clamp(0.95rem, 1vw, 1.05rem); margin-bottom: clamp(0.9rem, 1.8vh, 1.5rem); }
.hero-deck { display: flex; flex-direction: column; justify-content: center; min-height: 0; }
/* Cap the shell at the deck's own max height: on a tall screen the leftover space then
   goes above the card and below the dots (justify-content: center) instead of opening a
   gap between them. Short screens still stretch to fit. */
.deck-shell {
  display: flex; align-items: center; justify-content: center; gap: 0.75rem;
  flex: 1 1 auto; min-height: 0; max-height: 620px;
}
.deck { position: relative; flex: 1 1 auto; align-self: stretch; min-height: 220px; max-height: 620px; max-width: 440px; }
.deck-card {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.85rem; box-shadow: 0 6px 24px rgba(0,0,0,0.10);
  transition: transform .7s cubic-bezier(.2,.7,.2,1), opacity .5s ease;
  will-change: transform;
  transform: translateY(30px) scale(.88) rotate(-1deg); /* back of the stack; front three override */
  z-index: 1;
}
.deck-card img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.deck-card figcaption { padding: 0.75rem 0.35rem 0.15rem; }
.deck-kicker {
  display: block; color: var(--accent);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
  margin-bottom: 0.25rem;
}
.deck-title { display: block; font-size: 0.92rem; color: var(--ink); font-weight: 600; line-height: 1.45; }
.deck-card[data-pos="0"] { transform: none; z-index: 4; }
.deck-card[data-pos="1"] { transform: translateY(10px) scale(.96) rotate(-1.6deg); z-index: 3; }
.deck-card[data-pos="2"] { transform: translateY(20px) scale(.92) rotate(1.6deg); z-index: 2; }
.deck-card:not([data-pos="0"]) { pointer-events: none; }
.deck-card:not([data-pos="0"]) figcaption { visibility: hidden; }  /* no text peeking past the front card */
.deck-card.out { transform: translateX(-55%) rotate(-13deg) scale(.9); opacity: 0; z-index: 5; }
.deck-card.snap { transition: none; }

.deck-nav {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.deck-nav:hover { border-color: var(--accent); color: var(--accent); }
/* The stack fans down past the deck box by (translateY - the scale shrink), which grows
   as the card gets shorter — that is why the dots read as cramped on a laptop and loose
   on a 4K screen. The fan above is kept shallow (<=16px overhang at any card height) so
   one flat margin lands the dots ~30-50px clear of the stack everywhere. z-index keeps
   them painted above the cards regardless. */
.deck-dots {
  position: relative; z-index: 5;
  display: flex; justify-content: center; gap: 0.2rem; margin-top: 2.9rem;
}
.deck-dot {
  box-sizing: content-box; width: 8px; height: 8px; padding: 5px;  /* 18px tap target, 8px dot */
  border: 0; border-radius: 50%; background: #b0aca6; background-clip: content-box;
  cursor: pointer; transition: background-color .2s;
}
.deck-dot.on { background: var(--accent); background-clip: content-box; }

@media (max-width: 900px) {
  .hero .container.hero-grid { grid-template-columns: 1fr; gap: 2rem; align-content: center; }
  .hero-deck { margin: 0 auto; width: 100%; max-width: 480px; }
  .deck { height: 60vh; max-height: 460px; }
}
@media (max-width: 560px) { .deck { height: 380px; } }
@media (prefers-reduced-motion: reduce) { .deck-card { transition: opacity .3s ease; } }

/* Media gallery */
.gallery { columns: 2; column-gap: 1.75rem; }
.photo {
  break-inside: avoid; margin: 0 0 1.75rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.75rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.photo img { width: 100%; border-radius: calc(var(--radius) - 4px); }
.photo figcaption { padding: 0.85rem 0.35rem 0.25rem; }
.photo-date {
  display: block; color: var(--accent);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
  margin-bottom: 0.3rem;
}
.photo-caption { display: block; font-size: 0.9rem; color: var(--body); line-height: 1.5; }
@media (max-width: 700px) { .gallery { columns: 1; } }
