/* ========================================
   FIRMATA PROTOCOL — CINEMATIC LANDING
   ======================================== */

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

:root {
  --bg: #0a0a0a;
  --white: #f0f0f0;
  --white-dim: rgba(240, 240, 240, 0.5);
  --white-faint: rgba(240, 240, 240, 0.18);
  --white-ghost: rgba(240, 240, 240, 0.08);
  --gold: #c8a44e;
  --gold-hover: #d4b362;
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-sans);
  font-weight: 300;
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ========================================
   FILM GRAIN OVERLAY
   ======================================== */

.grain {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
}

.grain::before {
  content: '';
  position: absolute;
  inset: -200%;
  width: 400%;
  height: 400%;
  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.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  animation: grain-shift 0.5s steps(4) infinite;
}

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-5%, -5%); }
  50%  { transform: translate(5%, 2%); }
  75%  { transform: translate(-2%, 5%); }
  100% { transform: translate(3%, -3%); }
}

/* ========================================
   PRELOADER
   ======================================== */

#preloader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s var(--ease-out);
}

#preloader.fade-out {
  opacity: 0;
  pointer-events: none;
}

#halftone-logo {
  width: 120px;
  height: 120px;
}

/* ========================================
   PARTICLE FIELD (THREE.JS CANVAS)
   ======================================== */

#particle-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#hero-terrain {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ========================================
   SECTIONS BASE
   ======================================== */

.section {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========================================
   HERO
   ======================================== */

.section-hero {
  flex-direction: column;
  padding: 0 clamp(24px, 5vw, 80px);
}

.hero-logo {
  position: fixed;
  top: 32px;
  left: clamp(24px, 5vw, 48px);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--white);
  opacity: 0;
  animation: fade-in-up 0.8s var(--ease-out) 1.8s forwards;
}

.hero-logo svg {
  opacity: 0.7;
}

.hero-content {
  text-align: center;
  max-width: 900px;
  opacity: 0;
  animation: fade-in-up 1s var(--ease-out) 1.6s forwards;
}

.hero-headline {
  font-size: clamp(36px, 8vw, 96px);
  font-weight: 300;
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin-bottom: 32px;
}

.hero-line {
  display: block;
}

.hero-sub {
  font-family: var(--font-mono);
  font-size: clamp(12px, 1.6vw, 15px);
  color: var(--white-dim);
  max-width: 600px;
  margin: 0 auto 48px;
  line-height: 1.7;
  min-height: 2.6em; /* prevent layout shift */
}

.hero-sub .cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.7s steps(1) infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ========================================
   BUTTONS
   ======================================== */

.hero-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 32px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.06em;
  border-radius: 4px;
  cursor: pointer;
  transition: background 180ms var(--ease-out),
              color 180ms var(--ease-out),
              border-color 180ms var(--ease-out),
              transform 180ms var(--ease-out),
              box-shadow 180ms var(--ease-out);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gold);
  color: #0a0a0a;
  border: 1px solid var(--gold);
}

.btn-primary:hover {
  background: var(--gold-hover);
  border-color: var(--gold-hover);
  box-shadow: 0 0 30px rgba(200, 164, 78, 0.15);
}

.btn-ghost {
  background: transparent;
  color: var(--white);
  border: 1px solid var(--white-faint);
}

.btn-ghost:hover {
  border-color: var(--white-dim);
  background: var(--white-ghost);
}

/* Disabled buttons — Coming soon */
.btn-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  position: relative;
}

.btn-disabled:hover {
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.btn-disabled.btn-primary:hover {
  background: var(--gold);
  border-color: var(--gold);
}

.btn-disabled::after {
  content: 'Coming soon';
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(20, 20, 20, 0.95);
  color: var(--white-dim);
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--white-ghost);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}

.btn-disabled:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.footer-disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.footer-disabled:hover {
  color: var(--white-dim) !important;
}

/* ========================================
   STATS SECTION
   ======================================== */

.section-stats {
  background: var(--bg);
  flex-direction: column;
  padding: clamp(80px, 10vh, 160px) clamp(24px, 5vw, 80px);
}

.stats-inner {
  text-align: center;
  max-width: 800px;
}

.section-title {
  font-size: clamp(32px, 6vw, 72px);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 64px;
}

.stats-row {
  display: flex;
  justify-content: center;
  gap: clamp(24px, 5vw, 64px);
  flex-wrap: wrap;
  margin-bottom: 48px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--white);
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--white-dim);
}

.stats-desc {
  font-size: clamp(14px, 1.6vw, 16px);
  color: var(--white-dim);
  line-height: 1.8;
  max-width: 560px;
  margin: 0 auto;
}

/* Meridian Pay settlement badge — subtle pill below stats */
.meridian-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 32px;
  padding: 5px 12px;
  border: 1px solid rgba(200, 164, 78, 0.18);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: rgba(200, 164, 78, 0.45);
  text-transform: uppercase;
  pointer-events: none;
  user-select: none;
}

.meridian-badge-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(200, 164, 78, 0.5);
  flex-shrink: 0;
}

/* ========================================
   LIFECYCLE SECTION
   ======================================== */

.section-lifecycle {
  flex-direction: column;
  padding: clamp(80px, 10vh, 160px) clamp(24px, 5vw, 80px);
  background: var(--bg);
}

.lifecycle-inner {
  max-width: 680px;
  width: 100%;
}

.lifecycle-inner .section-title {
  text-align: center;
  margin-bottom: 80px;
}

.lifecycle-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: clamp(16px, 3vw, 32px);
  padding: 32px 0;
  position: relative;
}

.step-num {
  font-family: var(--font-mono);
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 400;
  color: var(--white-ghost);
  line-height: 1;
  min-width: 72px;
  flex-shrink: 0;
  text-align: right;
}

.step-line {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--white-ghost);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.8s var(--ease-out);
}

.step.is-visible .step-line {
  transform: scaleX(1);
}

.step-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
}

.step-verb {
  font-family: var(--font-sans);
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--white);
}

.step-desc {
  font-size: clamp(13px, 1.5vw, 15px);
  color: var(--white-dim);
  line-height: 1.6;
}

/* ========================================
   DIFFERENTIATORS
   ======================================== */

.section-diff {
  flex-direction: column;
  padding: clamp(60px, 8vh, 120px) clamp(24px, 5vw, 80px);
  min-height: auto;
  background: var(--bg);
}

.diff-inner {
  max-width: 1100px;
  width: 100%;
}

.diff-inner .section-title {
  text-align: center;
  margin-bottom: 64px;
}

.diff-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.diff-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--white-ghost);
  border-radius: 8px;
  padding: clamp(28px, 3vw, 40px);
  transition: border-color 300ms var(--ease-out),
              box-shadow 300ms var(--ease-out);
}

.diff-card:hover {
  border-color: rgba(240, 240, 240, 0.15);
  box-shadow: 0 0 40px rgba(240, 240, 240, 0.03);
}

.diff-card-title {
  font-size: clamp(16px, 1.8vw, 19px);
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.diff-card-desc {
  font-size: clamp(13px, 1.4vw, 15px);
  color: var(--white-dim);
  line-height: 1.7;
}

/* ========================================
   CLOSING CTA
   ======================================== */

.section-closing {
  position: relative;
  flex-direction: column;
  padding: clamp(80px, 10vh, 160px) clamp(24px, 5vw, 80px);
  overflow: hidden;
}

#terrain-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.closing-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.closing-headline {
  font-size: clamp(32px, 7vw, 80px);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 48px;
}

/* ========================================
   FOOTER
   ======================================== */

.footer {
  position: relative;
  z-index: 1;
  background: var(--bg);
  border-top: 1px solid var(--white-ghost);
  padding: 32px clamp(24px, 5vw, 48px);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--white-dim);
}

.footer-left svg {
  opacity: 0.5;
}

.footer-right {
  display: flex;
  gap: 24px;
}

.footer-right a {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--white-dim);
  transition: color 180ms var(--ease-out);
}

.footer-right a:hover {
  color: var(--white);
}

/* Meridian Finance footer link — slightly warmer on hover */
.footer-meridian {
  opacity: 0.55;
}

.footer-meridian:hover {
  color: var(--gold) !important;
  opacity: 1;
}



/* ========================================
   SCROLL REVEAL ANIMATIONS
   ======================================== */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s var(--ease-out),
              transform 0.8s var(--ease-out);
}

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

.reveal[data-delay="1"] { transition-delay: 0.15s; }
.reveal[data-delay="2"] { transition-delay: 0.3s; }
.reveal[data-delay="3"] { transition-delay: 0.45s; }

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .diff-cards {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }

  .step-num {
    min-width: 48px;
  }

  .hero-logo {
    position: absolute;
    top: 24px;
    left: 24px;
  }

  .hide-mobile {
    display: none;
  }

  .hero-headline {
    margin-top: 40px;
  }
}

@media (max-width: 480px) {
  .hero-buttons {
    flex-direction: column;
    align-items: center;
  }

  .btn {
    width: 100%;
    max-width: 240px;
  }
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .grain::before {
    animation: none;
  }

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

  .hero-content,
  .hero-logo {
    opacity: 1;
    animation: none;
  }
}
