/* ML Arch Studio - motion layer. Ported from the DV8 Motion Kit (Oct 2026), retuned for an
   interiors studio: slower, quieter, more like a door opening than a reveal.

   motion.js sets html.mo only when motion is allowed, and every scene variable defaults to
   its finished state, so reduced motion, a failed script or a crawler all get a complete,
   still page. Nothing above the fold is ever clipped or faded (LCP). */

:root { --wipe: cubic-bezier(.7, 0, .2, 1); --spring: cubic-bezier(.2, .8, .2, 1); --pin-h: 100vh; }
@supports (height: 100svh) { :root { --pin-h: 100svh; } }

/* ---------- headline unmask ---------- */
html.mo [data-unmask] {
  clip-path: inset(0 0 100% 0); transform: translateY(36px); opacity: .2;
  transition: clip-path 1.2s var(--wipe), transform 1.3s var(--spring), opacity 1s ease;
}
html.mo [data-unmask].in { clip-path: inset(-22% -8% -30% -8%); transform: none; opacity: 1; }

/* ---------- image wipe: every frame opens like a door ---------- */
html.mo [data-wipe] { clip-path: inset(8% 6% 8% 6%); transition: clip-path 1.4s var(--wipe); }
html.mo [data-wipe].in { clip-path: inset(0); }
html.mo [data-wipe] img { transform: scale(1.14); transition: transform 1.9s var(--spring); }
html.mo [data-wipe].in img { transform: none; }
html.mo img[data-wipe] { transform: none; }

/* ---------- soft rise for body copy blocks ---------- */
html.mo [data-rise] { translate: 0 30px; opacity: 0; transition: translate 1s var(--spring), opacity .9s ease; }
html.mo [data-rise].in { translate: 0 0; opacity: 1; }

/* ---------- words light up ---------- */
html.mo .mo-words .w { opacity: .22; transition: opacity .3s; }
html.mo .mo-words .w.lit { opacity: 1; }

/* ---------- kinetic band ---------- */
.mo-kinetic { overflow: hidden; padding: clamp(2.2rem, 5vw, 3.6rem) 0; display: grid; row-gap: .4rem; background: var(--bg); border-top: 1px solid var(--line); }
.mo-kin {
  display: flex; align-items: baseline; width: max-content; gap: .5em;
  font-family: var(--serif); font-weight: 300; font-size: clamp(2.6rem, 7vw, 6.2rem);
  line-height: 1.16; letter-spacing: -.02em; white-space: nowrap; margin: 0; will-change: transform; color: var(--ink);
}
.mo-kin > * { flex: none; font-weight: inherit; }
.mo-kin em { color: var(--walnut); }
.mo-kin i { font-style: normal; font-size: .4em; opacity: .5; align-self: center; }

/* ---------- pinned scenes ---------- */
.mo-scene { position: relative; --e: 1; --t: 1; --c: 0; }
.mo-pin { position: sticky; top: 0; height: var(--pin-h); overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
html:not(.mo) .mo-scene { height: auto !important; }
html:not(.mo) .mo-pin { position: relative; height: var(--pin-h); }

/* window expand: a framed room grows until you are standing in it */
.mo-xp { height: 230vh; background: var(--bg); --ix: 20%; --iy: 17%; }
.mo-xp-cap {
  position: absolute; left: 0; right: 0; top: calc(var(--hdr) + clamp(1.4rem, 6vh, 4rem)); z-index: 2; text-align: center; padding: 0 var(--pad);
  opacity: var(--c); transform: scale(calc(1 + .08 * (1 - var(--c))));
}
.mo-xp-cap h2 { margin: 0; }
.mo-xp-frame {
  position: absolute; inset: 0; overflow: hidden;
  clip-path: inset(calc((var(--iy) + 11%) * (1 - var(--e))) calc(var(--ix) * (1 - var(--e))) calc((var(--iy) - 9%) * (1 - var(--e))) round calc(6px * (1 - var(--e))));
}
.mo-xp-frame img { width: 100%; height: 100%; object-fit: cover; transform: scale(calc(1.2 - .2 * var(--e))); }
.mo-xp-frame::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20,30,35,.05) 20%, rgba(20,30,35,.4) 60%, rgba(20,30,35,.86) 100%); opacity: var(--t); }
.mo-xp-txt {
  position: absolute; left: 0; right: 0; bottom: clamp(2.6rem, 8vh, 5.5rem); z-index: 2; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad);
  color: var(--on-night); opacity: var(--t); transform: translateY(calc(40px * (1 - var(--t))));
}
.mo-xp-txt h2 { color: #fff; max-width: 16ch; }
.mo-xp-txt h2 em { color: #e3c7a8; }
.mo-xp-txt .eyebrow { color: rgba(255,255,255,.75); }
.mo-xp-nums { display: flex; flex-wrap: wrap; gap: 1rem 3rem; margin-top: 1.4rem; }
.mo-xp-nums div { font-size: .92rem; color: rgba(255,255,255,.82); max-width: 17ch; }
.mo-xp-nums b { display: block; font-family: var(--serif); font-weight: 300; font-size: clamp(2.2rem, 4vw, 3.4rem); line-height: 1; color: #fff; }
@media (max-width: 899px) { .mo-xp { height: 175vh; --ix: 6%; --iy: 20%; } }

/* horizontal pinned gallery: scrolling down walks the rooms sideways */
.mo-hs { height: 240vh; background: var(--paper); }
.mo-hs .mo-pin { gap: clamp(1.4rem, 3.5vh, 2.6rem); padding-top: var(--hdr); }
.mo-hs-head { display: flex; justify-content: space-between; align-items: end; gap: 2rem; max-width: none; }
.mo-hs-head h2 { margin: 0; max-width: 15ch; }
.mo-hs-head p { margin: 0; color: var(--ink-2); max-width: 40ch; font-size: .96rem; }
.mo-scroller { width: 100%; }
.mo-htrack { display: flex; align-items: flex-end; gap: clamp(14px, 1.6vw, 22px); padding-left: var(--pad); width: max-content; will-change: transform; }
.mo-htrack::after { content: ''; flex: 0 0 var(--pad); }
.mo-hcard { margin: 0; flex: 0 0 auto; }
.mo-hcard .fr { overflow: hidden; border-radius: var(--r); background: var(--bg-3); height: min(58vh, 560px); aspect-ratio: 4 / 5; }
.mo-hcard:nth-child(3n+2) .fr { height: min(48vh, 460px); }
.mo-hcard img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.4s var(--spring); }
.mo-hcard:hover img { transform: scale(1.04); }
.mo-hcard figcaption { display: flex; justify-content: space-between; gap: 1rem; margin-top: .9rem; font-size: .9rem; }
.mo-hcard figcaption b { font-family: var(--serif); font-weight: 400; font-size: 1.2rem; }
.mo-hcard figcaption span { color: var(--ink-3); font-size: .66rem; letter-spacing: .2em; text-transform: uppercase; align-self: center; }
.mo-hend { flex: 0 0 clamp(280px, 28vw, 380px); align-self: stretch; display: flex; flex-direction: column; justify-content: center; padding: 2rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); }
.mo-hend h3 { font-size: clamp(1.7rem, 2.4vw, 2.2rem); }
.mo-hend p { color: var(--ink-2); font-size: .95rem; margin-bottom: 1.6rem; }
.mo-hs-note { font-size: .74rem; color: var(--ink-3); padding: 0 var(--pad); margin: 0; }
@media (max-width: 899px) {
  .mo-hs { height: auto; }
  .mo-hs .mo-pin { position: static; height: auto; padding: clamp(4rem, 9vh, 5rem) 0; overflow: visible; }
  .mo-hs-head { flex-direction: column; align-items: start; }
  .mo-hcard .fr, .mo-hcard:nth-child(3n+2) .fr { height: auto; width: 72vw; }
  .mo-hend { flex-basis: 72vw; }
}
@media (max-width: 899px), (scripting: none) {
  .mo-scroller { overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .mo-scroller::-webkit-scrollbar { display: none; }
  .mo-hcard, .mo-hend { scroll-snap-align: start; }
}
html:not(.mo) .mo-hs { height: auto; }
html:not(.mo) .mo-hs .mo-pin { position: static; height: auto; padding: 5rem 0; overflow: visible; }
html:not(.mo) .mo-scroller { overflow-x: auto; }

/* ---------- tilt on package cards (fine pointers) ---------- */
html.mo [data-tilt] { transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--ty, 0)); transition: transform .6s var(--spring), box-shadow .6s; }
html.mo .pkg[data-tilt]:hover { --ty: -4px; box-shadow: 0 30px 60px -36px rgba(29,43,49,.45); }

@media (prefers-reduced-motion: reduce) { .mo-kin { transform: none !important; } }
