/* ─── CUSTOM PROPERTIES ─── */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #818cf8;
  --accent-bright: #a78bfa;
  --success: #34d399;
  --highlight: #fbbf24;
  --border-subtle: rgba(129, 140, 248, 0.1);
  --border-hover: rgba(129, 140, 248, 0.3);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 12px;
  --container: 1140px;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  font-size: 16px;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-bright); }
img { max-width: 100%; display: block; }
ul { list-style: none; }
table { border-collapse: collapse; width: 100%; }

/* ─── UTILITIES ─── */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ─── NAV ─── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 1rem 0;
  transition: background 0.3s, backdrop-filter 0.3s, padding 0.3s;
}
.nav.scrolled {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.nav-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.nav-brand:hover { color: var(--accent-bright); }
.nav-links {
  display: flex;
  gap: 2rem;
}
.nav-links a {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--text-primary); }

/* Burger */
.nav-burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 28px;
  height: 20px;
  position: relative;
  z-index: 1001;
}
.nav-burger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-secondary);
  position: absolute;
  left: 0;
  transition: transform 0.3s, opacity 0.3s;
}
.nav-burger span:nth-child(1) { top: 0; }
.nav-burger span:nth-child(2) { top: 9px; }
.nav-burger span:nth-child(3) { top: 18px; }
.nav-burger.open span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.nav-burger.open span:nth-child(2) { opacity: 0; }
.nav-burger.open span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

/* ─── HERO ─── */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10rem 1.5rem 6rem;
  overflow: hidden;
}
.particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.hero .particle-canvas {
  pointer-events: auto;
}
.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 800px;
}
.hero-overtitle {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--accent);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.hero-title {
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 0.75rem;
}
.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 1.5rem;
}
.hero-tagline {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 3rem;
}
.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  font-weight: 500;
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  transition: background 0.2s, border-color 0.2s;
}
.hero-cta:hover {
  background: rgba(129, 140, 248, 0.08);
  border-color: var(--accent);
  color: var(--accent-bright);
}
.cta-arrow { font-size: 1.2rem; }

/* ─── EQUATION (inline only) ─── */
.eq-op { color: var(--text-muted); padding: 0 0.1em; }
.eq-bracket { color: var(--text-muted); }

/* ─── SECTIONS ─── */
.section {
  position: relative;
  overflow: hidden;
}
.section--about { padding: 6rem 0 5rem; }
.section--research { padding: 7rem 0 6rem; }
.section--apps { padding: 6rem 0 5rem; }
.section--results { padding: 8rem 0 6rem; }
.section--projects { padding: 6rem 0 5rem; }
.section--infra { padding: 5rem 0 4rem; }

.section--research,
.section--results {
  background: var(--bg-secondary);
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 1rem;
}
.section-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  margin-bottom: 3rem;
  letter-spacing: -0.01em;
}

/* ─── ABOUT ─── */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
}
.about-text h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  font-weight: 700;
  margin-bottom: 1.5rem;
  line-height: 1.3;
}
.about-text p {
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  font-size: 1rem;
}
.about-diagram {
  text-align: center;
}
#phase-diagram {
  width: 100%;
  max-width: 500px;
  height: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.5);
}
.diagram-caption {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

/* ─── CARDS ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 2rem;
  transition: border-color 0.3s, transform 0.3s;
}
.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}
.card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}
.card p:last-child { margin-bottom: 0; }
.card-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.card--link {
  display: block;
  position: relative;
}
.card--link:hover { color: var(--text-primary); }
.card-arrow {
  position: absolute;
  top: 2rem;
  right: 2rem;
  font-size: 1.25rem;
  color: var(--accent);
  transition: transform 0.2s;
}
.card--link:hover .card-arrow { transform: translateX(4px); }

/* Constants grid inside card */
.constants-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.25rem;
}
.const-item {
  text-align: center;
  padding: 0.75rem;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 8px;
  border: 1px solid rgba(129, 140, 248, 0.06);
}
.const-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--accent-bright);
}
.const-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Equation inline */
.eq-inline {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--accent);
  padding: 1rem;
  background: rgba(15, 23, 42, 0.5);
  border-radius: 8px;
  border: 1px solid rgba(129, 140, 248, 0.08);
  margin: 1rem 0;
  text-align: center;
  overflow-x: auto;
}

/* Pattern list */
.pattern-list li {
  padding: 0.4rem 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.pattern-list li strong {
  color: var(--accent-bright);
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ─── GRIDS ─── */
.research-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.apps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

/* ─── COUNTERS ─── */
.counters-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 4rem;
}
.counter-card {
  text-align: center;
  padding: 2rem 1rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}
.counter-card .counter-value,
.counter-card .counter-suffix,
.counter-card .counter-prefix {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  color: var(--accent-bright);
}
.counter-card .counter-suffix {
  color: var(--accent);
  font-weight: 500;
}
.counter-card .counter-prefix {
  color: var(--accent);
  font-weight: 500;
}
.counter-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ─── RESULTS TABLE ─── */
.results-table-wrap {
  max-width: 700px;
  margin: 0 auto;
}
.results-table-wrap h3 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}
.results-table {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}
.results-table th,
.results-table td {
  padding: 0.9rem 1.25rem;
  text-align: left;
  font-size: 0.9rem;
}
.results-table th {
  background: rgba(129, 140, 248, 0.06);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.results-table td {
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.results-table .highlight-row td {
  background: rgba(129, 140, 248, 0.04);
}
.highlight-cell {
  color: var(--success) !important;
  font-weight: 700;
  font-family: var(--font-mono);
}
.table-callout {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--highlight);
  margin-top: 1.25rem;
  text-align: center;
}

/* ─── INFRASTRUCTURE ─── */
.infra-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.5rem;
}
.infra-item {
  text-align: center;
  padding: 2rem 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}
.infra-item:hover { border-color: var(--border-hover); }
.infra-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}
.infra-unit {
  display: block;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
  margin-top: 0.1rem;
}
.infra-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ─── FOOTER ─── */
.footer {
  padding: 3rem 0;
  border-top: 1px solid var(--border-subtle);
}
.footer-inner {
  text-align: center;
}
.footer-copy {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.footer-powered {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.footer-powered a {
  color: var(--accent);
}
.footer-powered a:hover {
  color: var(--accent-bright);
  text-decoration: underline;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 1199px) {
  .research-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 899px) {
  .nav-burger { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-direction: column;
    padding: 1rem 1.5rem 1.5rem;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
  }
  .nav-links.open { display: flex; }
  .nav-links li { padding: 0.6rem 0; }
  .nav-links a { font-size: 1rem; }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
  .research-grid { grid-template-columns: 1fr; }
  .apps-grid { grid-template-columns: 1fr; }
  .projects-grid { grid-template-columns: 1fr; }
  .counters-grid { grid-template-columns: repeat(2, 1fr); }
  .infra-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-inner {
    text-align: center;
  }
}

@media (max-width: 639px) {
  .hero { padding: 8rem 1rem 4rem; }
  .section--about { padding: 4rem 0 3rem; }
  .section--research { padding: 5rem 0 4rem; }
  .section--apps { padding: 4rem 0 3rem; }
  .section--results { padding: 5rem 0 4rem; }
  .section--projects { padding: 4rem 0 3rem; }
  .section--infra { padding: 3rem 0 3rem; }

  .counters-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .infra-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
}
