/* ═══════════════════════════════════════════
   NIO AUTOMATION — Apple-Style Dark Website
   ═══════════════════════════════════════════ */

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

:root {
  --bg:       #1a1a1e;
  --bg2:      #212126;
  --bg3:      #28282e;
  --text:     #f4f1ec;
  --muted:    #aaaaaa;
  --dim:      #555560;
  --border:   #333338;
  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
}

html { scroll-behavior: auto; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── LOADER ────────────────────────────────── */
#loader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
}
.loader-brand {
  font-family: var(--font-display); font-weight: 900;
  font-size: 2.5rem; letter-spacing: 0.25em; color: var(--text);
}
#loader-bar {
  width: 220px; height: 1px; background: var(--border); overflow: hidden;
}
#loader-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--dim), var(--text));
  transition: width 0.08s linear;
}
#loader-percent {
  font-size: 0.72rem; letter-spacing: 0.15em; color: var(--muted);
  font-family: var(--font-display);
}
#loader.hidden {
  opacity: 0; pointer-events: none;
  transition: opacity 0.8s ease;
}

/* ── NAV ────────────────────────────────────── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  padding: 22px 52px;
  display: flex; align-items: center;
  transition: background 0.5s, border-color 0.5s, backdrop-filter 0.5s;
  border-bottom: 1px solid transparent;
}
.site-header.scrolled {
  background: rgba(15,15,18,0.88);
  border-bottom-color: var(--border);
  backdrop-filter: blur(24px);
}
nav { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.logo {
  font-family: var(--font-display); font-weight: 900;
  font-size: 1rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text); text-decoration: none;
}
.logo span { color: var(--dim); }
.nav-links { display: flex; gap: 36px; }
.nav-links a {
  font-size: 0.8rem; color: var(--muted); text-decoration: none;
  letter-spacing: 0.06em; transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }
.nav-cta {
  font-size: 0.78rem; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--bg); background: var(--text);
  padding: 10px 24px; border-radius: 2px; text-decoration: none;
  transition: opacity 0.2s;
}
.nav-cta:hover { opacity: 0.85; }

/* ── HERO STANDALONE ─────────────────────────── */
.hero-standalone {
  position: relative; z-index: 10;
  min-height: 100vh;
  display: flex; align-items: flex-end;
  padding: 0 52px 88px;
  background: var(--bg);
  overflow: hidden;
}
/* radial gradient to give depth */
.hero-standalone::after {
  content: '';
  position: absolute; inset: 0; z-index: 0;
  background: radial-gradient(ellipse 80% 60% at 70% 40%, rgba(255,255,255,0.02) 0%, transparent 70%);
  pointer-events: none;
}
.hero-content {
  position: relative; z-index: 2;
  max-width: 880px;
}

.section-label {
  display: block;
  font-size: 0.68rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 22px;
}

.hero-heading {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(4rem, 10vw, 11rem);
  line-height: 0.92; letter-spacing: -0.04em;
  color: var(--text); margin-bottom: 36px;
}
.hero-heading .word { display: inline-block; margin-right: 0.12em; }
.hero-heading .dim  { color: var(--dim); }

.hero-tagline {
  font-size: 1.1rem; color: var(--muted); font-weight: 300;
  line-height: 1.75; max-width: 420px; margin-bottom: 44px;
}

.hero-actions { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.btn-primary {
  font-size: 0.82rem; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--bg); background: var(--text);
  padding: 14px 32px; border-radius: 2px; text-decoration: none;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-ghost {
  font-size: 0.85rem; color: var(--muted); letter-spacing: 0.04em;
  text-decoration: none; transition: color 0.2s;
}
.btn-ghost:hover { color: var(--text); }

.hero-scroll-indicator {
  position: absolute; right: 52px; bottom: 52px; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.scroll-line {
  width: 1px; height: 56px;
  background: linear-gradient(to bottom, var(--muted), transparent);
}
.hero-scroll-indicator span {
  font-size: 0.6rem; letter-spacing: 0.22em; color: var(--muted);
  text-transform: uppercase; writing-mode: vertical-rl;
}

/* ── CANVAS ──────────────────────────────────── */
.canvas-wrap {
  position: fixed; inset: 0; z-index: 1;
  clip-path: circle(0% at 50% 50%);
  will-change: clip-path;
}
canvas { width: 100%; height: 100%; display: block; }

/* ── DARK OVERLAY ────────────────────────────── */
#dark-overlay {
  position: fixed; inset: 0; z-index: 2;
  background: rgba(20,20,24,0.91);
  opacity: 0; pointer-events: none;
  will-change: opacity;
}

/* ── MARQUEE ─────────────────────────────────── */
.marquee-wrap {
  position: fixed; z-index: 3;
  bottom: 8%; left: 0; right: 0;
  overflow: hidden; opacity: 0;
  pointer-events: none;
  will-change: opacity;
}
.marquee-text {
  white-space: nowrap;
  font-family: var(--font-display); font-weight: 900;
  font-size: 11vw; letter-spacing: -0.03em;
  color: rgba(242,239,233,0.05);
  text-transform: uppercase;
  will-change: transform;
}

/* ── SCROLL CONTAINER ────────────────────────── */
#scroll-container {
  position: relative; z-index: 4;
  height: 900vh;
}

/* ── SCROLL SECTIONS ─────────────────────────── */
.scroll-section {
  position: absolute; left: 0; right: 0;
  display: flex; align-items: center;
  pointer-events: none; opacity: 0;
  will-change: opacity, transform;
  min-height: 100vh;
}

/* TEXT SCRIM — solid dark background on the text side so it's
   always readable regardless of what the video shows */
.align-left {
  padding: 0 55vw 0 52px;
  background: linear-gradient(90deg, rgba(22,22,26,0.97) 44%, transparent 64%);
}
.align-right {
  padding: 0 52px 0 55vw;
  background: linear-gradient(270deg, rgba(22,22,26,0.97) 44%, transparent 64%);
}
.align-left .section-inner,
.align-right .section-inner {
  max-width: 40vw;
}
.section-inner { display: flex; flex-direction: column; }

.section-heading {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(2.6rem, 4.8vw, 5.2rem);
  line-height: 1.0; letter-spacing: -0.035em;
  color: var(--text); margin: 14px 0 20px;
}
.section-body {
  font-size: 1.05rem; color: var(--muted); font-weight: 300;
  line-height: 1.8; max-width: 380px;
}
.section-note {
  font-family: var(--font-display); font-weight: 700;
  font-size: 2rem; color: var(--text);
  letter-spacing: -0.02em; margin-top: 28px;
}

/* ── STATS SECTION ───────────────────────────── */
.section-stats {
  justify-content: center; align-items: center;
  padding: 0 52px;
}
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--border);
  width: 100%; max-width: 1060px; margin: 0 auto;
  /* Stats have their own overlay so need readable bg */
}
.stat {
  background: rgba(22,22,26,0.97);
  padding: 52px 36px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-number {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(3rem, 5.5vw, 6rem);
  line-height: 1; letter-spacing: -0.04em; color: var(--text);
}
.stat-suffix {
  font-family: var(--font-display); font-weight: 700;
  font-size: 2rem; color: var(--dim); letter-spacing: -0.03em;
}
.stat-label {
  font-size: 0.8rem; color: var(--muted); font-weight: 300;
  line-height: 1.4; margin-top: 10px; letter-spacing: 0.02em;
}

/* ── DEMO SECTION ────────────────────────────── */
.section-demo.align-left .section-inner {
  max-width: 42vw;
}

.chat-window {
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; margin-top: 28px;
  background: var(--bg2);
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
}
.chat-header {
  background: var(--bg3); border-bottom: 1px solid var(--border);
  padding: 14px 20px; display: flex; align-items: center; gap: 10px;
}
.chat-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #1a4a1a;
  box-shadow: 0 0 8px rgba(0, 220, 80, 0.5);
  animation: pulse-green 2s infinite;
}
@keyframes pulse-green { 0%,100%{opacity:1} 50%{opacity:0.3} }
.chat-title { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.08em; }

.chat-body {
  padding: 20px; display: flex; flex-direction: column;
  gap: 10px; min-height: 160px; max-height: 280px; overflow-y: auto;
}
.msg {
  font-size: 0.9rem; line-height: 1.6; padding: 12px 15px;
  border-radius: 6px; max-width: 88%;
}
.msg-user  { background: var(--bg3); color: var(--muted); align-self: flex-end;  border: 1px solid var(--border); }
.msg-agent { background: var(--bg);  color: var(--text);  align-self: flex-start; border: 1px solid var(--border); }

.msg-typing {
  display: inline-flex; gap: 5px; align-items: center;
  padding: 14px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; align-self: flex-start;
}
.typing-dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--dim);
  animation: typing-blink 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-blink { 0%,80%,100%{opacity:0.15} 40%{opacity:1} }

.chat-input-row {
  border-top: 1px solid var(--border); padding: 12px 20px;
  display: flex; gap: 12px; align-items: center; background: var(--bg3);
}
.chat-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 0.9rem; color: var(--text); font-family: var(--font-body);
  pointer-events: all;
}
.chat-input::placeholder { color: var(--dim); }
.chat-send {
  font-size: 0.78rem; letter-spacing: 0.08em; color: var(--muted);
  background: var(--bg2); border: 1px solid var(--border);
  padding: 8px 16px; border-radius: 3px; cursor: pointer;
  font-family: var(--font-body); transition: all 0.2s; pointer-events: all;
}
.chat-send:hover { color: var(--text); border-color: var(--muted); }

/* ── CTA SECTION ─────────────────────────────── */
.section-cta {
  justify-content: center;
  background: rgba(20,20,24,0.97);
  backdrop-filter: blur(8px);
}
.cta-inner {
  max-width: 640px; margin: 0 auto;
  text-align: center; align-items: center; gap: 0;
  padding: 60px 40px;
  background: rgba(26,26,30,0.98);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 40px 120px rgba(0,0,0,0.8);
}
.cta-inner .section-heading {
  font-size: clamp(3.5rem, 8vw, 8rem);
  margin: 14px 0 20px;
}
.cta-inner .section-body {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 100%;
}
.cta-button {
  display: inline-block; margin-top: 36px;
  font-size: 0.9rem; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: #000; background: #ffffff;
  padding: 18px 52px; border-radius: 4px; text-decoration: none;
  transition: background 0.2s, transform 0.2s;
  box-shadow: 0 8px 32px rgba(255,255,255,0.15);
}
.cta-button:hover {
  background: #e8e4df;
  transform: translateY(-2px);
}
.cta-sub {
  font-size: 0.8rem; color: var(--dim);
  margin-top: 20px; letter-spacing: 0.08em;
}

/* ── ACTIVE POINTER EVENTS ───────────────────── */
.scroll-section.active { pointer-events: all; }

/* ── TABLET (≤ 1024px) ───────────────────────── */
@media (max-width: 1024px) {
  .align-left  { padding-right: 48vw; }
  .align-right { padding-left:  48vw; }
  .align-left .section-inner,
  .align-right .section-inner { max-width: 44vw; }

  .section-heading { font-size: clamp(2.2rem, 4vw, 3.8rem); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 36px 24px; }
  .stat-number { font-size: clamp(2.8rem, 5vw, 4.5rem); }
}

/* ── MOBILE (≤ 768px) ────────────────────────── */
@media (max-width: 768px) {

  /* NAV */
  .site-header { padding: 16px 20px; }
  .nav-links { display: none; }
  .nav-cta { font-size: 0.72rem; padding: 8px 16px; }

  /* HERO */
  .hero-standalone { padding: 80px 20px 60px; align-items: flex-end; }
  .hero-heading { font-size: clamp(2.8rem, 12vw, 4.5rem); margin-bottom: 20px; }
  .hero-tagline { font-size: 0.92rem; max-width: 100%; margin-bottom: 28px; }
  .hero-actions { flex-direction: column; align-items: flex-start; gap: 14px; }
  .btn-primary, .btn-ghost { font-size: 0.8rem; }
  .hero-scroll-indicator { display: none; }

  /* SCROLL CONTAINER */
  #scroll-container { height: 700vh; }

  /* KEY MOBILE FIX: sections sit at BOTTOM of viewport so video
     is visible in the top portion of the screen */
  .scroll-section {
    padding: 0;
    align-items: flex-end; /* anchor text to bottom */
  }

  /* Text block: bottom overlay, semi-transparent so video shows above */
  .align-left, .align-right {
    padding: 28px 20px 36px;
    background: linear-gradient(
      to top,
      rgba(18,18,22,0.97) 60%,
      rgba(18,18,22,0.7) 85%,
      transparent 100%
    );
    align-items: flex-end;
  }
  .align-left .section-inner,
  .align-right .section-inner,
  .section-demo.align-left .section-inner { max-width: 100%; }

  .section-label { font-size: 0.62rem; margin-bottom: 12px; }
  .section-heading { font-size: clamp(1.9rem, 8.5vw, 3rem); margin: 8px 0 12px; }
  .section-body { font-size: 0.93rem; max-width: 100%; }
  .section-note { font-size: 1.4rem; }

  /* STATS — stays centered, semi-transparent bg */
  .section-stats {
    padding: 0 16px;
    align-items: center;
    background: linear-gradient(
      to bottom,
      transparent 0%,
      rgba(18,18,22,0.88) 20%,
      rgba(18,18,22,0.92) 80%,
      transparent 100%
    );
  }
  .stats-grid { grid-template-columns: repeat(2, 1fr); max-width: 100%; }
  .stat { background: rgba(18,18,22,0.92); padding: 24px 16px; }
  .stat-number { font-size: clamp(2.2rem, 9vw, 3.2rem); }
  .stat-suffix { font-size: 1.3rem; }
  .stat-label { font-size: 0.72rem; }

  /* MARQUEE */
  .marquee-wrap { bottom: 2%; }
  .marquee-text { font-size: 20vw; }

  /* DEMO */
  .section-demo.align-left {
    background: linear-gradient(
      to top,
      rgba(18,18,22,0.98) 70%,
      rgba(18,18,22,0.7) 90%,
      transparent 100%
    );
  }
  .chat-window { margin-top: 16px; }
  .chat-body { min-height: 110px; }
  .msg { font-size: 0.83rem; }

  /* CTA */
  .section-cta {
    padding: 0 16px;
    background: rgba(18,18,22,0.97);
  }
  .cta-inner { padding: 36px 20px; border-radius: 6px; max-width: 100%; }
  .cta-inner .section-heading { font-size: clamp(3rem, 14vw, 5rem); }
  .cta-button { padding: 15px 32px; font-size: 0.82rem; width: 100%; text-align: center; }
}

/* ── SMALL MOBILE (≤ 390px) ──────────────────── */
@media (max-width: 390px) {
  .hero-heading { font-size: clamp(2.4rem, 11vw, 3.2rem); }
  .section-heading { font-size: clamp(1.7rem, 8vw, 2.4rem); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-number { font-size: 2.2rem; }
  .cta-inner .section-heading { font-size: clamp(2.6rem, 13vw, 3.8rem); }
  .cta-inner { padding: 32px 18px; }
  .cta-button { width: 100%; text-align: center; padding: 16px 20px; }
}
