/* ==========================================================================
   Effects – presentation driven by JavaScript (classes / properties are only
   ever set by assets/js). Loaded last: these states override the components.
   ========================================================================== */

/* ---------- View switch (View Transitions API, view.js) ----------
   The new view is revealed as a growing circle (clip-path animated by view.js) on top of
   the old one; the audience switch glides to its place in the new view. */
::view-transition-old(root), ::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-group(audience-switch) {
  animation-duration: .7s;
  animation-timing-function: var(--ease-in-out);
}
::view-transition-old(audience-switch), ::view-transition-new(audience-switch) { animation-duration: .35s; }

/* ---------- Scroll progress (CSS only, where scroll timelines are supported) ---------- */
.scroll-progress {
  position: fixed; inset: 0 0 auto; z-index: 60; height: 3px; pointer-events: none;
  background: linear-gradient(90deg, var(--olive), var(--lime));
  box-shadow: 0 0 12px rgb(230 254 44 / .6);
  transform-origin: 0 50%; scale: 0 1;
}
@supports (animation-timeline: scroll()) {
  .scroll-progress { animation: progress linear both; animation-timeline: scroll(root); }
  @keyframes progress { to { scale: 1 1; } }
}

/* ---------- Scroll reveal (motion.js) ---------- */
.reveal { opacity: 0; }
.reveal.is-visible { opacity: 1; animation: reveal .9s var(--ease-out) var(--reveal-delay, 0s) both; }
@keyframes reveal {
  from { opacity: 0; translate: 0 28px; }
  to { opacity: 1; translate: 0 0; }
}

/* Split-word headlines: the words rise in one by one */
.split .word { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .06em; margin-bottom: -.06em; }
.split .word > span { display: inline-block; translate: 0 105%; }
.split.is-visible .word > span {
  animation: word-up 1s var(--ease-out) calc(var(--reveal-delay, 0s) + var(--i) * 45ms) both;
}
@keyframes word-up { from { translate: 0 105%; } to { translate: 0 0; } }
.split.reveal { opacity: 1; }
.split.reveal.is-visible { animation: none; }

/* ---------- Card spotlight + glowing edge and tilt (pointer.js adds .has-spotlight) ---------- */
.has-spotlight {
  --mx: 50%; --my: 50%;
  position: relative;
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: --spot .6s var(--ease-out), transform .6s var(--ease-out), box-shadow .6s var(--ease-out), filter .6s var(--ease-out);
}
.has-spotlight:hover { --spot: 1; }
.has-spotlight::after,
.has-spotlight::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 1;
}
.has-spotlight::after {
  background: radial-gradient(320px circle at var(--mx) var(--my), rgb(var(--spot-color) / calc(var(--spot) * var(--spot-strength))), transparent 65%);
}
.has-spotlight::before {
  padding: 1px;
  background: radial-gradient(220px circle at var(--mx) var(--my), rgb(var(--spot-color) / calc(var(--spot) * .75)), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

/* ---------- Lime light that follows the pointer across the whole page (pointer.js writes --gx/--gy) ----------
   Sits above the content and blends in, so it also shows on opaque panels:
   screen only lightens the dark view, multiply only tints the light view – text stays crisp. */
.pointer-glow {
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  mix-blend-mode: screen;
  background: radial-gradient(520px circle at var(--gx, 70%) var(--gy, 40%), rgb(230 254 44 / var(--glow-alpha, .06)), transparent 70%);
  opacity: 0; transition: opacity .6s var(--ease-out);
}
.pointer-glow.is-active { opacity: 1; }
html[data-view="creators"] .pointer-glow { --glow-alpha: .2; mix-blend-mode: multiply; }

/* ---------- Phone swipe carousels (sliders.js) ----------
   The hero reel and the card grids become snap carousels (.m-carousel) with dot
   navigation (.m-dots); the centred slide is .is-current. The !important flags
   override the grid layouts of the individual sections. */
.m-dots { display: none; }

/* ---------- Page loader (html.is-loading is set by the inline boot script for external arrivals) ---------- */
.loader { display: none; }
html.is-loading .loader {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-content: center; justify-items: center; gap: 22px;
  background: var(--bg);
  clip-path: inset(0 0 0 0);
}
/* soft accent glow behind the mark */
html.is-loading .loader::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 360px; height: 360px; translate: -50% -50%;
  border-radius: 50%; background: var(--accent-ui); opacity: .14; filter: blur(90px);
  animation: breathe 2.4s var(--ease-in-out) infinite alternate;
}
html.is-loading:not(.is-loaded) { overflow: hidden; }
/* hold the page's own entrance animations until the curtain lifts */
html.is-loading:not(.is-loaded) :is(.site-header, main) * { animation-play-state: paused !important; }

.loader__logo { width: 200px; height: auto; color: var(--text); opacity: .92; }
/* progress: creeps towards 85 % while loading, completes on exit */
.loader__bar {
  position: relative; width: 200px; height: 2px; overflow: hidden; border-radius: 2px;
  background: var(--glass-edge);
}
.loader__bar::after {
  content: ""; position: absolute; inset: 0; transform-origin: 0 50%;
  background: var(--accent-ui); box-shadow: 0 0 12px var(--accent-ui);
  scale: 0 1; animation: loader-progress .6s var(--ease-out) forwards;
}
@keyframes loader-progress { to { scale: .85 1; } }

/* exit: bar completes, content lifts away, then the curtain wipes upwards */
html.is-loaded .loader__bar::after { scale: 1 1; animation: none; transition: scale .25s var(--ease-out); }
html.is-loaded .loader > * { opacity: 0; translate: 0 -16px; transition: opacity .25s var(--ease-out) .1s, translate .35s var(--ease-out) .1s; }
html.is-loaded .loader {
  clip-path: inset(0 0 100% 0);
  transition: clip-path .6s var(--ease-in-out) .15s; /* ends before boot script removes .is-loading (800 ms) */
}

/* ---------- Custom cursor: spinning star + viewfinder frame (cursor.js, fine pointers only) ---------- */
html.has-cursor, html.has-cursor * { cursor: none !important; }
.cursor { position: fixed; inset: 0; z-index: 10000; pointer-events: none; opacity: 0; transition: opacity .3s var(--ease-out); }
.cursor.is-visible { opacity: 1; }
.cursor__star, .cursor__frame { position: absolute; top: 0; left: 0; will-change: transform; }
/* star: JS moves the wrapper, the svg spins and reacts to state */
.cursor__star svg {
  position: absolute; left: 0; top: 0; width: 14px; height: 14px; max-width: none; translate: -50% -50%;
  color: var(--accent-ui);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent-ui) 70%, transparent));
  animation: spin 6s linear infinite;
  transition: scale .35s var(--ease-spring);
}
.cursor.is-hover .cursor__star svg { scale: .55; animation-duration: 1.6s; }
.cursor.is-down .cursor__star svg { scale: .5; }
/* viewfinder: JS sets transform + size; corners are drawn with borders */
.cursor__frame { width: 30px; height: 30px; }
.cursor__frame i {
  position: absolute; width: 8px; height: 8px;
  border: 0 solid color-mix(in srgb, var(--accent-ui) 60%, transparent);
  transition: border-color .3s var(--ease-out), width .3s var(--ease-out), height .3s var(--ease-out);
}
.cursor__frame i:nth-child(1) { left: 0; top: 0; border-width: 1.5px 0 0 1.5px; border-top-left-radius: 3px; }
.cursor__frame i:nth-child(2) { right: 0; top: 0; border-width: 1.5px 1.5px 0 0; border-top-right-radius: 3px; }
.cursor__frame i:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 1.5px 1.5px; border-bottom-left-radius: 3px; }
.cursor__frame i:nth-child(4) { right: 0; bottom: 0; border-width: 0 1.5px 1.5px 0; border-bottom-right-radius: 3px; }
.cursor.is-hover .cursor__frame i { width: 12px; height: 12px; border-color: var(--accent-ui); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 640px) {
  .hero-reel { --m-card: 56vw; }
  .bento { --m-card: 80vw; }
  .step-list { --m-card: 76vw; }
  .system-grid { --m-card: 80vw; }
  .stat-list { --m-card: 64vw; }

  .m-carousel {
    position: relative;
    display: flex !important; align-items: center; justify-content: flex-start !important; gap: 12px;
    width: auto; max-width: none !important;
    margin-inline: calc(var(--gutter) * -1) !important;
    padding: 12px calc((100vw - var(--m-card)) / 2) !important;
    overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scrollbar-width: none;
    -webkit-mask-image: none; mask-image: none;
    transform: none;
  }
  .m-carousel::-webkit-scrollbar { display: none; }
  .m-carousel > * {
    flex: 0 0 var(--m-card);
    width: var(--m-card) !important; max-width: none !important; height: auto;
    margin: 0 !important; justify-self: auto;
    scroll-snap-align: center; scroll-snap-stop: always;
    scale: .9; opacity: .55;
    transition: scale .5s var(--ease-out), opacity .5s var(--ease-out), transform .3s ease;
  }
  .m-carousel > .is-current { scale: 1; opacity: 1; }
  .stat-list.m-carousel > * { height: 190px; }

  .m-dots { display: flex; justify-content: center; gap: 6px; margin-top: 16px; color: var(--text); }
  .m-dots button {
    position: relative; width: 8px; height: 8px; padding: 0; border: 0; border-radius: 99px;
    background: currentColor; opacity: .22; cursor: pointer;
    transition: width .4s var(--ease-out), opacity .4s var(--ease-out), background-color .4s var(--ease-out);
  }
  .m-dots button::after { content: ""; position: absolute; inset: -12px -3px; } /* bigger tap target */
  .m-dots button[aria-current="true"] { width: 26px; opacity: 1; background: var(--accent-ui); }
}
@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .m-carousel > * { transition: none; }
}

@media (hover: none) {
  .has-spotlight:hover { --spot: 0; }

  /* Touch devices: lighter compositing. Phones have little GPU memory, and every extra
     layer (3D transform, backdrop blur, animated blur) costs it – too many layers make
     iOS drop tiles while scrolling, which shows as flicker.
     - The tilt is pointer-only, so the cards need no 3D transform (= no layer each).
     - The breathing glows and the hero aurora are huge blurred layers; they stay, still.
     - Backdrop blur only on the header and its menu. Elsewhere it sits on elements that
       fade in, which is a known cause of flicker in Safari; panels on photos get a
       slightly denser surface instead, so their text stays readable.
     - The CTA ring pulses a few times when the button appears instead of forever
       (it is repainted every frame while it runs). */
  .has-spotlight { transform: none; }
  .glow, .hero::before { animation: none; }
  .btn--glass, .btn--white, .faq__list .faq__item, .stat, .to-top__icon, .campaign__tag, .campaign__stats div {
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .campaign__tag { background: rgb(23 23 23 / .72); }
  .campaign__stats div { background: linear-gradient(90deg, rgb(40 40 40 / .82), rgb(40 40 40 / .55)); }
  .btn--primary, .btn--lime { animation-iteration-count: 3; }
  .btn--primary.reveal.is-visible, .btn--lime.reveal.is-visible { animation-iteration-count: 1, 3; }
}
