
/* =============================
   Base & Design Tokens
   ============================= */
:root {
  --brand: #0071c5;
  --brand-strong: #005fa3;
  --ink: #333;
  --ink-light: #555;
  --line: #eee;
  --bg: #fff;
  --bg-soft: #fafafa;
  --bg-card: #f4f7fb;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Helvetica Neue', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  scroll-behavior: smooth; /* smooth anchor jumps */
}

/* helper to constrain content width where helpful */
.container { width: min(1200px, 90vw); margin-inline: auto; }

/* =============================
   Accessible Skip Link
   ============================= */
.skip-link {
  position: absolute; left: 8px; top: -40px;
  background: var(--brand); color: #fff; padding: 6px 10px;
  border-radius: 6px; text-decoration: none; font-weight: 700;
  transition: top .15s ease;
  z-index: 10000;
}
.skip-link:focus { top: 8px; }

/* =============================
   Header / Navigation (mobile-first)
   ============================= */
header {
  position: sticky; top: 0; z-index: 1000;
  backdrop-filter: blur(6px);
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid var(--line);
}

.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 0;
}

.nav-brand {
  display: inline-flex; align-items: baseline; gap: .5rem;
  font-weight: 800; letter-spacing: .2px; color: var(--ink);
  text-decoration: none; font-size: 1.05rem;
}

/* Hamburger control (button + icon bars) */
.nav-toggle {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  width: 42px; height: 36px; display: inline-grid; place-items: center;
  cursor: pointer; transition: background .2s ease, transform .06s ease;
}
.nav-toggle:hover { background: #f7f7f7; transform: translateY(-1px); }
.nav-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.nav-toggle-bars { width: 22px; height: 14px; display: grid; gap: 4px; }
.nav-toggle-bars span { display: block; height: 2px; background: var(--ink); }

/* Collapsible menu: hidden by default on small screens */
.nav-menu {
  display: none; /* toggled by [data-open="true"] in JS */
  flex-direction: column; gap: .25rem; padding: .5rem 0 0;
}

.nav-menu a {
  text-decoration: none; color: var(--ink); font-weight: 700; padding: .5rem .25rem;
  border-radius: 6px;
}
.nav-menu a:hover, .nav-menu a:focus-visible { background: #f2f6ff; color: var(--brand-strong); outline: none; }

/* On wider screens, show the menu inline and hide hamburger */
@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .nav-menu { display: flex !important; flex-direction: row; gap: 1.25rem; padding: 0; }
}

/* Data-driven open state (no class juggling needed) */
#site-nav[data-open="true"] .nav-menu { display: flex; }

/* =============================
   Sections & Headings
   ============================= */
section { padding: 64px 0; }

section h2 {
  font-size: 2rem; margin: 0 0 24px; color: #000; text-align: left;
}

/* Center only first headers in key sections */
#research > h2:first-of-type,
#people > h2:first-of-type { text-align: center; }

/* Hero keeps your look, just constrained */
.hero {
  background: url('lab-banner.jpg') center/cover no-repeat; color: #fff;
  min-height: 72vh; display: grid; place-items: center; text-align: center;
}
.hero-inner { padding: 48px 0; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.2rem); margin: 0 0 .5rem; }
.hero p { font-size: clamp(1.05rem, 2.5vw, 1.6rem); margin: 0 0 1.25rem; }
.hero .cta { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; }
.hero .cta a {
  background: var(--brand); color: #fff; padding: .75rem 1.25rem; border-radius: 8px; text-decoration: none; font-weight: 800;
}
.hero .cta a:hover { background: var(--brand-strong); }

/* =============================
   People (grid collapses to 1-col)
   ============================= */
.people-section { background: var(--bg-soft); }

.people-grid {
  display: grid; gap: 40px; max-width: 1100px; margin: 0 auto;
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 1024px) { .people-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 680px) { .people-grid { grid-template-columns: 1fr; } }

.person-card {
  background: #fff; padding: 20px; border-radius: 10px; text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
}
.person-card img {
  width: 180px; height: 180px; object-fit: cover; border-radius: 50%; margin-bottom: 15px;
}
.person-card h3 { margin: 10px 0 4px; font-size: 1.2rem; color: var(--brand); }
.person-role { font-size: .95rem; color: var(--ink); margin: 0 0 10px; font-weight: 700; }
.person-card p { font-size: .95rem; color: #444; }

.alumni-title { font-size: 1.4rem; margin: 48px 0 14px; color: #000; }
.alumni-list { list-style: none; padding: 0; margin: 0; font-size: .95rem; color: #333; }
.alumni-list li { margin: 10px 0; padding-left: 1rem; position: relative; }
.alumni-list li::before { content: "•"; position: absolute; left: 0; color: var(--brand); font-weight: 800; }

/* =============================
   Research cards + modal
   ============================= */
.research-grid {
  display: grid; gap: 32px; max-width: 1100px; margin: 0 auto;
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 900px) { .research-grid { grid-template-columns: 1fr; } }

.research-card { padding: 0; text-align: center; border-radius: 10px; background: #fff; border: 1px solid #e6eef7; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.research-media { position: relative; display: block; }
.research-thumb { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 10px; transition: transform .25s ease, filter .25s ease; }
.research-overlay { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: clamp(1.25rem, 3.5vw, 2.2rem); text-align: center; padding: 10px; }

/* =============================
   Modal responsiveness
   ============================= */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 1rem; /* ensure breathing space on small screens */
}

.modal:target { display: flex; }

.modal-content {
  background: #fff;
  padding: 24px;
  border-radius: 10px;
  width: min(680px, 92vw);
  max-height: 90vh;        /* never taller than viewport */
  overflow-y: auto;        /* allow scroll inside */
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  position: relative;
}

.modal-content h2 {
  margin-top: 0;
}

.modal .close {
  position: sticky;   /* so the X stays visible when scrolling */
  top: 0;
  float: right;
  font-size: 1.5rem;
  text-decoration: none;
  color: #333;
  padding: 0 .25rem;
}

@media (max-width: 480px) {
  .modal-content {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
}

/* =============================
   Publications & video
   ============================= */
.publications-section { background: #fdfdfd; }
.pub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.pub-card { background: var(--bg-card); border: 2px solid var(--brand); border-radius: 10px; padding: 20px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 10px; }
.pub-card:hover { background: #e9f2f9; transform: translateY(-2px); }
.pub-card h3 { margin: 0; font-size: 1.1rem; color: var(--brand-strong); }
.pub-card p { margin: 0; font-size: .95rem; color: var(--ink-light); }

.video-container { position: relative; width: 100%; }
.pub-video { width: 100%; display: block; }
.pub-video.mirror { transform: scaleY(-1); opacity: .4; margin-top: -5px; mask-image: linear-gradient(to bottom, rgba(0,0,0,.6), transparent); -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.6), transparent); }

/* Wrapper for links to all pubs / patents */
.pubs-wrapper {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;   /* center the columns horizontally */
  gap: 40px;
  text-align: center;        /* ensure headings and text align uniformly */
}

.pubs-column {
  flex: 1 1 300px;           /* equal flex columns */
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;       /* ensures heading/button are aligned center */
}

.pubs-column h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;        /* force heading text to center */
}

.all-pubs-button {
  display: flex;
  justify-content: center;
  margin: 12px 0 20px;
  width: 100%;              /* button wrapper fills the column */
}

.all-pubs-button a {
  flex: 1 1 auto;
  width: 100%;              /* button always stretches full column width */
  text-align: center;
  padding: 12px 18px;
  background: #0073e6;
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
}

.all-pubs-button a:hover {
  background: #005bb5;
}

/* =============================
   Join / Opportunities
   ============================= */
.join-section p { margin: .5rem 0 1rem; }

.opportunity-card { background: #fff; border: 1px solid #e6eef7; border-radius: 14px; padding: 24px; box-shadow: 0 6px 18px rgba(0,0,0,.05); margin-top: 22px; }
.opportunity-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 22px; }
@media (max-width: 900px) { .opportunity-grid { grid-template-columns: 1fr; } }

.opportunity-header { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.deadline-badge { background: #ffe8e6; color: #b60000; border: 1px solid #ffcdc8; padding: 6px 10px; border-radius: 999px; font-size: .85rem; font-weight: 800; }
.project-title { margin: 6px 0 12px; font-size: 1.05rem; color: #222; }

.nice-bullets { list-style: none; padding: 0; margin: 0; }
.nice-bullets li { position: relative; padding-left: 1.6rem; margin: 10px 0; }
.nice-bullets li::before { content: "▸"; position: absolute; left: 0; color: var(--brand); font-weight: 900; }

.meta-box { border: 1px solid #e6eef7; background: #f8fbff; border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; font-size: .95rem; }
.meta-box .meta-label { min-width: 90px; color: #555; font-weight: 800; margin-right: 6px; display: inline-block; }

.opportunity-cta { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.btn-primary { background: #0073e6; color: #fff; padding: 10px 14px; border-radius: 8px; font-weight: 800; text-decoration: none; box-shadow: 0 4px 10px rgba(0,115,230,.25); }
.btn-primary:hover { background: #005bb5; }

/* =============================
   News / Highlights
   ============================= */
.news-card { background: var(--bg-card); border-left: 4px solid var(--brand); border-radius: 10px; padding: 18px; margin: 16px 0 22px; }
.news-card h4 { margin: 0 0 6px; color: var(--brand-strong); }

/* =============================
   Lab Photos modal gallery (kept)
   ============================= */
.lab-photos-launch, .lab-photos-section { background: #fff; }
.lab-photos-dialog { width: min(1100px, 92vw); max-height: 85vh; border: none; border-radius: 14px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: auto; }
.lab-photos-dialog::backdrop { background: rgba(0,0,0,.55); }
.dlg-close { position: sticky; top: 6px; float: right; border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: #333; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; }
.gallery-grid img { width: 100%; height: clamp(160px, 24vw, 220px); object-fit: cover; display: block; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }

/* =============================
   Contact
   ============================= */
.contact-section { background: var(--bg-soft); }

.contact-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}
@media (max-width: 900px) {
  .contact-container { grid-template-columns: 1fr; }
}

/* Gallery: 4-up when space allows, otherwise horizontal scroller */
.contact-gallery {
  --gap: 20px;
  --card-w: clamp(240px, 25vw, 320px); /* width of each image in scroll mode */
  display: grid;
  gap: var(--gap);
  margin-top: 24px;
}

/* ≥1200px: classic 4 columns, all equal */
@media (min-width: 1200px) {
  .contact-gallery {
    grid-template-columns: repeat(4, 1fr);
    overflow: visible;
  }
  .contact-gallery img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
  }
}

/* <1200px: one-row horizontal scroll with identical card widths */
@media (max-width: 1199px) {
  .contact-gallery {
    grid-auto-flow: column;             /* lay items left→right in one row */
    grid-auto-columns: var(--card-w);   /* every item same width */
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;                /* space for scrollbar/thumb */
  }
  .contact-gallery > img {
    scroll-snap-align: center;
    width: 100%;
    height: 220px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
  }
}


/* =============================
   Footer
   ============================= */
.site-footer { background: var(--bg-card); border-top: 1px solid #ddd; padding: 30px 0; margin-top: 40px; }
.footer-content { display: grid; place-items: center; gap: 16px; }
.footer-logos { display: flex; flex-wrap: wrap; gap: 32px; justify-content: center; }
.footer-logos img { max-height: 60px; object-fit: contain; }

/* =============================
   Global Responsive Tweaks
   ============================= */
@media (max-width: 768px) {
  /* Single-column intent on phones: narrow paddings & full-width blocks */
  section { padding: 52px 0; }
  .container { width: 92vw; }

  /* Ensure all complex grids stack cleanly */
  .pubs-wrapper { flex-direction: column; align-items: center; }
  .hero .cta { gap: .75rem; }
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}



/* =============================
   FULL-SCREEN HERO (all screens)
   ============================= */

/* Header height variable so we can subtract it from the hero */
:root { --header-h: 64px; }
@media (min-width: 900px) { :root { --header-h: 72px; } }

/* Make header a consistent height */
header { min-height: var(--header-h); display: flex; align-items: center; }

/* Base hero fills the remaining viewport height, shows one full image */
.hero {
  position: relative;
  display: grid;
  place-items: center;
  text-align: center;
  color: #fff;
  /* Fill viewport minus header so the next section isn't visible initially */
  min-height: calc(100svh - var(--header-h));
  /* Single, non-repeating background */
  background-color: #000;
  background-image: url('lab-banner.webp');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

/* Keep text readable over any crop */
.hero h1, .hero p { color:#fff; text-shadow: 0 2px 8px rgba(0,0,0,.55); }
.hero-inner { width: min(680px, 90vw); padding: 56px 0; margin-inline:auto; z-index: 1; }

/* Phones: swap to cropped image that composes better in tall viewports */
@media (max-width: 680px) {
  .hero {
    background-image: url('lab_banner_mobile.webp'), url('lab-banner.webp'); /* fallback to desktop banner if cropped not found */
    background-position: center;
    background-size: cover;    /* still cover, no tiling */
  }
  .hero p {
    max-width: 30ch;           /* encourage ~2 lines */
    text-wrap: balance;
  }
}

/* Ensure the section after the hero starts cleanly */
section { scroll-margin-top: var(--header-h); }



/* =============================
   FINAL HERO CENTERING OVERRIDES
   (placed last so they always win)
   ============================= */

/* Full-screen hero remains */
.hero {
  position: relative;
  min-height: calc(100svh - var(--header-h));
  display: flex;
  flex-direction: column;
  justify-content: center;       /* vertical centering */
  align-items: center;           /* horizontal centering */
  text-align: center;
  color: #fff;
  background: #000 url('lab-banner.webp') center / cover no-repeat;
}

/* Mobile crop swap */
@media (max-width: 680px) {
  .hero {
    background-image: url('lab_banner_mobile.webp'), url('lab-banner.webp');
    background-position: center;
    background-size: cover;
  }
}

/* Force the inner wrapper to center its children */
.hero .hero-inner,
.hero > .container.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: min(680px, 90vw) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 0 !important;
  z-index: 1;
}

/* Center the title */
.hero .hero-inner h1 {
  margin: 0 0 .5rem !important;
  font-size: clamp(2rem, 4vw, 3.2rem);
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.55);
}

/* Critically: center the subtitle block and balance lines */
.hero .hero-inner p {
  margin: 0 0 1.25rem !important;
  max-width: 40ch;                /* wider cap to avoid lopsided look */
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: center !important;
  text-wrap: balance;
  font-size: clamp(1.05rem, 2.5vw, 1.6rem);
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.55);
}

/* On phones, slightly tighter line length for a neat two-line wrap */
@media (max-width: 680px) {
  .hero .hero-inner p { max-width: 34ch; }
}

/* CTA keeps centered row */
.hero .hero-inner .cta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Ensure the section after hero doesn't peek in initial viewport */
section { scroll-margin-top: var(--header-h); }
