/* Mineral Line — motion base states. See MOTION.md.
   Every initial (hidden) state is scoped under html.motion: without it, everything is final. */

:root {
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-spring: cubic-bezier(.34, 1.36, .64, 1);
  --reveal-dur: 1.1s;
  --reveal-dist: 28px;
  --split-dur: 1s;
}

/* ---------- reveal ---------- */

html.motion [data-reveal]:not(.is-in) { opacity: 0; }
html.motion :is([data-reveal=""], [data-reveal="up"]):not(.is-in) { translate: 0 var(--reveal-dist); }
html.motion [data-reveal="left"]:not(.is-in) { translate: calc(var(--reveal-dist) * -1.5) 0; }
html.motion [data-reveal="right"]:not(.is-in) { translate: calc(var(--reveal-dist) * 1.5) 0; }
html.motion [data-reveal="scale"]:not(.is-in) { scale: .94; }
html.motion [data-reveal="clip"]:not(.is-in) { opacity: 1; clip-path: inset(100% 0 0 0); }
html.motion [data-reveal="clip"].is-in:not(.is-done) { clip-path: inset(0 0 0 0); }

html.motion [data-reveal]:not(.is-done) {
  transition:
    opacity calc(var(--reveal-dur) * .8) var(--ease-out),
    translate var(--reveal-dur) var(--ease-out),
    scale var(--reveal-dur) var(--ease-out),
    clip-path var(--reveal-dur) var(--ease-in-out);
  transition-delay: var(--reveal-delay, 0ms);
}
html.motion [data-reveal]:not(.is-in) { will-change: opacity, translate; }

/* ---------- split text ---------- */

.ml-sr {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.ml-m {
  display: inline-block;
  vertical-align: top;
  /* room for descenders and accents inside the mask */
  padding: .12em .02em .14em;
  margin: -.12em -.02em -.14em;
}
.ml-w, .ml-c { display: inline-block; }
.ml-cw { display: inline-block; white-space: nowrap; }
html.motion [data-split] .ml-m { overflow: hidden; }
html.motion [data-split]:not(.is-in) .ml-w,
html.motion [data-split]:not(.is-in) .ml-c { translate: 0 110%; }
html.motion [data-split="chars"]:not(.is-in) .ml-c { opacity: 0; }
html.motion [data-split]:not(.is-done) .ml-w,
html.motion [data-split]:not(.is-done) .ml-c {
  transition:
    translate var(--split-dur) var(--ease-out),
    opacity calc(var(--split-dur) * .6) var(--ease-out);
  transition-delay: calc(var(--reveal-delay, 0ms) + var(--si, 0) * var(--split-stagger, 35ms));
}
/* Until JS has split it, keep the text invisible only if JS is about to split it. */
html.motion [data-split]:not(.ml-split):not(.is-in) { opacity: 0; }

/* ---------- scramble / count ---------- */

[data-count] { font-variant-numeric: tabular-nums; }
.ml-scr { white-space: pre; }
.ml-scr-lock { display: inline-block; white-space: nowrap; overflow: hidden; vertical-align: bottom; }
html.motion [data-scramble]:not(.is-in) { opacity: 0; }

/* ---------- scenes ---------- */

:where(html.motion [data-scene]) { height: var(--len, 300vh); position: relative; }

/* ---------- tilt ---------- */

html.motion.pointer-fine [data-tilt] {
  transform: perspective(var(--tilt-perspective, 1000px)) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
}
:where([data-tilt]) { position: relative; }
.ml-sheen {
  position: absolute; inset: 0; pointer-events: none; border-radius: inherit; z-index: 2;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(166, 230, 243, .16), rgba(166, 230, 243, .04) 32%, transparent 60%);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity .5s var(--ease-out);
}
html.motion.pointer-fine [data-tilt].is-tilting > .ml-sheen { opacity: 1; }

/* ---------- marquee ---------- */

[data-marquee] { overflow: hidden; }
.ml-marquee-track { display: flex; flex-wrap: nowrap; width: max-content; will-change: transform; }
.ml-marquee-track > * { flex: none; }

/* ---------- cursor follower ---------- */

.ml-cursor {
  --cursor-bg: #ECEDEF; --cursor-fg: #0E0F11;
  position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none;
  translate: 14px 18px;
}
.ml-cursor-label {
  display: block;
  padding: 7px 12px 7px;
  font: 600 12px/1 'Barlow', system-ui, sans-serif;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--cursor-fg); background: var(--cursor-bg);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  white-space: nowrap;
  opacity: 0; scale: .6;
  transition: opacity .25s var(--ease-out), scale .45s var(--ease-spring);
}
.ml-cursor.is-on .ml-cursor-label { opacity: 1; scale: 1; }

/* ---------- hero ---------- */

:where([data-hero-canvas], [data-crystal-echo]) {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
}
[data-hero-canvas], [data-crystal-echo] { opacity: 0; transition: opacity 1s var(--ease-out); }
html.hero-gl [data-hero-canvas], html.hero-still [data-hero-canvas],
[data-crystal-echo].is-live { opacity: 1; }
html:not(.js) [data-hero-canvas], html:not(.js) [data-crystal-echo],
html.hero-nogl [data-hero-canvas] { display: none; }

html.js .hero-fallback { opacity: 0; visibility: hidden; transition: opacity .8s var(--ease-out), visibility 0s .8s; }
html.js .hero-fallback.is-active { opacity: 1; visibility: visible; transition: opacity .8s var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  [data-hero-canvas], [data-crystal-echo], .hero-fallback { transition: none !important; }
}
