/* ============================================================
   MainGrid — landing styles
   Dark cosmic theme · Space Grotesk display / Inter body
   ============================================================ */

:root {
  --bg: #05060f;
  /* opaque-ish: glass panels used to backdrop-blur the animating canvas every
     frame, which crushed desktop frame rate. Solid fill reads the same on dark. */
  --bg-raise: rgba(11, 14, 28, 0.82);
  --text: #eaecff;
  --muted: #a9b1d6;
  --line: rgba(255, 255, 255, 0.09);
  --accent-a: #6c7bff;
  --accent-b: #00d4ff;
  --grad: linear-gradient(92deg, var(--accent-a), var(--accent-b));
  --radius: 20px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  /* z-scale: 10 nav-below / 20 content / 30 nav / 50 progress */
}

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

/* NOTE: never add `scroll-behavior: smooth` here — it fights Lenis (the browser
   re-animates every per-frame scroll set, making wheel input lag by ~1s). */

body {
  background: var(--bg);
  /* fallback nebulas if WebGL is unavailable */
  background-image:
    radial-gradient(1200px 700px at 80% -10%, rgba(108, 123, 255, 0.14), transparent 60%),
    radial-gradient(1000px 600px at 10% 40%, rgba(0, 212, 255, 0.08), transparent 60%);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  overflow-x: hidden;
}

::selection { background: rgba(108, 123, 255, 0.45); }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.08; letter-spacing: -0.02em; }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-b);
  outline-offset: 3px;
  border-radius: 6px;
}

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ---------- WebGL canvas + progress ---------- */

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

#progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 100%;
  background: var(--grad);
  transform-origin: 0 50%;
  transform: scaleX(0);
  z-index: 50;
}

main, .footer { position: relative; z-index: 20; }

/* ---------- Nav ---------- */

.nav {
  position: fixed;
  top: 16px; left: 16px; right: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 12px 20px;
  border-radius: 16px;
  border: 1px solid transparent;
  transition: background-color 0.25s ease, border-color 0.25s ease, backdrop-filter 0.25s ease;
}

.nav.scrolled {
  background: rgba(7, 9, 20, 0.72);
  border-color: var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.brand-mark { width: 30px; height: 30px; }
.mk-a { fill: var(--accent-a); }
.mk-b { fill: var(--accent-b); }
.mk-d { fill: #333c66; }

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 8px 14px;
  border-radius: 10px;
  transition: color 0.2s ease, background-color 0.2s ease;
  cursor: pointer;
}

.nav-links a:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  border-radius: 999px;
  padding: 15px 30px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
}

.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--grad);
  color: #05060f;
  box-shadow: 0 8px 30px rgba(56, 130, 255, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.12);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(56, 130, 255, 0.5);
}

.btn-ghost {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.btn-ghost:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-2px);
}

.btn-sm { padding: 10px 20px; font-size: 0.9rem; margin-left: auto; }
.nav .btn-sm { margin-left: 0; }
.btn-lg { padding: 18px 38px; font-size: 1.1rem; }

/* ---------- Hero ---------- */

.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 130px 24px 60px;
  max-width: 1100px;
  margin: 0 auto;
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-b);
  margin-bottom: 22px;
}

.hero-title {
  font-size: clamp(2.7rem, 7.4vw, 5.4rem);
  font-weight: 700;
}

.hero-title .line { display: block; overflow: hidden; padding-bottom: 0.08em; }
.hero-title .w { display: inline-block; will-change: transform; }

.hero-sub {
  max-width: 640px;
  margin: 26px auto 0;
  font-size: clamp(1.02rem, 1.5vw, 1.2rem);
  color: var(--muted);
}

.cta-row {
  display: flex;
  gap: 14px;
  margin-top: 36px;
  flex-wrap: wrap;
  justify-content: center;
}

.hero-badges {
  list-style: none;
  display: flex;
  gap: 10px 26px;
  margin-top: 40px;
  flex-wrap: wrap;
  justify-content: center;
}

.hero-badges li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.hero-badges svg { width: 16px; height: 16px; color: var(--accent-b); }

.scroll-hint {
  margin-top: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.mouse {
  width: 24px; height: 38px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 14px;
  display: flex;
  justify-content: center;
  padding-top: 7px;
}

.wheel {
  width: 3px; height: 7px;
  border-radius: 3px;
  background: var(--accent-b);
  animation: wheel 1.6s ease-in-out infinite;
}

@keyframes wheel {
  0%   { transform: translateY(0); opacity: 1; }
  70%  { transform: translateY(12px); opacity: 0; }
  100% { transform: translateY(0); opacity: 0; }
}

/* ---------- Marquee ---------- */

.marquee {
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
  background: rgba(7, 9, 20, 0.5);
}

.marquee-track {
  display: inline-flex;
  align-items: center;
  gap: 34px;
  white-space: nowrap;
  padding-right: 34px;
  animation: marquee 30s linear infinite;
}

.marquee-track span {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--muted);
}

.marquee-track i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--grad);
  flex: none;
}

@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Sections ---------- */

.section {
  max-width: 1160px;
  margin: 0 auto;
  padding: 10vh 24px;
}

.kicker {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-b);
  margin-bottom: 14px;
}

.section h2 {
  font-size: clamp(2rem, 4.6vw, 3.4rem);
  font-weight: 700;
  margin-bottom: 18px;
}

.section-sub {
  color: var(--muted);
  max-width: 620px;
  font-size: 1.05rem;
}

/* keep copy readable when it floats directly over bright grid lines */
.section h2,
.section-sub,
.kicker,
.hero-sub,
.hero-badges li {
  text-shadow: 0 2px 24px rgba(5, 6, 15, 0.9), 0 0 10px rgba(5, 6, 15, 0.7);
}

/* shadows bleed through transparent gradient glyphs — keep those clean */
.grad-text { text-shadow: none; }

/* ---------- Cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-top: 54px;
}

.card {
  position: relative;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px 28px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
  transform-style: preserve-3d;
  will-change: transform;
}

.card:hover {
  border-color: rgba(108, 123, 255, 0.5);
  box-shadow: 0 18px 60px rgba(30, 60, 200, 0.22);
}

.card-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(108, 123, 255, 0.18), rgba(0, 212, 255, 0.14));
  border: 1px solid rgba(108, 123, 255, 0.35);
  display: grid;
  place-items: center;
  margin-bottom: 22px;
}

.card-icon svg { width: 26px; height: 26px; color: var(--accent-b); }

.card h3 { font-size: 1.3rem; margin-bottom: 12px; }
.card > p { color: var(--muted); font-size: 0.97rem; }

.card-list {
  list-style: none;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.card-list li {
  position: relative;
  padding: 5px 0 5px 22px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
}

.card-list li::before {
  content: '';
  position: absolute;
  left: 2px; top: 13px;
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--grad);
}

/* work cards — four case studies read best as 2×2 */
.work-grid { grid-template-columns: repeat(2, 1fr); }

.work-card h3 { font-size: 1.18rem; }

.work-tags { display: flex; gap: 8px; margin-bottom: 18px; }

.work-tags span {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-b);
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 999px;
  padding: 4px 12px;
}

.work-stack {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--font-display);
}

/* ---------- Steps ---------- */

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
  margin-top: 54px;
}

.step {
  border-top: 1px solid var(--line);
  padding: 22px 20px 24px;
  position: relative;
  background: rgba(7, 9, 20, 0.55);
  border-radius: 0 0 16px 16px;
}

.step::before {
  content: '';
  position: absolute;
  top: -1px; left: 0;
  width: 56px; height: 2px;
  background: var(--grad);
}

.step-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.6rem;
  line-height: 1;
  background: linear-gradient(180deg, rgba(234, 236, 255, 0.5), rgba(234, 236, 255, 0.06));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  display: block;
  margin-bottom: 14px;
}

.step h3 { font-size: 1.15rem; margin-bottom: 10px; }
.step p { color: var(--muted); font-size: 0.95rem; }

/* ---------- Training split ---------- */

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
}

.split-panel {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.offer {
  display: flex;
  gap: 16px;
  padding: 18px 16px;
  border-radius: 14px;
  transition: background-color 0.2s ease;
}

.offer:hover { background: rgba(255, 255, 255, 0.04); }

.offer svg {
  width: 20px; height: 20px;
  color: var(--accent-b);
  flex: none;
  margin-top: 4px;
}

.offer h3 { font-size: 1.05rem; margin-bottom: 4px; }
.offer p { color: var(--muted); font-size: 0.92rem; }

/* ---------- About ---------- */

.about-panel {
  display: flex;
  gap: 36px;
  align-items: flex-start;
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 46px;
}

.about-avatar {
  flex: none;
  width: 84px; height: 84px;
  border-radius: 24px;
  background: var(--grad);
  display: grid;
  place-items: center;
}

.about-avatar svg { width: 46px; height: 46px; }

.about-title { font-size: clamp(1.6rem, 3vw, 2.3rem); margin-bottom: 14px; }

.about-panel .section-sub { max-width: none; }
.about-panel strong { color: var(--text); }

/* ---------- CTA ---------- */

.cta-panel {
  text-align: center;
  background:
    radial-gradient(600px 300px at 50% -40%, rgba(108, 123, 255, 0.22), transparent 70%),
    var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: clamp(50px, 8vw, 90px) 30px;
}

.cta-panel h2 { font-size: clamp(2.1rem, 5vw, 3.6rem); }

.cta-panel .section-sub { margin: 18px auto 34px; }

.contact-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.contact-actions .btn { font-family: var(--font-display); }
.contact-actions button.btn { border: none; }

.cta-alt { margin-top: 22px; color: var(--muted); font-size: 0.95rem; }
.cta-alt a { color: var(--accent-b); text-decoration: none; }
.cta-alt a:hover { text-decoration: underline; }

/* ---------- Footer ---------- */

.footer { border-top: 1px solid var(--line); background: rgba(5, 6, 15, 0.8); }

.footer-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 34px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.footer p { color: var(--muted); font-size: 0.9rem; }

.footer-contact a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-contact a:hover { color: var(--accent-b); }

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .nav-links { display: none; }
  .split { grid-template-columns: 1fr; gap: 40px; }
  .section { padding: 8vh 20px; }
}

@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; gap: 34px; }
  .about-panel { flex-direction: column; padding: 32px 24px; }
  .hero { padding-top: 110px; }
  .scroll-hint { margin-top: 44px; }
  .btn { padding: 14px 24px; }
  .btn-sm { padding: 10px 16px; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .marquee-track { animation: none; }
  .wheel { animation: none; }
  .btn, .card, .offer, .nav-links a { transition: none; }
}

/* ---------- Chat widget ---------- */

#mg-chat-launcher {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 40;
  width: 58px; height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--grad);
  color: #05060f;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 34px rgba(56, 130, 255, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#mg-chat-launcher:hover { transform: translateY(-3px); box-shadow: 0 14px 40px rgba(56, 130, 255, 0.6); }
#mg-chat-launcher svg { width: 26px; height: 26px; }
#mg-chat-launcher.mg-hidden { display: none; }

/* our display:flex would override the [hidden] UA style — restore it */
#mg-chat-panel[hidden] { display: none; }

#mg-chat-panel {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 40;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - 44px));
  display: flex;
  flex-direction: column;
  background: #0b0e1c;
  border: 1px solid rgba(108, 123, 255, 0.35);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.mg-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(90deg, rgba(108, 123, 255, 0.18), rgba(0, 212, 255, 0.12));
  border-bottom: 1px solid var(--line);
}

.mg-chat-head strong { font-family: var(--font-display); font-size: 0.98rem; display: block; }
.mg-chat-head small { color: var(--muted); font-size: 0.75rem; }

.mg-chat-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #2ee6a8;
  box-shadow: 0 0 10px rgba(46, 230, 168, 0.8);
  flex: none;
}

#mg-chat-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
#mg-chat-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
#mg-chat-close svg { width: 18px; height: 18px; }

#mg-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mg-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.mg-assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}

.mg-user {
  align-self: flex-end;
  background: linear-gradient(92deg, rgba(108, 123, 255, 0.85), rgba(0, 212, 255, 0.85));
  color: #05060f;
  font-weight: 500;
  border-bottom-right-radius: 6px;
}

.mg-typing { color: var(--muted); }

#mg-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 6px;
}

.mg-chip {
  border: 1px solid rgba(108, 123, 255, 0.45);
  background: rgba(108, 123, 255, 0.1);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.mg-chip:hover { background: rgba(108, 123, 255, 0.22); border-color: var(--accent-a); }

#mg-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

#mg-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px; /* ≥16px so iOS doesn't zoom on focus */
  padding: 10px 14px;
  outline: none;
}
#mg-chat-input:focus { border-color: var(--accent-a); }
#mg-chat-input::placeholder { color: var(--muted); }

#mg-chat-send {
  border: none;
  border-radius: 12px;
  width: 44px;
  background: var(--grad);
  color: #05060f;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: filter 0.2s ease;
}
#mg-chat-send:hover { filter: brightness(1.12); }
#mg-chat-send svg { width: 18px; height: 18px; }

@media (max-width: 480px) {
  #mg-chat-panel { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: calc(100dvh - 16px); }
}
