/* Motion system — local preview only until you publish.
   Respects prefers-reduced-motion throughout. */

:root {
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --motion-fast: 0.28s;
  --motion-med: 0.55s;
  --motion-slow: 0.9s;
}

/* ---------- Speed lines: slow diagonal drift ---------- */
.speed-lines {
  animation: speed-drift 28s linear infinite;
  will-change: background-position;
}

@keyframes speed-drift {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 240px 80px;
  }
}

/* Soft pulse on the hero glow (body gradients stay static; overlay pulse) */
body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(
    700px 380px at 70% 0%,
    color-mix(in srgb, var(--accent) 22%, transparent),
    transparent 65%
  );
  opacity: 0.55;
  animation: glow-breathe 7s var(--ease-soft) infinite alternate;
}

@keyframes glow-breathe {
  from {
    opacity: 0.35;
    transform: scale(1);
  }
  to {
    opacity: 0.7;
    transform: scale(1.06);
  }
}

/* ---------- Hero entrance ---------- */
.hero .badge,
.hero h1,
.hero .subtitle,
.hero .nav {
  opacity: 0;
  transform: translateY(18px);
  animation: rise-in var(--motion-slow) var(--ease-out) forwards;
}

.hero .badge {
  animation-delay: 0.05s;
}
.hero h1 {
  animation-delay: 0.14s;
}
.hero .subtitle {
  animation-delay: 0.26s;
}
.hero .nav {
  animation-delay: 0.38s;
}

.hero h1 {
  background: linear-gradient(
    105deg,
    var(--ink) 0%,
    var(--ink) 40%,
    var(--accent-soft) 50%,
    var(--ink) 60%,
    var(--ink) 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation:
    rise-in var(--motion-slow) var(--ease-out) 0.14s forwards,
    title-shine 4.5s var(--ease-soft) 1.1s infinite;
}

/* Fallback: if bg-clip fails, keep ink color after rise */
@supports not (background-clip: text) {
  .hero h1 {
    color: var(--ink);
    background: none;
    animation: rise-in var(--motion-slow) var(--ease-out) 0.14s forwards;
  }
}

@keyframes rise-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes title-shine {
  0%,
  100% {
    background-position: 100% 50%;
  }
  50% {
    background-position: 0% 50%;
  }
}

.badge {
  position: relative;
  overflow: hidden;
}

.badge::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 30%,
    color-mix(in srgb, var(--accent-soft) 35%, transparent) 50%,
    transparent 70%
  );
  transform: translateX(-120%);
  animation: badge-sweep 3.8s var(--ease-soft) 1.4s infinite;
}

@keyframes badge-sweep {
  0%,
  70%,
  100% {
    transform: translateX(-120%);
  }
  85% {
    transform: translateX(120%);
  }
}

/* Hero count pop when the number loads / changes */
#hero-count.is-pop,
#total-count.is-pop {
  display: inline-block;
  animation: count-pop 0.55s var(--ease-out);
}

@keyframes count-pop {
  0% {
    transform: scale(0.7);
    opacity: 0.4;
  }
  55% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---------- Buttons ---------- */
.btn {
  transition:
    background 0.2s var(--ease-soft),
    border-color 0.2s var(--ease-soft),
    transform 0.2s var(--ease-out),
    box-shadow 0.25s var(--ease-soft);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary {
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent);
  animation: cta-pulse 2.8s var(--ease-soft) 1.6s infinite;
}

.btn-primary:hover {
  box-shadow:
    0 8px 28px color-mix(in srgb, var(--accent) 35%, transparent),
    0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
  animation: none;
}

@keyframes cta-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent);
  }
  50% {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 0%, transparent),
      0 0 24px color-mix(in srgb, var(--accent) 28%, transparent);
  }
}

.btn-x .x-logo {
  display: inline-block;
  transition: transform 0.35s var(--ease-out);
}

.btn-x:hover .x-logo {
  transform: rotate(-8deg) scale(1.12);
}

/* ---------- Scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity var(--motion-med) var(--ease-out),
    transform var(--motion-med) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal.is-in {
  opacity: 1;
  transform: translateY(0);
}

.reveal-scale {
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transition:
    opacity var(--motion-med) var(--ease-out),
    transform var(--motion-med) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal-scale.is-in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Pillars stagger via delay vars set in HTML / JS */
.pillars li {
  transition:
    border-color 0.2s,
    background 0.2s,
    transform 0.25s var(--ease-out),
    box-shadow 0.25s var(--ease-soft);
}

.pillars li:hover {
  transform: translateY(-3px);
  border-color: var(--surface-hover-border);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Cards */
.card {
  transition:
    border-color 0.25s var(--ease-soft),
    box-shadow 0.3s var(--ease-soft),
    transform 0.3s var(--ease-out);
}

.card:hover {
  box-shadow:
    var(--shadow),
    0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent);
}

/* ---------- Rail panels ---------- */
html.motion-on .rail-panel:not(.is-in) {
  opacity: 0;
  transform: translateX(18px);
}

@media (max-width: 959px) {
  html.motion-on .rail-panel:not(.is-in) {
    transform: translateY(18px);
  }
}

.rail-panel {
  transition:
    border-color 0.25s,
    box-shadow 0.3s var(--ease-soft),
    transform 0.35s var(--ease-out),
    opacity 0.35s var(--ease-out);
}

.rail-panel.is-in {
  opacity: 1;
  transform: none;
  animation: panel-in 0.7s var(--ease-out) both;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 959px) {
  @keyframes panel-in {
    from {
      opacity: 0;
      transform: translateY(18px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* ---------- List items (signatories / comments) ---------- */
.signatory-list li,
.comment-showcase > li,
.comment-list li {
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  animation: item-in 0.45s var(--ease-out) forwards;
  animation-delay: var(--item-delay, 0ms);
}

@keyframes item-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.signatory-list li {
  transition:
    border-color 0.2s,
    background 0.2s,
    transform 0.22s var(--ease-out),
    box-shadow 0.22s var(--ease-soft);
}

.signatory-list li:hover {
  transform: translateX(3px);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 10%, transparent);
}

.avatar {
  transition: transform 0.3s var(--ease-out);
}

.signatory-list li:hover .avatar {
  transform: scale(1.08);
}

/* Chips */
.chip {
  transition:
    transform 0.2s var(--ease-out),
    border-color 0.2s,
    background 0.2s;
}

.chip:hover {
  transform: translateY(-2px) scale(1.03);
  border-color: var(--surface-hover-border);
}

/* Load more */
.load-more.is-shown {
  animation: rise-in 0.4s var(--ease-out) both;
}

/* Banner entrance */
.banner:not([hidden]) {
  animation: banner-in 0.5s var(--ease-out) both;
}

@keyframes banner-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Theme toggle */
.theme-toggle {
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.25s var(--ease-out),
    box-shadow 0.25s;
}

.theme-toggle:hover {
  transform: translateY(-1px) scale(1.03);
}

.theme-toggle:active .theme-icon {
  animation: theme-spin 0.45s var(--ease-out);
}

@keyframes theme-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(180deg);
  }
}

/* Footer fade */
footer.reveal.is-in {
  transition-duration: 0.7s;
}

/* ---------- Reduced motion ---------- */
@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;
  }

  .hero .badge,
  .hero h1,
  .hero .subtitle,
  .hero .nav,
  .reveal,
  .reveal-scale,
  .signatory-list li,
  .comment-showcase > li,
  .comment-list li,
  .rail-panel,
  body::before,
  .speed-lines {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }

  .hero h1 {
    color: var(--ink);
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
  }
}
