/* =====================================================================
   MOTION & MICRO-INTERACTIONS
   Electrical theme: current flowing through lines, energised glow,
   precise engineered movement. Transform/opacity only (GPU friendly).
   Everything is disabled for users who prefer reduced motion.
   html.m-js is set before first paint; html.m-failsafe shows all content
   if the motion script ever fails to load.
   ===================================================================== */
:root {
  --m-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --m-out: cubic-bezier(0.16, 1, 0.3, 1);
  --m-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --m-accent: #4a86dc;
}

/* ---------- 1. Scroll progress — a live "current" along the top ---------- */
.m-progress {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: 3px;
  z-index: 260;
  pointer-events: none;
  transform: scaleX(var(--m-p, 0));
  transform-origin: left center;
  background: linear-gradient(90deg, #1f4d8c, #4a86dc 60%, #cfe0f8);
  box-shadow: 0 0 10px rgba(74, 134, 220, 0.7);
}
html[dir="rtl"] .m-progress { transform-origin: right center; }

/* ---------- 2. Hero entrance (staggered, plays once on load) ---------- */
.m-js .hero-eyebrow,
.m-js .hero-title > span,
.m-js .hero-subtitle,
.m-js .hero-cta-row > *,
.m-js .hero-pillar-chip {
  opacity: 0;
  transform: translateY(22px);
}
.m-js .hero-title > span { display: inline-block; filter: blur(6px); }

.m-hero-in .hero-eyebrow,
.m-hero-in .hero-title > span,
.m-hero-in .hero-subtitle,
.m-hero-in .hero-cta-row > *,
.m-hero-in .hero-pillar-chip {
  opacity: 1;
  transform: none;
  filter: none;
  transition: opacity 0.9s var(--m-out), transform 0.9s var(--m-out), filter 0.9s var(--m-out);
}
.m-hero-in .hero-eyebrow { transition-delay: 0.05s; }
.m-hero-in .hero-title > span:nth-of-type(1) { transition-delay: 0.15s; }
.m-hero-in .hero-title > span:nth-of-type(2) { transition-delay: 0.32s; }
.m-hero-in .hero-subtitle { transition-delay: 0.5s; }
.m-hero-in .hero-cta-row > :nth-child(1) { transition-delay: 0.65s; }
.m-hero-in .hero-cta-row > :nth-child(2) { transition-delay: 0.75s; }
.m-hero-in .hero-pillar-chip:nth-child(1) { transition-delay: 0.85s; }
.m-hero-in .hero-pillar-chip:nth-child(2) { transition-delay: 0.93s; }
.m-hero-in .hero-pillar-chip:nth-child(3) { transition-delay: 1.01s; }
.m-hero-in .hero-pillar-chip:nth-child(4) { transition-delay: 1.09s; }

/* energised shimmer across the highlighted headline words */
.hero-title .gold-highlight {
  background-size: 220% 100% !important;
  animation: mShimmer 6s ease-in-out 1.6s infinite;
}
@keyframes mShimmer {
  0%, 100% { background-position: 0% 0; }
  50% { background-position: 100% 0; }
}

/* eyebrow bolt flickers like an arc once, then glows */
.m-hero-in .hero-eyebrow .ic { animation: mArc 1.6s ease-out 0.4s 1 both; }
@keyframes mArc {
  0% { opacity: 0.2; filter: drop-shadow(0 0 0 transparent); }
  8% { opacity: 1; filter: drop-shadow(0 0 8px #8fb4f0); }
  12% { opacity: 0.3; }
  18% { opacity: 1; filter: drop-shadow(0 0 10px #8fb4f0); }
  100% { opacity: 1; filter: drop-shadow(0 0 4px rgba(143, 180, 240, 0.6)); }
}

/* hero content drifts up & fades while scrolling away (set by JS) */
.hero-layout { will-change: transform, opacity; }

/* ---------- 3. Scroll reveals (applied by JS to below-the-fold elements) ---------- */
[data-m] {
  transition:
    opacity 0.85s var(--m-out),
    transform 0.85s var(--m-out);
  transition-delay: var(--m-delay, 0ms);
}
[data-m="up"] { opacity: 0; transform: translateY(34px); }
[data-m="scale"] { opacity: 0; transform: translateY(18px) scale(0.95); }
[data-m="side"] { opacity: 0; transform: translateX(var(--m-side, 36px)); }
html[dir="rtl"] [data-m="side"] { --m-side: -36px; }
/* gallery: fade + settle (clip-path would hide it from IntersectionObserver) */
[data-m="wipe"] { opacity: 0; transform: translateY(26px) scale(0.96); }
[data-m].m-in { opacity: 1; transform: none; }

/* section heading: the side lines "charge up" when revealed */
.section-tag::before,
.section-tag::after {
  transform-origin: center;
  transition: transform 0.9s var(--m-out) 0.25s;
}
.section-header[data-m]:not(.m-in) .section-tag::before,
.section-header[data-m]:not(.m-in) .section-tag::after { transform: scaleX(0); }

/* ---------- 4. Current flowing through the section-tag lines ---------- */
.section-tag::before,
.section-tag::after {
  background: linear-gradient(90deg, transparent 0%, currentColor 35%, #8fb4f0 50%, currentColor 65%, transparent 100%) !important;
  background-size: 300% 100% !important;
  animation: mFlow 3.2s linear infinite;
  opacity: 0.85;
}
.section-tag::after { animation-direction: reverse; }
@keyframes mFlow {
  from { background-position: 100% 0; }
  to { background-position: -200% 0; }
}

/* ---------- 5. Cards: cursor spotlight + gentle 3D tilt (mouse only) ---------- */
.division-card,
.tool-card {
  position: relative;
  transform-style: preserve-3d;
}
.division-card::after,
.tool-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s var(--m-ease);
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(74, 134, 220, 0.13), transparent 45%);
}
.division-card:hover::after,
.tool-card:hover::after { opacity: 1; }
[data-theme="dark"] .division-card::after,
[data-theme="dark"] .tool-card::after {
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(143, 180, 240, 0.12), transparent 45%);
}
.m-tilt {
  transition: transform 0.5s var(--m-out), box-shadow 0.4s var(--m-ease), border-color 0.4s var(--m-ease) !important;
}
.m-tilt.m-tilting { transition: transform 0.08s linear, box-shadow 0.4s var(--m-ease), border-color 0.4s var(--m-ease) !important; }

/* icons inside cards come alive on hover */
.division-card .division-icon-box,
.tool-card .tool-card-icon {
  transition: transform 0.5s var(--m-spring);
}
.division-card:hover .division-icon-box,
.tool-card:hover .tool-card-icon { transform: translateY(-3px) rotate(-6deg) scale(1.08); }
html[dir="rtl"] .division-card:hover .division-icon-box,
html[dir="rtl"] .tool-card:hover .tool-card-icon { transform: translateY(-3px) rotate(6deg) scale(1.08); }

/* card links: arrow slides forward */
.tool-card-link .ic, .division-action-link .outline-icon { transition: transform 0.35s var(--m-spring); }
.tool-card:hover .tool-card-link .ic { transform: translateX(-5px); }
html[dir="ltr"] .tool-card:hover .tool-card-link .ic { transform: translateX(5px); }
.division-action-link:hover .outline-icon { transform: translateX(-4px); }
html[dir="ltr"] .division-action-link:hover .outline-icon { transform: translateX(4px) scaleX(-1); }

/* ---------- 6. Click ripple on buttons ---------- */
.btn-gold, .btn-navy, .btn-outline-light, .tool-tab, .sim-test, .sim-option, .sim-case,
.cat-pill, .sector-tab, .calc-tab-btn, .symptom-chip, .add-rfq-btn, .rfq-trigger-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.m-ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  background: currentColor;
  opacity: 0.22;
  z-index: -1;
  animation: mRipple 0.65s var(--m-out) forwards;
}
@keyframes mRipple {
  to { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* pressed feedback for interactive tiles */
.sim-test:active:not(:disabled), .sim-option:active:not(:disabled), .sim-case:active,
.process-step-node:active, .tool-tab:active, .cat-pill:active, .symptom-chip:active {
  transform: scale(0.97);
}

/* ---------- 7. Magnetic primary buttons (mouse only, set by JS) ---------- */
.m-magnetic { transition: transform 0.45s var(--m-spring) !important; }
.m-magnetic .ic { transition: transform 0.45s var(--m-spring); }

/* ---------- 8. Header reacts to scroll ---------- */
.site-header { transition: box-shadow 0.35s var(--m-ease), background-color 0.35s var(--m-ease); }
.m-scrolled .site-header {
  background: rgba(6, 19, 38, 0.92);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.55);
}

/* nav link of the section in view */
.nav-link.m-spy { color: #ffffff; }
.nav-link.m-spy::after { inset-inline: 11px !important; }

/* ---------- 9. Tool center: panel switch + tab indicator ---------- */
.tool-panel.is-active { animation: mPanelIn 0.55s var(--m-out) both; }
@keyframes mPanelIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
.tool-tab { transition: background 0.3s var(--m-ease), color 0.3s var(--m-ease), transform 0.2s var(--m-ease); }
.tool-tab.active .ic { animation: mPop 0.5s var(--m-spring); }
@keyframes mPop { 0% { transform: scale(0.6); } 100% { transform: scale(1); } }

/* ---------- 10. FAQ opens smoothly ---------- */
.faq-item.open .faq-answer { animation: mDrop 0.4s var(--m-out); }
@keyframes mDrop {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.faq-question .outline-icon { transition: transform 0.45s var(--m-spring) !important; }

/* ---------- 11. Simulator: instruments and report feel live ---------- */
.sim-meter-screen { position: relative; }
.sim-meter:not(.is-measuring) .sim-meter-screen::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 40%;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(126, 232, 178, 0.08), transparent);
  animation: mScan 1.1s var(--m-out) 1 both;
}
@keyframes mScan {
  from { transform: translateY(-100%); opacity: 1; }
  to { transform: translateY(250%); opacity: 0; }
}
.sim-score { animation: mScoreIn 0.9s var(--m-spring) both; }
@keyframes mScoreIn {
  from { transform: scale(0.6) rotate(-20deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.sim-status-dot { animation: mDot 2s ease-in-out infinite; }
@keyframes mDot { 50% { transform: scale(1.25); } }
.sim-option.is-wrong { animation: mShake 0.45s var(--m-ease); }
@keyframes mShake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ---------- 12. Gallery: slow zoom-in once revealed ---------- */
.gallery-item[data-m].m-in img { animation: mKen 1.6s var(--m-out) both; }
@keyframes mKen { from { transform: scale(1.12); } to { transform: scale(1); } }
.gallery-item:hover img { transform: scale(1.06) !important; }

/* ---------- 13. Back-to-top button ---------- */
.m-top {
  position: fixed;
  z-index: 149;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  inset-inline-end: calc(28px + env(safe-area-inset-right, 0px));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: rgba(10, 29, 55, 0.88);
  border: 1px solid rgba(143, 180, 240, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(14px) scale(0.85);
  pointer-events: none;
  transition: opacity 0.35s var(--m-ease), transform 0.45s var(--m-spring), background 0.25s;
}
.m-top.show { opacity: 1; transform: none; pointer-events: auto; }
.m-top:hover { background: #1f4d8c; }
.m-top svg { transform: rotate(-90deg); }
body:has(.rfq-drawer.open) .m-top, body:has(.modal-dialog.open) .m-top { opacity: 0; pointer-events: none; }
@media (max-width: 680px) {
  .m-top { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); inset-inline-end: calc(23px + env(safe-area-inset-right, 0px)); }
}

/* ---------- Failsafe & reduced motion ---------- */
.m-failsafe .hero-eyebrow, .m-failsafe .hero-title > span, .m-failsafe .hero-subtitle,
.m-failsafe .hero-cta-row > *, .m-failsafe .hero-pillar-chip, .m-failsafe [data-m] {
  opacity: 1 !important; transform: none !important; filter: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
  .m-js .hero-eyebrow, .m-js .hero-title > span, .m-js .hero-subtitle,
  .m-js .hero-cta-row > *, .m-js .hero-pillar-chip, [data-m] {
    opacity: 1 !important; transform: none !important; filter: none !important;
  }
}

/* never let an entrance offset widen the page */
html { overflow-x: clip; }
@media (max-width: 680px) {
  [data-m="side"] { transform: translateY(28px); }
}
