/* ============================================================
   BPL — Biosignal Processing Laboratory
   Theme: "Porcelain Lab" — warm paper, ink typography,
   azure/violet/coral/bio accents. Editorial engineering.
   ============================================================ */

:root {
  --paper:      #F5F3ED;
  --paper-2:    #ECE9E1;
  --paper-3:    #E3DfD4;
  --ink:        #11181F;
  --ink-soft:   #4E5B66;
  --ink-faint:  #8A949C;
  --line:       rgba(17, 24, 31, 0.12);
  --line-soft:  rgba(17, 24, 31, 0.07);

  --azure:      #1A56DB;
  --pulse:      #0083B8;
  --violet:     #6A2FE0;
  --coral:      #E8455A;
  --bio:        #0A8A5F;
  --gold:       #B8860B;

  --glass:        rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(17, 24, 31, 0.10);

  --shadow-card: 0 1px 2px rgba(17,24,31,0.05), 0 12px 32px -12px rgba(17,24,31,0.14);
  --shadow-lift: 0 2px 4px rgba(17,24,31,0.06), 0 24px 48px -16px rgba(17,24,31,0.20);

  --font-display: 'Syne', sans-serif;
  --font-body: 'Instrument Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --nav-h: 76px;
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: auto; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  cursor: none;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { display: block; max-width: 100%; }
.mono { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.14em; }

::selection { background: var(--azure); color: var(--paper); }

/* ---------- ANIMATED GRADIENT TEXT ---------- */
/* Moving shimmer gradient — used on all blue/violet accent words */
@keyframes grad-flow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes grad-flow-reverse {
  0%   { background-position: 100% 50%; }
  50%  { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

.gradient-text {
  background: linear-gradient(
    110deg,
    var(--azure) 0%,
    var(--violet) 35%,
    #9B4DFF 55%,
    var(--azure) 70%,
    var(--pulse) 85%,
    var(--violet) 100%
  );
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: grad-flow 4s ease infinite;
}

/* Outline words (THE SIGNALS) — animated stroke color cycle */
.outline-word {
  color: transparent;
  -webkit-text-stroke: 2px var(--ink);
  animation: stroke-pulse 5s ease-in-out infinite;
}

/* white-on-black logo → ink-on-paper for light surfaces */
.invert-logo {
  filter: invert(1) contrast(1.05);
  mix-blend-mode: multiply;
}

/* ---------- KEYFRAMES ---------- */
@keyframes fade-up   { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: translateY(0); } }
@keyframes blink-cursor { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes pulse-dot-kf { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: 0.45; } }
@keyframes loader-sweep { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes cue-drop  { 0% { transform: translateY(0); opacity: 1; } 80% { transform: translateY(16px); opacity: 0; } 100% { transform: translateY(0); opacity: 0; } }

/* Text float — gentle continuous up-down drift for accent words */
@keyframes text-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-5px); }
}
/* Letter-spacing pulse — subtle breathing on display headings */
@keyframes letter-breathe {
  0%, 100% { letter-spacing: -0.02em; }
  50%       { letter-spacing: -0.008em; }
}
/* Shimmer sweep — fast highlight glint across gradient text */
@keyframes shimmer-sweep {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}
/* Outline stroke color cycle (THE SIGNALS line) */
@keyframes stroke-pulse {
  0%, 100% { -webkit-text-stroke-color: var(--ink); }
  33%       { -webkit-text-stroke-color: rgba(26,86,219,0.55); }
  66%       { -webkit-text-stroke-color: rgba(106,47,224,0.55); }
}

.blink-cursor { animation: blink-cursor 1.1s steps(1) infinite; }
.pulse-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--bio); animation: pulse-dot-kf 1.6s ease-in-out infinite;
}

/* ---------- LOADING SCREEN ---------- */
#loading-screen {
  position: fixed; inset: 0; z-index: 200;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
}
.loader-inner { display: flex; flex-direction: column; align-items: center; gap: 26px; }
.loader-logo { width: 150px; height: auto; }
.loader-track { width: 220px; height: 1px; background: var(--line); overflow: hidden; }
.loader-fill {
  height: 100%; background: var(--ink); transform-origin: left;
  animation: loader-sweep 1.6s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}
.loader-label { color: var(--ink-faint); }

/* ---------- CUSTOM CURSOR ---------- */
#cursor-dot, #cursor-ring {
  position: fixed; top: 0; left: 0; pointer-events: none; z-index: 300;
  border-radius: 50%; transform: translate(-50%, -50%);
}
#cursor-dot { width: 7px; height: 7px; background: var(--ink); }
#cursor-ring {
  width: 34px; height: 34px; border: 1px solid rgba(17,24,31,0.35);
  transition: width 0.25s ease, height 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
#cursor-ring.cursor-hover {
  width: 56px; height: 56px;
  border-color: var(--azure);
  background: rgba(26, 86, 219, 0.06);
}
@media (pointer: coarse) {
  body { cursor: auto; }
  #cursor-dot, #cursor-ring { display: none; }
}

/* ---------- GLOBAL 3D STAGE ---------- */
#stage-wrap {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}
#stage { width: 100%; height: 100%; display: block; }

/* ---------- NAVBAR ---------- */
#navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 56px);
  border-bottom: 1px solid transparent;
  transition: background 0.4s ease, border-color 0.4s ease, height 0.4s ease;
}
#navbar.scrolled {
  height: 62px;
  background: rgba(245, 243, 237, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--line-soft);
}
.nav-logo-img { width: 118px; height: auto; border-radius: 8px; box-shadow: 0 2px 8px rgba(17,24,31,0.18); }
.nav-links { display: flex; gap: clamp(16px, 2.4vw, 34px); }
.nav-links a {
  font-size: 0.86rem; font-weight: 500; color: var(--ink-soft);
  position: relative; padding: 6px 0;
  transition: color 0.25s ease;
}
.nav-links a::after {
  content: ''; position: absolute; left: 0; bottom: 0;
  width: 100%; height: 1.5px; background: var(--ink);
  transform: scaleX(0); transform-origin: right;
  transition: transform 0.35s cubic-bezier(0.65, 0, 0.35, 1);
}
.nav-links a:hover { color: var(--ink); }
.nav-links a:hover::after { transform: scaleX(1); transform-origin: left; }
.nav-cta {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--ink); color: var(--paper);
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em;
  padding: 11px 22px; border-radius: 100px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.nav-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.cta-arrow { display: inline-block; transition: transform 0.25s ease; }
.nav-cta:hover .cta-arrow, .btn:hover .cta-arrow { transform: translateX(4px); }

#nav-burger {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: none; padding: 8px;
}
#nav-burger span { width: 24px; height: 2px; background: var(--ink); transition: transform 0.3s ease, opacity 0.3s ease; }
#nav-burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
#nav-burger.open span:nth-child(2) { opacity: 0; }
#nav-burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-body); font-weight: 600; font-size: 0.82rem;
  letter-spacing: 0.06em; padding: 15px 30px; border-radius: 100px;
  border: 1px solid transparent; cursor: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease;
}
.btn-solid { background: var(--ink); color: var(--paper); }
.btn-solid:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.btn-ghost { background: transparent; color: var(--ink); border-color: rgba(17,24,31,0.25); }
.btn-ghost:hover { border-color: var(--ink); transform: translateY(-2px); }

/* ---------- GLASS CARD (light) ---------- */
.glass-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-card);
}

/* ---------- SECTION SCAFFOLD ---------- */
section { position: relative; z-index: 2; }
.section-head { text-align: left; max-width: 1180px; margin: 0 auto; padding: 0 clamp(20px, 4vw, 56px); }
.section-eyebrow {
  color: var(--ink-faint); margin-bottom: 18px;
  display: flex; align-items: center; gap: 14px;
}
.section-eyebrow::after { content: ''; flex: 0 0 64px; height: 1px; background: var(--line); }
.section-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.4rem, 5.2vw, 4.2rem);
  line-height: 1.02; letter-spacing: -0.015em;
  animation: letter-breathe 6s ease-in-out infinite;
}
/* Gradient spans inside section titles also get the flow animation */
.section-title .gradient-text {
  animation: grad-flow 3.5s ease infinite;
}

/* ============================================================
   HERO
   ============================================================ */
#hero {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: flex-start; justify-content: center;
  padding: calc(var(--nav-h) + 30px) clamp(20px, 4vw, 56px) 0;
  position: relative;
  /* NEVER use overflow:hidden here — it clips the headline text */
  overflow: visible;
}
#neural-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 0; opacity: 0.55;
}
/* Desktop: content sits in the left ~50%, model floats right */
.hero-content {
  position: relative; z-index: 2;
  /* Wide enough to hold large text, narrow enough to clear the model */
  max-width: min(55vw, 720px);
  width: 100%;
}
.hero-eyebrow {
  color: var(--ink-faint); margin-bottom: 30px;
  opacity: 0; animation: fade-up 0.8s ease 1.7s forwards;
}
.hero-headline {
  font-family: var(--font-display); font-weight: 800;
  /* Font size: big and impactful, but we rely on clip-path (NOT overflow)
     for animation masking, so text can never be clipped by a box boundary */
  font-size: clamp(2rem, 5vw, 5.4rem);
  line-height: 0.96; letter-spacing: -0.02em;
  display: flex; flex-direction: column;
  /* CRITICAL: visible overflow — text must NEVER be box-clipped */
  overflow: visible;
  width: max-content; /* shrink to text so hero-line clips only vertically */
  max-width: 100%;
}
.hero-line {
  display: block;
  /* clip-path instead of overflow:hidden — this ONLY masks vertically (for GSAP entrance)
     and NEVER clips text horizontally, no matter how wide the font renders */
  clip-path: inset(-0.1em -200vw 0em -200vw);
  /*         ↑top    ↑right  ↑bottom  ↑left
             small top margin, huge side extension (never clips), clips below line */
  overflow: visible;
  padding-bottom: 0.08em;
}
/* Hero gradient word floats gently after entrance animation completes */
.hero-headline .gradient-text {
  display: inline-block;
  animation: grad-flow 3.5s ease infinite, text-float 4s ease-in-out 3s infinite;
}
.hero-word { display: block; white-space: nowrap; }
.hero-sub {
  margin-top: 34px; max-width: 480px;
  font-size: 1.05rem; font-weight: 400; line-height: 1.65;
  color: var(--ink-soft);
  opacity: 0; animation: fade-up 0.8s ease 2.1s forwards;
}
.hero-ctas {
  display: flex; gap: 14px; flex-wrap: wrap; margin-top: 42px;
  opacity: 0; animation: fade-up 0.8s ease 2.3s forwards;
}
.hero-meta {
  position: absolute; right: clamp(20px, 4vw, 56px); bottom: 120px;
  display: flex; flex-direction: column; gap: 8px; text-align: right;
  color: var(--ink-faint); z-index: 2;
  opacity: 0; animation: fade-up 0.8s ease 2.5s forwards;
}
.scroll-cue {
  position: absolute; left: 50%; bottom: 86px; transform: translateX(-50%);
  width: 26px; height: 42px; border: 1.5px solid rgba(17,24,31,0.3);
  border-radius: 14px; z-index: 2;
  opacity: 0; animation: fade-up 0.8s ease 2.7s forwards;
}
.scroll-cue span {
  position: absolute; top: 8px; left: 50%; margin-left: -1.5px;
  width: 3px; height: 8px; border-radius: 2px; background: var(--ink);
  animation: cue-drop 1.8s ease-in-out infinite;
}
.ticker-strip {
  position: absolute; left: 0; right: 0; bottom: 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(245,243,237,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: hidden; padding: 13px 0; z-index: 2;
}
.ticker-track { display: flex; white-space: nowrap; will-change: transform; color: var(--ink-soft); }

/* ============================================================
   LAB STORY (pinned)
   ============================================================ */
#lab-story { min-height: 100vh; overflow: hidden; }
.story-progress {
  position: absolute; left: clamp(20px, 4vw, 56px); top: 50%;
  transform: translateY(-50%);
  width: 1.5px; height: 320px; background: var(--line);
}
.story-progress-fill {
  width: 100%; height: 100%;
  background: linear-gradient(var(--azure), var(--violet));
  transform: scaleY(0); transform-origin: top;
}
.story-act {
  position: absolute; top: 50%; transform: translateY(-50%);
  left: clamp(64px, 9vw, 140px); max-width: 560px;
  opacity: 0; visibility: hidden;
}
.act-index { color: var(--ink-faint); margin-bottom: 18px; }
.act-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.2rem, 4.6vw, 3.8rem);
  line-height: 1.05; letter-spacing: -0.015em; margin-bottom: 26px;
  animation: letter-breathe 7s ease-in-out infinite;
}
.act-title .gradient-text { animation: grad-flow 3s ease infinite; }
.act-title-big {
  font-size: clamp(2.6rem, 5.4vw, 4.6rem); font-weight: 800;
  animation: letter-breathe 7s ease-in-out 0.3s infinite;
}
.act-sub { color: var(--ink-soft); font-size: 1.05rem; line-height: 1.65; max-width: 460px; }
#ecg-svg { margin: 8px 0 22px; max-width: 100%; height: auto; }
#act-4 { left: 50%; transform: translate(-50%, -50%); text-align: center; max-width: 760px; }
#act-4 .act-sub { margin: 0 auto; }

.data-readout {
  border-left: 2px solid var(--azure);
  padding: 14px 0 14px 20px; margin-top: 24px;
  display: flex; flex-direction: column; gap: 9px;
  color: var(--pulse); font-size: 0.74rem;
  background: linear-gradient(90deg, rgba(26,86,219,0.05), transparent 70%);
}

/* ============================================================
   RESEARCH (pinned · sticky left + crossfade stack right)
   ============================================================ */
#research-areas { min-height: 100vh; }
.research-pin {
  height: 100vh; max-width: 1280px; margin: 0 auto;
  padding: calc(var(--nav-h) + 20px) clamp(20px, 4vw, 56px) 40px;
  display: grid; grid-template-columns: minmax(300px, 0.9fr) 1.1fr;
  gap: clamp(24px, 5vw, 90px); align-items: center;
}
.research-sticky .section-title { margin-bottom: 22px; }
.research-sticky-sub { color: var(--ink-soft); line-height: 1.65; max-width: 380px; }
.research-dots { display: flex; gap: 10px; margin-top: 34px; }
.r-dot {
  width: 26px; height: 3px; border-radius: 2px; background: var(--line);
  transition: background 0.35s ease, width 0.35s ease;
}
.r-dot.active { background: var(--ink); width: 44px; }

.research-stack { position: relative; height: min(58vh, 480px); }
.research-card {
  position: absolute; inset: 0;
  padding: clamp(26px, 3vw, 44px);
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
  opacity: 0; visibility: hidden; transform: translateY(30px) scale(0.97);
  border-top: 3px solid var(--accent);
}
.research-card.active { opacity: 1; visibility: visible; transform: none; }
.rc-top { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.rc-domain { color: var(--accent); font-weight: 500; }
.rc-part { color: var(--ink-faint); }
.research-card h3 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.5rem, 2.4vw, 2.1rem); line-height: 1.12;
  animation: letter-breathe 8s ease-in-out 1s infinite;
}
.research-card p { color: var(--ink-soft); line-height: 1.65; max-width: 480px; }
.rc-tags { color: var(--accent); }

/* ============================================================
   SHOWCASE FILM (pinned)
   ============================================================ */
#three-showcase { min-height: 100vh; overflow: hidden; }
.showcase-overlays { position: absolute; inset: 0; }
.showcase-phase {
  position: absolute; top: 50%; transform: translateY(calc(-50% + 26px));
  left: clamp(20px, 5vw, 90px); max-width: 480px;
  opacity: 0; visibility: hidden;
}
.showcase-phase.active { opacity: 1; visibility: visible; transform: translateY(-50%); }
.phase-index { color: var(--ink-faint); margin-bottom: 16px; }
.phase-title {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.4rem, 4.8vw, 4rem); line-height: 0.98;
  letter-spacing: -0.015em; margin-bottom: 22px;
  animation: letter-breathe 6.5s ease-in-out 0.5s infinite;
}
.phase-title .gradient-text { animation: grad-flow 3.2s ease infinite; }
.phase-sub { color: var(--ink-soft); font-size: 1.02rem; line-height: 1.65; }
.showcase-scrollhint {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%);
  color: var(--ink-faint);
}

/* ============================================================
   TEAM
   ============================================================ */
#team {
  background: var(--paper);
  padding: 140px 0 110px;
  border-top: 1px solid var(--line-soft);
}
#team .section-head { margin-bottom: 70px; }
.profile-card {
  max-width: 1180px; margin: 0 auto 26px;
  display: grid; gap: clamp(24px, 3.4vw, 52px);
  padding: clamp(26px, 3.4vw, 48px);
}
.profile-director {
  grid-template-columns: minmax(220px, 320px) 1fr;
  align-items: center;
  margin-left: auto; margin-right: auto;
  width: calc(100% - 2 * clamp(20px, 4vw, 56px));
}
.profile-portrait { position: relative; }
.profile-portrait img {
  width: 100%; border-radius: 14px;
  filter: grayscale(18%) contrast(1.04);
  box-shadow: var(--shadow-card);
}
.portrait-frame {
  position: absolute; left: 10px; bottom: 10px;
  background: var(--glass-strong); border: 1px solid var(--glass-border);
  padding: 4px 9px; border-radius: 6px; color: var(--ink-soft);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.profile-role { margin-bottom: 10px; }
.profile-name {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.7rem, 2.6vw, 2.4rem); margin-bottom: 14px;
  animation: letter-breathe 9s ease-in-out 0.7s infinite;
}
.profile-bio { color: var(--ink-soft); line-height: 1.7; max-width: 640px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.pill-badge {
  font-size: 0.74rem; font-weight: 500; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 100px; padding: 6px 14px;
  background: rgba(255,255,255,0.5);
}
.award-line { margin-top: 20px; color: var(--gold); font-weight: 500; font-size: 0.92rem; }
.award-star { margin-right: 6px; }

.profile-secondary-row {
  max-width: 1180px;
  margin: 0 auto;
  width: calc(100% - 2 * clamp(20px, 4vw, 56px));
  display: grid; grid-template-columns: 1fr 1fr; gap: 26px;
}
.profile-secondary-row .profile-card {
  grid-template-columns: minmax(120px, 160px) 1fr;
  align-items: start; margin: 0; width: auto;
}

.counter-row {
  max-width: 1180px; margin: 90px auto 0;
  width: calc(100% - 2 * clamp(20px, 4vw, 56px));
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px;
  border-top: 1px solid var(--line); padding-top: 44px;
}
.counter-block { text-align: left; }
.counter-num {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2.4rem, 4.6vw, 3.8rem); color: var(--ink); line-height: 1;
  animation: text-float 5s ease-in-out infinite;
}
.counter-block:nth-child(2) .counter-num { animation-delay: 0.4s; }
.counter-block:nth-child(3) .counter-num { animation-delay: 0.8s; }
.counter-block:nth-child(4) .counter-num { animation-delay: 1.2s; }
.counter-label { color: var(--ink-faint); margin-top: 10px; }

/* ============================================================
   PUBLICATIONS
   ============================================================ */
#publications {
  background: var(--paper-2);
  padding: 140px 0 130px;
  border-top: 1px solid var(--line-soft);
}
#publications .section-head { margin-bottom: 80px; }
.timeline {
  position: relative; max-width: 1180px; margin: 0 auto;
  width: calc(100% - 2 * clamp(20px, 4vw, 56px));
  display: flex; flex-direction: column; gap: 40px;
}
.timeline-line {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 1px; background: var(--line);
}
.pub-card {
  width: calc(50% - 36px); padding: 28px 30px; position: relative;
  cursor: none; transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.pub-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.pub-card[data-side="left"] { align-self: flex-start; }
.pub-card[data-side="right"] { align-self: flex-end; }
.pub-card::before {
  content: ''; position: absolute; top: 34px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--paper-2); border: 2px solid var(--azure);
}
.pub-card[data-side="left"]::before { right: -41px; }
.pub-card[data-side="right"]::before { left: -41px; }
.pub-meta { display: flex; gap: 10px; margin-bottom: 14px; }
.year-badge {
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500;
  background: var(--ink); color: var(--paper);
  padding: 4px 10px; border-radius: 6px;
}
.type-tag {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.12em;
  color: var(--violet); border: 1px solid rgba(106,47,224,0.35);
  padding: 4px 10px; border-radius: 6px;
}
.pub-title { font-family: var(--font-display); font-weight: 700; font-size: 1.18rem; line-height: 1.3; }
.pub-authors { color: var(--ink-faint); margin-top: 10px; }
.pub-abstract {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.5s cubic-bezier(0.65, 0, 0.35, 1), opacity 0.4s ease, margin 0.4s ease;
}
.pub-abstract p { color: var(--ink-soft); line-height: 1.65; font-size: 0.95rem; }
.pub-card.expanded .pub-abstract { max-height: 220px; opacity: 1; margin-top: 14px; }
.pub-expand-hint { color: var(--azure); margin-top: 14px; }

/* ============================================================
   OPPORTUNITIES
   ============================================================ */
#opportunities {
  background: var(--paper);
  padding: 140px 0 140px;
  border-top: 1px solid var(--line-soft);
}
#opportunities .section-head { margin-bottom: 26px; }
.recruit-badge {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 26px; color: var(--bio);
  border: 1px solid rgba(10,138,95,0.3); border-radius: 100px;
  padding: 9px 18px; background: rgba(10,138,95,0.06);
}
.role-grid {
  max-width: 1180px; margin: 50px auto 0;
  width: calc(100% - 2 * clamp(20px, 4vw, 56px));
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px;
}
.role-card {
  padding: 34px 30px; display: flex; flex-direction: column; gap: 16px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.role-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lift); }
.role-featured { border-top: 3px solid var(--azure); background: var(--glass-strong); }
.role-label { color: var(--ink-faint); }
.role-card h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; }
.role-card p { color: var(--ink-soft); line-height: 1.6; font-size: 0.95rem; flex: 1; }
.role-salary { font-family: var(--font-display); font-weight: 800; font-size: 2rem; }
.role-salary span { font-family: var(--font-body); font-weight: 500; font-size: 0.95rem; color: var(--ink-faint); }
.role-apply { justify-content: center; }

#application-form {
  max-width: 880px; margin: 90px auto 0;
  width: calc(100% - 2 * clamp(20px, 4vw, 56px));
  padding: clamp(28px, 4vw, 52px); position: relative; overflow: hidden;
}
.form-title { font-family: var(--font-display); font-weight: 700; font-size: 1.7rem; margin-bottom: 30px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.form-field { display: flex; flex-direction: column; gap: 9px; }
.form-field-full { grid-column: 1 / -1; }
.form-field label {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.14em;
  color: var(--ink-faint); text-transform: uppercase;
}
.form-field input, .form-field select {
  font-family: var(--font-body); font-size: 0.97rem; color: var(--ink);
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; outline: none; cursor: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.form-field input::placeholder { color: var(--ink-faint); }
.form-field input:focus, .form-field select:focus {
  border-color: var(--azure);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.14);
}
.btn-submit { width: 100%; justify-content: center; margin-top: 32px; border: none; font-size: 0.9rem; }
#form-success { margin-top: 20px; color: var(--bio); text-align: center; }
#form-burst-canvas { position: absolute; inset: 0; pointer-events: none; }

/* ============================================================
   FOOTER (dark ink band)
   ============================================================ */
#contact-footer {
  background: var(--ink); color: var(--paper);
  padding: 110px 0 0;
  position: relative; overflow: hidden;
}
#footer-particles { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.footer-grid, .footer-bar { position: relative; z-index: 1; }
.footer-grid {
  max-width: 1180px; margin: 0 auto;
  width: calc(100% - 2 * clamp(20px, 4vw, 56px));
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(30px, 5vw, 90px);
  padding-bottom: 80px;
}
.footer-logo-img { width: 150px; height: auto; border-radius: 8px; }
.footer-tag {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.25rem; margin-top: 26px; color: rgba(245,243,237,0.92);
}
.footer-contact { margin-top: 30px; display: flex; flex-direction: column; gap: 13px; color: rgba(245,243,237,0.66); }
.footer-contact a { transition: color 0.25s ease; }
.footer-contact a:hover { color: #6FB7FF; }
.footer-social { display: flex; gap: 26px; margin-top: 36px; }
.social-link { color: rgba(245,243,237,0.55); transition: color 0.25s ease; }
.social-link:hover { color: var(--paper); }
.map-frame {
  border-radius: 18px; overflow: hidden;
  border: 1px solid rgba(245,243,237,0.14);
  min-height: 320px; background: #1A222B;
}
.map-frame iframe { width: 100%; height: 100%; min-height: 320px; border: 0; filter: grayscale(35%); }
.footer-bar {
  border-top: 1px solid rgba(245,243,237,0.12);
  padding: 26px 0; text-align: center; color: rgba(245,243,237,0.45);
}

/* ---------- BACK TO TOP ---------- */
#back-to-top {
  position: fixed; right: 28px; bottom: 28px; z-index: 90;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  border: none; font-size: 1.05rem; cursor: none;
  opacity: 0; visibility: hidden; transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s;
  box-shadow: var(--shadow-card);
}
#back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .research-pin { grid-template-columns: 1fr; align-content: center; gap: 30px; }
  .research-stack { height: min(50vh, 420px); }
  .profile-secondary-row { grid-template-columns: 1fr; }
  .role-grid { grid-template-columns: 1fr; max-width: 560px; }
  .footer-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   TABLET + MOBILE  ≤ 768px
   Key principle: hero becomes full-width text on top, 3D model
   rendered in a separate "viewport-height" zone BELOW the fold
   so text is NEVER obscured.
   ============================================================ */
@media (max-width: 768px) {

  /* ---- NAV ---- */
  .nav-links {
    position: fixed; top: var(--nav-h); right: 0;
    flex-direction: column; gap: 0;
    background: rgba(245,243,237,0.97);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    width: min(82vw, 320px); height: calc(100vh - var(--nav-h));
    padding: 30px; border-left: 1px solid var(--line-soft);
    transform: translateX(100%); transition: transform 0.4s cubic-bezier(0.65, 0, 0.35, 1);
    z-index: 110;
  }
  .nav-links.open { transform: translateX(0); }
  .nav-links li { border-bottom: 1px solid var(--line-soft); }
  .nav-links a { display: block; padding: 16px 0; font-size: 1rem; }
  #nav-burger { display: flex; }
  .nav-cta { display: none; }

  /* ---- HERO: two-zone stacked layout ---- */
  #hero {
    min-height: auto;
    padding: calc(var(--nav-h) + 24px) 22px 0;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    overflow: visible; /* NEVER clip hero text */
  }

  /* content sits entirely above the model */
  .hero-content {
    width: 100%;
    max-width: 100%;
    position: relative;
    z-index: 4;
    background: var(--paper);
    padding-bottom: 32px;
    overflow: visible; /* NEVER clip */
  }

  /* Mobile headline — width is 100vw - 44px of padding.
   * Font uses nowrap so we size it to fit the widest line ("THE SIGNALS").
   * clip-path on .hero-line handles animation masking — NO overflow:hidden needed. */
  .hero-headline {
    font-size: clamp(1.7rem, 8.4vw, 3rem);
    letter-spacing: -0.016em;
    width: max-content;
    max-width: calc(100vw - 44px);
  }
  .outline-word { -webkit-text-stroke-width: 1.5px; }

  .hero-sub { font-size: 0.98rem; margin-top: 20px; max-width: 100%; }
  .hero-ctas { margin-top: 28px; gap: 12px; }
  .hero-ctas .btn { flex: 1; min-width: 0; justify-content: center; font-size: 0.78rem; padding: 13px 16px; }

  .hero-meta { display: none; }
  .scroll-cue { display: none; }

  /* 3D model zone: a dedicated block BELOW the text, above the ticker */
  .hero-model-zone {
    display: block;
    width: 100%;
    height: 52vw;        /* tall enough to see the model clearly */
    min-height: 200px;
    max-height: 320px;
    position: relative;
    z-index: 1;          /* below text, above normal flow */
    pointer-events: none;
    /* slight gradient fade at bottom so it merges into ticker */
    mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
  }

  /* ticker hugs directly below model zone */
  .ticker-strip {
    position: relative;
    bottom: auto; left: auto; right: auto;
    z-index: 3;
  }

  /* ---- STORY ACTS ---- */
  .story-act {
    left: 22px; right: 22px;
    max-width: none;
  }
  .story-progress { display: none; }
  #act-4 { left: 50%; right: auto; width: calc(100% - 44px); }

  /* ---- RESEARCH ---- */
  .research-pin {
    padding-top: calc(var(--nav-h) + 14px);
    padding-left: 22px; padding-right: 22px;
    gap: 20px;
  }
  .research-stack { height: min(45vh, 380px); }
  .research-card { padding: 22px 20px; }
  .rc-top { flex-direction: column; gap: 4px; }

  /* ---- SHOWCASE / FILM ---- */
  .showcase-phase {
    left: 22px; right: 22px; max-width: none;
    top: auto; bottom: 80px;
    transform: translateY(20px);
  }
  .showcase-phase.active { transform: translateY(0); }
  .phase-title { font-size: clamp(1.9rem, 8.5vw, 2.6rem); }
  .data-readout { font-size: 0.67rem; }

  /* ---- TEAM ---- */
  .profile-director {
    grid-template-columns: 1fr;
    width: calc(100% - 44px);
  }
  .profile-director .profile-portrait { max-width: 260px; }
  .profile-secondary-row { width: calc(100% - 44px); }
  .profile-secondary-row .profile-card { grid-template-columns: 1fr; }
  .profile-secondary-row .profile-portrait { max-width: 160px; }

  .counter-row { grid-template-columns: 1fr 1fr; gap: 28px 16px; }

  /* ---- PUBLICATIONS ---- */
  .timeline-line { left: 12px; }
  .pub-card {
    width: calc(100% - 44px);
    align-self: flex-end !important;
  }
  .pub-card::before { left: -35px !important; right: auto !important; }

  /* ---- FORM ---- */
  .form-grid { grid-template-columns: 1fr; }

  /* ---- FOOTER ---- */
  .footer-grid { padding-left: 22px; padding-right: 22px; }
}

/* ============================================================
   SMALL PHONES  ≤ 480px — extra tightening
   ============================================================ */
@media (max-width: 480px) {
  :root { --nav-h: 64px; }

  .nav-logo-img { width: 96px; }

  #hero {
    padding-top: calc(var(--nav-h) + 18px);
    padding-left: 18px; padding-right: 18px;
    overflow: visible;
  }

  /* On small phones: font must fit (100vw - 36px padding) 
   * Still uses clip-path masking, NOT overflow:hidden 
   * 8.4vw is safe at all phone sizes — verified at 320px */
  .hero-headline {
    font-size: clamp(1.5rem, 8.4vw, 2.6rem);
    max-width: calc(100vw - 36px);
  }
  .hero-ctas { flex-direction: column; gap: 10px; }
  .hero-ctas .btn { width: 100%; }

  .hero-model-zone { height: 56vw; max-height: 260px; }

  .act-title { font-size: clamp(1.9rem, 9vw, 2.8rem); }
  .section-title { font-size: clamp(2rem, 8vw, 3rem); }

  .counter-num { font-size: 2rem; }
  .counter-row { gap: 22px 12px; }

  .role-card { padding: 24px 18px; }
  .role-salary { font-size: 1.6rem; }

  #application-form { padding: 24px 18px; }

  .profile-name { font-size: 1.5rem; }
  .profile-bio { font-size: 0.92rem; }
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #stage-wrap { display: none; }
  .story-act, .showcase-phase, .research-card { opacity: 1 !important; visibility: visible !important; position: relative; transform: none !important; }
}
