:root {
  color-scheme: dark;
  --page-bg: #00010c;
  --surface: #101326;
  --text: #ffffff;
  --muted: #aeb6c4;
  --primary: #cb66ff;
  --accent: #f06b54;
  --focus: #fff06a;
  --container: 1320px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --border-progress: 0;
  font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  scroll-behavior: smooth;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  background: var(--page-bg);
  color: var(--text);
}

body {
  overflow-x: hidden;
  font-size: 1rem;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: #f8f9fa;
  text-decoration-thickness: 0.11em;
  text-underline-offset: 0.2em;
}

a:hover {
  color: #e6a9ff;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
  border-radius: 0.2rem;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  padding: 0.65rem 1rem;
  color: #000;
  background: var(--focus);
  font-weight: 800;
  transform: translateY(-180%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.motion-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  min-height: 44px;
  padding: 0.55rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  color: var(--text);
  background: rgba(0, 1, 12, 0.82);
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.28);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.js .motion-toggle {
  display: block;
}

.motion-toggle::before {
  content: "◼";
  margin-right: 0.45rem;
  color: var(--primary);
}

.motion-toggle[aria-pressed="true"]::before {
  content: "▶";
}

.container {
  width: min(100% - (2 * var(--gutter)), var(--container));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

[data-reveal] {
  opacity: 0;
}

.hero,
.error-hero {
  position: relative;
  display: grid;
  min-height: 100svh;
  overflow: clip;
  isolation: isolate;
}

.gradient-background {
  position: absolute;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(circle at 16% 85%, rgba(243, 201, 191, 0.9), transparent 36%),
    radial-gradient(circle at 72% 20%, rgba(254, 104, 96, 0.92), transparent 42%),
    linear-gradient(135deg, #fe6860 0%, #fe8a71 38%, #d9bbae 70%, #f3c9bf 100%);
  background-size: 150% 150%;
  animation: gradient-drift 14s ease-in-out infinite alternate;
  animation-play-state: paused;
}

.gradient-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 1, 12, 0.02), rgba(0, 1, 12, 0.38));
}

@keyframes gradient-drift {
  to { background-position: 80% 40%; }
}

.scene {
  position: absolute;
  inset: -8%;
  z-index: -2;
  pointer-events: none;
}

.scene-layer {
  position: absolute;
  inset: 0;
  transform: translate3d(var(--parallax-x, 0), var(--parallax-y, 0), 0);
  transition: none;
  will-change: transform;
}

.scene-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left bottom;
}

.hero-content {
  display: grid;
  align-items: center;
  min-height: 100svh;
  padding-block: 6rem 4rem;
}

.hero-title {
  width: max-content;
  max-width: 100%;
  margin: 0 0 0 auto;
  font-size: clamp(2.7rem, 5vw, 5rem);
  font-weight: 300;
  line-height: 0.98;
  letter-spacing: -0.04em;
  text-wrap: balance;
  color: #101427;
  text-shadow: none;
}

.hero-title code {
  display: block;
  padding-top: 0.15em;
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: 0.76em;
  font-weight: 400;
  color: #101427;
}

.hero-title span,
.hero-title code {
  display: block;
  width: fit-content;
  margin-left: auto;
  padding: 0.04em 0.12em;
  border-radius: 0.08em;
  color: #101427;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 0.1em 0.3em rgba(37, 15, 47, 0.2);
  white-space: nowrap;
  -webkit-text-fill-color: currentColor;
  animation: title-reveal 1.25s 0.2s cubic-bezier(.22,.61,.36,1) both;
}

.hero-title code {
  animation-delay: 0.55s;
}

@keyframes title-reveal {
  from { clip-path: inset(0 100% 0 0); transform: translateY(0.12em); }
  to { clip-path: inset(0); transform: translateY(0); }
}

.sky-section {
  position: relative;
  min-height: 160vh;
  padding-block: clamp(5rem, 9vw, 9rem);
  background: var(--page-bg);
  isolation: isolate;
}

.particles-wrap {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.particle-canvas {
  position: sticky;
  top: 0;
  display: block;
  width: 100%;
  height: 100svh;
  opacity: 0.82;
}

.sticky-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sticky-frame-inner {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
}

.animated-frame {
  position: absolute;
  inset: 0;
  --frame-size: clamp(0.65rem, 2.8vw, 2.6rem);
}

.frame-edge {
  position: absolute;
  display: block;
  background: linear-gradient(65deg, var(--primary) 10%, var(--accent) 50%, var(--primary) 90%);
  box-shadow: 0 0 1rem rgba(203, 102, 255, 0.35);
  will-change: transform;
}

.frame-edge-top,
.frame-edge-bottom {
  right: 0;
  left: 0;
  height: var(--frame-size);
  transform: scaleY(calc(1 - var(--border-progress)));
}

.frame-edge-top {
  top: 0;
  transform-origin: center top;
}

.frame-edge-bottom {
  bottom: 0;
  transform-origin: center bottom;
}

.frame-edge-left,
.frame-edge-right {
  top: 0;
  bottom: 0;
  width: var(--frame-size);
  transform: scaleX(calc(1 - var(--border-progress)));
}

.frame-edge-left {
  left: 0;
  transform-origin: left center;
}

.frame-edge-right {
  right: 0;
  transform-origin: right center;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(18rem, 5fr);
  gap: clamp(2.5rem, 6vw, 6rem);
  align-items: start;
}

.article-copy {
  max-width: 58rem;
}

.section-kicker,
.section-heading {
  margin: 0 0 1rem;
}

.section-heading {
  margin-top: 4rem;
  font-size: clamp(1.4rem, 2.4vw, 2.2rem);
  color: #e8b6ff;
}

.section-kicker {
  font-size: clamp(1.05rem, 1.5vw, 1.25rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f5c4ff;
}

.intro-title {
  margin: 0 0 1.5rem;
  font-size: clamp(2rem, 4.5vw, 4.25rem);
  font-weight: 500;
  line-height: 1.08;
  text-wrap: balance;
  color: #ff9c7f;
}

.intro-lead {
  margin: 0 0 4rem;
  font-size: clamp(1.25rem, 2.2vw, 1.8rem);
  line-height: 1.42;
  color: #f0c5ff;
}

.article-copy p {
  margin: 0 0 1.35rem;
  color: #f7f7fb;
  font-size: 1.05rem;
}

.highlight {
  position: relative;
  color: #fff;
}

.highlight::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -0.1em;
  left: 0;
  z-index: -1;
  height: 0.16em;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s ease 0.15s;
}

.is-visible .highlight::after,
.highlight.is-visible::after {
  transform: scaleX(1);
}

.formula-panel {
  position: sticky;
  top: 5rem;
  z-index: 2;
  padding: clamp(1.25rem, 2.5vw, 2rem);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 1.25rem;
  background: rgba(12, 14, 29, 0.83);
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(14px);
}

.result-label {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.counter-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0.25rem 0 1.5rem;
}

.counter-number {
  font-size: clamp(4rem, 8vw, 7rem);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.counter-suffix {
  margin-bottom: 0.5rem;
  padding: 0.1rem 0.4rem;
  border-radius: 0.35rem;
  color: #000;
  background: #fff;
  font-weight: 900;
  font-size: 1.3rem;
}

.formula-card {
  position: relative;
  margin: 0 0 2rem;
  padding: 1rem;
  overflow: hidden;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
}

.formula-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(65deg, var(--accent), var(--primary));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1s ease;
}

.formula-card.is-visible::before {
  transform: scaleX(1);
}

.formula-card code {
  display: block;
  color: #fff;
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: clamp(0.78rem, 1.15vw, 0.96rem);
  overflow-wrap: anywhere;
}

.metric {
  display: grid;
  grid-template-columns: minmax(7rem, 0.8fr) 1.4fr;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.metric-label {
  font-weight: 800;
  color: #eab1ff;
}

.metric-label-muted {
  color: #c5cbd4;
}

.progress-track {
  height: 0.9rem;
  overflow: hidden;
  border-radius: 999px;
  background: #343846;
}

.progress-fill {
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(65deg, var(--accent), var(--primary));
  transform: scaleX(1);
  transform-origin: left;
  transition: transform 1s cubic-bezier(.22, .61, .36, 1);
}

.js .progress-fill {
  transform: scaleX(0);
}

.js .progress-track.is-visible .progress-fill {
  transform: scaleX(1);
}

.progress-fill-muted {
  background: #858d9a;
}

.site-footer {
  position: relative;
  display: grid;
  min-height: min(100svh, 52rem);
  overflow: clip;
  background:
    linear-gradient(135deg, rgba(203, 102, 255, 0.55), transparent 55%),
    linear-gradient(35deg, #151730, #bd397d 55%, #581b78);
  isolation: isolate;
}

.triangle-pattern {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0.9;
  pointer-events: none;
}

.triangle-pattern .triangle {
  opacity: 0;
  transform: scale(0.12) rotate(-8deg);
  transform-box: fill-box;
  transform-origin: center;
  transition:
    opacity 0.75s ease var(--triangle-delay),
    transform 1.1s cubic-bezier(.18,.72,.28,1.15) var(--triangle-delay);
}

.triangle-pattern.is-active .triangle {
  opacity: var(--triangle-opacity, 0.72);
  transform: scale(1) rotate(0);
}

.site-footer::before,
.site-footer::after {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: -1;
  background: conic-gradient(from 60deg, transparent, rgba(255,255,255,.08), transparent 28%);
  animation: footer-pattern 18s linear infinite;
  animation-play-state: paused;
}

.site-footer::after {
  animation-direction: reverse;
  animation-duration: 26s;
}

@keyframes footer-pattern {
  to { transform: rotate(1turn) scale(1.08); }
}

.footer-stage {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  min-height: 38rem;
  padding-block: 5rem 8rem;
  text-align: center;
}

.footer-stage .eyebrow {
  margin: 0 0 0.5rem;
  font-size: clamp(1.25rem, 2.5vw, 2rem);
  color: #fff;
  text-shadow: 0 0.12em 0.6em rgba(0, 0, 0, 0.48);
}

.footer-role {
  display: inline-block;
  animation: role-glitch 5.4s steps(1, end) infinite;
  animation-play-state: paused;
}

.footer-role:last-child {
  animation-delay: 0.35s;
}

.footer-title {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(3rem, 9vw, 8rem);
  font-weight: 700;
  line-height: 0.95;
  text-wrap: balance;
  color: #fff;
  text-shadow: 0 0.08em 0.32em rgba(0, 0, 0, 0.4);
  animation: glitch-main 4.6s steps(1, end) infinite;
  animation-play-state: paused;
}

.footer-title::before,
.footer-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  animation-duration: 4.6s;
  animation-iteration-count: infinite;
  animation-timing-function: steps(1, end);
  animation-play-state: paused;
}

.footer-title::before {
  color: #55fff0;
  text-shadow: -0.055em 0 #2a43ff;
  clip-path: polygon(0 7%, 100% 7%, 100% 42%, 0 42%);
  animation-name: glitch-upper;
}

.footer-title::after {
  color: #ff57b5;
  text-shadow: 0.055em 0 #ff7b39;
  clip-path: polygon(0 58%, 100% 58%, 100% 94%, 0 94%);
  animation-name: glitch-lower;
}

.js:not(.motion-paused) .gradient-background,
.js:not(.motion-paused) .site-footer::before,
.js:not(.motion-paused) .site-footer::after,
.js:not(.motion-paused) .footer-title,
.js:not(.motion-paused) .footer-title::before,
.js:not(.motion-paused) .footer-title::after,
.js:not(.motion-paused) .footer-role {
  animation-play-state: running;
}

.footer-subtitle {
  margin: 1.2rem 0 0;
  font-size: clamp(1.15rem, 2.5vw, 2rem);
}

@keyframes glitch-main {
  0%, 74%, 81%, 100% { transform: translate(0); }
  75% { transform: translate(-0.018em, 0.008em) skewX(-1deg); }
  77% { transform: translate(0.014em, -0.006em) skewX(1deg); }
  79% { transform: translate(-0.008em, 0); }
}

@keyframes glitch-upper {
  0%, 73%, 82%, 100% { transform: translate(0); opacity: 0.34; }
  74% { transform: translate(-0.075em, -0.018em); opacity: 0.9; }
  76% { transform: translate(0.045em, 0.012em); opacity: 0.68; }
  79% { transform: translate(-0.028em, 0); opacity: 0.82; }
}

@keyframes glitch-lower {
  0%, 72%, 83%, 100% { transform: translate(0); opacity: 0.3; }
  74% { transform: translate(0.065em, 0.018em); opacity: 0.82; }
  77% { transform: translate(-0.05em, -0.012em); opacity: 0.72; }
  80% { transform: translate(0.025em, 0); opacity: 0.9; }
}

@keyframes role-glitch {
  0%, 68%, 76%, 100% { transform: translate(0); text-shadow: none; }
  69% { transform: translateX(-0.05em); text-shadow: 0.06em 0 #55fff0, -0.06em 0 #ff57b5; }
  72% { transform: translateX(0.035em); text-shadow: -0.04em 0 #55fff0, 0.04em 0 #ff57b5; }
  74% { transform: translate(0); text-shadow: none; }
}

.license {
  position: relative;
  z-index: 2;
  align-self: end;
  margin: 0;
  padding: 1rem var(--gutter);
  color: #fff;
  background: rgba(0, 1, 12, 0.68);
  text-align: center;
  font-size: 0.95rem;
}

.license-icons {
  display: inline-flex;
  gap: 0.2rem;
  margin-left: 0.25rem;
  vertical-align: middle;
}

.license-icons img {
  width: 22px;
  height: 22px;
}

.error-page {
  min-height: 100svh;
}

.error-hero {
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: 6rem var(--gutter) 0;
  text-align: center;
}

.error-content {
  position: relative;
  z-index: 2;
  max-width: 46rem;
}

.error-code {
  margin: 0;
  font-family: "Fira Code", ui-monospace, monospace;
  font-size: clamp(7rem, 25vw, 18rem);
  font-weight: 600;
  line-height: 0.82;
  color: #fff;
  text-shadow: 0 0 2rem rgba(92, 24, 103, 0.4);
}

.error-message {
  margin: 2rem 0;
  font-size: clamp(1.3rem, 3vw, 2rem);
  color: #221126;
  font-weight: 800;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.7rem 1.4rem;
  border-radius: 0.66rem;
  color: #000;
  background: linear-gradient(315deg, #fe6860, #fe8a71 47%, #d9bbae);
  box-shadow: 0 0.25rem 0.65rem rgba(26, 41, 77, 0.45);
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button:hover,
.button:focus-visible {
  color: #000;
  transform: translateY(-2px);
  box-shadow: 0 0 0 4px rgba(255,255,255,.3), 0 0.7rem 1.5rem rgba(26, 41, 77, 0.5);
}

.error-license {
  position: relative;
  z-index: 3;
  width: calc(100% + var(--gutter) + var(--gutter));
  margin: 4rem calc(0px - var(--gutter)) 0;
}

@media (max-width: 900px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .formula-panel {
    position: relative;
    top: auto;
    order: -1;
  }

  .hero-title {
    margin-inline: auto 0;
  }

  .sky-section {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .motion-toggle {
    top: 0.65rem;
    right: 0.65rem;
    font-size: 0.9rem;
  }

  .hero-content {
    align-items: end;
  }

  .hero-title {
    width: 100%;
    margin: 0;
    padding-bottom: 8vh;
    font-size: clamp(2.15rem, 11vw, 3.2rem);
  }

  .hero-title span,
  .hero-title code {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .metric {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .result-label {
    text-align: left;
  }

  .counter-wrap {
    justify-content: flex-start;
  }

  .footer-stage {
    min-height: 30rem;
  }

  .license {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

html.motion-paused {
  scroll-behavior: auto;
}

html.motion-paused *,
html.motion-paused *::before,
html.motion-paused *::after {
  animation-play-state: paused !important;
  transition-duration: 0.001ms !important;
}

html.motion-paused .scene-layer {
  transform: none !important;
}

html.motion-paused .frame-edge {
  transform: none !important;
}

html.motion-paused .triangle-pattern .triangle {
  opacity: var(--triangle-opacity, 0.72) !important;
  transform: none !important;
  transition: none !important;
}

html.motion-paused .footer-title::before,
html.motion-paused .footer-title::after {
  transform: none !important;
}

html.motion-paused .progress-fill,
html.motion-paused .formula-card::before,
html.motion-paused .highlight::after {
  transform: scaleX(1);
}

@media (forced-colors: active) {
  .hero-title span,
  .hero-title code {
    -webkit-text-fill-color: CanvasText;
  }

  .animated-frame,
  .formula-panel,
  .button,
  .motion-toggle {
    border: 2px solid CanvasText;
  }

  .footer-title::before,
  .footer-title::after,
  .triangle-pattern {
    display: none;
  }
}

@media print {
  .motion-toggle,
  .scene,
  .gradient-background,
  .particles-wrap,
  .sticky-frame,
  .triangle-pattern {
    display: none !important;
  }

  body,
  .sky-section,
  .site-footer {
    color: #000;
    background: #fff;
  }

  .formula-panel {
    position: static;
    color: #000;
    background: #fff;
    box-shadow: none;
  }
}
