/* ============================================================
   Motion layer — shared across the whole site.
   Smooth scroll (Lenis) · eased reveals · marquee · magnetic hover
   · page-to-page fade. One easing language everywhere.
   ============================================================ */
:root {
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);   /* clean decel — the house curve */
  --ease-spring:   cubic-bezier(0.34, 1.28, 0.5, 1); /* slight overshoot, hovers only */
  --rv-dur: 0.95s;
}

/* —— Lenis smooth scroll —————————————————————————————————— */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: clip; }

/* —— Reveals (scoped to .js so no-JS shows everything) ——— */
.js [data-reveal] { opacity: 0; will-change: transform, opacity;
  transition: opacity var(--rv-dur) var(--ease-out-expo), transform var(--rv-dur) var(--ease-out-expo);
  transition-delay: var(--rv-d, 0s); }
.js [data-reveal="up"]    { transform: translateY(26px); }
.js [data-reveal="up-lg"] { transform: translateY(56px); }
.js [data-reveal="scale"] { transform: scale(0.965); }
.js [data-reveal="mask"]  { opacity: 1; clip-path: inset(0 0 101% 0);
  transition: clip-path 1.05s var(--ease-out-expo); transition-delay: var(--rv-d, 0s); }
.js [data-reveal].is-in   { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }

/* —— Marquee ————————————————————————————————————————————— */
.marquee { overflow: hidden; width: 100%; }
.marquee__track { display: inline-flex; flex-wrap: nowrap; white-space: nowrap; will-change: transform; }
.marquee__track > * { flex: 0 0 auto; }

/* —— Magnetic ———————————————————————————————————————————— */
[data-magnetic] { display: inline-block; will-change: transform; }

/* —— Page entry: masthead fades up from white first, content follows — a pure CSS animation that plays from the first paint, so there's no JS-release blank frame / reload blink —— */
.js .v3head { animation: pageIn 0.6s var(--ease-out-expo) both; }
.js main { animation: pageIn 0.7s var(--ease-out-expo) 0.16s both; }
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }

/* —— Page exit: content fades + lifts away; the masthead (the name) stays put —— */
.is-leaving main { opacity: 0; transition: opacity 0.42s var(--ease-out-expo); }
.is-leaving main > * { transform: translateY(-16px); transition: transform 0.42s var(--ease-out-expo); }

/* —— Cursor: solid black dot trailing the arrow; morphs to a CLICK pill over links —— */
.v3cursor { position: fixed; top: 0; left: 0; z-index: 9998; pointer-events: none; will-change: transform; }
.v3cursor__blob { position: absolute; top: 0; left: 0; display: flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; border-radius: 50%; background: #111110; overflow: hidden; will-change: transform, width, height;
  transition: width 0.34s var(--ease-out-expo), height 0.34s var(--ease-out-expo), border-radius 0.34s var(--ease-out-expo); }
.v3cursor__label { color: var(--paper); font-family: var(--mono); font-size: 0.6rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; opacity: 0; transform: translateX(-3px) scale(0.8);
  transition: opacity 0.24s var(--ease-out-expo), transform 0.3s var(--ease-out-expo); }
.v3cursor.is-link .v3cursor__blob { width: 84px; height: 32px; border-radius: 18px; }
.v3cursor.is-link .v3cursor__label { opacity: 1; transform: none; }
@media (hover: none), (pointer: coarse) { .v3cursor { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] { opacity: 1 !important; transform: none !important; clip-path: none !important; transition: none; }
  .js .v3head, .js main { animation: none; }
  .is-leaving main, .is-leaving main > * { opacity: 1; transform: none; }
  .v3cursor { display: none; }
}

/* —— Screensaver — the word cylinder OVER the live site (js/screensaver.js) ————
   Not a panel: the canvas is transparent, so the site — and everything still animating
   on it — reads straight through. No blend mode: the words carry their own white keyline
   to stay legible over anything, which leaves the gif / googly-eye marks untouched.
   The drop-in from the top of the frame is the cylinder's OWN spring (its intro phase),
   so there's nothing to slide. Below the cursor (9998). */
/* .saver carries NO position / z-index / transform ON PURPOSE. Any of those would make it a
   stacking context, and a blended child only blends with the backdrop of its nearest ancestor
   stacking context — i.e. the empty inside of .saver, not the site. The keyline would then
   difference against nothing and render plain white. Left as a bare wrapper (visibility
   inherits to the canvases), so each fixed canvas blends against the ROOT backdrop = the page. */
.saver { visibility: hidden; }
.saver.is-on { visibility: visible; }

/* One canvas per blend mode; z-index is the stack. The blended layers are click-through so the
   fill layer (which carries the cylinder's pointer handlers) gets every event. */
.saver__cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; pointer-events: none; }
.saver__cv--stroke { z-index: 9990; mix-blend-mode: difference; }   /* keyline differences against the SITE — inverts on dark, drops out on paper */
.saver__cv--fill   { z-index: 9991; cursor: pointer; }              /* solid black words + the un-blended marks */
.saver__cv--mul    { z-index: 9992; mix-blend-mode: multiply; }     /* orbit-mark-1 only */
.saver.is-on .saver__cv--fill { pointer-events: auto; }
@media (max-width: 760px) { .saver { display: none; } }   /* desktop only — screensaver.js bails on phones too */

/* ============================================================
   MOBILE LAYER · iPhone-first.  Scoped to ≤760px so desktop +
   tablet (768px and up) render exactly as before.  The menu markup
   is injected at the bottom of motion.js; Lenis is skipped on
   phones there too (native scroll).  #fafafa paper, editorial type.
   ============================================================ */
.m-menu-btn, .m-menu, .m-mark { display: none; }             /* injected on every page, revealed only ≤760px */

@media (max-width: 760px) {
  body { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }   /* NB: no overflow-x here — it turns html/body into scroll containers and breaks scroll + reveals; overflow is prevented at the source instead */
  * { -webkit-tap-highlight-color: transparent; }

  /* home masthead → compact fixed bar on phones (v3.js skips its desktop scroll-shrink here) */
  .v3head--home { height: auto; min-height: 0; align-items: center;
    padding-top: calc(env(safe-area-inset-top) + 0.55rem); padding-bottom: 0.6rem; }
  .v3head--home .v3brand { font-size: 1.05rem; line-height: 1; word-spacing: 0.26em; }
  .v3head--home .brand__studio { display: none; }                 /* "David Stamatis ©" — Studio drops on the compact bar */
  .v3head--home + main { padding-top: calc(env(safe-area-inset-top) + 2.9rem); }   /* fallback (reduced-motion): compact bar stays visible */

  /* —— Home INTRO (v3.js adds .m-home-hero on mobile, non-reduced): ONE wordmark starts big + centered on a white top-half over a bottom-half video, then shrinks + slides to the corner (STUDIO fades) as the white panel collapses — same effect as the desktop masthead —— */
  .m-home-hero .v3head--home { animation: none; height: 50svh; overflow: hidden; }   /* white backdrop; JS collapses it to a bar on scroll (video rises flush) */
  .m-home-hero .v3head--home .v3brand,
  .m-home-hero .v3head--home .v3head__desc { display: none; }             /* the morphing .m-mark replaces the static header brand */
  .m-home-hero .v3head--home + main { padding-top: 50svh; }               /* video sits in the bottom half */
  .m-home-hero .m-menu-btn { opacity: 1; }                                /* stays visible + tappable — the menu must be reachable from the top of the home */
  .m-home-hero .m-mark { display: inline-block; }                         /* the morphing wordmark (fixed; JS drives transform) */
  .m-mark { position: fixed; left: 0; top: 0; z-index: 205; transform-origin: top left; white-space: nowrap; will-change: transform; color: var(--ink);
    font-family: var(--sans); font-weight: 600; font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.01em; word-spacing: 0.26em; line-height: 1.1; text-decoration: none; }
  .m-mark .brand__c { word-spacing: normal; font-weight: 500; }
  .m-mark__studio { will-change: opacity; }
  .m-home-hero .feature { height: 50svh; }
  .m-home-hero .feature video { width: 100%; height: 100%; object-fit: cover; margin: 0; }

  /* video hero → full-bleed, no desktop edge-crop */
  .feature video { width: 100%; max-width: 100%; height: auto; margin: 0; }

  /* Index → 2D drag-plane is desktop-only; mobile boots into the Text list (v3-index.js) → hide the Image/Text toggle */
  .idx__toggle { display: none; }

  /* About → portrait spans full width on mobile (desktop uses a half-grid beside text) */
  .about__portrait { grid-column: 1 / -1; }

  /* —— the mark (top-right) — two lines that cross into a close —— */
  .m-menu-btn {
    position: fixed; top: env(safe-area-inset-top); right: 0; z-index: 210;
    width: 58px; height: 58px; padding-right: var(--margin);
    display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 6px;
    border: 0; background: none; cursor: pointer;
    mix-blend-mode: difference; color: #fff;                 /* legible over any backdrop, open or closed */
  }
  .m-menu-btn span { display: block; width: 26px; height: 1.5px; background: currentColor;
    transition: transform 0.45s var(--ease-out-expo), opacity 0.3s var(--ease-out-expo); }
  .m-menu-btn.is-open span:first-child { transform: translateY(3.75px) rotate(45deg); }
  .m-menu-btn.is-open span:last-child  { transform: translateY(-3.75px) rotate(-45deg); }

  /* —— full-screen editorial menu, nav dropped into the thumb zone —— */
  .m-menu {
    position: fixed; inset: 0; z-index: 200; background: var(--paper); color: var(--ink);
    display: flex; flex-direction: column;
    padding: calc(env(safe-area-inset-top) + 4.4rem) var(--margin) calc(env(safe-area-inset-bottom) + 1.8rem);
    opacity: 0; visibility: hidden; transition: opacity 0.45s var(--ease-out-expo), visibility 0.45s;
    overscroll-behavior: contain;
  }
  .m-menu.is-open { opacity: 1; visibility: visible; }
  .m-menu__top { font-family: var(--mono); font-size: var(--t-cap); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
  .m-menu__top b { font-weight: 400; }
  .m-menu__list { list-style: none; margin: auto 0 0; padding: 0; }   /* auto-top → nav sits low, thumb-reachable */
  .m-menu__list li { overflow: hidden; }
  .m-menu__list a {
    display: flex; align-items: center; justify-content: space-between; gap: 0.4em;
    font-family: var(--display); font-weight: 600; color: var(--ink);
    font-size: clamp(2.7rem, 1.1rem + 13vw, 5rem); line-height: 1.16; letter-spacing: -0.022em;
    transform: translateY(118%); transition: transform 0.72s var(--ease-out-expo);
    transition-delay: calc(var(--i) * 0.055s + 0.04s);
  }
  .m-menu.is-open .m-menu__list a { transform: translateY(0); }
  .m-menu__list a[aria-current="page"] { color: var(--ink-mute); }
  .m-menu__list a span { font-size: 0.3em; font-weight: 400; opacity: 0.5; }
  .m-menu__foot {
    margin-top: 2rem; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap;
    font-family: var(--mono); font-size: var(--t-cap); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-mute);
    opacity: 0; transition: opacity 0.5s var(--ease-out-expo) 0.35s;
  }
  .m-menu.is-open .m-menu__foot { opacity: 1; }
  .m-menu__foot a { color: var(--ink-soft); }
  .m-menu__soc { display: inline-flex; gap: 1.1rem; }

  html.m-locked, html.m-locked body { overflow: hidden; }
}
