/* Mobile-only fix: prevent large blank gaps caused by `content-visibility` placeholders.
   On some mobile browsers the deferred rendering can leave a big empty area between sections. */
@media (max-width: 768px) {
  /* Prevent horizontal scroll / white space on right side */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  /* `contain-intrinsic-size: auto;` is invalid CSS (it needs a length).
     Use a valid value so the override actually applies on strict parsers. */
  .content-lazy,
  .cv-auto,
  section:not(.hero):not(.hero-section):not([class*="hero"]) {
    content-visibility: visible;
    contain-intrinsic-size: 0px 0px;
  }

  /* Prevent scroll anchoring jitter while accordions animate open/closed. */
  .faq,
  .faq-section,
  .faq-content,
  .faq-list,
  .faq-container {
    overflow-anchor: none;
  }

  /* Mobile nav menu: avoid "pushed to top" + allow scrolling when content is tall. */
  .nav-mobile-menu {
    justify-content: flex-start;
    align-items: stretch;
    gap: 14px;
    padding: calc(env(safe-area-inset-top, 0px) + 96px) 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .nav-mobile-menu > a {
    text-align: left;
  }

  .nav-mobile-menu a {
    font-size: 22px;
    padding: 10px 0;
  }

  /* Accordion-style submenus inside the mobile nav. */
  .nav-mobile-menu .mobile-accordion {
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.02);
    overflow: hidden;
  }

  .nav-mobile-menu .mobile-accordion-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 12px;
    font-size: 22px;
    font-weight: 300;
    color: var(--black);
    text-align: left;
  }

  .nav-mobile-menu .mobile-accordion-summary::-webkit-details-marker {
    display: none;
  }

  .nav-mobile-menu .mobile-accordion-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    transition: transform 200ms ease;
    opacity: 0.8;
  }

  .nav-mobile-menu .mobile-accordion[open] .mobile-accordion-icon {
    transform: rotate(180deg);
  }

  .nav-mobile-menu .mobile-accordion-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 12px 12px;
  }

  .nav-mobile-menu .mobile-accordion-panel a {
    font-size: 15px;
    font-weight: 400;
    color: var(--gray-700, #525252);
    padding: 10px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
  }

  .nav-mobile-menu .mobile-accordion-panel a:hover {
    opacity: 1;
    color: var(--black);
    background: rgba(0, 0, 0, 0.04);
  }

  .nav-mobile-menu .mobile-accordion-panel a.mobile-accordion-toplink {
    font-weight: 500;
    color: var(--black);
  }
}

/* The dropdown uses staggered reveal styles that set `opacity: 0` on each link.
   If the animation doesn't run (common on some browsers), the dropdown looks blank.
   Force dropdown links to remain visible; the panel itself still controls visibility. */
.nav-dropdown a {
  opacity: 1 !important;
}

/* On touch devices, also disable the reveal animation to avoid flicker/jank. */
@media (hover: none) and (pointer: coarse) {
  .nav-dropdown a {
    transform: none;
    animation: none;
  }

  /* The custom cursor is for mouse devices; on touch it can cause odd repaint/jank. */
  .cursor-dot,
  .cursor-ring {
    display: none !important;
  }
}

/* Nav compatibility layer:
   Some pages still toggle `.active` / `.is-active` on the menu itself, while the shared CSS expects `.is-open`.
   Map those legacy classes to the same visible state so mobile nav works consistently. */
.nav-mobile-menu.active,
.nav-mobile-menu.is-active,
.nav-mobile-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Hamburger to X animation for both .active and .is-active classes */
.nav-mobile-toggle.active span:nth-child(1),
.nav-mobile-toggle.is-active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-mobile-toggle.active span:nth-child(2),
.nav-mobile-toggle.is-active span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.nav-mobile-toggle.active span:nth-child(3),
.nav-mobile-toggle.is-active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

