/* =========================================
   ROOT
========================================= */
:root {
  --hero-radius: 0px;
  --hold-ms: 3000ms;
  --overlay-fade-ms: 980ms;
  --base-crossfade-ms: 1800ms;
  --text-fade-ms: 860ms;
  --rows: 4;
  --cols: 7;
}

/* =========================================
   BASE / RESET
========================================= */
body {
  color: white;
  background:
    radial-gradient(circle at 15% 20%, rgba(80, 180, 255, 0.14), transparent 22%),
    radial-gradient(circle at 85% 80%, rgba(255, 70, 140, 0.14), transparent 24%),
    linear-gradient(135deg, #08111f, #0c1b2d 46%, #04070c);
}

/* =========================================
   LAYOUT
========================================= */
.frame {
  width: 100%;
}

/* =========================================
   HERO
========================================= */
.hero {
  position: relative;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background: #050a12;
  border: 0;
  box-shadow: none;
  --fx-x: 0px;
  --fx-y: 0px;
  --fx-scale: 1;
}

.hero__base,
.hero__path,
.hero__shade,
.hero__grade,
.hero__atmosphere,
.hero__soft-grid,
.hero__trace-svg,
.hero__content,
.hero__ui {
  position: absolute;
  inset: 0;
}

.hero__base {
  z-index: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transform: translate3d(var(--base-shift-x, 0px), var(--base-shift-y, 0px), 0) scale(1.045);
  filter: brightness(0.9) saturate(0.9) contrast(1.06);
  will-change: transform, filter, opacity;
  transition:
    opacity var(--base-crossfade-ms) cubic-bezier(.16, 1, .3, 1),
    filter var(--base-crossfade-ms) cubic-bezier(.16, 1, .3, 1);
}

.hero__base.is-active {
  opacity: 1;
}

.hero__base.is-animating {
  animation: baseKenBurns var(--hold-ms) linear forwards;
}

.hero__path,
.hero__soft-grid,
.hero__trace-svg {
  transform:
    translate3d(var(--fx-x), var(--fx-y), 0)
    scale(var(--fx-scale));
  transform-origin: center center;
}

.hero__path {
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--overlay-fade-ms) cubic-bezier(.16, 1, .3, 1);
  --incoming-image: none;
  will-change: opacity, transform;
}

.hero__path.is-visible {
  opacity: 1;
}

.cell {
  position: relative;
  overflow: hidden;
  background-image: var(--incoming-image);
  background-repeat: no-repeat;
  background-size: calc(var(--cols) * 100%) calc(var(--rows) * 100%);
  background-position: calc(var(--bg-x) * 100%) calc(var(--bg-y) * 100%);
  opacity: 0;

  --cell-brightness: 1;
  --cell-sat: 1;
  --cell-contrast: 1.04;
  --cell-glow-alpha: 0;
  --cell-edge-alpha: 0.10;
  --cell-edge-soft-alpha: 0.08;

  filter:
    brightness(calc(0.94 * var(--cell-brightness)))
    saturate(calc(0.92 * var(--cell-sat)))
    contrast(var(--cell-contrast));
  will-change: opacity, filter;
}

.cell::before {
  content: "";
  position: absolute;
  inset: -12%;
  pointer-events: none;
  background:
    radial-gradient(
      circle at center,
      rgba(255, 255, 255, 0.18) 0%,
      rgba(255, 255, 255, 0.08) 24%,
      rgba(255, 255, 255, 0.00) 68%
    );
  opacity: var(--cell-glow-alpha);
  mix-blend-mode: screen;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, var(--cell-edge-alpha)) 0%,
      rgba(255, 255, 255, 0) 18%,
      rgba(255, 255, 255, 0) 82%,
      rgba(255, 255, 255, calc(var(--cell-edge-alpha) * 0.6)) 100%
    );
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 0 0 18px rgba(255, 255, 255, var(--cell-edge-soft-alpha)),
    inset 0 -18px 26px rgba(0, 0, 0, 0.06);
  opacity: 1;
}

.hero__shade {
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(4, 8, 16, 0.16), rgba(4, 8, 16, 0.34) 46%, rgba(4, 8, 16, 0.78)),
    linear-gradient(90deg, rgba(4, 8, 16, 0.70), rgba(4, 8, 16, 0.18) 44%, rgba(4, 8, 16, 0.05));
}

.hero__grade {
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(15, 18, 28, 0.22), rgba(8, 10, 18, 0.08) 28%, rgba(8, 10, 18, 0.18) 72%, rgba(5, 8, 14, 0.34)),
    linear-gradient(110deg, rgba(22, 26, 38, 0.16), rgba(66, 84, 124, 0.05) 42%, rgba(16, 18, 30, 0.16)),
    radial-gradient(100% 90% at 50% 48%, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0) 62%);
  mix-blend-mode: soft-light;
  opacity: 0.95;
}

.hero__grade::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 110% at 50% 18%, rgba(121, 147, 197, 0.08), transparent 48%),
    radial-gradient(100% 100% at 50% 82%, rgba(19, 24, 39, 0.20), transparent 52%);
  mix-blend-mode: multiply;
  opacity: 0.8;
}

.hero__atmosphere {
  z-index: 4;
  pointer-events: none;
  opacity: 0.9;
  background:
    radial-gradient(120% 86% at 14% 10%, rgba(255, 255, 255, 0.055), transparent 42%),
    radial-gradient(90% 72% at 82% 24%, rgba(130, 170, 255, 0.05), transparent 46%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 18%, transparent 70%, rgba(7, 12, 20, 0.12)),
    linear-gradient(115deg, rgba(10, 16, 28, 0.09), transparent 36%, rgba(255, 255, 255, 0.02) 58%, rgba(10, 16, 28, 0.12));
}

.hero__atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.11;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.05), transparent 18%),
    radial-gradient(circle at 78% 24%, rgba(255, 255, 255, 0.03), transparent 16%),
    radial-gradient(circle at 62% 76%, rgba(255, 255, 255, 0.025), transparent 15%);
}

.hero__soft-grid {
  z-index: 5;
  pointer-events: none;
  width: 100%;
  height: 100%;
  opacity: 1;
  will-change: transform;
}

.hero__trace-svg {
  z-index: 6;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  transition: opacity 320ms ease;
  mix-blend-mode: screen;
}

.hero__trace-svg.is-visible {
  opacity: 1;
}

#tracePathGlowWide {
  fill: none;
  stroke: rgba(116, 178, 255, 0.10);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#traceGlowBlur);
}

#tracePathGlowCore {
  fill: none;
  stroke: rgba(214, 236, 255, 0.42);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url(#traceGlowBlur);
}

#tracePathHead {
  fill: none;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero__content {
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding:
    calc(var(--topbar-height) + var(--navbar-height-desktop) + 32px)
    clamp(28px, 6vw, 88px)
    clamp(40px, 6vh, 72px);
}

.hero__copy {
  max-width: min(720px, 52vw);
  will-change: opacity, transform, filter;
  transition:
    opacity var(--text-fade-ms) cubic-bezier(.16, 1, .3, 1),
    transform var(--text-fade-ms) cubic-bezier(.16, 1, .3, 1),
    filter var(--text-fade-ms) cubic-bezier(.16, 1, .3, 1);
}

.hero__copy.is-exiting {
  opacity: 0.14;
  transform: translateY(20px);
  filter: blur(7px);
}

.hero__copy.is-entering {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(9px);
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}

h1 {
  margin: 0;
  font-size: clamp(2.8rem, 6vw, 6.2rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  max-width: 11ch;
  text-wrap: balance;
}

.copy {
  margin: 18px 0 0;
  max-width: 56ch;
  font-size: clamp(1rem, 1.5vw, 1.12rem);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.78);
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 26px;
  flex-wrap: wrap;
}

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, opacity 180ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.btn--solid {
  background: #fff;
  color: #0b1423;
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(10px);
}

.hero__ui {
  z-index: 8;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: start;
  padding:
    calc(var(--topbar-height) + var(--navbar-height-desktop) + 10px)
    clamp(20px, 3vw, 32px)
    0;
}

.badge,
.counter {
  opacity: 0;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.92rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8fe2ff;
  box-shadow: 0 0 0 6px rgba(143, 226, 255, 0.12);
}

.preview {
  color: rgba(255, 255, 255, 0.68);
}

.path-measure {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

/* =========================================
   KEYFRAMES
========================================= */
@keyframes baseKenBurns {
  0%,
  16% {
    transform: translate3d(var(--base-shift-x, 0px), var(--base-shift-y, 0px), 0) scale(1.045);
    filter: brightness(0.9) saturate(0.9) contrast(1.06);
  }

  100% {
    transform:
      translate3d(
        calc(var(--base-shift-x, 0px) * -0.18),
        calc(var(--base-shift-y, 0px) * -0.18),
        0
      )
      scale(1.008);
    filter: brightness(0.96) saturate(0.94) contrast(1.08);
  }
}

/* =========================================
   MEDIA QUERIES
========================================= */
@media (max-width: 992px) {
  .hero__content {
    align-items: end;
    justify-content: flex-start;
    padding:
      calc(var(--navbar-height-mobile) + 28px)
      24px
      34px;
  }

  .hero__ui {
    padding:
      calc(var(--navbar-height-mobile) + 10px)
      20px
      0;
  }

  .hero__copy {
    max-width: 100%;
  }

  h1 {
    max-width: 9ch;
  }
}

@media (max-width: 768px) {
  .badge {
    display: none;
  }
}

@media (max-width: 576px) {
  .hero__ui {
    justify-content: flex-end;
  }
}

/* =========================================
   ACCESSIBILITY / REDUCED MOTION
========================================= */
@media (prefers-reduced-motion: reduce) {
  .hero__base,
  .hero__path,
  .hero__copy,
  .hero__trace-svg,
  button {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}