/* =========================================================================
   Alpha Oak — Mobile experience layer
   Loaded site-wide after main + page styles. Targets phones/tablets only.
   ========================================================================= */

/* ── Tokens (phones) ─────────────────────────────────────────────────────── */
@media (max-width: 1023px) {
  :root {
    --header-h: 72px;
    --ao-mobile-menu-ease: cubic-bezier(0.22, 1, 0.36, 1);
  }

  /* Avoid smooth-scroll flash when tapping links (especially before unload). */
  html {
    scroll-behavior: auto;
  }
}

/* ── Backdrop when nav is open ───────────────────────────────────────────── */
.ao-mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 997;
  background: rgba(10, 10, 10, 0.42);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s var(--ao-mobile-menu-ease, ease),
    visibility 0.32s;
}

body.ao-nav-open .ao-mobile-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ── Mobile drawer: smooth open (no display flip) ────────────────────────── */
@media (max-width: 1023px) {
  .ao-mobile-menu {
    display: flex;
    flex-direction: column;
    visibility: hidden;
    opacity: 0;
    transform: translate3d(0, -12px, 0);
    pointer-events: none;
    transition:
      opacity 0.34s var(--ao-mobile-menu-ease, ease),
      transform 0.38s var(--ao-mobile-menu-ease, ease),
      visibility 0.34s;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    box-shadow: 0 -8px 40px -12px rgba(0, 0, 0, 0.12);
  }

  .ao-mobile-menu--open {
    visibility: visible;
    opacity: 1;
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
  }

  .ao-mobile-menu__link,
  .ao-mobile-menu__flyout-toggle {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--c-ink);
    -webkit-tap-highlight-color: transparent;
  }

  .ao-mobile-menu__link:active,
  .ao-mobile-menu__flyout-toggle:active,
  .ao-mobile-menu__sub-link:active {
    background: rgba(0, 0, 0, 0.04);
  }

  .ao-mobile-menu__cta {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    padding-top: var(--sp-6);
    padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom, 0px));
    background: linear-gradient(
      to top,
      var(--c-bg) 72%,
      rgba(255, 255, 255, 0.94) 88%,
      transparent
    );
    z-index: 1;
  }

  .ao-mobile-menu__cta .ao-btn {
    min-height: 52px;
    font-size: 1rem;
    border-radius: var(--r-md);
    box-shadow: 0 8px 24px -8px rgba(235, 0, 27, 0.45);
  }

  .ao-hamburger {
    width: 44px;
    height: 44px;
    padding: 10px;
    margin-right: -6px;
    justify-content: center;
    gap: 5px;
    border-radius: var(--r-full);
    transition: background var(--t-fast);
  }

  .ao-hamburger:active {
    background: rgba(0, 0, 0, 0.06);
  }

  .ao-hamburger__line {
    width: 20px;
    height: 2px;
    margin-inline: auto;
  }

  .ao-hamburger[aria-expanded="true"] .ao-hamburger__line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .ao-hamburger[aria-expanded="true"] .ao-hamburger__line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  body.ao-header-canvas .ao-header__inner {
    padding-inline: var(--sp-4);
  }

  body.ao-header-canvas .ao-header .ao-logo__img,
  body.ao-header-canvas .ao-header .ao-logo__img--raster {
    height: 34px;
    max-height: 34px;
  }
}

@media (min-width: 1024px) {
  .ao-mobile-backdrop {
    display: none !important;
  }
}

/* Lock page scroll when menu open (paired with JS position:fixed on body) */
body.ao-nav-open {
  overflow: hidden;
  touch-action: none;
}

/* ── Sticky mobile consultation bar ──────────────────────────────────────── */
.ao-mobile-sticky-cta {
  display: none;
}

@media (max-width: 1023px) {
  .ao-mobile-sticky-cta {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 996;
    padding: var(--sp-3) var(--container-px);
    padding-bottom: max(var(--sp-3), env(safe-area-inset-bottom, 0px));
    background: linear-gradient(
      to top,
      rgba(255, 255, 255, 0.98) 55%,
      rgba(255, 255, 255, 0.88) 80%,
      transparent
    );
    pointer-events: none;
    opacity: 0;
    transform: translateY(100%);
    transition:
      opacity 0.35s var(--ao-mobile-menu-ease, ease),
      transform 0.4s var(--ao-mobile-menu-ease, ease);
  }

  .ao-mobile-sticky-cta--visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  body.ao-nav-open .ao-mobile-sticky-cta {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
  }

  .ao-mobile-sticky-cta__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 50px;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fff;
    background: var(--c-brand-red);
    border-radius: var(--r-md);
    text-align: center;
    box-shadow: 0 10px 28px -10px rgba(235, 0, 27, 0.55);
    transition: background var(--t-fast), transform var(--t-fast);
    -webkit-tap-highlight-color: transparent;
  }

  .ao-mobile-sticky-cta__btn:active {
    background: var(--c-brand-red-hover);
    transform: scale(0.98);
  }

  /* Reserve space for the fixed sticky bar — constant padding avoids scroll jumps
     when the bar appears (toggling padding used to trigger scroll anchoring). */
  .ao-footer {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  }
}

/* ── Page heroes & inner layouts ─────────────────────────────────────────── */
@media (max-width: 767px) {
  .ao-page-hero {
    padding-top: calc(var(--ao-header-stack-below, var(--header-h)) + var(--sp-8));
    padding-bottom: var(--sp-10);
  }

  .ao-page-hero--has-image {
    min-height: 260px;
  }

  .ao-page-hero__title {
    font-size: clamp(1.65rem, 7.2vw, 2.35rem);
    line-height: 1.12;
    text-wrap: balance;
  }

  .ao-page-hero__sub {
    font-size: var(--text-base);
    line-height: 1.55;
    margin-top: var(--sp-3);
  }

  .ao-page-hero .ao-hero-btns {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-3);
    margin-top: var(--sp-5);
  }

  .ao-page-hero .ao-hero-btns .ao-btn {
    width: 100%;
    justify-content: center;
  }

  .ao-page-hero__scroll-cue {
    display: none;
  }

  .ao-breadcrumb {
    font-size: var(--text-xs);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .ao-breadcrumb::-webkit-scrollbar {
    display: none;
  }

  .ao-breadcrumb__inner {
    white-space: nowrap;
    padding-bottom: 2px;
  }

  .ao-h2 {
    font-size: clamp(1.45rem, 5.5vw, 1.85rem);
    line-height: 1.15;
    text-wrap: balance;
  }

  .ao-h3 {
    font-size: clamp(1.2rem, 4.5vw, 1.45rem);
    text-wrap: balance;
  }

  .ao-section-intro,
  .ao-lead {
    font-size: var(--text-base);
    line-height: 1.6;
    max-width: none;
  }

  .ao-prose {
    font-size: var(--text-base);
    line-height: 1.65;
  }

  .ao-prose h2,
  .ao-prose h3 {
    margin-top: var(--sp-8);
  }

  .ao-cards {
    gap: var(--sp-5);
  }

  .ao-card__body {
    padding: var(--sp-5);
  }

  .ao-sectors-row {
    gap: var(--sp-6);
  }

  .ao-sectors-row__media {
    border-radius: var(--r-lg);
  }

  .ao-contact-grid {
    gap: var(--sp-8);
  }

  .ao-form input,
  .ao-form select,
  .ao-form textarea {
    font-size: 16px;
    min-height: 48px;
  }

  .ao-accordion__trigger {
    padding: var(--sp-5) var(--sp-4);
    min-height: 52px;
    font-size: var(--text-base);
  }

  .ao-faq-tab {
    min-height: 44px;
    padding: var(--sp-3) var(--sp-4);
  }
}

/* Home: proportionate hero on phones */
@media (max-width: 767px) {
  body.home .ao-home-hero {
    padding-inline: var(--container-px);
    padding-bottom: var(--sp-4);
  }

  body.home .ao-home-hero__stage {
    height: min(56vh, 440px);
    min-height: 240px;
    max-height: min(64vh, 500px);
    border-radius: clamp(16px, 4vw, 24px);
  }

  body.home .ao-home-hero__headline {
    font-size: clamp(1.65rem, 7vw, 2.5rem);
  }

  body.home .ao-home-statement__headline {
    font-size: clamp(1.75rem, 6.5vw, 2.35rem);
  }
}

/* MC / country pages: readable type + spacing */
@media (max-width: 767px) {
  body.ao-mc-page .ao-mc-opp-hero__title,
  body.ao-mc-page .ao-country-hub__hero-title {
    font-size: clamp(1.6rem, 6.8vw, 2.25rem);
    text-wrap: balance;
  }

  body.ao-mc-page .ao-country-subpage__poster-headline,
  body.ao-mc-page .ao-country-subpage__imgfeat-headline {
    font-size: clamp(1.5rem, 6vw, 2rem);
    max-width: none;
  }

  body.ao-mc-page .ao-country-subpage__ekgp-surface {
    padding: var(--sp-8) var(--sp-5);
    border-radius: clamp(16px, 4vw, 22px);
  }
}

/* ── Touch devices: disable desktop hover lifts (prevents sticky/janky taps) ─ */
@media (hover: none), (pointer: coarse) {
  .ao-section-header:hover,
  .ao-section > .ao-container:hover,
  .ao-h2:hover,
  .ao-h3:hover,
  .ao-prose p:hover,
  .ao-prose h2:hover,
  .ao-prose h3:hover,
  .ao-prose h4:hover,
  .ao-lead:hover,
  .ao-section-intro:hover,
  .ao-card:hover,
  .ao-team-card:hover,
  .ao-testimonial:hover,
  .ao-step:hover,
  .ao-page-hero__title:hover,
  .ao-page-hero__sub:hover,
  .ao-cta-section .ao-h2:hover,
  .ao-sectors-row__content:hover,
  .ao-contact-grid > div:hover,
  .ao-highlight-list li:hover {
    transform: none !important;
  }

  .ao-btn:hover {
    transform: none;
  }

  .ao-btn:active {
    transform: scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ao-mobile-menu,
  .ao-mobile-backdrop,
  .ao-mobile-sticky-cta {
    transition-duration: 0.01ms !important;
  }

  .ao-mobile-menu--open {
    transform: none;
  }
}
