/* ==========================================================================
   MOTION.CSS — Elegant, Minimalist & Luxurious Motion Layer
   Antigravity Portfolio | Handcrafted Pure CSS (Zero Libraries)
   All new motion uses `translate` and `opacity` to avoid overriding transforms.
   ========================================================================== */

/* ── 0. Base Initialization & Reduced Motion Guard ── */
:root {
  --mx-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --mx-dur-hero: 0.9s;
  --mx-dur-nav: 0.6s;
  --mx-dur-reveal: 1.0s;
}

/* ── 1. Scroll Progress Indicator ── */
.mx-scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 105;
  pointer-events: none;
  transform-origin: left center;
  transform: scaleX(0);
  background: var(--hero-orange, #EC5E27);
  transition: transform 0.08s linear;
}

:is(.dark, [data-theme="dark"]) .mx-scroll-progress {
  background: var(--dk-lime, #C6FF34);
}

/* ── 2. Hero Text Staggered Entrance (Left Column Only) ── */
html.mx-js #hero .hero-text .hero-badge,
html.mx-js #hero .hero-text .hero-greeting,
html.mx-js #hero .hero-text .hero-subtitle-wrap,
html.mx-js #hero .hero-text .hero-desc,
html.mx-js #hero .hero-text .hero-info,
html.mx-js #hero .hero-text .hero-btns,
html.mx-js #hero .hero-text .hero-socials {
  opacity: 0;
  translate: 0 24px;
  transition: opacity 0.9s var(--mx-ease), translate 0.9s var(--mx-ease);
}

html.mx-js #hero.mx-hero-ready .hero-text .hero-badge,
html.mx-js #hero.mx-hero-ready .hero-text .hero-greeting,
html.mx-js #hero.mx-hero-ready .hero-text .hero-subtitle-wrap,
html.mx-js #hero.mx-hero-ready .hero-text .hero-desc,
html.mx-js #hero.mx-hero-ready .hero-text .hero-info,
html.mx-js #hero.mx-hero-ready .hero-text .hero-btns,
html.mx-js #hero.mx-hero-ready .hero-text .hero-socials {
  opacity: 1;
  translate: 0 0;
}

/* Stagger delays */
html.mx-js #hero.mx-hero-ready .hero-text .hero-badge         { transition-delay: 0.05s; }
html.mx-js #hero.mx-hero-ready .hero-text .hero-greeting      { transition-delay: 0.14s; }
html.mx-js #hero.mx-hero-ready .hero-text .hero-subtitle-wrap { transition-delay: 0.32s; }
html.mx-js #hero.mx-hero-ready .hero-text .hero-desc          { transition-delay: 0.41s; }
html.mx-js #hero.mx-hero-ready .hero-text .hero-info          { transition-delay: 0.50s; }
html.mx-js #hero.mx-hero-ready .hero-text .hero-btns          { transition-delay: 0.59s; }
html.mx-js #hero.mx-hero-ready .hero-text .hero-socials       { transition-delay: 0.68s; }

/* Hero Name: bottom-line reveal clip-path */
html.mx-js #hero .hero-text h1,
html.mx-js #hero .hero-text .hero-title {
  clip-path: inset(0 0 100% 0);
  translate: 0 40%;
  transition: clip-path 1.1s var(--mx-ease) 0.23s, translate 1.1s var(--mx-ease) 0.23s;
}

html.mx-js #hero.mx-hero-ready .hero-text h1,
html.mx-js #hero.mx-hero-ready .hero-text .hero-title {
  clip-path: inset(0 0 0% 0);
  translate: 0 0;
}

/* ── 3. Floating Glass Island Navbar (Desktop > 860px) ── */
@media (min-width: 861px) {
  #mainNav,
  :is(.dark, [data-theme="dark"]) #mainNav,
  html[data-theme="light"] #mainNav {
    background: transparent !important;
    border-bottom: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transition: padding 0.5s var(--mx-ease);
  }

  #mainNav .nav-links {
    position: relative;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 6px 10px !important;
    border-radius: 999px !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    transition: padding 0.5s var(--mx-ease), background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  }

  /* Light mode glass island */
  html[data-theme="light"] #mainNav .nav-links {
    background: rgba(253, 253, 241, 0.74) !important;
    border: 1px solid rgba(38, 40, 42, 0.14) !important;
    box-shadow: 0 10px 30px -10px rgba(38, 40, 42, 0.14), 0 2px 6px rgba(38, 40, 42, 0.04) !important;
  }

  /* Dark mode glass island */
  :is(.dark, [data-theme="dark"]) #mainNav .nav-links {
    background: rgba(12, 12, 16, 0.74) !important;
    border: 1px solid rgba(255, 255, 255, 0.13) !important;
    box-shadow: 0 12px 36px -8px rgba(0, 0, 0, 0.8), 0 2px 8px rgba(0, 0, 0, 0.5) !important;
  }

  /* Scrolled island compression (> 80px) */
  #mainNav.mx-scrolled .nav-links {
    padding: 3px 6px !important;
  }

  /* Smooth Sliding Active Pill */
  .mx-nav-pill {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: calc(100% - 10px);
    border-radius: 999px;
    pointer-events: none;
    z-index: 1;
    transition: transform 0.6s var(--mx-ease), width 0.6s var(--mx-ease), opacity 0.3s ease;
    opacity: 0;
  }

  .mx-nav-pill.mx-active {
    opacity: 1;
  }

  html[data-theme="light"] .mx-nav-pill {
    background: rgba(236, 94, 39, 0.12);
    border: 1px solid rgba(236, 94, 39, 0.24);
  }

  :is(.dark, [data-theme="dark"]) .mx-nav-pill {
    background: rgba(198, 255, 52, 0.12);
    border: 1px solid rgba(198, 255, 52, 0.28);
  }

  /* Neutralize old static line/border under active link */
  #mainNav .nav-links a.active::after,
  :is(.dark, [data-theme="dark"]) #mainNav .nav-links a.active::after,
  :is(.dark, [data-theme="dark"]) #mainNav .nav-links a::after {
    display: none !important;
    content: none !important;
  }
  #mainNav .nav-links a.active,
  :is(.dark, [data-theme="dark"]) #mainNav .nav-links a.active,
  html[data-theme="light"] #mainNav .nav-links a.active {
    border-bottom: none !important;
    background: transparent !important;
  }

  /* Nav Rolling Text Effect */
  #mainNav .nav-links a {
    position: relative;
    z-index: 2;
  }

  .mx-roll {
    display: inline-block;
    overflow: hidden;
    height: 1.35em;
    line-height: 1.35em;
    vertical-align: middle;
    pointer-events: none;
  }

  .mx-roll-inner {
    display: flex;
    flex-direction: column;
    transition: transform 0.55s var(--mx-ease);
  }

  .mx-roll-item {
    display: block;
    height: 1.35em;
    line-height: 1.35em;
  }

  #mainNav .nav-links a:hover .mx-roll-inner,
  #mainNav .nav-links a:focus-visible .mx-roll-inner {
    transform: translateY(-50%);
  }
}

/* ── 4. Section Boundary Accent Divider Lines ── */
.mx-section-line {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  height: 1px;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 1.4s var(--mx-ease);
  pointer-events: none;
  background-color: rgba(38, 40, 42, 0.14);
}

:is(.dark, [data-theme="dark"]) .mx-section-line {
  background-color: rgba(255, 255, 255, 0.12);
}

.mx-section-line.mx-drawn {
  transform: scaleX(1);
}

/* Section divider drawing under title */
.section-divider {
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 1.0s var(--mx-ease);
}

.section-divider.mx-drawn {
  transform: scaleX(1);
}

/* ── 6. Contact Title Word-by-Word Reveal ── */
.mx-word-mask {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  margin-right: 0.25em;
}

.mx-word-mask:last-child {
  margin-right: 0;
}

.mx-word-inner {
  display: inline-block;
  translate: 0 115%;
  transition: translate 0.85s var(--mx-ease);
}

.mx-word-mask.mx-word-in .mx-word-inner {
  translate: 0 0;
}

/* ── 7. Staggered Scroll Reveal Elements ── */
html.mx-js .mx-reveal {
  opacity: 0;
  translate: 0 28px;
  transition: opacity 1.0s var(--mx-ease), translate 1.0s var(--mx-ease);
}

html.mx-js .mx-reveal.mx-in {
  opacity: 1;
  translate: 0 0;
}

/* ── 7. Timeline Progress Sync ── */
.timeline-line {
  position: absolute;
  overflow: hidden;
}

.timeline-line::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--tl-p, 0%);
  background: var(--hero-orange, #EC5E27);
  transition: height 0.1s linear;
}

:is(.dark, [data-theme="dark"]) .timeline-line::after {
  background: var(--dk-lime, #C6FF34);
}

/* ── 10. Large Color Block Expanding Inset (Desktop > 860px) ── */
@media (min-width: 861px) {
  .mx-block-expand {
    will-change: margin, border-radius;
    transition: margin 0.1s linear, border-radius 0.1s linear;
  }
}

/* ── 11. Button Sheen & Magnetic Hover ── */
.mx-btn-shine {
  position: relative;
  overflow: hidden !important;
}

.mx-btn-shine::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -120%;
  width: 80%;
  height: 200%;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.04) 30%,
    rgba(255, 255, 255, 0.32) 50%,
    rgba(255, 255, 255, 0.04) 70%,
    transparent 100%
  );
  transform: rotate(25deg);
  pointer-events: none;
  transition: transform 0.9s var(--mx-ease), left 0.9s var(--mx-ease);
  opacity: 0;
  z-index: 5;
}

.mx-btn-shine:hover::after,
.mx-btn-shine:focus-visible::after {
  left: 140%;
  opacity: 1;
}

/* Magnetic button smooth return */
@media (hover: hover) and (pointer: fine) and (min-width: 861px) {
  .mx-magnetic {
    transition: translate 0.5s var(--mx-ease), transform 0.2s ease, background-color 0.2s ease, color 0.2s ease;
  }
}

/* ── 12. Accessibility & Prefers Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  html.mx-js #hero .hero-text .hero-badge,
  html.mx-js #hero .hero-text .hero-greeting,
  html.mx-js #hero .hero-text .hero-subtitle-wrap,
  html.mx-js #hero .hero-text .hero-desc,
  html.mx-js #hero .hero-text .hero-info,
  html.mx-js #hero .hero-text .hero-btns,
  html.mx-js #hero .hero-text .hero-socials,
  html.mx-js #hero .hero-text h1,
  html.mx-js #hero .hero-text .hero-title,
  html.mx-js .mx-reveal,
  .mx-word-inner,
  .mx-section-line,
  .section-divider,
  .mx-btn-shine::after,
  .mx-magnetic {
    opacity: 1 !important;
    translate: 0 0 !important;
    transform: none !important;
    clip-path: none !important;
    transition: none !important;
  }

  .mx-scroll-progress {
    transition: none !important;
  }

  .mx-block-expand {
    margin-left: unset !important;
    margin-right: unset !important;
    border-radius: unset !important;
  }
}
