/* ==========================================================
   Mobile menu (shared by every page)
   - Loaded from header.php; selectors are scoped under #masthead
     so they win over the per-page stylesheets (style-*.css).
   - Panel colour follows the header: dark by default,
     light grey where the mobile header is light (Home, single portfolio).
   ========================================================== */

#masthead {
  --mnav-bg: rgba(0, 0, 0, .94);
  --mnav-border: rgba(251, 155, 0, .25);
  --mnav-shadow: 0 30px 60px rgba(0, 0, 0, .6);
  --mnav-text: rgba(255, 255, 255, .85);
  --mnav-line: rgba(255, 255, 255, .2);
  --mnav-hover: #ffb32d;
}

/* ==========================================================
   Shared mobile safety net (every page)
   ========================================================== */

/* Decorative blobs/orbs must never make the page scroll sideways.
   clip (not hidden) so position: sticky keeps working; iOS ignores
   overflow-x on body alone. */
html,
body {
  overflow-x: clip;
}

/* Anchor links (#services, #video ...) land below the fixed navbar */
section[id],
header[id] {
  scroll-margin-top: 90px;
}

/* Navbar above the floating contact / social bubbles (z-index 999),
   so the open mobile menu is never covered by them. */
#masthead .navbar {
  z-index: 1001;
  top: 0;   /* fallback: some page CSS uses `inset`, which iOS < 14.5 ignores */
  left: 0;
  right: 0;
}

/* Hamburger must always take the tap (some phones missed it):
   own stacking layer above the logo/menu, no native button styling,
   no double-tap-zoom delay, and taps land on the button, not the bars. */
#masthead .menu-toggle {
  position: relative;
  z-index: 3;
  flex-shrink: 0;
  min-width: 46px;
  min-height: 46px;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#masthead .menu-toggle span {
  pointer-events: none;
}

@media (max-width: 900px) {
  #masthead .nav-inner {
    position: static;
  }

  #masthead .menu-toggle {
    display: block;
  }

  #masthead .menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    width: auto;
    max-height: calc(100vh - 80px);
    max-height: calc(100dvh - 80px); /* iOS: 100vh includes the hidden toolbar */
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0;
    padding: 10px 14px 20px;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    border-radius: 0;
    background: var(--mnav-bg);
    border-bottom: 1px solid var(--mnav-border);
    box-shadow: var(--mnav-shadow);
    transition: none;
  }

  #masthead .menu.is-open {
    display: flex;
    padding-top: 10px;
    animation: mnavIn .32s ease both;
  }

  #masthead .menu li {
    width: 100%;
  }

  #masthead .menu a,
  #masthead .menu a.contact-btn,
  #masthead .menu.is-open a,
  #masthead .menu.is-open .contact-btn {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    padding: 16px 20px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    box-shadow: none;
    color: var(--mnav-text) !important;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: .14em;
    text-align: left;
    text-decoration: none;
    transform: none;
    transition: background .22s ease, color .22s ease, padding .22s ease;
    -webkit-tap-highlight-color: transparent;
  }

  /* thin separator between items */
  #masthead .menu li + li a::before {
    content: "";
    display: block;
    position: absolute;
    left: 20px;
    right: 20px;
    top: -1px;
    height: 1px;
    background: var(--mnav-line);
    transition: opacity .22s ease;
  }

  /* dot on the right (shown on the current page) */
  #masthead .menu a::after {
    content: "";
    position: static;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #14161a;
    opacity: 0;
    transform: scale(.4);
    transition: opacity .22s ease, transform .22s ease;
  }

  #masthead .menu a:not(.active):hover {
    background: rgba(251, 155, 0, .1);
    color: var(--mnav-hover) !important;
  }

  /* current page: orange pill.
     The .is-open .contact-btn selectors match the reset rule above, which
     otherwise wins on the Contact page (CONTACT US is .contact-btn.active)
     and leaves dark text on the dark drawer with no pill. */
  #masthead .menu a.active,
  #masthead .menu.is-open a.active,
  #masthead .menu.is-open a.contact-btn.active {
    padding-left: 24px;
    background: #fb9b00;
    color: #14161a !important;
    box-shadow: 0 10px 24px rgba(251, 155, 0, .3);
  }

  #masthead .menu a.active::after {
    opacity: 1;
    transform: none;
    box-shadow: 0 0 0 4px rgba(20, 22, 26, .15);
  }

  #masthead .menu a.active::before,
  #masthead .menu li:has(a.active) + li a::before {
    opacity: 0;
  }

  /* separator under the last item (CONTACT US) */
  #masthead .menu li:last-child {
    position: relative;
  }

  #masthead .menu li:last-child::after {
    content: "";
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: -1px;
    height: 1px;
    background: var(--mnav-line);
    transition: opacity .22s ease;
  }

  #masthead .menu li:last-child:has(a.active)::after {
    opacity: 0;
  }

  /* Hamburger turns into an X while the menu is open */
  #masthead .menu-toggle span {
    transition: transform .25s ease, opacity .2s ease;
    transform-origin: center;
  }

  #masthead .menu-toggle.is-open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  #masthead .menu-toggle.is-open span:nth-child(2) {
    opacity: 0;
  }

  #masthead .menu-toggle.is-open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* Page behind the open menu stays put; floating bubbles step aside */
  body.menu-open {
    overflow: hidden;
  }

  body.menu-open .contact-bubble,
  body.menu-open .social-bubble {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

/* Light grey header on mobile: Home (<=768px) */
@media (max-width: 768px) {
  body.home #masthead {
    --mnav-bg: rgba(244, 246, 248, .96);
    --mnav-border: rgba(20, 22, 26, .06);
    --mnav-shadow: 0 30px 60px rgba(0, 0, 0, .35);
    --mnav-text: #14161a;
    --mnav-line: rgba(20, 22, 26, .08);
    --mnav-hover: #fb9b00;
  }
}

/* Light header on mobile: single portfolio (<=780px) */
@media (max-width: 780px) {
  body.single-portfolio #masthead {
    --mnav-bg: rgba(244, 246, 248, .96);
    --mnav-border: rgba(20, 22, 26, .06);
    --mnav-shadow: 0 30px 60px rgba(0, 0, 0, .35);
    --mnav-text: #14161a;
    --mnav-line: rgba(20, 22, 26, .08);
    --mnav-hover: #fb9b00;
  }
}

@keyframes mnavIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  #masthead .menu.is-open { animation: none; }
}
