/* THE BUTTON: main styles.
   No inline styles are used anywhere (the CSP forbids them). */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  color-scheme: dark;
  --bg: #040406;
  --fg: #f5f5f7;
  --muted: #8d8d99;
  --line: rgba(255, 255, 255, 0.16);

  /* Button size: as large as the screen allows. */
  --size: min(86vw, 50vh, 620px);
  --depth: calc(var(--size) * 0.05);
  --spin-time: 20s;

  --rainbow: conic-gradient(from 0deg, #ff3b30, #ff9500, #ffd60a, #30d158, #00c7be, #0a84ff, #5e5ce6, #bf5af2, #ff375f, #ff3b30);
  --rainbow-line: linear-gradient(90deg, #ff3b30, #ff9500, #ffd60a, #30d158, #00c7be, #0a84ff, #5e5ce6, #bf5af2, #ff375f);
}

@supports (height: 100svh) {
  :root { --size: min(86vw, 50svh, 620px); }
}

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  min-height: 100svh;
  background: radial-gradient(120% 80% at 50% 42%, #0a0a11 0%, #040406 58%, #000 100%);
  background-color: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

/* ---------- Layout ---------- */

.stage {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 3vh, 2rem);
  padding: clamp(1.25rem, 3vh, 2.25rem) 1.25rem 1.5rem;
  text-align: center;
}

.top { display: flex; flex-direction: column; align-items: center; }

.title {
  margin: 0;
  padding-left: 0.5em; /* balances the trailing letter-spacing */
  font-size: clamp(0.85rem, 2vw, 1.1rem);
  font-weight: 600;
  letter-spacing: 0.5em;
}

.counter {
  margin: 0.4em 0 0.1em;
  font-size: clamp(1.6rem, 6.4vw, 4.75rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.counter-sep { padding: 0 0.28em; color: var(--muted); font-weight: 300; }
.counter-goal { color: var(--muted); }

.counter-total-bump { animation: bump 0.35s ease-out; }

.counter-label {
  margin: 0;
  padding-left: 0.4em;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.4em;
}

.progress {
  width: min(320px, 70vw);
  height: 2px;
  margin-top: 0.9rem;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-fill {
  width: 100%;
  height: 100%;
  background: var(--rainbow-line);
  transform-origin: left center;
  transform: scaleX(var(--progress, 0));
  transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.3, 1);
}

/* ---------- The button ---------- */

.button-wrap {
  position: relative;
  flex: none;
  width: var(--size);
  height: calc(var(--size) + var(--depth));
  margin: calc(var(--size) * 0.03) 0;
}

.spin {
  position: absolute;
  inset: -2%;
  border-radius: 50%;
  background: var(--rainbow);
  animation: spin var(--spin-time) linear infinite;
  will-change: transform;
}

/* Soft colored light around the button. */
.glow {
  position: absolute;
  left: -9%;
  top: -5%;
  width: 118%;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(calc(var(--size) * 0.11));
  opacity: 0.42;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.glow .spin { inset: 0; }

/* The dark lower edge that gives the button its thickness. */
.btn-side {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 50%;
  box-shadow: 0 calc(var(--size) * 0.05) calc(var(--size) * 0.09) rgba(0, 0, 0, 0.65);
}
.btn-side .spin { filter: brightness(0.34) saturate(1.1); }

.btn-top {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: #111;
  color: inherit;
  cursor: pointer;
  isolation: isolate;
  transform: translateY(0);
  transition: transform 0.14s cubic-bezier(0.2, 0.8, 0.3, 1), filter 0.3s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-top.is-pressed {
  transform: translateY(calc(var(--depth) * 0.82));
  transition-duration: 0.06s;
}

.btn-top:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.85);
  outline-offset: calc(var(--size) * 0.025);
}

/* Spherical shading and inner light. */
.tint {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 52%),
    radial-gradient(circle at 50% 55%, rgba(0, 0, 0, 0) 56%, rgba(0, 0, 0, 0.38) 100%);
  box-shadow:
    inset 0 calc(var(--size) * 0.012) calc(var(--size) * 0.02) rgba(255, 255, 255, 0.6),
    inset 0 calc(var(--size) * -0.035) calc(var(--size) * 0.07) rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* Glossy reflection on the upper half. */
.gloss {
  position: absolute;
  left: 14%;
  top: 3.5%;
  width: 72%;
  height: 44%;
  border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.62) 0%, rgba(255, 255, 255, 0.14) 55%, rgba(255, 255, 255, 0) 100%);
  filter: blur(calc(var(--size) * 0.004));
  pointer-events: none;
}

/* Light bouncing back from the bottom edge. */
.bounce {
  position: absolute;
  left: 18%;
  bottom: 3%;
  width: 64%;
  height: 22%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

.button-wrap.is-pressed .glow { opacity: 0.62; }

@media (hover: hover) {
  .button-wrap[data-ready="true"] .btn-top:hover { filter: brightness(1.08); }
}

/* Signed in, but no click possible right now: the button stays visible but calmer. */
.button-wrap[data-ready="false"] .btn-top { filter: saturate(0.45) brightness(0.72); }
.button-wrap[data-ready="false"] .glow { opacity: 0.14; }
.button-wrap[data-busy="true"] .btn-top { cursor: progress; }

/* ---------- Text below the button ---------- */

.info { display: flex; flex-direction: column; align-items: center; gap: 0.45rem; }

.tagline {
  margin: 0;
  padding-left: 0.32em;
  font-size: clamp(0.9rem, 2.4vw, 1.15rem);
  font-weight: 600;
  letter-spacing: 0.32em;
}

.milestone { margin: 0.2rem 0 0; font-size: 0.98rem; font-variant-numeric: tabular-nums; }

.explain {
  max-width: 34rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.reached { margin: 0; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.actions { display: flex; flex-direction: column; align-items: center; gap: 0.85rem; width: 100%; }

.status { min-height: 1.5em; margin: 0; max-width: 34rem; font-size: 0.95rem; line-height: 1.5; }
.status[data-tone="error"] { color: #ff8a80; }
.status[data-tone="success"] { color: #7ee2a0; }

.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.stack { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; }

.user-line { margin: 0; color: var(--muted); font-size: 0.85rem; }

.packages { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; }
.package-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }
.fine { max-width: 30rem; margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }

.turnstile-box { display: flex; justify-content: center; }
.turnstile-box.is-active { margin-top: 0.5rem; }

.link-btn {
  display: inline-block;
  padding: 0.65em 1.35em;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.link-btn:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.32); }
.link-btn:active { transform: scale(0.98); }
.link-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.link-btn:disabled { opacity: 0.5; cursor: default; }
.link-btn--primary { border-color: transparent; background: #f5f5f7; color: #050507; font-weight: 600; }
.link-btn--primary:hover { background: #fff; border-color: transparent; }
.link-btn--quiet { border-color: transparent; color: var(--muted); }

.link-btn.attention { animation: attention 1.1s ease-out 1; }

.ad-slot { width: 100%; max-width: 728px; min-height: 90px; margin: 0 auto; }

.footer { margin-top: 0.5rem; }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem 1.25rem; font-size: 0.78rem; }
.footer-nav a { color: var(--muted); text-decoration: none; }
.footer-nav a:hover, .footer-nav a:focus-visible { color: var(--fg); text-decoration: underline; }

.noscript { color: var(--muted); font-size: 0.9rem; }

/* ---------- Milestone celebration (see js/celebration.js) ---------- */

.celebration-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 50;
}

.celebration {
  position: fixed;
  left: 50%;
  top: 16%;
  z-index: 60;
  max-width: calc(100vw - 2rem);
  padding: 1.1rem 1.8rem 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  background: rgba(8, 8, 12, 0.78);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 14px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.celebration.is-visible { opacity: 1; transform: translate(-50%, 0); }

.celebration-kicker { margin: 0; padding-left: 0.4em; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.4em; }

.celebration-number {
  margin: 0.15em 0;
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  background: var(--rainbow-line);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.celebration-text { margin: 0; color: var(--fg); font-size: 0.9rem; }

/* ---------- Animations ---------- */

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes attention {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.55); }
  100% { box-shadow: 0 0 0 18px rgba(255, 255, 255, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
  .counter-total-bump, .link-btn.attention { animation: none; }
  .btn-top, .glow, .progress-fill, .link-btn, .celebration { transition: none; }
}
