/* ==========================================================================
   Web MDT — Motion layer + mobile-specific designs
   --------------------------------------------------------------------------
   Pairs with motion.js (GSAP 3 + ScrollTrigger + SplitText, plain-WebGL hero).
   Flags on <html>:
     .motion        set by boot.js when motion is allowed (pre-hides intro)
     .motion-ready  set by motion.js once GSAP has taken over
     .menu-open     set by app.js while the mobile menu is open
   Everything degrades to the static design when JS/motion is unavailable.
   Values reference tokens.css; effect-only gradients/rgba are local.
   ========================================================================== */

/* ---------- pre-hide intro until GSAP sets its from-states ---------- */
.motion:not(.motion-ready) [data-intro],
.motion:not(.motion-ready) .hero__title,
.motion:not(.motion-ready) .hero__glyph { visibility: hidden; }

/* GSAP owns reveals + transforms once ready: drop CSS transitions that would fight it */
.motion-ready .reveal { opacity: 1; transform: none; transition: none; }
.motion-ready .card { transition: box-shadow var(--transition-slow), border-color var(--transition-slow); }
.motion-ready .card:hover { transform: none; }
.motion-ready .logo-tile { transition: none; }
.motion-ready .logo-tile:hover { transform: none; }
.motion-ready .slide { transition: none; }
.motion-ready .hero__progress-bar { transition: none; }

/* SplitText helpers */
/* masks clip descenders (y, g) unless the line box is padded */
.split-line, .split-line-mask, .split-word-mask { padding-bottom: .14em; margin-bottom: -.14em; }
.split-char, .split-word { display: inline-block; will-change: transform; }

/* ---------- scroll progress ---------- */
.scroll-progress { position: fixed; top: 0; left: 0; width: 100%; height: 3px; z-index: calc(var(--z-header) + 2); pointer-events: none; display: none; }
.motion-ready .scroll-progress { display: block; }
.scroll-progress__bar { display: block; height: 100%; width: 100%; background: var(--color-brand); transform: scaleX(0); transform-origin: 0 50%; box-shadow: 0 0 12px rgba(246, 197, 0, .6); }

/* ---------- header hide/show ---------- */
.site-header { will-change: transform; }
.site-header.is-hidden { transform: translateY(-100%); }
.motion-ready .site-header { transition: background var(--transition), box-shadow var(--transition), transform .45s var(--ease-out); }

/* ---------- hero: WebGL + grid ---------- */
.hero3d { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0; transition: opacity 1.2s ease; }
.hero3d.is-live { opacity: 1; }
.hero3d__canvas { display: block; width: 100%; height: 100%; }
.hero__grid {
  position: absolute; inset: -20% -10% 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(80% 60% at 50% 40%, #000 20%, transparent 75%);
  mask-image: radial-gradient(80% 60% at 50% 40%, #000 20%, transparent 75%);
}
.hero__inner, .hero__scrollcue { position: relative; z-index: 1; }
/* desktop: particles drift over the image stage (canvas never takes pointer events) */
@media (min-width: 880px) { .hero3d { z-index: 2; } }
.hero__glyph { z-index: 0; will-change: transform; }
.hero__stage { transform-style: preserve-3d; will-change: transform; }
.hero__mark::after { transform: scaleX(var(--mark, 1)); transform-origin: 0 50%; }
.hero__caption-label { display: inline-block; }

/* ---------- marquee band ---------- */
.marquee { position: relative; background: var(--color-dark); color: var(--color-on-dark); overflow: hidden; padding: 34px 0; border-top: 1px solid var(--hairline-dark); }
.marquee__row { display: flex; white-space: nowrap; }
.marquee__track { display: flex; align-items: center; gap: 34px; padding-right: 34px; flex: none; will-change: transform; }
.marquee__track span { font-size: clamp(30px, 4.6vw, 64px); font-weight: var(--fw-black); letter-spacing: -.02em; line-height: 1.1; }
.marquee__track i { font-style: normal; font-family: var(--font-mono); font-weight: var(--fw-bold); color: var(--color-brand); font-size: clamp(22px, 3vw, 42px); }

/* ---------- services cards: spotlight + 3D tilt ---------- */
.cards { perspective: 1400px; }
.card { transform-style: preserve-3d; }
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), rgba(246, 197, 0, .16), transparent 60%);
  transition: opacity var(--transition);
}
.card:hover::before { opacity: 1; }
.card--callout::before { background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), rgba(246, 197, 0, .22), transparent 60%); }
.card__icon, .card__title, .card__text { position: relative; }
.motion-ready .card__icon { will-change: transform; }
.card__shade { position: absolute; inset: 0; border-radius: inherit; background: var(--color-dark); opacity: 0; pointer-events: none; z-index: 2; }

/* ---------- about ---------- */
.stat__num .stat__count { color: var(--color-ink-strong); }
.about__media { will-change: clip-path; }
.about__media img { will-change: transform; }
.about__glyph { will-change: transform; }

/* ---------- clients ---------- */
.logos { perspective: 1200px; }
.logo-tile { will-change: transform; }

/* ---------- CTA ---------- */
.cta__bg { position: absolute; inset: 0; background: var(--color-brand); pointer-events: none; will-change: clip-path; }
.cta__inner { position: relative; z-index: 1; }
.motion-ready .cta { background: var(--color-dark); }
.cta__btn .brace { display: inline-block; transition: transform var(--transition); }
.cta__btn:hover .brace:first-child { transform: translateX(-6px); }
.cta__btn:hover .brace:last-child { transform: translateX(6px); }

/* ---------- footer wordmark ---------- */
/* mirrors the {web}mdt logo lockup: solid Montserrat, tone-on-tone, yellow mono braces */
.site-footer__mark {
  font-family: var(--font-base); font-weight: var(--fw-black); line-height: 1.1; text-align: center;
  font-size: min(13vw, 180px); letter-spacing: -.04em; white-space: nowrap;
  color: var(--color-on-dark);
  padding: 40px 0 14px; user-select: none;
}
.site-footer__brace { font-family: var(--font-mono); font-weight: var(--fw-bold); color: var(--color-brand); letter-spacing: -.06em; }

/* ---------- custom cursor (fine pointers only, desktop) ---------- */
.cursor { display: none; }
@media (hover: hover) and (pointer: fine) {
  .motion-ready .cursor {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 0; left: 0; width: 38px; height: 38px; margin: -19px 0 0 -19px;
    border: 1.5px solid var(--color-brand); border-radius: 50%;
    pointer-events: none; z-index: 1000; mix-blend-mode: difference;
  }
  .cursor__dot { position: fixed; top: 0; left: 0; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--color-brand); pointer-events: none; z-index: 1001; }
  .cursor__label { font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--color-brand); opacity: 0; }
}

/* ==========================================================================
   MOBILE-SPECIFIC DESIGN (≤ 879px, matches the burger breakpoint)
   ========================================================================== */
@media (max-width: 879px) {
  /* hero: tighter, headline first, chip rail for services */
  .hero { min-height: 100svh; padding-top: calc(var(--header-h) + 34px); }
  .hero__inner { gap: 30px; }
  .hero__inner > * { min-width: 0; } /* chip rail must not widen the grid column */
  .hero__intro { font-size: 15.5px; margin-bottom: 26px; }
  .hero__tabs {
    flex-direction: row; gap: 8px; border-top: 0; overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    margin: 0 calc(var(--gutter) * -1); padding: 2px var(--gutter) 6px;
    scroll-padding-inline: var(--gutter);
  }
  .hero__tabs::-webkit-scrollbar { display: none; }
  .tab {
    flex: none; width: auto; scroll-snap-align: start; gap: 8px;
    border: 1px solid var(--hairline-dark); border-radius: 999px; padding: 11px 16px;
    background: rgba(255, 255, 255, .03); transition: background var(--transition), border-color var(--transition);
  }
  .tab__num { width: auto; font-size: 11px; }
  .tab__label { font-size: 14px; white-space: nowrap; }
  .tab.is-active { padding-left: 16px; border-color: var(--color-brand); background: rgba(246, 197, 0, .12); }
  .hero__stage { width: 100%; aspect-ratio: 4 / 3.4; border-radius: 20px; }
  .hero__caption { padding: 20px; }
  .hero__glyph { font-size: 34vh; opacity: .7; }
  .hero__scrollcue { padding-top: 28px; padding-bottom: 28px; }
  .hero__scrollcue span:last-child { display: none; }

  /* full-screen overlay menu */
  .mobile-menu {
    display: flex; position: fixed; left: 0; right: 0; top: var(--header-h); height: calc(100dvh - var(--header-h));
    background: var(--color-dark); border-top: 0; padding: 28px var(--gutter) 32px;
    visibility: hidden; opacity: 0; transition: opacity .3s ease, visibility 0s linear .3s;
    counter-reset: mm; overflow-y: auto;
  }
  .mobile-menu.is-open { visibility: visible; opacity: 1; transition: opacity .3s ease; }
  .mobile-menu__link {
    counter-increment: mm; display: flex; align-items: baseline; gap: 16px;
    font-family: var(--font-base); font-size: clamp(30px, 9vw, 44px); font-weight: var(--fw-black);
    letter-spacing: -.02em; text-transform: none; color: var(--color-on-dark);
    padding: 16px 0; border-bottom: 1px solid var(--hairline-dark);
  }
  .mobile-menu__link::before { content: "0" counter(mm); font-family: var(--font-mono); font-size: 12px; font-weight: var(--fw-medium); letter-spacing: .1em; color: var(--color-brand); }
  .mobile-menu__link--cta {
    justify-content: center; margin-top: auto; padding: 18px; border-radius: var(--radius);
    font-family: var(--font-mono); font-size: 15px; letter-spacing: .06em; text-transform: uppercase;
    color: var(--color-ink-strong); background: var(--color-brand);
  }
  .mobile-menu__link--cta::before { display: none; }
  .mobile-menu .mobile-menu__link--cta { margin-top: 32px; }
  .menu-open body { overflow: hidden; }
  .menu-open .site-header { background: var(--color-bg); }

  /* marquee: tighter band */
  .marquee { padding: 22px 0; }
  .marquee__track { gap: 20px; padding-right: 20px; }

  /* about: image leads */
  .about__media { order: -1; min-height: 62vw; }
  .about__glyph { font-size: 84px; }
  .stats { gap: 0; justify-content: space-between; }
  .stats > div { flex: 1; }

  /* services: sticky stacking deck (only once motion.js is driving it) */
  .motion-ready .cards { display: block; perspective: none; }
  .motion-ready .card {
    position: sticky; top: calc(var(--header-h) + 18px + var(--i, 0) * 12px);
    margin-bottom: 22px; min-height: 240px; transform-origin: 50% 0;
    box-shadow: 0 -10px 30px -18px rgba(0, 0, 0, .35);
  }
  .motion-ready .card:last-child { margin-bottom: 0; }
  .card::before { display: none; }

  /* clients: twin marquee rails (built by motion.js) */
  .logo-rails { display: flex; flex-direction: column; gap: 12px; margin: 0 calc(var(--gutter) * -1); }
  .logo-rail { overflow: hidden; }
  .logo-rail__track { display: flex; gap: 12px; width: max-content; will-change: transform; }
  .logo-rail .logo-tile { flex: 0 0 auto; width: 62vw; max-width: 300px; height: 108px; }

  .cta { padding: 76px 0 84px; }
  .cta__btn { width: 100%; justify-content: center; }
  .site-footer__mark { padding-top: 34px; }
}

@media (max-width: 620px) {
  .hero__title { font-size: clamp(34px, 10.4vw, 46px); }
}
