/* ========================================================================== 
   SteeringCraft v341 — Site Architecture Navigation
   Scope: Header navigation hierarchy + mobile submenu only.
   Does not alter BMW landing page content, section UI, homepage cards, or page layouts.
   ========================================================================== */

/* Desktop: turn the existing Custom Steering Wheels item into a compact submenu. */
@media (min-width: 961px) {
  .primary-nav .sc-nav-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
  }

  .primary-nav .sc-nav-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #8a8580;
    font: inherit;
    font-size: 15px;
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
    cursor: pointer;
    transition: color 160ms ease;
  }

  .primary-nav .sc-nav-dropdown-toggle:hover,
  .primary-nav .sc-nav-dropdown-toggle:focus-visible,
  .primary-nav .sc-nav-dropdown:hover .sc-nav-dropdown-toggle,
  .primary-nav .sc-nav-dropdown:focus-within .sc-nav-dropdown-toggle {
    color: #101112;
  }

  .primary-nav .sc-nav-dropdown-toggle:focus-visible {
    outline: 2px solid rgba(9, 88, 232, 0.28);
    outline-offset: 5px;
    border-radius: 3px;
  }

  .sc-nav-dropdown-chevron {
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 160ms ease;
  }

  .sc-nav-dropdown:hover .sc-nav-dropdown-chevron,
  .sc-nav-dropdown:focus-within .sc-nav-dropdown-chevron {
    transform: translateY(2px) rotate(225deg);
  }

  .primary-nav .sc-nav-dropdown-panel {
    position: absolute;
    top: calc(100% + 14px);
    left: 50%;
    z-index: 10040;
    display: grid;
    width: 268px;
    max-width: min(268px, calc(100vw - 32px));
    padding: 8px;
    border: 1px solid rgba(17, 24, 39, 0.09);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.985);
    box-shadow: 0 18px 42px rgba(17, 24, 39, 0.13);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, -6px);
    transition: opacity 150ms ease, transform 150ms ease, visibility 150ms ease;
  }

  .primary-nav .sc-nav-dropdown:hover .sc-nav-dropdown-panel,
  .primary-nav .sc-nav-dropdown:focus-within .sc-nav-dropdown-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
  }

  .primary-nav .sc-nav-dropdown-panel a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #202327;
    font-size: 14px;
    font-weight: 720;
    line-height: 1.35;
    white-space: normal;
  }

  .primary-nav .sc-nav-dropdown-panel a::after {
    content: "→";
    flex: 0 0 auto;
    margin-left: 12px;
    color: #8a8580;
    font-size: 14px;
  }

  .primary-nav .sc-nav-dropdown-panel a:hover,
  .primary-nav .sc-nav-dropdown-panel a:focus-visible {
    background: #f6f4ef;
    color: #101112;
    outline: none;
  }

}

/* Mobile: nested accordion inside the existing mobile menu panel. */
@media (max-width: 768px) {
  .sc-mobile-menu-panel {
    max-height: calc(100dvh - 82px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .sc-mobile-nav-group {
    display: grid;
    width: 100%;
    min-width: 0;
    border-bottom: 1px solid rgba(17, 24, 39, 0.07);
  }

  .sc-mobile-submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 0 12px;
    border: 0;
    background: transparent;
    color: #101112;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    font-weight: 850;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
  }

  .sc-mobile-submenu-toggle span:first-child {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .sc-mobile-submenu-chevron {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin-right: 3px;
    border-right: 1.5px solid #8a8580;
    border-bottom: 1.5px solid #8a8580;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 160ms ease;
  }

  .sc-mobile-submenu-toggle[aria-expanded="true"] .sc-mobile-submenu-chevron {
    transform: translateY(2px) rotate(225deg);
  }

  .sc-mobile-submenu {
    display: none;
    width: 100%;
    min-width: 0;
    padding: 4px 8px 10px;
    background: #f7f5f0;
    border-radius: 10px;
  }

  .sc-mobile-nav-group.is-open .sc-mobile-submenu {
    display: grid;
  }

  /* Override legacy mobile-menu anchor rules without affecting other menu items. */
  .sc-mobile-menu-panel .sc-mobile-submenu a {
    min-height: 40px !important;
    padding: 8px 10px 8px 14px !important;
    border-bottom: 0 !important;
    border-radius: 8px;
    color: #34383d !important;
    font-size: 14px !important;
    font-weight: 720 !important;
    line-height: 1.35 !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  .sc-mobile-menu-panel .sc-mobile-submenu a::after {
    content: "→" !important;
    flex: 0 0 auto;
    margin-left: 12px;
    color: #8a8580 !important;
    font-size: 14px;
  }

  .sc-mobile-menu-panel .sc-mobile-submenu a:hover,
  .sc-mobile-menu-panel .sc-mobile-submenu a:focus-visible {
    background: rgba(255, 255, 255, 0.82);
    color: #101112 !important;
  }
}

/* Tablet / legacy-header fallback: preserve the site's existing horizontal-scroll behavior.
   The real nested dropdown is used on desktop and in the independent mobile header. */
@media (min-width: 769px) and (max-width: 960px) {
  .primary-nav .sc-nav-dropdown {
    display: contents;
  }

  .primary-nav .sc-nav-dropdown-toggle {
    display: none;
  }

  .primary-nav .sc-nav-dropdown-panel {
    position: static;
    display: flex;
    gap: clamp(18px, 2.2vw, 28px);
    min-width: max-content;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .primary-nav .sc-nav-dropdown-panel a {
    white-space: nowrap;
  }
}

/* Legacy site-header fallback below 769px when the independent mobile header is not active. */
@media (max-width: 768px) {
  .primary-nav .sc-nav-dropdown {
    display: contents;
  }

  .primary-nav .sc-nav-dropdown-toggle {
    display: none;
  }

  .primary-nav .sc-nav-dropdown-panel {
    display: flex;
    gap: 18px;
    min-width: max-content;
  }
}
