/* Polyviral base: tokens, reset, the horizon glow, and the primitives every
   page shares. Load this first; page-specific <style> comes after and wins. */

:root {
  color-scheme: dark;

  /* dusk palette for the horizon glow (raw channels, used inside rgba()) */
  --indigo: 43, 51, 143;
  --violet: 122, 85, 176;
  --peach: 240, 160, 110;
  --sage: 147, 168, 119;

  /* neutral ramp, darkest to lightest */
  --bg: #0e0e0e;
  --surface: #161616;   /* hover fill */
  --line: #1c1c1c;      /* hairline divider */
  --edge: #242424;      /* control border */
  --faint: #3a3a3a;     /* arrows, disabled text */
  --dim: #5a5a5a;       /* tertiary text */
  --muted: #8a8a8a;     /* secondary text */
  --fg: #ededed;        /* primary text */

  --select-bg: #f5f5f5;
  --select-fg: #111111;

  /* one spring for press/hover, one ease for entrances */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- reset ---------- */

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

html {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

::selection {
  background: var(--select-bg);
  color: var(--select-fg);
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ring only: border-radius is left to the element so a focused control keeps
   its own corners */
a:focus-visible {
  outline: 1px solid var(--dim);
  outline-offset: 3px;
}

/* ---------- background glow ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  animation: bg-in 1.6s ease-out both;
}

@keyframes bg-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* animated via transform/opacity only, stays GPU-composited.
   screen blend: overlaps combine like light, no dark halos */
.bg div {
  position: absolute;
  will-change: transform, opacity;
  transform: translateZ(0);
  mix-blend-mode: screen;
}

/* long eased falloff, no perceptible steps */
.bg .b1 {
  left: -30vw;
  bottom: -38vh;
  width: 90vw;
  height: 70vh;
  background: radial-gradient(
    closest-side,
    rgba(var(--indigo), 0.62),
    rgba(var(--indigo), 0.52) 20%,
    rgba(var(--indigo), 0.38) 38%,
    rgba(var(--indigo), 0.26) 52%,
    rgba(var(--indigo), 0.16) 63%,
    rgba(var(--indigo), 0.09) 72%,
    rgba(var(--indigo), 0.04) 80%,
    rgba(var(--indigo), 0) 90%
  );
  animation: drift-a 13s ease-in-out infinite;
}

.bg .b2 {
  left: 20vw;
  bottom: -42vh;
  width: 100vw;
  height: 74vh;
  background: radial-gradient(
    closest-side,
    rgba(var(--peach), 0.55),
    rgba(var(--peach), 0.42) 18%,
    rgba(var(--violet), 0.3) 36%,
    rgba(var(--violet), 0.22) 48%,
    rgba(var(--violet), 0.13) 60%,
    rgba(var(--violet), 0.07) 70%,
    rgba(var(--violet), 0.03) 78%,
    rgba(var(--violet), 0) 88%
  );
  animation: drift-b 9s ease-in-out infinite;
}

.bg .b3 {
  right: -35vw;
  bottom: -36vh;
  width: 80vw;
  height: 60vh;
  background: radial-gradient(
    closest-side,
    rgba(var(--sage), 0.4),
    rgba(var(--sage), 0.3) 25%,
    rgba(var(--sage), 0.18) 45%,
    rgba(var(--sage), 0.1) 60%,
    rgba(var(--sage), 0.05) 70%,
    rgba(var(--sage), 0) 82%
  );
  animation: drift-c 15s ease-in-out infinite;
}

/* film grain dithers away the remaining banding; static, no repaint */
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
  opacity: 0.16;
  /* grain hugs the glow low on the page, easing out well below center */
  -webkit-mask-image: linear-gradient(
    to top,
    rgba(0, 0, 0, 1) 8%,
    rgba(0, 0, 0, 0.55) 20%,
    rgba(0, 0, 0, 0.28) 30%,
    rgba(0, 0, 0, 0.12) 38%,
    rgba(0, 0, 0, 0.04) 45%,
    transparent 52%
  );
  mask-image: linear-gradient(
    to top,
    rgba(0, 0, 0, 1) 8%,
    rgba(0, 0, 0, 0.55) 20%,
    rgba(0, 0, 0, 0.28) 30%,
    rgba(0, 0, 0, 0.12) 38%,
    rgba(0, 0, 0, 0.04) 45%,
    transparent 52%
  );
}

@keyframes drift-a {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.5;
  }
  50% {
    transform: translate(5vw, -3vh) scale(1.1);
    opacity: 0.9;
  }
}

@keyframes drift-b {
  0%, 100% {
    transform: translate(0, 0) scale(1.08);
    opacity: 0.45;
  }
  50% {
    transform: translate(-6vw, 2vh) scale(1);
    opacity: 0.75;
  }
}

@keyframes drift-c {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.45;
  }
  50% {
    transform: translate(-4vw, -2vh) scale(1.09);
    opacity: 0.75;
  }
}

/* ---------- primitives ---------- */

/* the Polyviral wordmark glyph; pages set their own width */
.mark {
  height: auto;
  flex: none;
  transition: transform 0.28s var(--spring);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* backwards fill: hidden through the delay, released after the entrance,
   so hover and press transforms are never pinned */
.rise {
  animation: rise 0.5s var(--ease) backwards;
  animation-delay: var(--rise-delay, 0s);
}

/* ---------- App Store call to action ---------- */

/* Two states share one box so the button never moves when an app goes live:
     <a class="appstore" href="https://apps.apple.com/app/id...">   live
     <span class="appstore soon">                                   pre-launch
   Both wrap their label in .appstore-label. */
.appstore {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  user-select: none;
  -webkit-user-drag: none;
  transition: background 0.2s, border-color 0.2s, color 0.2s,
    box-shadow 0.25s, transform 0.16s var(--spring);
}

.appstore .apple {
  width: 15px;
  height: 15px;
  flex: none;
  transition: transform 0.28s var(--spring);
}

a.appstore:hover {
  background: #ffffff;
  border-color: #ffffff;
  box-shadow: 0 8px 28px rgba(255, 255, 255, 0.13);
}

a.appstore:hover .apple {
  transform: scale(1.12);
}

a.appstore:active {
  transform: scale(0.97);
  box-shadow: none;
}

/* pre-launch: the same pill, held back to a quiet outline */
.appstore.soon {
  background: transparent;
  border-color: var(--line);
  color: var(--dim);
  cursor: default;
}

.appstore.soon .apple {
  opacity: 0.55;
}

/* a little "not yet" head-shake when someone tries the disabled button */
@keyframes nope {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  70% { transform: translateX(4px); }
}

.appstore.soon:active .appstore-label {
  display: inline-block;
  animation: nope 0.28s ease;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .rise {
    animation: none;
    opacity: 1;
  }

  .bg,
  .bg div {
    animation: none;
    opacity: 0.5;
  }

  .bg {
    opacity: 1;
  }
}
