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

:root {
  color-scheme: dark;
  --plaque-line: rgba(163, 233, 255, 0.1);
  --plaque-text: rgba(244, 249, 255, 0.98);
  --plaque-accent: #6ee9ff;
  --plaque-shadow: rgba(0, 0, 0, 0.42);
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
}

body {
  color: var(--plaque-text);
}

canvas {
  position: fixed;
  inset: 0;
  display: block;
}

.tagline {
  position: fixed;
  right: clamp(20px, 4vw, 48px);
  bottom: clamp(18px, 4vh, 40px);
  z-index: 2;
  width: fit-content;
  min-width: clamp(280px, 24vw, 360px);
  max-width: min(76vw, 860px);
  padding: 18px 22px;
  border-radius: 24px;
  isolation: isolate;
  overflow: hidden;
  pointer-events: none;
  border: 1px solid var(--plaque-line);
  background: linear-gradient(135deg, rgba(7, 14, 30, 0.16), rgba(4, 10, 24, 0.04));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    0 0 30px rgba(53, 175, 226, 0.08),
    0 16px 40px var(--plaque-shadow);
  backdrop-filter: blur(6px);
  animation: tagline-float 7.2s ease-in-out infinite;
}

.tagline::before {
  content: "";
  position: absolute;
  inset: -18% -10%;
  z-index: -2;
  border-radius: 999px;
  background:
    radial-gradient(circle at 18% 50%, rgba(78, 219, 255, 0.16), transparent 36%),
    radial-gradient(circle at 82% 50%, rgba(78, 219, 255, 0.12), transparent 34%),
    linear-gradient(90deg, rgba(2, 8, 22, 0.08), rgba(8, 18, 38, 0.26), rgba(2, 8, 22, 0.08));
  filter: blur(18px);
  opacity: 0.95;
}

.tagline::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04), transparent 12%, transparent 88%, rgba(255, 255, 255, 0.03)),
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.04), transparent 30%);
}

.formula-stage {
  position: relative;
  min-height: 1.08em;
  font-size: clamp(1.2rem, 2.3vw, 3.4rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.045em;
  text-align: right;
  perspective: 1400px;
}

.formula-stage::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 0;
  bottom: -18%;
  height: 80%;
  background: radial-gradient(circle at center, rgba(78, 219, 255, 0.12), transparent 70%);
  filter: blur(26px);
  opacity: 0;
  transition: opacity 640ms ease;
  pointer-events: none;
}

.tagline[data-phase="formula"] .formula-stage::after,
.tagline[data-phase="result"] .formula-stage::after {
  opacity: 1;
}

.measure {
  position: absolute;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}

.measure__line,
.glyph-layer {
  width: 100%;
  min-height: 1.08em;
  text-align: right;
  white-space: pre;
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

.measure__line {
  display: inline-flex;
  justify-content: flex-end;
  align-items: baseline;
}

.measure__probe {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: baseline;
  width: max-content;
  white-space: pre;
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}

.measure__char {
  display: inline-block;
  white-space: pre;
  transform-origin: 50% 62%;
  transform: scale(var(--measure-scale, 1));
}

.glyph-layer {
  position: relative;
  transform-style: preserve-3d;
}

.glyph {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-block;
  white-space: pre;
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  color: var(--plaque-text);
  text-shadow:
    0 0 12px rgba(255, 255, 255, 0.14),
    0 0 22px rgba(110, 200, 255, 0.08);
  transform-origin: 50% 62%;
  will-change: transform, opacity, filter, color, text-shadow;
  transition:
    transform 900ms cubic-bezier(0.2, 1, 0.22, 1),
    opacity 620ms ease,
    filter 620ms ease,
    color 620ms ease,
    text-shadow 620ms ease;
  opacity: 1;
  filter: blur(0);
}

.glyph-layer[data-motion="peel"] .glyph,
.glyph-layer[data-motion="derive"] .glyph,
.glyph-layer[data-motion="resolve"] .glyph,
.glyph-layer[data-motion="rewind"] .glyph {
  text-shadow:
    0 0 16px rgba(255, 255, 255, 0.16),
    0 0 28px rgba(110, 200, 255, 0.11);
}

.glyph--accent {
  color: var(--plaque-accent);
  text-shadow:
    0 0 10px rgba(110, 233, 255, 0.7),
    0 0 22px rgba(68, 221, 255, 0.48),
    0 0 42px rgba(37, 202, 255, 0.34);
}

.glyph--final {
  text-shadow:
    0 0 14px rgba(255, 255, 255, 0.18),
    0 0 26px rgba(110, 200, 255, 0.12);
}

.glyph--accent.glyph--final {
  color: var(--plaque-accent);
  text-shadow:
    0 0 10px rgba(110, 233, 255, 0.7),
    0 0 22px rgba(68, 221, 255, 0.48),
    0 0 42px rgba(37, 202, 255, 0.34);
}

.glyph--ghost {
  opacity: 0;
  filter: blur(8px);
}

@keyframes tagline-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -4px, 0);
  }
}

@media (max-width: 768px) {
  .tagline {
    left: 50%;
    right: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
    width: fit-content;
    min-width: min(82vw, 320px);
    max-width: min(92vw, 560px);
    transform: translateX(-50%);
    padding: 14px 18px 16px;
  }

  .formula-stage {
    font-size: clamp(1.05rem, 6vw, 2.15rem);
    line-height: 1;
    text-align: center;
  }

  .measure__line,
  .glyph-layer {
    text-align: center;
  }

  .measure__line {
    justify-content: center;
  }

  @keyframes tagline-float {
    0%,
    100% {
      transform: translateX(-50%) translate3d(0, 0, 0);
    }
    50% {
      transform: translateX(-50%) translate3d(0, -3px, 0);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
