/* ==========================================================================
   Emby Technology — Motion
   Preloader, custom cursor, and initial states for scripted reveals.
   ========================================================================== */

/* ---------- Preloader ---------- */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  pointer-events: none;
}

.is-loading .preloader {
  display: block;
  pointer-events: auto;
}

.preloader__panel {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

.preloader__meta {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preloader__meta--top {
  top: calc(var(--nav-h) / 2 - 0.5em);
}

.preloader__meta--bottom {
  bottom: 2.25rem;
}

.preloader__count {
  font-variant-numeric: tabular-nums;
  color: var(--navy);
}

.preloader__bar {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: 1.5rem;
  height: 1px;
  background: var(--line);
  overflow: hidden;
}

.preloader__bar span {
  position: absolute;
  inset: 0;
  background: var(--gradient);
  transform: scaleX(0);
  transform-origin: left;
}

.preloader__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.preloader {
  --pl-mark: clamp(88px, 9vw, 112px);
}

.preloader__meta span {
  white-space: nowrap;
}

.preloader__mark {
  width: var(--pl-mark);
  height: var(--pl-mark);
}

.preloader__words {
  position: absolute;
  top: calc(50% + var(--pl-mark) / 2 + 2rem);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  height: 1.2em;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* positioned by GSAP; hidden until it takes over */
.preloader__words span {
  position: absolute;
  opacity: 0;
}

/* Phones: one calm column — logo, rotating word, progress. No competing labels. */
@media (max-width: 560px) {
  .preloader__meta--top {
    justify-content: center;
  }

  .preloader__meta--top span:last-child {
    display: none;
  }

  .preloader__words {
    font-size: 0.75rem;
  }
}

/* While loading, the nav brand is hidden — the preloader mark flies into it */
.is-loading .brand__mark,
.is-loading .brand__text,
.is-loading .nav__links,
.is-loading .nav__actions {
  opacity: 0;
}

.is-loading .hero [data-hero] {
  opacity: 0;
}

.is-loading .hero__title {
  visibility: hidden;
}

.is-loading .hero__mark {
  opacity: 0;
}

/* ---------- Custom cursor (fine pointers only) ---------- */
.cursor {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .has-cursor .cursor {
    display: block;
  }

  .has-cursor,
  .has-cursor * {
    cursor: none;
  }

  .has-cursor input,
  .has-cursor textarea,
  .has-cursor select {
    cursor: text;
  }

  .cursor__dot,
  .cursor__ring {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9500;
    pointer-events: none;
    border-radius: 50%;
  }

  .cursor__dot {
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    background: var(--navy);
  }

  .cursor__ring {
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 1px solid rgba(7, 27, 62, 0.35);
    transition: width 0.45s var(--ease-out), height 0.45s var(--ease-out), margin 0.45s var(--ease-out),
      background-color 0.45s, border-color 0.45s, opacity 0.3s;
  }

  .cursor.is-hover .cursor__ring {
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    background: rgba(0, 204, 255, 0.08);
    border-color: rgba(1, 87, 244, 0.4);
  }

  .cursor.is-hover .cursor__dot {
    background: var(--blue);
  }

  .cursor.is-light .cursor__dot {
    background: #fff;
  }

  .cursor.is-light .cursor__ring {
    border-color: rgba(255, 255, 255, 0.45);
  }

  .cursor.is-light.is-hover .cursor__ring {
    background: rgba(0, 204, 255, 0.12);
    border-color: rgba(0, 204, 255, 0.6);
  }

  .cursor__label {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #fff;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.3s, transform 0.45s var(--ease-out);
  }

  .cursor.is-view .cursor__ring {
    width: 96px;
    height: 96px;
    margin: -48px 0 0 -48px;
    background: var(--navy);
    border-color: var(--navy);
  }

  .cursor.is-view .cursor__label {
    opacity: 1;
    transform: none;
  }

  .cursor.is-view .cursor__dot {
    opacity: 0;
  }

  .cursor.is-hidden .cursor__dot,
  .cursor.is-hidden .cursor__ring {
    opacity: 0;
  }
}

/* ---------- Scroll reveal initial states (only when JS + motion are on) ---------- */
.js.motion [data-reveal] {
  opacity: 0;
  transform: translateY(28px);
}

/* Split headings stay hidden until their lines are measured and masked */
.js.motion [data-split]:not(.is-split) {
  visibility: hidden;
}

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