/* ================================================================
   IBD MOBILE STABILITY PASS
   Purpose: remove mobile-only scroll/animation conflicts without
   changing the desktop experience.
   ================================================================ */

@media (max-width: 991.98px) {

  /* overflow-x:hidden used to live here on both html and body. Removed:
     it's the documented cause of position:fixed breaking on iOS Safari
     (see corrections.css for the full explanation) — and this page has
     two position:fixed elements that depend on staying put: #header
     right below, and the ScrollTrigger-pinned mobile cube in #services.
     Horizontal-scroll containment now happens on #ibd-scroll-guard
     instead (a plain wrapper div, not html/body). */
  html {
    width: 100%;
    max-width: 100%;
    scroll-behavior: auto !important;
    overscroll-behavior-x: none;
  }

  body {
    width: 100%;
    max-width: 100%;
    font-size: 15.5px !important;
    line-height: 1.6 !important;
    font-weight: 400 !important;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overscroll-behavior-x: none;
    touch-action: pan-y;
    font-synthesis: none;
  }

  /* -------------------------------------------------------------
     FIXED HEADER + MOBILE MENU
     ------------------------------------------------------------- */
  #header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 10000 !important;
    padding: 8px 0 !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  #header .navbar {
    position: relative;
    width: calc(100% - 20px) !important;
    max-width: none !important;
    min-height: 58px;
    margin: 0 10px !important;
    padding: 8px 14px !important;
    border-radius: 18px !important;
  }

  #header .navbar > .container {
    width: 100%;
    max-width: none;
    padding: 0 !important;
  }

  #header .navbar-brand {
    margin-right: auto;
    min-width: 0;
  }

  #header .navbar-brand img {
    width: auto;
    max-width: 112px;
    height: auto;
  }

  #header .menu-toggle {
    display: inline-flex !important;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    margin: 0;
    padding: 0;
    border: 0;
    position: relative;
    z-index: 10003;
    cursor: pointer !important;
  }

  #header .menu-toggle span {
    display: block !important;
    width: 23px;
    height: 2px;
    border-radius: 10px;
    background: #171717;
  }

  #header .navbar-collapse {
    position: absolute !important;
    top: calc(100% + 8px) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: calc(100svh - 90px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px !important;
    margin: 0 !important;
    background: rgba(255,255,255,.98) !important;
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 18px !important;
    box-shadow: 0 20px 50px rgba(0,0,0,.14) !important;
    z-index: 10002 !important;
  }

  #header .navbar-collapse:not(.show) {
    display: none !important;
  }

  #header .navbar-collapse.show {
    display: block !important;
  }

  #header .navbar-nav {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 2px !important;
  }

  #header .nav-item,
  #header .nav-link {
    width: 100% !important;
  }

  #header .nav-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px !important;
    font-family: "Montserrat", sans-serif !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    font-weight: 600 !important;
  }

  #header .btn-nav {
    display: flex !important;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    margin: 10px 0 0 !important;
    font-size: 13px !important;
  }

  /* -------------------------------------------------------------
     SHOWREEL — clear the fixed header.
     ------------------------------------------------------------- */
  #showreel {
    margin-top: 86px !important;
    padding: 0 0 35px !important;
  }

  #showreel .showreel-frame {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 0 !important;
    box-shadow: none;
  }

  #showreel .showreel-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* -------------------------------------------------------------
     HERO — no mobile scroll-parallax.
     Static poster replaces the heavy background video.
     ------------------------------------------------------------- */
  #hero {
    min-height: calc(100svh - 86px) !important;
    height: auto !important;
    padding: 65px 0 55px !important;
    overflow: hidden !important;
  }

  #hero .hero-bg {
    background: url("../../images/bg-mobile.jpg") center center / cover no-repeat !important;
  }

  #hero .hero-bg video {
    display: none !important;
  }

  #hero .hero-title {
    font-family: "Montserrat", sans-serif !important;
    font-weight: 800 !important;
    font-size: clamp(2rem, 9vw, 3.15rem) !important;
    line-height: 1.02 !important;
    letter-spacing: -0.03em !important;
    text-transform: none !important;
  }

  #hero .hero-word {
    font-weight: 800 !important;
  }

  #hero .hero-headline > .text-center {
    font-family: "Inter", sans-serif !important;
    font-size: 15px !important;
    line-height: 1.5 !important;
    font-weight: 400 !important;
  }

  /* -------------------------------------------------------------
     GLOBAL MOBILE TYPE
     ------------------------------------------------------------- */
  .section-title {
    font-family: "Montserrat", sans-serif !important;
    font-weight: 700 !important;
    font-size: clamp(1.9rem, 8vw, 2.7rem) !important;
    line-height: 1.05 !important;
    letter-spacing: -0.025em !important;
  }

  p,
  .story-subtitle,
  .services-intro p,
  .work-content p,
  .contact p,
  .contact-info {
    font-family: "Inter", sans-serif !important;
    font-weight: 400 !important;
    font-size: 15.5px !important;
    line-height: 1.65 !important;
  }

  /* -------------------------------------------------------------
     ABOUT — no pin, no transform, clean mobile flow.
     ------------------------------------------------------------- */
  #story {
    overflow: hidden !important;
    padding: 64px 0 78px !important;
  }

  #story .story-copy-col,
  #story .story-media-col {
    transform: none !important;
  }

  #story .story-title,
  #story .story-title .story-word {
    font-family: "Montserrat", sans-serif !important;
    font-weight: 700 !important;
  }

  /* -------------------------------------------------------------
     SERVICES / CUBE
     ------------------------------------------------------------- */
  #services {
    position: relative !important;
    min-height: 100svh !important;
    height: 100svh;
    overflow: visible !important;
    padding: 78px 0 86px !important;
    isolation: isolate;
  }

  #services #service-bg,
  #services .video-bg {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    z-index: 0 !important;
    pointer-events: none !important;
    background: url("../../images/about-mobile.jpg") center center / cover no-repeat !important;
  }

  #services #service-bg video,
  #services .video-bg video {
    display: none !important;
  }

  #services::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: rgba(255,255,255,.60);
    pointer-events: none;
  }

  #services > .container {
    position: relative !important;
    z-index: 2 !important;
  }

  #services .services-intro {
    margin-bottom: 28px !important;
  }

  #services .services-intro h2 {
    font-family: "Montserrat", sans-serif !important;
    font-weight: 700 !important;
    font-size: clamp(2rem, 9vw, 3rem) !important;
    line-height: 1 !important;
  }

  #services .cube-wrapper {
    width: 260px !important;
    height: 260px !important;
    margin: 8px auto 0 !important;
    transform: scale(.68) !important;
    transform-origin: center center !important;
    perspective: 1200px !important;
    -webkit-perspective: 1200px !important;
    transform-style: preserve-3d !important;
    -webkit-transform-style: preserve-3d !important;
    overflow: visible !important;
  }

  #services .cube {
    width: 260px !important;
    height: 260px !important;
    transform-style: preserve-3d !important;
    -webkit-transform-style: preserve-3d !important;
    transform-origin: center center !important;
    /* STABILITY FIX: `will-change: transform` removed from here too —
       this rule and mobile-final-fix.css's #services .cube rule were
       both setting it, meaning removing it from only one file left it
       in effect via the other. See the comment in mobile-final-fix.css
       for why: it's now toggled inline by ibd.js only while the cube's
       pinned animation is actually running, instead of being held for
       the whole time the page is open. */
  }

  #services .face {
    width: 260px !important;
    height: 260px !important;
    font-family: "Montserrat", sans-serif !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    backface-visibility: visible !important;
    -webkit-backface-visibility: visible !important;
  }

  /* Exactly the same face geometry as desktop. */
  #services .front { transform: translateZ(130px) !important; }
  #services .back { transform: rotateY(180deg) translateZ(130px) !important; }
  #services .right { transform: rotateY(90deg) translateZ(130px) !important; }
  #services .left { transform: rotateY(-90deg) translateZ(130px) !important; }
  #services .top { transform: rotateX(90deg) translateZ(130px) !important; }
  #services .bottom { transform: rotateX(-90deg) translateZ(130px) !important; }

  /* -------------------------------------------------------------
     IMPACT — static background, smaller cards, no viewport video.
     ------------------------------------------------------------- */
  #impact {
    overflow: hidden !important;
    padding: 70px 0 !important;
    background: url("../../images/social-mobile.jpg") center center / cover no-repeat !important;
  }

  #impact #proof-bg {
    display: none !important;
  }

  #impact .impact-card {
    min-height: 150px;
    margin-bottom: 0 !important;
    padding: 26px 20px !important;
  }

  #impact .impact-card h2 {
    font-family: "Montserrat", sans-serif !important;
    font-weight: 700 !important;
    font-size: clamp(2.2rem, 11vw, 3.4rem) !important;
  }

  /* -------------------------------------------------------------
     CONTACT — mobile-specific crop, form fills the width.
     ------------------------------------------------------------- */
  #contact {
    background-image: url("../../images/contact-mobile.jpg") !important;
    background-size: cover !important;
    background-position: center center !important;
    background-attachment: scroll !important;
    padding: 76px 0 82px !important;
  }

  #contact .container {
    padding-left: 18px;
    padding-right: 18px;
  }

  #contact .contact-content {
    padding-right: 0 !important;
  }

  #contact .contact-form {
    width: 100%;
    padding: 28px 20px !important;
    border-radius: 20px !important;
  }

  #contact .form-group {
    margin-bottom: 28px !important;
  }

  #contact .form-group input,
  #contact .form-group textarea {
    font-family: "Inter", sans-serif !important;
    font-size: 15px !important;
    font-weight: 400 !important;
  }

  /* -------------------------------------------------------------
     WORK CARDS — absolutely no pinning/overlap on mobile.
     ------------------------------------------------------------- */
  #selected-work,
  #selected-work .work-stage,
  #selected-work .work-card {
    overflow: hidden !important;
  }

  #selected-work .work-card {
    position: relative !important;
    inset: auto !important;
    height: auto !important;
    min-height: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    padding: 52px 0 !important;
  }

  #selected-work .work-content {
    padding: 28px 0 0 !important;
  }

  #selected-work .work-content h2 {
    font-family: "Montserrat", sans-serif !important;
    font-weight: 700 !important;
    font-size: clamp(2rem, 10vw, 3rem) !important;
    line-height: 1 !important;
  }

  /* -------------------------------------------------------------
     FOOTER
     ------------------------------------------------------------- */
  #footer {
    overflow: hidden !important;
    padding: 90px 0 50px !important;
  }

  #footer .footer-title {
    font-family: "Montserrat", sans-serif !important;
    font-weight: 700 !important;
    font-size: clamp(2.3rem, 10vw, 3.6rem) !important;
    line-height: .98 !important;
  }
}

@media (max-width: 575.98px) {
  #header .navbar {
    width: calc(100% - 16px) !important;
    margin-left: 8px !important;
    margin-right: 8px !important;
  }

  #showreel {
    margin-top: 82px !important;
  }

  #hero {
    padding-top: 58px !important;
  }

  #story .story-subtitle,
  #contact p {
    font-size: 15px !important;
  }

  #services .cube-wrapper {
    width: 78vw !important;
    height: 78vw !important;
  }

  #services .cube,
  #services .face {
    width: 58vw !important;
    height: 58vw !important;
  }

  #contact .contact-form {
    padding: 24px 16px !important;
  }
}

