/* ============ Sidekick lander — arcade-noir ============ */

:root {
  --bg0: #06070c;
  --bg1: #0b0e17;
  --ink: #eef0fa;
  --muted: #9aa3c0;
  --faint: #8890ad;
  --line: rgba(122, 138, 255, 0.09);
  --accent-a: #7c5cff;
  --accent-b: #4ea8ff;
  --glass: rgba(20, 24, 42, 0.55);
  --glass-edge: rgba(140, 152, 255, 0.14);
  --radius: 18px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-arcade: "Press Start 2P", monospace;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg0);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
em { font-style: normal; color: #cfd6ff; }

::selection { background: rgba(124, 92, 255, 0.45); }

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

/* ---------- ambient background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; background: linear-gradient(180deg, var(--bg0), var(--bg1) 60%, var(--bg0)); }
.bg-maze {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 20%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 20%, black 30%, transparent 75%);
}
.bg-glow { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.32; }
.bg-glow-a { width: 44vw; height: 44vw; left: -10vw; top: -12vw; background: #3b2a8f; }
.bg-glow-b { width: 38vw; height: 38vw; right: -8vw; top: 18vh; background: #143a6e; }

/* ---------- game layers ---------- */
#pellets { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#ghost-layer { position: fixed; inset: 0; z-index: 4; pointer-events: none; }

/* ---------- nav ---------- */
.nav {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 56px);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-ghost {
  position: relative; width: 26px; height: 28px; background: #e8e8f0;
  border-radius: 13px 13px 3px 3px; display: inline-block;
  clip-path: polygon(0 0, 100% 0, 100% 88%, 87% 100%, 75% 88%, 62% 100%, 50% 88%, 38% 100%, 25% 88%, 13% 100%, 0 88%);
}
.brand-eye { position: absolute; top: 9px; width: 4px; height: 6px; background: #2a2d36; border-radius: 50%; }
.brand-eye.l { left: 6px; } .brand-eye.r { right: 6px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.02em; }
.brand-by { font-size: 0.72rem; color: var(--faint); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 3px; }
.nav-links { display: flex; gap: clamp(16px, 3vw, 34px); }
.nav-links a { text-decoration: none; color: var(--muted); font-size: 0.92rem; transition: color 200ms; }
.nav-links a:hover { color: var(--ink); }

/* ---------- hero ---------- */
main { position: relative; z-index: 5; }
.hero {
  min-height: calc(100svh - 90px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 4vh clamp(20px, 6vw, 64px) 8vh;
}
.hero-kicker {
  font-size: 0.82rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent-b);
  margin: 0 0 18px;
}
.hero-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.9rem, 2rem + 5.4vw, 6.2rem);
  line-height: 1.02; letter-spacing: -0.03em; margin: 0;
  text-wrap: balance;
}
.accent-dot { background: linear-gradient(120deg, var(--accent-a), var(--accent-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub {
  max-width: 620px; color: var(--muted); margin: 26px 0 38px;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem);
  text-wrap: pretty;
}
.hero-cta { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; justify-content: center; }
.btn-primary {
  position: relative; display: inline-flex; align-items: center; gap: 12px;
  padding: 17px 30px; border-radius: 999px; text-decoration: none;
  font-family: var(--font-display); font-weight: 700; font-size: 1.06rem; color: #fff;
  background: linear-gradient(120deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 10px 40px rgba(101, 111, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform: translate(var(--mx, 0px), var(--my, 0px));
  transition: transform 250ms var(--ease-spring), box-shadow 250ms;
  overflow: hidden;
  will-change: transform;
}
.btn-primary:hover { box-shadow: 0 14px 52px rgba(101, 111, 255, 0.5), inset 0 1px 0 rgba(255,255,255,0.25); }
.btn-primary:active { transform: translate(var(--mx, 0px), var(--my, 0px)) scale(0.97); }
.btn-primary::after {
  content: ""; position: absolute; top: 0; left: -80%; width: 55%; height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-20deg); transition: left 650ms var(--ease-out);
}
.btn-primary:hover::after { left: 130%; }
.btn-ico { width: 20px; height: 20px; }
.version-chip {
  font-family: var(--font-body); font-weight: 500; font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.18); border-radius: 999px; padding: 3px 10px;
  min-width: 52px; text-align: center;
}
.btn-ghostlink { color: var(--muted); text-decoration: none; font-size: 0.95rem; transition: color 200ms; }
.btn-ghostlink:hover { color: var(--ink); }
.hero-micro { color: var(--faint); font-size: 0.85rem; margin-top: 26px; letter-spacing: 0.02em; }

.scroll-hint { margin-top: 7vh; width: 26px; height: 42px; border: 2px solid var(--faint); border-radius: 14px; position: relative; opacity: 0.7; }
.scroll-hint span { position: absolute; left: 50%; top: 8px; width: 4px; height: 8px; margin-left: -2px; border-radius: 2px; background: var(--muted); animation: scrollDrip 1.8s ease-in-out infinite; }
@keyframes scrollDrip { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(14px); opacity: 0; } 100% { opacity: 0; } }

/* ---------- sections ---------- */
.section-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.9rem, 1.4rem + 2.6vw, 3.4rem);
  letter-spacing: -0.02em; line-height: 1.08; text-align: center; margin: 0 0 54px;
  text-wrap: balance;
}
.features { padding: 12vh clamp(20px, 6vw, 64px); max-width: 1180px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 22px; }
.card {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-radius: var(--radius); padding: 30px 28px;
  transition: transform 350ms var(--ease-out), border-color 350ms, box-shadow 350ms;
}
.card:hover { transform: translateY(-5px); border-color: rgba(140, 152, 255, 0.32); box-shadow: 0 18px 44px rgba(10, 12, 30, 0.55); }
.card-ico { width: 44px; height: 44px; color: var(--accent-b); margin-bottom: 18px; }
.card-ico svg { width: 100%; height: 100%; }
.card h3 { font-family: var(--font-display); font-size: 1.22rem; margin: 0 0 8px; letter-spacing: -0.01em; }
.card p { color: var(--muted); font-size: 0.97rem; margin: 0; }

/* ---------- install ---------- */
.install { padding: 8vh clamp(20px, 6vw, 64px) 14vh; max-width: 760px; margin: 0 auto; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.step {
  display: flex; gap: 22px; align-items: flex-start;
  background: var(--glass); border: 1px solid var(--glass-edge);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius); padding: 24px 26px;
}
.step-n {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1.1rem;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.25), rgba(78, 168, 255, 0.25));
  border: 1px solid rgba(140, 152, 255, 0.3); color: #cfd6ff;
}
.step h3 { font-family: var(--font-display); font-size: 1.12rem; margin: 6px 0 6px; }
.step p { color: var(--muted); font-size: 0.95rem; margin: 0; }
.install-cta { display: flex; justify-content: center; margin-top: 48px; }

/* ---------- footer ---------- */
.footer { position: relative; z-index: 5; text-align: center; padding: 40px 20px 120px; color: var(--faint); font-size: 0.9rem; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--ink); }
.footer-hint { font-size: 0.78rem; margin-top: 10px; }
.footer-ghost { filter: grayscale(0.4); }

/* ---------- scroll reveals (hidden only when JS is running to add .in back) ---------- */
.js .reveal { opacity: 0; transform: translateY(26px); transition: opacity 700ms var(--ease-out), transform 700ms var(--ease-out); }
.js .reveal.in { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: 90ms; } .reveal.d2 { transition-delay: 180ms; }
.reveal.d3 { transition-delay: 270ms; } .reveal.d4 { transition-delay: 360ms; }
.reveal.d5 { transition-delay: 480ms; }
.grid .card:nth-child(2) { transition-delay: 80ms; } .grid .card:nth-child(3) { transition-delay: 160ms; }
.grid .card:nth-child(4) { transition-delay: 80ms; } .grid .card:nth-child(5) { transition-delay: 160ms; }
.grid .card:nth-child(6) { transition-delay: 240ms; }
.steps .step:nth-child(2) { transition-delay: 110ms; } .steps .step:nth-child(3) { transition-delay: 220ms; }

/* ---------- roaming ghosts ---------- */
.ghost { position: absolute; left: 0; top: 0; width: 46px; height: 52px; will-change: transform; }
.ghost-body {
  position: absolute; inset: 0;
  border-radius: 23px 23px 4px 4px;
  clip-path: polygon(0 0, 100% 0, 100% 88%, 87% 100%, 75% 88%, 62% 100%, 50% 88%, 38% 100%, 25% 88%, 13% 100%, 0 88%);
  transition: background-color 400ms;
  animation: ghostWobble 0.9s ease-in-out infinite;
}
@keyframes ghostWobble { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.96) scaleX(1.02); } }
.g-eye { position: absolute; top: 15px; width: 11px; height: 12px; background: #fff; border-radius: 50%; z-index: 1; }
.g-eye.l { left: 8px; } .g-eye.r { right: 8px; }
.g-pupil { position: absolute; left: 3px; top: 3px; width: 5px; height: 6px; background: #232742; border-radius: 50%; transition: transform 180ms; }
.g-mouth { display: none; }

.g-rose .ghost-body { background: #ff7a95; } .g-pink .ghost-body { background: #ffa3d1; }
.g-cyan .ghost-body { background: #63e7ff; } .g-amber .ghost-body { background: #ffb86b; }

.ghost.frightened .ghost-body { background: #3346d3; animation: ghostWobble 0.45s ease-in-out infinite; }
.ghost.frightened .g-eye { background: #f2f4ff; width: 8px; height: 8px; top: 17px; }
.ghost.frightened .g-pupil { display: none; }
.ghost.frightened .g-mouth {
  display: block; position: absolute; left: 9px; right: 9px; top: 32px; height: 5px; z-index: 1;
  background: linear-gradient(135deg, #f2f4ff 25%, transparent 25%, transparent 50%, #f2f4ff 50%, #f2f4ff 75%, transparent 75%);
  background-size: 8px 5px;
}
.ghost.frightened.flash .ghost-body { background: #dfe4ff; }
.ghost.frightened.flash .g-eye { background: #3346d3; }
.ghost.eaten .ghost-body { background: transparent; animation: none; }
.ghost.eaten .g-mouth { display: none; }
.ghost.eaten .g-eye { background: #fff; }
.ghost.eaten .g-pupil { display: block; }

/* ---------- buddy follower ---------- */
.buddy {
  position: fixed; left: 0; top: 0; z-index: 6; pointer-events: none;
  width: 52px; height: 58px; will-change: transform;
  opacity: 0; transition: opacity 600ms;
}
.buddy.awake { opacity: 1; }
.buddy-body {
  position: absolute; inset: 0; background: #e8e8f0;
  border-radius: 26px 26px 4px 4px;
  clip-path: polygon(0 0, 100% 0, 100% 88%, 87% 100%, 75% 88%, 62% 100%, 50% 88%, 38% 100%, 25% 88%, 13% 100%, 0 88%);
  animation: buddyFloat 3.4s ease-in-out infinite;
  box-shadow: 0 0 24px rgba(160, 170, 255, 0.25);
}
@keyframes buddyFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.b-eye {
  position: absolute; top: 19px; width: 8px; height: 11px; background: #2a2d36; border-radius: 50%;
  animation: buddyBlink 5s infinite; z-index: 1;
}
.b-eye.l { left: 13px; } .b-eye.r { right: 13px; }
.b-pupil { display: none; }
@keyframes buddyBlink { 0%, 93%, 100% { transform: scaleY(1); } 95%, 98% { transform: scaleY(0.08); } }
.buddy.chomp .buddy-body { animation: buddyChomp 240ms var(--ease-spring); }
@keyframes buddyChomp { 0% { transform: scale(1.25, 0.8); } 100% { transform: scale(1, 1); } }

/* ---------- HUD ---------- */
.hud {
  position: fixed; left: 18px; bottom: 18px; z-index: 7;
  display: flex; align-items: center; gap: 16px;
  background: rgba(10, 12, 24, 0.78); border: 1px solid var(--glass-edge);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 12px; padding: 10px 16px;
  font-family: var(--font-arcade); font-size: 9px; color: var(--muted);
  letter-spacing: 0.04em;
}
.hud b { color: var(--ink); font-weight: 400; }
.hud-ghost {
  width: 14px; height: 16px; background: #e8e8f0; display: inline-block;
  border-radius: 7px 7px 2px 2px;
  clip-path: polygon(0 0, 100% 0, 100% 88%, 80% 100%, 60% 88%, 50% 100%, 40% 88%, 20% 100%, 0 88%);
}
.score-pop {
  position: fixed; z-index: 7; pointer-events: none;
  font-family: var(--font-arcade); font-size: 11px; color: #9fe8ff;
  text-shadow: 0 0 12px rgba(99, 231, 255, 0.8);
  animation: scorePop 900ms var(--ease-out) forwards;
}
@keyframes scorePop { 0% { opacity: 0; transform: translateY(6px) scale(0.7); } 15% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-34px) scale(1); } }

.level-clear {
  position: fixed; inset: 0; z-index: 8; display: grid; place-items: center;
  pointer-events: none; font-family: var(--font-arcade);
  font-size: clamp(20px, 4.5vw, 44px); color: #fff;
  text-shadow: 0 0 30px rgba(124, 92, 255, 0.9), 0 0 60px rgba(78, 168, 255, 0.6);
  animation: levelClear 2s var(--ease-out) forwards;
}
@keyframes levelClear {
  0% { opacity: 0; transform: scale(0.6); }
  18% { opacity: 1; transform: scale(1.05); }
  30% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.08); }
}

/* ---------- reduced motion / small screens ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
  #pellets, #ghost-layer, .buddy, .hud, .scroll-hint { display: none !important; }
}

@media (max-width: 640px) {
  .nav-links a:not(:last-child) { display: none; }
  .hero { min-height: calc(100svh - 80px); }
  .hud { left: 12px; bottom: 12px; gap: 10px; padding: 8px 12px; font-size: 8px; }
  .ghost { width: 38px; height: 43px; }
  .footer { padding-bottom: 90px; }
}
