/* ==========================================================================
   motion.css — interaction layer for the new marcodinorcia.com
   Two layers:
   1. ORIGINALI: every Webflow IX2 interaction, same durations and easings
      (read from the site's own interaction data, not eyeballed).
   2. MIGLIORATE: html.fx-plus adds what the original did not have.
   site.css stays untouched; this file only adds behaviour.
   ========================================================================== */

:root {
  /* Webflow IX2 easings, as cubic-bezier */
  --inQuad: cubic-bezier(.55,.085,.68,.53);
  --outQuart: cubic-bezier(.165,.84,.44,1);
  --outQuint: cubic-bezier(.23,1,.32,1);
  --outBack: cubic-bezier(.175,.885,.32,1.275);
  --outExpo: cubic-bezier(.19,1,.22,1);
  --inOutExpo: cubic-bezier(1,0,0,1);
  --inOutCubic: cubic-bezier(.645,.045,.355,1);
  --inOutQuart: cubic-bezier(.77,0,.175,1);
  --inOutSine: cubic-bezier(.445,.05,.55,.95);
  --inOutCirc: cubic-bezier(.785,.135,.15,.86);
  --linearish: cubic-bezier(.25,.25,.75,.75);
}

/* ---------- 1. Page appears (a-97: opacity 0→1, 500ms inQuad) ---------- */
.page-wrapper, .page-menu.is--nav { animation: fx-fade .5s var(--inQuad) both; }
@keyframes fx-fade { from { opacity: 0; } }

/* ---------- 2. Hero squares (a-11 / a-63) ---------- */
.hero__elem.suare_3 { animation: fx-sq3-fade 1s ease .5s both, fx-sq3-move 1.7s var(--outBack) .5s both; }
@keyframes fx-sq3-fade { from { opacity: 0; } }
@keyframes fx-sq3-move { to { transform: translateY(-87px); } }
@media (min-width: 992px) {
  .hero__elem.square_1 { animation: fx-fade 1s var(--inQuad) .5s both, fx-sq1 1s var(--outBack) .5s both; }
  .hero__elem.square_2 { animation: fx-fade 1s var(--inQuad) .5s both, fx-sq2 1s var(--outBack) .5s both; }
}
@keyframes fx-sq1 { to { transform: translateY(30px); } }
@keyframes fx-sq2 { to { transform: translateY(40px); } }

/* ---------- 3. Cursor (a-14 / a-16, smoothing 50 / 90) ---------- */
.cursor-wrapper { opacity: 0; transition: opacity .3s ease; pointer-events: none; }
.cursor, .cursor-outer { will-change: transform; }
.cursor-outer { display: grid; place-items: center; transition: width .5s var(--outQuart), height .5s var(--outQuart), background-color .3s ease, border-color .3s ease; }
.cursor-label { font: 600 11px/1 "Work Sans", sans-serif; letter-spacing: .02em; color: var(--bamm-darker); opacity: 0; transition: opacity .2s ease; }

/* ---------- 4. Header hides on scroll down, returns on scroll up (500ms) ---------- */
.page-menu.is--nav { transition: transform .5s ease; }
.page-menu.is--nav.is-hidden, body.panel-open .page-menu.is--nav { transform: translateY(-90px); }
body.menu-open .page-menu.is--nav { transform: none; }

/* ---------- 5. Menu links: siblings fade to .3 (a-84, 500ms outQuart) ---------- */
@media (min-width: 992px) and (hover: hover) {
  .menu_link { transition: opacity .5s var(--outQuart); }
  .grid_item.is--menu:has(.menu_link:hover) .menu_link:not(:hover) { opacity: .3; }
}

/* ---------- 6. Mobile menu (slides from -100%, 500ms outQuart) ---------- */
.hamburger_icon.js-menu-toggle { display: block; padding: 0; border: 0; background: none; cursor: pointer; color: var(--bamm-darker); line-height: 0; }
.hamburger_icon svg { width: 100%; height: auto; overflow: visible; }
.hamburger_icon { transition: color .3s ease; }
.hamburger_icon .bar { stroke: currentColor; stroke-width: 2; stroke-linecap: round; fill: none; transform-origin: 15px 15px; transition: transform .5s var(--outQuart), opacity .3s ease; }
.js-menu-toggle[aria-expanded="true"] { color: var(--ennis-ligth); }
.js-menu-toggle[aria-expanded="true"] .b1 { transform: translateY(7px) rotate(45deg); }
.js-menu-toggle[aria-expanded="true"] .b2 { opacity: 0; }
.js-menu-toggle[aria-expanded="true"] .b3 { transform: translateY(-7px) rotate(-45deg); }
@media (max-width: 991px) {
  .grid_item.is--menu { transform: translateY(-100%); transition: transform .5s var(--outQuart); }
  .grid_item.is--menu.is-open { display: flex; }
  .grid_item.is--menu.is-in { transform: none; }
  body.menu-open { overflow: hidden; }
}

/* ---------- 7. Project cards: hover (a-60 / a-61) ---------- */
[class*="geocard-"] { cursor: pointer; }
[class*="geocard-"]:focus-visible { outline: 3px solid var(--honey-dark); outline-offset: -3px; }
.scroll-type { animation: fx-marquee 15s linear infinite; }          /* a-58: -50% in 15s */
@keyframes fx-marquee { to { transform: translateX(-50%); } }
@media (min-width: 992px) {
  [class*="geocard-"] .card-inner { opacity: 0; transition: opacity .8s var(--outQuart); }
  [class*="geocard-"] .main-heading { transform: translateY(5vh); transition: transform .75s var(--inOutSine); }
  [class*="geocard-"] img.image-container { transform: scale(1.01); transition: transform 1s var(--inOutQuart); }
  [class*="geocard-"] .scroll-type-wrapper { transform: translateY(100%); transition: transform .5s var(--outQuart); }
  [class*="geocard-"]:is(:hover, :focus-visible) .card-inner { opacity: 1; transition: opacity .5s var(--inOutExpo); }
  [class*="geocard-"]:is(:hover, :focus-visible) .main-heading { transform: none; transition: transform .75s var(--inOutCubic); }
  [class*="geocard-"]:is(:hover, :focus-visible) img.image-container { transform: scale(1.05); }
  [class*="geocard-"]:is(:hover, :focus-visible) .scroll-type-wrapper { transform: none; transition: transform 1s var(--outQuint); }
}

/* ---------- 8. Card → case-study panel (a-67 … a-71) ---------- */
div[class*="geospace-section-content"] { display: none; }
.is-open > div[class*="geospace-section-content"] { display: block; }
div[class*="geospace-section-content"] > div { display: none; }
div[class*="geospace-section-content"] > div.is-active { display: block; }
.is-open > .is-active[class*="geocard-"] .card-inner { opacity: 0 !important; transition: opacity .5s var(--outQuart) !important; }

@media (min-width: 992px) {
  [class*="geocard-"] { transition: width .85s var(--inOutCubic) .1s, transform .85s var(--inOutCubic) .1s; }
  .is-open > .is-active[class*="geocard-"] {
    z-index: 5; width: 50% !important; height: 100vh;
    transform: translateX(var(--shift, 0));
    transition: width 1s var(--inOutQuart), transform 1s var(--inOutQuart);
  }
  div[class*="geospace-section-content"] { transform: translateX(100%); transition: transform .85s var(--inOutQuart) .25s; }
  .is-open.is-in > div[class*="geospace-section-content"] { transform: none; transition: transform var(--panel-in, 1.25s) var(--inOutCirc); }
}
@media (max-width: 991px) {
  body.panel-open { overflow: hidden; }
  [class*="geocard-"] { transition: transform .35s var(--inOutCubic) .3s; }
  .is-open > [class*="geocard-"] { transform: scale(.9); transition: transform .5s ease; }
  .is-open > div[class*="geospace-section-content"] {
    position: fixed; inset: 0; z-index: 2000; height: 100%; overflow: auto;
    transform: translateX(100%); transition: transform .35s var(--inOutQuart) .3s;
  }
  .is-open.is-in > div[class*="geospace-section-content"] { transform: none; transition: transform 1.25s var(--inOutCirc); }
}
.button-close { will-change: transform; }

/* ---------- 9. Buttons (a-29 … background 300ms) ---------- */
.button { transition: background-color .3s var(--linearish), color .3s var(--linearish); }

/* ---------- 10. Client logos on mobile (15s loops, two directions) ---------- */
@media (max-width: 479px) {
  .logo-container { animation: fx-logos 15s linear infinite; }
  .logo-container-2 { animation: fx-logos 15s linear infinite reverse; }
}
@keyframes fx-logos { from { transform: translateX(0); } to { transform: translateX(-99.9%); } }

/* ---------- 11. Big theme line scrolls sideways (a-48: 30vw → -160vw) ---------- */
.xlarge-paragraph { will-change: transform; white-space: nowrap; }

/* ==========================================================================
   MIGLIORATE — html.fx-plus
   ========================================================================== */

/* A. Reveal on scroll, staggered */
.fx-plus .rv { opacity: 0; transform: translateY(28px); }
.fx-plus .rv.in { opacity: 1; transform: none; transition: opacity .8s var(--outQuart), transform 1s var(--outExpo); transition-delay: calc(var(--i, 0) * 70ms); }

/* B. Highlight strokes draw in under the words */
.fx-plus .span-element { clip-path: inset(0 100% 0 0); }
.fx-plus .span-element.in { clip-path: inset(0 0 0 0); transition: clip-path 1.1s var(--outExpo) .25s; }

/* C. Contextual cursor */
.fx-plus .cursor-wrapper.is-link .cursor-outer { width: 70px; height: 70px; background-color: rgba(255,202,15,.18); }
.fx-plus .cursor-wrapper.is-card .cursor-outer { width: 96px; height: 96px; background-color: var(--honey-dark); border-color: var(--honey-dark); }
.fx-plus .cursor-wrapper.is-card .cursor-label { opacity: 1; }
.fx-plus .cursor-wrapper.is-card .cursor { opacity: 0; }
.fx-plus .cursor { transition: opacity .2s ease; }

/* D. Case-study content staggers in once the panel lands */
.fx-plus .is-in div[class*="geospace-section-content"] > .is-active .inner-container > *,
.fx-plus .is-in div[class*="geospace-section-content"] > .is-active .wrap-image-content { animation: fx-up .9s var(--outExpo) both; animation-delay: calc(.55s + var(--i, 0) * 80ms); }
@keyframes fx-up { from { opacity: 0; transform: translateY(24px); } }

/* E. View Transition for the card → panel morph (Chrome, Edge, Safari 18+) */
::view-transition-group(fx-card) { animation-duration: .9s; animation-timing-function: var(--inOutQuart); }
::view-transition-new(fx-panel) { animation: fx-panel-in .9s var(--outExpo) both; }
::view-transition-old(fx-panel) { animation: fx-panel-out .6s var(--inOutQuart) both; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .35s; }
@keyframes fx-panel-in { from { transform: translateX(100%); } }
@keyframes fx-panel-out { to { transform: translateX(100%); } }
.vt-instant, .vt-instant * { transition: none !important; }

/* F. "Get in touch" grows into place as it enters */
.fx-plus .getintouch-link { display: inline-block; transform: translate(var(--mx, 0), var(--my, 0)) scale(var(--git, 1)); transform-origin: 50% 80%; }
.fx-plus .featured-projects .button { transform: translate(var(--mx, 0), var(--my, 0)); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .fx-plus .rv, .fx-plus .span-element { opacity: 1 !important; transform: none !important; clip-path: none !important; }
}
