@import "fonts.css";
@import "tokens.css";

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--brand-ink);
  color: var(--white);
  font-family: var(--font-body);
}

body.is-ready { overflow: hidden; }

:root {
  --intro-logo-size: 120px;
  --intro-lines-size: 300px;
}

/* ========== INTRO / LOADER ========== */
.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--brand-ink);
  overflow: hidden;
}

.intro.is-inverted {
  background: var(--white);
}

.intro__construction {
  position: fixed;
  inset: 0;
  z-index: 101;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.intro__lines {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.intro__inner {
  transform-box: fill-box;
  transform-origin: center;
}

.intro__lines .cline {
  fill: none;
  stroke: rgba(151, 163, 175, 0.55);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.intro__lines .cline-accent {
  stroke: rgba(110, 124, 255, 0.42);
}

.intro__flight {
  position: fixed;
  left: 50%;
  top: 50%;
  width: var(--intro-logo-size);
  height: var(--intro-logo-size);
  margin-left: calc(var(--intro-logo-size) / -2);
  margin-top: calc(var(--intro-logo-size) / -2);
  z-index: 103;
  will-change: left, top, width, height;
}

.intro__logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.intro.is-inverted .intro__logo {
  filter: invert(1);
}

.intro__logo.is-glitch {
  animation: logo-glitch 0.85s steps(2, end) infinite;
}

.intro__logo.is-settled {
  animation: none !important;
  transform: none !important;
  filter: none !important;
}

@keyframes logo-glitch {
  0%, 82%, 100% { transform: translate(0, 0); }
  84% { transform: translate(-2px, 1px); }
  86% { transform: translate(2px, -1px); }
  88% { transform: translate(-1px, 0); }
}

.intro__flash {
  position: fixed;
  inset: 0;
  z-index: 106;
  background: var(--white);
  opacity: 0;
  pointer-events: none;
}

/* ========== HERO SCENE ========== */
.hero-scene {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  background: var(--brand-ink);
}

.hero-scene.is-visible {
  visibility: visible;
}

.hero-scene__viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--brand-ink);
}

.hero-scene__canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--frame-w);
  height: var(--frame-h);
  transform-origin: top left;
  overflow: visible;
  background: transparent;
  will-change: transform;
  z-index: 2;
}

.hero-scene__grid {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  overflow: visible;
  background: url("../svg/grid.svg") center center / cover no-repeat;
}

.hero-scene__logo {
  position: absolute;
  left: var(--logo-x);
  top: var(--logo-y);
  width: var(--logo-size);
  height: var(--logo-size);
  z-index: 2;
  object-fit: fill;
  pointer-events: none;
  opacity: 0;
}

.hero-scene__character-wrap {
  position: absolute;
  left: var(--char-x);
  top: var(--char-y);
  width: var(--char-w);
  z-index: 3;
  overflow: visible;
  will-change: transform;
}

.hero-scene__character {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  object-position: center top;
  pointer-events: none;
  opacity: 0;
}

.hero-scene__copy {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  width: min(92%, 900px);
  max-width: 900px;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.hero-scene__title {
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-size: clamp(30px, 3.6vw, 56px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  opacity: 0;
  transform: translateY(24px);
  text-wrap: balance;
}

.hero-scene__title-line {
  display: block;
}

.hero-scene__title .accent {
  color: var(--brand-blue);
}

.hero-scene__lead {
  margin: 0 auto;
  font-family: var(--font-body);
  font-size: clamp(14px, 1.25vw, 18px);
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 640px;
  opacity: 0;
  transform: translateY(20px);
  text-wrap: balance;
}

.hero-scene__vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(
    ellipse 70% 60% at 50% 50%,
    transparent 30%,
    rgba(0, 0, 0, 0.45) 100%
  );
}

/* Reduced motion */
html.reduced-motion .intro { display: none; }
html.reduced-motion .hero-scene {
  opacity: 1;
  visibility: visible;
}
html.reduced-motion .hero-scene__grid,
html.reduced-motion .hero-scene__logo,
html.reduced-motion .hero-scene__character,
html.reduced-motion .hero-scene__title,
html.reduced-motion .hero-scene__lead {
  opacity: 1;
  transform: none;
}

@media (max-width: 900px) {
  .hero-scene__copy {
    width: calc(100% - 48px);
  }
}
