/* ============================================================
   BrainLM Project Page
   Extends the site design system
   ============================================================ */

:root {
  /* Light base shared with main site */
  --bg-primary: #fafaf8;
  --bg-secondary: #f3f3fb;
  --bg-tertiary: #ecebfd;
  --bg-card: rgba(0, 0, 0, 0.03);
  --bg-card-hover: rgba(0, 0, 0, 0.05);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.16);
  --text-primary: #151526;
  --text-secondary: #52526d;
  --text-tertiary: #8a8aa3;

  /* BrainLM-specific accents (indigo / violet) */
  --accent-coral: #5046e5;
  --accent-coral-light: #7c73f0;
  --accent-teal: #6f8fc0;
  --accent-teal-light: #9bb1de;
  --accent-gold: #d4a05e;
  --accent-gradient: linear-gradient(135deg, #5046e5, #7c73f0);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --nav-height: 72px;
  --section-padding: 100px;
  --container-width: 1100px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 17px;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
a { color: var(--accent-coral); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-coral-light); }
img { max-width: 100%; height: auto; display: block; }
strong { color: var(--accent-coral); font-weight: 600; }
code { font-family: var(--font-mono); font-size: 0.88em; background: rgba(0,0,0,0.04); padding: 2px 6px; border-radius: 4px; }

.container { max-width: var(--container-width); margin: 0 auto; padding: 0 40px; }

/* ---- TYPOGRAPHY ---- */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.15; letter-spacing: -0.03em; }
h1 { font-size: clamp(2.8rem, 5.5vw, 4.2rem); }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.6rem); }
h3 { font-size: clamp(1.15rem, 2vw, 1.4rem); }
h4 { font-size: 1.1rem; }

.section-label {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--accent-coral);
  margin-bottom: 16px; display: inline-flex; align-items: center; gap: 12px;
}
.section-label::before { content: ''; display: block; width: 24px; height: 1px; background: var(--accent-coral); }
.section-title { margin-bottom: 20px; }
.section-subtitle { color: var(--text-secondary); font-size: 1.1rem; max-width: 640px; line-height: 1.75; }

/* ---- NAVIGATION ---- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  z-index: 1000;
  background: rgba(250, 250, 248, 0.96);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
.nav__inner {
  max-width: var(--container-width); margin: 0 auto; padding: 0 40px;
  height: 100%; display: flex; align-items: center; justify-content: space-between;
}
.nav__logo { font-weight: 700; font-size: 1.05rem; color: var(--text-primary); letter-spacing: -0.01em; }
.nav__logo:hover { color: var(--text-primary); }
.nav__menu { display: flex; align-items: center; gap: 28px; list-style: none; }
.nav__link { font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); transition: color var(--transition); padding: 4px 0; }
.nav__link:hover { color: var(--text-primary); }
.nav__toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 4px; }
.nav__toggle span { display: block; width: 24px; height: 2px; background: var(--text-primary); border-radius: 1px; transition: transform var(--transition), opacity var(--transition); }
.nav__toggle--open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle--open span:nth-child(2) { opacity: 0; }
.nav__toggle--open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- HERO ---- */
.brainlm-hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding-top: var(--nav-height);
  position: relative;
  overflow: hidden;
}
.brainlm-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 75% 55% at 80% 0%, rgba(80, 70, 229, 0.20) 0%, transparent 65%),
    radial-gradient(ellipse 55% 60% at 0% 90%, rgba(124, 115, 240, 0.14) 0%, transparent 70%);
  pointer-events: none;
}
.brainlm-hero__inner {
  display: grid; grid-template-columns: 1fr 400px; gap: 60px; align-items: center;
  position: relative; z-index: 1;
}
.brainlm-hero__content { max-width: 600px; }
.brainlm-hero__title {
  font-size: clamp(3.5rem, 7vw, 5.5rem); font-weight: 800; line-height: 1;
  letter-spacing: -0.04em; margin-bottom: 16px;
  background: var(--accent-gradient); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text;
}
.brainlm-hero__subtitle {
  font-size: clamp(1rem, 1.8vw, 1.25rem); font-weight: 500;
  color: var(--text-secondary); line-height: 1.5; margin-bottom: 20px;
}
.brainlm-hero__desc {
  font-size: 1.05rem; color: var(--text-secondary); line-height: 1.7; margin-bottom: 28px;
}
.brainlm-hero__desc strong { color: var(--accent-teal-light); }
.brainlm-hero__authors {
  display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px;
}
.brainlm-hero__author {
  font-size: 0.9rem; color: var(--text-secondary);
}
.brainlm-hero__author strong { color: var(--text-primary); }
.brainlm-hero__affiliation {
  font-size: 0.82rem; color: var(--text-tertiary); margin-bottom: 32px;
}
.brainlm-hero__actions { display: flex; gap: 16px; flex-wrap: wrap; }

.brainlm-hero__graphic {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-sans);
  font-size: 0.9rem; font-weight: 600; padding: 12px 28px; border-radius: 10px;
  border: none; cursor: pointer; transition: all var(--transition); text-decoration: none;
}
.btn--primary { background: var(--accent-coral); color: #fff; }
.btn--primary:hover { background: var(--accent-coral-light); color: #fff; transform: translateY(-2px); box-shadow: 0 8px 24px rgba(224,107,94,0.25); }
.btn--outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-subtle); }
.btn--outline:hover { border-color: var(--text-primary); color: var(--text-primary); transform: translateY(-2px); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---- TOC BAR ---- */
.toc-bar {
  position: sticky; top: var(--nav-height); z-index: 900;
  background: rgba(15, 20, 36, 0.92); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle); padding: 0;
}
.toc-bar__inner {
  display: flex; gap: 32px; overflow-x: auto; padding: 14px 0;
  scrollbar-width: none;
}
.toc-bar__inner::-webkit-scrollbar { display: none; }
.toc-bar__link {
  font-size: 0.8rem; font-weight: 500; color: var(--text-tertiary);
  white-space: nowrap; transition: color var(--transition);
}
.toc-bar__link:hover { color: var(--text-primary); }

/* ---- SECTIONS ---- */
.section { padding: var(--section-padding) 0; position: relative; }
.section--alt { background: var(--bg-secondary); }
.section__header { margin-bottom: 56px; }

/* ---- PROSE ---- */
.prose { max-width: 760px; }
.prose p { margin-bottom: 20px; color: var(--text-secondary); font-size: 1.05rem; line-height: 1.8; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--accent-coral-light); }

/* ---- DATA CARDS ---- */
.data-overview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-bottom: 56px; }
.data-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 16px;
  padding: 32px 28px; transition: all var(--transition);
}
.data-card:hover { background: var(--bg-card-hover); border-color: var(--border-hover); transform: translateY(-4px); }
.data-card__icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}
.data-card__icon svg { width: 24px; height: 24px; }
.data-card__icon--coral { background: rgba(224,107,94,0.1); }
.data-card__icon--coral svg { color: var(--accent-coral); }
.data-card__icon--teal { background: rgba(94,184,212,0.1); }
.data-card__icon--teal svg { color: var(--accent-teal); }
.data-card__icon--gold { background: rgba(212,160,94,0.1); }
.data-card__icon--gold svg { color: var(--accent-gold); }
.data-card__title { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.data-card__value { font-size: 1.3rem; font-weight: 700; color: var(--accent-teal); margin-bottom: 10px; }
.data-card__desc { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.6; }

.data-format { margin-top: 20px; }
.data-format h3 { margin-bottom: 12px; }
.data-format p { color: var(--text-secondary); margin-bottom: 16px; }

/* ---- CODE BLOCKS ---- */
.code-block {
  background: var(--bg-tertiary); border: 1px solid var(--border-subtle); border-radius: 12px;
  overflow-x: auto; margin-top: 16px;
}
.code-block pre { padding: 24px; margin: 0; }
.code-block code {
  font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.7;
  color: var(--text-secondary); background: none; padding: 0;
}
.code-block--cite { border-color: rgba(94,184,212,0.2); }

/* ---- TOKEN COMPARISON ---- */
.token-comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-bottom: 56px; }
.token-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 16px;
  overflow: hidden; transition: all var(--transition);
}
.token-card:hover { border-color: var(--border-hover); }
.token-card__header {
  padding: 24px 28px 20px; border-bottom: 1px solid var(--border-subtle);
}
.token-card__header h3 { font-size: 1.1rem; margin-top: 8px; }
.token-card__header--coral { background: rgba(224,107,94,0.04); }
.token-card__header--teal { background: rgba(94,184,212,0.04); }
.token-card__badge {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 12px; border-radius: 100px; display: inline-block;
}
.token-card__header--coral .token-card__badge { background: rgba(224,107,94,0.15); color: var(--accent-coral); }
.token-card__header--teal .token-card__badge { background: rgba(94,184,212,0.15); color: var(--accent-teal); }
.token-card__body { padding: 24px 28px; }
.token-card__body p { color: var(--text-secondary); font-size: 0.92rem; line-height: 1.65; margin-bottom: 20px; }
.token-card__detail {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0; border-top: 1px solid var(--border-subtle);
}
.token-card__label { font-size: 0.82rem; color: var(--text-tertiary); font-weight: 500; }
.token-card__formula { font-family: var(--font-mono); font-size: 0.82rem; color: var(--accent-teal); }

.token-order { margin-top: 20px; }
.token-order h3 { margin-bottom: 8px; }
.token-order p { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 20px; }
.token-order__visual {
  background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 12px;
  padding: 28px; overflow-x: auto; min-height: 100px;
}

/* ---- ARCHITECTURE TABS ---- */
.arch-tabs { display: flex; gap: 12px; margin-bottom: 32px; }
.arch-tab {
  display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-sans);
  font-size: 0.92rem; font-weight: 600; padding: 12px 24px; border-radius: 10px;
  border: 1px solid var(--border-subtle); background: transparent; color: var(--text-secondary);
  cursor: pointer; transition: all var(--transition);
}
.arch-tab:hover { border-color: var(--border-hover); color: var(--text-primary); }
.arch-tab--active { background: rgba(224,107,94,0.1); border-color: var(--accent-coral); color: var(--accent-coral); }
.arch-tab__num {
  width: 24px; height: 24px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; background: rgba(255,255,255,0.06);
}
.arch-tab--active .arch-tab__num { background: var(--accent-coral); color: #fff; }

.arch-panel { display: none; }
.arch-panel--active { display: block; }

.arch-diagram { margin-bottom: 40px; overflow-x: auto; }
.arch-svg { width: 100%; height: auto; }
.arch-node__box {
  fill: rgba(255,255,255,0.04); stroke: rgba(255,255,255,0.12); stroke-width: 1.5;
  transition: all 0.3s;
}
.arch-node__box--input { fill: rgba(94,184,212,0.08); stroke: rgba(94,184,212,0.3); }
.arch-node__box--output { fill: rgba(224,107,94,0.08); stroke: rgba(224,107,94,0.3); }
.arch-node__box--main { fill: rgba(212,160,94,0.06); stroke: rgba(212,160,94,0.25); }
.arch-node__box--mask { fill: rgba(224,107,94,0.06); stroke: rgba(224,107,94,0.2); }
.arch-node__title { fill: var(--text-primary); font-size: 13px; font-weight: 700; text-anchor: middle; font-family: var(--font-sans); }
.arch-node__sub { fill: var(--text-secondary); font-size: 10.5px; text-anchor: middle; font-family: var(--font-sans); }
.arch-node__sub--accent { fill: var(--accent-teal); font-weight: 600; }
.arch-arrow { stroke: rgba(255,255,255,0.2); stroke-width: 1.5; }
.arch-arrow--dashed { stroke-dasharray: 4 3; }
.arch-arrow-head { fill: rgba(255,255,255,0.2); }
.arch-note { fill: rgba(94,184,212,0.05); stroke: rgba(94,184,212,0.15); stroke-width: 1; }
.arch-note__text { fill: var(--accent-teal); font-size: 11.5px; font-weight: 600; text-anchor: middle; font-family: var(--font-sans); }
.arch-note__sub { fill: var(--text-secondary); font-size: 10px; text-anchor: middle; font-family: var(--font-sans); }

.arch-details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.arch-detail {
  padding: 24px; background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 14px; transition: all var(--transition);
}
.arch-detail:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.arch-detail h4 { font-size: 0.95rem; margin-bottom: 10px; color: var(--accent-coral-light); }
.arch-detail p { font-size: 0.88rem; color: var(--text-secondary); line-height: 1.65; }

/* ---- DEMO BLOCKS ---- */
.demo-block {
  background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 18px;
  padding: 40px; margin-bottom: 48px;
}
.demo-block:last-child { margin-bottom: 0; }
.demo-block__header { margin-bottom: 24px; }
.demo-block__header h3 { margin-bottom: 8px; }
.demo-block__header p { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.65; }

.demo-block__controls { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; align-items: center; }
.demo-btn {
  font-family: var(--font-sans); font-size: 0.82rem; font-weight: 600;
  padding: 8px 20px; border-radius: 8px; border: none; cursor: pointer;
  background: var(--accent-coral); color: #fff; transition: all var(--transition);
}
.demo-btn:hover { background: var(--accent-coral-light); transform: translateY(-1px); }
.demo-btn--outline { background: transparent; border: 1px solid var(--border-subtle); color: var(--text-secondary); }
.demo-btn--outline:hover { border-color: var(--text-primary); color: var(--text-primary); background: transparent; }
.demo-btn--teal { background: var(--accent-teal); }
.demo-btn--teal:hover { background: var(--accent-teal-light); }

.demo-label { font-size: 0.82rem; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.demo-label select {
  font-family: var(--font-mono); font-size: 0.82rem; padding: 6px 12px; border-radius: 6px;
  background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-subtle);
}

.demo-block__canvas-wrap { position: relative; }
#masking-canvas { width: 100%; max-width: 700px; height: auto; border-radius: 8px; }
.demo-block__labels { position: absolute; left: -10px; top: 50%; transform: rotate(-90deg) translateX(-50%); transform-origin: left center; }
.demo-block__label-y { font-size: 0.72rem; color: var(--text-tertiary); letter-spacing: 0.1em; text-transform: uppercase; }
.demo-block__legend { display: flex; gap: 20px; margin-top: 16px; justify-content: center; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-secondary); }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; }
.legend-swatch--signal { background: var(--accent-teal); }
.legend-swatch--masked { background: rgba(255,255,255,0.1); border: 1px dashed rgba(255,255,255,0.3); }
.legend-swatch--recon { background: var(--accent-coral); }

.demo-block__viz-wrap { position: relative; overflow-x: auto; }

/* Attention heatmap */
.attn-tooltip {
  position: fixed; pointer-events: none; z-index: 1100;
  background: rgba(15, 20, 36, 0.95); border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 10px 14px; font-size: 0.78rem; color: var(--text-primary);
  opacity: 0; transition: opacity 0.15s;
  backdrop-filter: blur(8px);
}
.attn-tooltip.visible { opacity: 1; }

/* ---- USAGE STEPS ---- */
.usage-steps { margin-bottom: 56px; }
.usage-step { display: flex; gap: 28px; margin-bottom: 40px; }
.usage-step:last-child { margin-bottom: 0; }
.usage-step__num {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px;
  background: rgba(224,107,94,0.1); color: var(--accent-coral); font-weight: 700;
  font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
}
.usage-step__content h3 { margin-bottom: 8px; }
.usage-step__content p { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.65; }

.usage-config h3 { margin-bottom: 20px; }
.config-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.config-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: 10px; transition: all var(--transition);
}
.config-item:hover { border-color: var(--border-hover); }
.config-item__key { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-secondary); }
.config-item__val { font-family: var(--font-mono); font-size: 0.82rem; color: var(--accent-teal); font-weight: 500; }

/* ---- CITATION ---- */
.citation-block__note { color: var(--text-secondary); font-size: 1rem; margin-bottom: 20px; }
.citation-block .demo-btn { margin-top: 16px; }

/* ---- FOOTER ---- */
.footer {
  background: var(--bg-secondary); border-top: 1px solid var(--border-subtle); padding: 64px 0 40px;
}
.footer__inner { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 40px; }
.footer__info h4 { font-size: 1rem; margin-bottom: 8px; }
.footer__info p { color: var(--text-secondary); font-size: 0.88rem; line-height: 1.7; }
.footer__links { display: flex; gap: 24px; }
.footer__link { color: var(--text-secondary); font-size: 0.86rem; font-weight: 500; transition: color var(--transition); }
.footer__link:hover { color: var(--text-primary); }
.footer__bottom { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border-subtle); text-align: center; color: var(--text-tertiary); font-size: 0.8rem; }

/* ---- FADE-IN ---- */
.fade-in { opacity: 0; transform: translateY(24px); transition: opacity 0.8s ease, transform 0.8s ease; }
.fade-in--visible { opacity: 1; transform: translateY(0); }

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  :root { --section-padding: 80px; }
  .container { padding: 0 32px; }
  .brainlm-hero__inner { grid-template-columns: 1fr 320px; gap: 40px; }
  .data-overview { grid-template-columns: 1fr 1fr; }
  .arch-details { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --section-padding: 64px; }
  .container { padding: 0 20px; }
  .nav__inner { padding: 0 20px; }
  .nav__menu {
    position: fixed; top: 0; right: 0; width: 280px; height: 100vh;
    background: rgba(15, 20, 36, 0.98); backdrop-filter: blur(20px);
    flex-direction: column; justify-content: center; align-items: center; gap: 24px;
    transform: translateX(100%); transition: transform var(--transition);
    border-left: 1px solid var(--border-subtle);
  }
  .nav__menu--open { transform: translateX(0); }
  .nav__toggle { display: flex; }
  .nav__link { font-size: 1.1rem; }
  .brainlm-hero { min-height: auto; padding-top: calc(var(--nav-height) + 40px); padding-bottom: 60px; }
  .brainlm-hero__inner { grid-template-columns: 1fr; gap: 40px; }
  .brainlm-hero__graphic { max-width: 300px; margin: 0 auto; }
  .data-overview { grid-template-columns: 1fr; }
  .token-comparison { grid-template-columns: 1fr; }
  .arch-tabs { flex-direction: column; }
  .arch-details { grid-template-columns: 1fr; }
  .demo-block { padding: 24px; }
  .usage-step { flex-direction: column; gap: 16px; }
  .config-grid { grid-template-columns: 1fr; }
  .footer__inner { flex-direction: column; }
}

@media (max-width: 480px) {
  .brainlm-hero__actions { flex-direction: column; }
  .btn { justify-content: center; }
}
