/* ============================================================
   mobile-motion.css — SoftHire Mobile Motion Pass
   All rules scoped to coarse pointer + ≤768px viewport.
   Coexists with motion.css and cinematic.css.
   Kill-switch body classes: no-sticky-cta, no-swipe, no-haptics, low-power.
   ============================================================ */

/* ============================================================
   HARD MOBILE OVERFLOW GUARDS — applied first so nothing later
   can produce horizontal scroll. Audited cause: 3-column grids
   with inline grid-template-columns:repeat(3,1fr), animated
   absolute-positioned mesh extending beyond viewport, decorative
   pseudo-elements with negative inset.
   ============================================================ */
@media (max-width: 900px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100%;
  }
  /* Force every 3-column grid to single column on mobile */
  .services-grid,
  .guides-grid,
  .seg-panel-3col,
  .plans-grid,
  .markets-grid {
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  /* Section content cannot exceed viewport */
  section, .container, .hero-left, .hero-right, .seg-panel {
    max-width: 100vw !important;
    box-sizing: border-box;
  }
  /* Decorative absolute layers must clip strictly inside viewport */
  #hero .hero-mesh,
  #hero .hero-particles,
  #problem::before, #problem::after,
  footer#contact::before {
    max-width: 100vw !important;
    overflow: hidden;
  }
  /* Trust flags + seg-tabs use negative margin to extend to viewport
     edges. Cap that so they never exceed viewport width */
  .trust-flags, .seg-tabs {
    max-width: 100vw !important;
    margin-left: -20px !important;
    margin-right: -20px !important;
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* ============================================================
   BASE MOBILE LAYER — things that apply regardless of touch
   ============================================================ */
@media (max-width: 768px) {
  /* Replace grain + cursor spotlight with a single lightweight vignette */
  .mt-grain, .mt-cursor-dot, .mt-cursor-ring, .mt-spotlight { display: none !important; }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9996;
    pointer-events: none;
    background:
      radial-gradient(ellipse 120% 80% at 50% 50%, transparent 55%, rgba(2,1,19,.38) 100%),
      radial-gradient(ellipse 60% 30% at 50% 0%, rgba(240,180,41,.05) 0%, transparent 70%);
  }

  /* Below-the-fold paint deferral */
  #problem, #how, #segments, #markets, #founder, #pricing, #community, #cta, footer {
    content-visibility: auto;
    contain-intrinsic-size: 800px;
  }

  /* ---------- Hero — defensive centering + visible mobile treatments ---------- */
  #hero {
    grid-template-columns: 1fr !important;
    min-height: auto !important;
    padding-top: 72px !important;
    padding-bottom: 32px !important;
    position: relative;
    overflow: hidden;
  }
  /* Floating ambient gold orbs behind the hero — new, visible mobile flair */
  #hero::after {
    content: "";
    position: absolute;
    top: 10%; left: -30%;
    width: 260px; height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240,180,41,.35), rgba(240,180,41,0) 70%);
    filter: blur(50px);
    opacity: .6;
    pointer-events: none;
    z-index: 0;
    animation: mt-hero-orb 14s ease-in-out infinite alternate;
  }
  @keyframes mt-hero-orb {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 40px) scale(1.12); }
  }
  .hero-left {
    width: 100%;
    padding: 28px 24px 24px !important;
    text-align: center !important;
    align-items: center !important;
    margin: 0 auto;
    position: relative;
    z-index: 2;
  }
  .hero-left > * { width: 100%; max-width: 100%; }
  .hero-left .eyebrow {
    white-space: normal !important;
    text-overflow: clip !important;
    overflow: visible !important;
    font-size: 10.5px !important;
    letter-spacing: 2px;
    text-align: center;
  }
  .hero-h1 {
    text-align: center !important;
    margin: 0 auto 16px !important;
    font-size: clamp(30px, 8.2vw, 44px) !important;
    line-height: 1.08 !important;
  }
  .hero-sub {
    text-align: center !important;
    margin: 0 auto 26px !important;
    font-size: 15px !important;
    max-width: 340px;
  }
  .hero-actions {
    flex-direction: column !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100%;
  }
  .hero-actions > * {
    width: 100% !important;
    max-width: 300px !important;
    min-height: 48px;
  }
  .trust-label {
    text-align: center !important;
    margin-top: 24px;
  }

  /* Italic word ("global opportunity.") gets a continuous gold shimmer loop
     on mobile — the most visible hero treatment. */
  .hero-h1 em {
    background-image: linear-gradient(
      90deg,
      #C8960C 0%, #F0B429 35%, #FFE9A8 50%, #F0B429 65%, #C8960C 100%) !important;
    background-size: 200% 100% !important;
    -webkit-background-clip: text !important;
            background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
            color: transparent !important;
    animation: mt-hero-italic-loop 4.5s ease-in-out infinite;
  }
  @keyframes mt-hero-italic-loop {
    0%   { background-position: 100% 0; }
    50%  { background-position: -100% 0; }
    100% { background-position: 100% 0; }
  }

  /* Hero image frame — visible gold corner accents + glow */
  .hero-right {
    margin: 0 20px !important;
    min-height: 260px !important;
    border-radius: 20px !important;
    overflow: hidden !important;
    position: relative;
    box-shadow:
      0 30px 60px rgba(0, 0, 0, .6),
      0 0 0 1px rgba(240, 180, 41, .18);
    z-index: 2;
  }
  /* Gold corner brackets on the image frame */
  .hero-right::before,
  .hero-right::after {
    width: auto !important;
    height: auto !important;
    background: none !important;
  }
  .hero-right::before {
    content: "";
    position: absolute;
    top: 12px; left: 12px;
    width: 28px; height: 28px;
    border-top: 1.5px solid rgba(240,180,41,.7);
    border-left: 1.5px solid rgba(240,180,41,.7);
    border-top-left-radius: 6px;
    z-index: 5;
    pointer-events: none;
  }
  .hero-right::after {
    content: "";
    position: absolute;
    bottom: 12px; right: 12px;
    width: 28px; height: 28px;
    border-bottom: 1.5px solid rgba(240,180,41,.7);
    border-right: 1.5px solid rgba(240,180,41,.7);
    border-bottom-right-radius: 6px;
    z-index: 5;
    pointer-events: none;
  }

  #hero .hero-right img {
    animation: mt-mobile-kenburns 20s ease-in-out infinite alternate;
    will-change: transform;
  }
  @keyframes mt-mobile-kenburns {
    from { transform: scale(1.08) translate3d(0, 0, 0); }
    to   { transform: scale(1.00) translate3d(0, 12px, 0); }
  }

  /* Headline reveal: no blur (GPU-heavy on iOS) — override motion.css filter */
  [data-motion="split-words"] .mt-word {
    filter: none !important;
  }
  [data-motion="split-words"] .mt-word:not(.is-in) {
    opacity: 0;
    transform: translate3d(0, 12px, 0);
  }

  /* Country chips as a horizontal snap rail with fade masks */
  .trust-flags {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 8px !important;
    padding: 4px 24px 12px 24px;
    margin: 0 -24px !important;
    mask-image: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
  }
  .trust-flags > .flag-pill {
    scroll-snap-align: start;
    flex: 0 0 auto;
  }

  /* ---------- Sticky CTA bar (floating bottom dock) ---------- */
  .mt-sticky-cta {
    position: fixed;
    left: 16px; right: 16px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
    z-index: 9500;
    display: flex;
    gap: 10px;
    padding: 12px 14px 12px 18px;
    background: rgba(10, 14, 28, .78);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    border: 1px solid rgba(240, 180, 41, .22);
    border-radius: 18px;
    box-shadow: 0 18px 40px -10px rgba(0,0,0,.65), 0 0 0 1px rgba(240,180,41,.06);
    transform: translate3d(0, 140%, 0);
    opacity: 0;
    transition:
      transform .42s cubic-bezier(.2,.8,.2,1),
      opacity .28s ease;
    align-items: center;
    pointer-events: none;
  }
  .mt-sticky-cta.is-visible {
    transform: translate3d(0, 0, 0);
    opacity: 1;
    pointer-events: auto;
  }
  .mt-sticky-cta.is-dismissed {
    transform: translate3d(0, 180%, 0);
    opacity: 0;
    pointer-events: none;
  }
  body.no-sticky-cta .mt-sticky-cta { display: none !important; }

  .mt-sticky-cta-btn {
    flex: 1;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    background: linear-gradient(180deg, #E6B025, #C8960C);
    color: #07070F;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    letter-spacing: .02em;
    border-radius: 12px;
    text-decoration: none;
    box-shadow: 0 6px 16px -4px rgba(240,180,41,.4);
  }
  .mt-sticky-cta-btn:active { transform: scale(.97); }
  .mt-sticky-cta-close {
    min-width: 32px; min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: rgba(255,255,255,.6);
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
  }
  .mt-sticky-cta-close:active { color: #fff; }

  /* ---------- How It Works on mobile: stacked cards + focus mode ---------- */
  body.rail-active .how-rail-outer,
  .how-rail-outer {
    overflow: visible !important;
  }
  .how-rail-track {
    flex-wrap: wrap !important;
    gap: 14px !important;
    transform: none !important; /* kill any GSAP residue from desktop layout */
  }
  .how-card {
    flex: 1 1 100% !important;
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition:
      transform .5s cubic-bezier(.2,.8,.2,1),
      opacity .5s,
      border-color .5s;
  }
  .how-card.mt-mobile-focus {
    transform: scale(1.02) !important;
    border-color: rgba(240,180,41,.35) !important;
    box-shadow: 0 30px 60px -25px rgba(240,180,41,.25);
  }
  .how-rail-outer:has(.mt-mobile-focus) .how-card:not(.mt-mobile-focus) {
    opacity: .6 !important;
  }
  .how-rail-progress { display: none !important; }
  .how-connector { display: none !important; }

  /* ---------- Solutions tabs on mobile: horizontal scroll strip ---------- */
  .seg-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 8px !important;
    padding: 6px 20px;
    margin: 0 -20px !important;
    mask-image: linear-gradient(90deg, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%);
  }
  .seg-tab {
    scroll-snap-align: start;
    flex: 0 0 auto;
    min-height: 44px;
    white-space: nowrap;
  }
  .seg-tab:active { transform: scale(.97); }

  /* Panel area gets swipe affordance */
  .seg-panel {
    touch-action: pan-y;
  }

  /* ---------- Markets: 2-col grid + long-press drawer ---------- */
  .markets-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .mkt-card {
    position: relative;
    min-height: 120px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
  }
  .mkt-card:active { transform: scale(.985); }

  /* Long-press progress ring overlay */
  .mt-press-ring {
    position: absolute;
    inset: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .1s ease;
  }
  .mkt-card.mt-is-pressing .mt-press-ring { opacity: 1; }
  .mt-press-ring svg { width: 100%; height: 100%; overflow: visible; }
  .mt-press-ring .ring-bg { stroke: rgba(240,180,41,.15); }
  .mt-press-ring .ring-fg {
    stroke: var(--c-gold-3, #F0B429);
    stroke-linecap: round;
    stroke-dasharray: var(--ring-len, 260);
    stroke-dashoffset: var(--ring-len, 260);
    filter: drop-shadow(0 0 6px rgba(240,180,41,.5));
  }
  .mkt-card.mt-is-pressing .mt-press-ring .ring-fg {
    animation: mt-ring-fill 500ms linear forwards;
  }
  @keyframes mt-ring-fill {
    to { stroke-dashoffset: 0; }
  }

  /* Legal detail drawer */
  .mt-mkt-drawer {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 10px 14px 12px;
    background: linear-gradient(180deg, rgba(10,14,28,.2), rgba(10,14,28,.95));
    color: #fff;
    font-size: 11px;
    font-family: 'Outfit', sans-serif;
    letter-spacing: .04em;
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
    transform: translateY(100%);
    opacity: 0;
    transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .2s;
    pointer-events: none;
  }
  .mkt-card.mt-drawer-open .mt-mkt-drawer {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
  .mt-mkt-drawer strong {
    display: block;
    font-weight: 700;
    color: var(--c-gold-3, #F0B429);
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 2px;
  }

  /* ---------- Pricing on mobile ---------- */
  .plans-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  /* Reorder — Featured first */
  .plan-card { order: 2; }
  .plan-card.featured { order: 1; transform: none !important; }

  /* Persistent "Most Popular" ribbon */
  .plan-card.featured .plan-badge {
    position: absolute;
    top: -12px; left: 50%;
    transform: translateX(-50%);
    padding: 6px 18px;
    background: linear-gradient(90deg, #C8960C, #E6B025, #C8960C);
    color: #07070F;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .18em;
    text-transform: uppercase;
    border-radius: 14px;
    box-shadow: 0 6px 22px -4px rgba(240,180,41,.4);
    white-space: nowrap;
  }

  /* Tactile tap feel on cards */
  .plan-card {
    transition: transform 120ms ease, border-color .3s, box-shadow .3s;
  }
  .plan-card:active { transform: scale(.98) !important; }

  /* ---------- Nav drawer: slide from RIGHT with stagger ---------- */
  .mobile-nav {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; right: 0;
    left: auto;
    width: min(86vw, 380px);
    padding: 88px 28px 40px;
    background: linear-gradient(180deg, #0D1222 0%, #05051A 100%);
    border-left: 1px solid rgba(240,180,41,.14);
    box-shadow: -20px 0 60px -20px rgba(0,0,0,.6);
    transform: translate3d(100%, 0, 0);
    transition: transform .32s cubic-bezier(.2,.8,.2,1);
    z-index: 9100;
    visibility: visible;
    gap: 18px;
  }
  .mobile-nav.active {
    transform: translate3d(0, 0, 0);
  }
  .mobile-nav > a {
    opacity: 0;
    transform: translate3d(24px, 0, 0);
    transition:
      opacity .35s cubic-bezier(.2,.8,.2,1),
      transform .35s cubic-bezier(.2,.8,.2,1);
  }
  .mobile-nav.active > a {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  .mobile-nav.active > a:nth-child(1) { transition-delay: .04s; }
  .mobile-nav.active > a:nth-child(2) { transition-delay: .08s; }
  .mobile-nav.active > a:nth-child(3) { transition-delay: .12s; }
  .mobile-nav.active > a:nth-child(4) { transition-delay: .16s; }
  .mobile-nav.active > a:nth-child(5) { transition-delay: .20s; }
  .mobile-nav.active > a:nth-child(6) { transition-delay: .24s; }

  /* Scrim behind drawer */
  .mt-nav-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(4px);
    z-index: 9050;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
  }
  .mt-nav-scrim.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* ---------- Contact modal: bottom sheet ---------- */
  .modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important;
  }
  .modal-overlay .modal-box {
    width: 100%;
    max-width: none !important;
    border-radius: 22px 22px 0 0 !important;
    padding: 14px 22px 34px !important;
    padding-bottom: calc(34px + env(safe-area-inset-bottom, 0px)) !important;
    max-height: 92vh;
    overflow-y: auto;
    transform: translate3d(0, 110%, 0);
    transition: transform .38s cubic-bezier(.2,.8,.2,1);
  }
  .modal-overlay.open .modal-box {
    transform: translate3d(0, 0, 0);
  }
  .modal-box::before {
    content: "";
    display: block;
    width: 44px;
    height: 4px;
    background: rgba(255,255,255,.25);
    border-radius: 3px;
    margin: 0 auto 18px;
  }

  /* ---------- Accessibility baseline ---------- */
  a, button, .seg-tab, .flag-pill, .mkt-card, .plan-card {
    min-height: 44px;
  }
  *:focus-visible {
    outline: 2px solid var(--c-gold-3, #F0B429);
    outline-offset: 2px;
    border-radius: 4px;
  }
}

/* ============================================================
   COARSE POINTER OVERRIDES
   (touch devices at any size — iPads in portrait, folded phones)
   ============================================================ */
@media (pointer: coarse) {
  /* Disable cursor spotlight + magnetic button math — they're irrelevant */
  .mt-spotlight, .mt-cursor-dot, .mt-cursor-ring { display: none !important; }

  /* Prevent sticky hover color residues */
  .btn-gold:hover, .nav-cta:hover, .btn-ghost:hover, .seg-tab:hover,
  .plan-card:hover, .mkt-card:hover, .how-card:hover, .comm-perk:hover {
    transform: none !important;
  }
}

/* ============================================================
   LOW POWER — disables decorative infinite loops
   Added to body by mobile-motion.js when:
     (battery.level<.2 && !charging) OR deviceMemory<=2 OR visibility hidden
   ============================================================ */
body.low-power .mt-grain,
body.low-power #problem::before,
body.low-power #problem::after,
body.low-power footer#contact::before,
body.low-power #problem .problem-img .mt-scan-overlay::before,
body.low-power .founder-photo img,
body.low-power .plan-card.featured,
body.low-power #hero .btn-gold,
body.low-power .nav-cta,
body.low-power .footer-clocks .mt-clock-pulse,
body.low-power #hero .hero-right img {
  animation: none !important;
}
body.low-power section[data-stage]::before { opacity: .2; }

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .mt-sticky-cta { transition: opacity .12s; transform: none !important; }
  .mt-sticky-cta:not(.is-visible) { opacity: 0; pointer-events: none; }
  #hero .hero-right img { animation: none !important; }
  .mobile-nav { transition: transform .12s; }
  .mobile-nav.active > a { transition: opacity .12s; transform: none !important; }
  .modal-overlay .modal-box { transition: transform .12s; }
  .how-card { transition: opacity .12s; transform: none !important; }
  .mkt-card.mt-is-pressing .mt-press-ring .ring-fg { animation: none !important; stroke-dashoffset: 0; }
}
