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

:root {
  --bg: #050508;
  --bg-card: rgb(255 255 255 / 3%);
  --border: rgb(255 255 255 / 6%);
  --border-hover: rgb(255 255 255 / 12%);
  --text: #f0f0f2;
  --text-sec: #b0b0be;
  --text-dim: #7a7a8e;
  --accent: #e63226;
  --accent2: #ff4136;
  --magenta: #c2185b;
  --orange: #ff6d3a;
  --indigo: #6366f1;
  --cyan: #06b6d4;
  --green: #22c55e;
  --font: 'Sora', sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --text-xs: clamp(0.6rem, 0.55rem + 0.25vw, 0.75rem);
  --text-sm: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-base: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-lg: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1rem + 1vw, 1.75rem);
  --text-2xl: clamp(1.75rem, 1.2rem + 2.5vw, 3rem);
  --text-3xl: clamp(2.5rem, 1.5rem + 4vw, 4.5rem);
  --space-xs: clamp(8px, 1vw, 12px);
  --space-sm: clamp(16px, 2vw, 24px);
  --space-md: clamp(32px, 4vw, 48px);
  --space-lg: clamp(48px, 6vw, 80px);
  --space-xl: clamp(80px, 10vw, 140px);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- GRAIN --- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
  animation: grainShift 0.5s steps(4) infinite;
}

@keyframes grainShift {
  0% {
    transform: translate(0, 0);
  }

  25% {
    transform: translate(-2px, 2px);
  }

  50% {
    transform: translate(2px, -2px);
  }

  75% {
    transform: translate(-2px, -2px);
  }

  100% {
    transform: translate(2px, 2px);
  }
}

/* --- PAGE ENTER --- */
.page-curtain {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10000;
  pointer-events: none;
  animation: curtainLift 1s ease 0.2s forwards;
}

@keyframes curtainLift {
  to {
    opacity: 0;
  }
}

/* --- BACKGROUND --- */
.bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-gradient {
  position: absolute;
  inset: -50%;
  background:
    radial-gradient(ellipse 80% 60% at 20% 40%, rgb(198 24 60 / 6%) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 20%, rgb(230 50 38 / 4%) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 60% 80%, rgb(255 109 58 / 3%) 0%, transparent 50%);
  animation: bgShift 25s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  33% {
    transform: translate(3%, -2%) rotate(1deg) scale(1.02);
  }

  66% {
    transform: translate(-2%, 3%) rotate(-0.5deg) scale(0.98);
  }

  100% {
    transform: translate(1%, -1%) rotate(0.5deg) scale(1.01);
  }
}

/* --- NAV --- */
.labs-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 24px 40px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(to bottom, rgb(5 5 8) 0%, rgb(5 5 8 / 90%) 70%, transparent 100%);
}

.nav-wordmark {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 35%);
  text-decoration: none;
  transition:
    color 0.3s ease,
    text-shadow 0.3s ease;
}

.nav-wordmark:hover {
  color: rgb(255 255 255 / 60%);
  text-shadow: 0 0 20px rgb(230 50 38 / 30%);
}

.nav-sep {
  width: 1px;
  height: 14px;
  background: rgb(255 255 255 / 12%);
}

.nav-label {
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.nav-tab {
  font-family: var(--mono);
  font-size: clamp(0.6rem, 0.55rem + 0.25vw, 0.75rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgb(122 122 142);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid transparent;
  transition:
    color 0.3s ease,
    border-color 0.3s ease;
}

.nav-tab:hover {
  color: rgb(176 176 190);
  border-color: rgb(255 255 255 / 6%);
}

/* --- LAUNCH BUTTON --- */
.launch-btn {
  margin-left: auto;
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  padding: 8px 18px;
  border-radius: 100px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition:
    color 0.3s ease,
    border-color 0.3s ease;
  flex-shrink: 0;
}

.launch-btn:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.launch-btn i {
  width: 14px;
  height: 14px;
}

/* --- LAYOUT --- */
main {
  position: relative;
  z-index: 2;
}

.labs-hero {
  min-height: 40vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: var(--space-xl) var(--space-sm) var(--space-lg);
}

.hero-tabs {
  display: none;
}

.tab-sep {
  width: 1px;
  height: 12px;
  background: rgb(255 255 255 / 10%);
  flex-shrink: 0;
}

/* --- MINI TABS (mobile scroll) --- */
.nav-mini-tabs {
  display: none;
  margin-left: auto;
  gap: 6px;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.nav-mini-tabs.visible {
  opacity: 1;
  pointer-events: auto;
}

.mini-tab {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.mini-tab:hover {
  color: var(--text-sec);
  border-color: var(--border);
}

.labs-title {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  background: linear-gradient(180deg, var(--text) 0%, var(--text-sec) 100%);
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.labs-subtitle {
  margin-top: var(--space-xs);
  font-size: var(--text-lg);
  color: var(--text-dim);
  max-width: 680px;
  line-height: 1.5;
}

/* --- SECTION DIVIDER --- */
.section-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgb(230 50 38 / 12%), transparent);
  position: relative;
}

.section-divider::after {
  content: '';
  position: absolute;
  inset: -15px 0;
  background: linear-gradient(90deg, transparent, rgb(230 50 38 / 3%), transparent);
  filter: blur(10px);
}

/* --- PROJECT SECTION --- */
.project-section {
  padding: var(--space-lg) var(--space-sm);
  max-width: 1200px;
  margin: 0 auto;
}

.project-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: var(--space-md);
}

.project-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.project-icon i {
  width: 24px;
  height: 24px;
}

.project-icon--courtview {
  background: rgb(6 182 212 / 10%);
  border: 1px solid rgb(6 182 212 / 20%);
  color: var(--cyan);
}

.project-icon--reforge {
  background: rgb(255 109 58 / 10%);
  border: 1px solid rgb(255 109 58 / 20%);
  color: var(--orange);
}

.project-icon--signal {
  background: rgb(99 102 241 / 10%);
  border: 1px solid rgb(99 102 241 / 20%);
  color: var(--indigo);
}

.project-icon--tesseract {
  background: rgb(194 24 91 / 10%);
  border: 1px solid rgb(194 24 91 / 20%);
  color: var(--magenta);
}

.project-name {
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.project-tagline {
  font-size: var(--text-base);
  color: var(--text-sec);
  margin-top: 2px;
}

/* --- CAPABILITY PILLS --- */
.capabilities {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-sm);
}

.cap-pill {
  font-family: var(--mono);
  font-size: var(--text-xs);
  padding: 6px 14px;
  border-radius: 100px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-sec);
  letter-spacing: 0.02em;
}

/* --- SPEC GRID --- */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: var(--space-md);
}

.spec-card {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.3s ease;
}

.spec-card:hover {
  border-color: var(--border-hover);
}

.spec-label {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.spec-value {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text);
}

/* --- 3D EMBED --- */
.model-embed {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #050508;
  position: relative;
}

.model-embed iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* --- INTERACT GATE --- */
.interact-gate {
  position: absolute;
  inset: 0;
  z-index: 10;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
  border-radius: inherit;
}

.interact-gate::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgb(5 5 8 / 40%);
  border-radius: inherit;
  transition: opacity 0.3s ease;
}

.interact-gate-label {
  position: relative;
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--text-dim);
  background: rgb(5 5 8 / 80%);
  padding: 8px 20px;
  border-radius: 100px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  transition:
    border-color 0.3s ease,
    color 0.3s ease;
}

.interact-gate:hover .interact-gate-label {
  border-color: var(--border-hover);
  color: var(--text-sec);
}

.interact-gate.hidden {
  opacity: 0;
  pointer-events: none;
}

.model-embed--compact {
  aspect-ratio: 4 / 3;
  max-width: 700px;
  margin: 0 auto;
}

/* --- REFORGE PIPELINE SVG --- */
.pipeline-visual {
  padding: var(--space-sm) 0;
}

.pipeline-visual svg {
  width: 100%;
  height: auto;
  display: block;
}

.pipeline-horizontal {
  display: block;
}

.pipeline-vertical {
  display: none;
  max-width: 400px;
  margin: 0 auto;
}

/* --- SVG ANIMATIONS --- */
@keyframes drawLine {
  from {
    stroke-dashoffset: 1;
  }

  to {
    stroke-dashoffset: 0;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 0.8;
  }
}

@keyframes scanPulse {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }

  50% {
    opacity: 0.6;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}

@keyframes dotStream {
  0% {
    offset-distance: 0%;
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    offset-distance: 100%;
    opacity: 0;
  }
}

@keyframes meshBuild {
  from {
    stroke-dashoffset: 200;
  }

  to {
    stroke-dashoffset: 0;
  }
}

@keyframes floatUp {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }

  50% {
    transform: translateY(-4px);
    opacity: 0.8;
  }
}

@keyframes cloudBreathe {
  0%,
  100% {
    transform: translateX(-3px);
  }

  50% {
    transform: translateX(3px);
  }
}

@keyframes vertexPulse {
  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

@keyframes labelCycle {
  0%,
  20% {
    opacity: 0.4;
  }

  30%,
  50% {
    opacity: 1;
  }

  60%,
  100% {
    opacity: 0.4;
  }
}

@keyframes driftDot {
  0%,
  100% {
    transform: translate(0, 0);
  }

  25% {
    transform: translate(2px, -2px);
  }

  50% {
    transform: translate(-1px, 2px);
  }

  75% {
    transform: translate(1px, -1px);
  }
}

.cloud-shape {
  animation: cloudBreathe 3s ease-in-out infinite;
  transform-origin: center;
}

.upload-arrow {
  animation: floatUp 2s ease-in-out infinite;
}

.mesh-vertex {
  animation: vertexPulse 2s ease-in-out infinite;
}

.mesh-vertex:nth-child(2n) {
  animation-delay: 0.3s;
}

.mesh-vertex:nth-child(3n) {
  animation-delay: 0.6s;
}

.scatter-dot {
  animation: driftDot 3s ease-in-out infinite;
}

.lidar-dot {
  animation: lidarPulse 3s ease-in-out infinite;
}

@keyframes lidarPulse {
  0%,
  100% {
    opacity: 0.3;
  }

  50% {
    opacity: 0.7;
  }
}

.scatter-dot:nth-child(2n) {
  animation-delay: 0.5s;
}

.scatter-dot:nth-child(3n) {
  animation-delay: 1s;
}

.format-label-1 {
  animation: labelCycle 3s ease-in-out infinite;
}

.format-label-2 {
  animation: labelCycle 3s ease-in-out infinite 1s;
}

.pipeline-stage {
  opacity: 0;
  animation: fadeIn 0.6s var(--ease) forwards;
}

.pipeline-stage:nth-child(1) {
  animation-delay: 0.1s;
}

.pipeline-stage:nth-child(2) {
  animation-delay: 0.3s;
}

.pipeline-stage:nth-child(3) {
  animation-delay: 0.5s;
}

.pipeline-stage:nth-child(4) {
  animation-delay: 0.7s;
}

.connector-line {
  stroke-dasharray: 6 4;
  animation: drawLine 1.5s ease forwards;
}

.scan-ring {
  animation: ringShimmer 4s ease-in-out infinite;
}

.scan-ring:nth-child(2) {
  animation-delay: 1.3s;
}

.scan-ring:nth-child(3) {
  animation-delay: 2.6s;
}

@keyframes ringShimmer {
  0%,
  100% {
    opacity: 0.15;
  }

  50% {
    opacity: 0.35;
  }
}

.lidar-core {
  animation: coreGlow 2.5s ease-in-out infinite;
}

@keyframes coreGlow {
  0%,
  100% {
    opacity: 0.25;
  }

  50% {
    opacity: 0.5;
  }
}

/* --- SCROLL REVEAL --- */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity 0.9s var(--ease),
    transform 0.9s var(--ease);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- BACK LINK --- */
.labs-footer {
  text-align: center;
  padding: var(--space-sm) var(--space-sm) var(--space-lg);
}

.back-link {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--text-dim);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 0.3s ease;
}

.back-link:hover {
  color: var(--text);
}

.back-link i {
  width: 16px;
  height: 16px;
}

/* --- RESPONSIVE --- */
@media (width <= 768px) {
  .labs-nav {
    padding: 16px 20px;
  }

  .nav-tabs {
    display: none;
  }

  .nav-mini-tabs {
    display: flex;
  }

  .labs-hero {
    min-height: 30vh;
    padding-top: 60px;
    justify-content: flex-start;
  }

  .hero-tabs {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-bottom: 0;
    flex-wrap: nowrap;
  }

  .labs-title {
    margin-top: 60px;
  }

  .hero-tabs .nav-tab {
    font-family: var(--mono);
    font-size: clamp(0.6rem, 0.55rem + 0.25vw, 0.75rem);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgb(122 122 142);
    text-decoration: none;
    padding: 5px 4px;
    border-radius: 100px;
    border: 1px solid transparent;
  }

  .hero-tabs .nav-tab:hover {
    color: rgb(176 176 190);
    border-color: rgb(255 255 255 / 6%);
  }

  .project-header {
    gap: 12px;
    align-items: flex-start;
  }

  .project-tagline {
    font-size: 0.7rem;
  }

  .launch-btn {
    margin-left: auto;
    flex-shrink: 0;
    padding: 6px 14px;
    font-size: 0.6rem;
    margin-top: 4px;
  }

  .spec-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .model-embed {
    aspect-ratio: 4 / 3;
  }

  .pipeline-horizontal {
    display: none;
  }

  .pipeline-vertical {
    display: block;
  }

  .capabilities {
    gap: 6px;
  }

  .cap-pill {
    font-size: 0.55rem;
    padding: 3px 8px;
  }
}

@media (width <= 480px) {
  .spec-grid {
    grid-template-columns: 1fr;
  }

  .labs-title {
    font-size: clamp(1.8rem, 1.2rem + 3vw, 2.5rem);
  }

  .model-embed {
    aspect-ratio: 1 / 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grain {
    animation: none;
  }

  .bg-gradient {
    animation: none;
  }

  .page-curtain {
    animation: none;
    opacity: 0;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  .pipeline-stage {
    opacity: 1;
    animation: none;
  }

  .scan-ring {
    animation: none;
    opacity: 0.4;
  }

  .connector-line {
    animation: none;
  }
}
