/* =========================
   D20 Mobile Nav Fix
   ========================= */

body.d20-scroll-lock {
  overflow: hidden !important;
}

@media (max-width: 992px) {
  .d20-shell--header {
    position: relative;
    z-index: 2000;
  }

  .d20-shell--header .d20-navbar,
  .d20-shell--header .d20-navbar .d20-container {
    overflow: visible !important;
  }

  .d20-shell--header .d20-container {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    gap: 10px;
    min-height: 64px;
    height: auto !important;
  }

  .d20-shell--header .d20-brand-logo {
    order: 1;
  }

  .d20-shell--header .d20-mobile-toggle {
    order: 2;
    margin-left: auto;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    z-index: 2003;
  }

  /* Stop Bootstrap/OJS list/link leakage */
  .d20-shell--header .d20-nav-menu,
  .d20-shell--header .d20-nav-menu * {
    box-sizing: border-box;
  }

  .d20-shell--header .d20-nav-menu {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    display: none !important;
    list-style: none;
    margin: 6px 0 0;
    padding: 14px 14px 10px;
    position: static !important;
    float: none !important;
    clear: both;
    background: rgba(20, 12, 24, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
    overflow: visible !important;
    max-height: none !important;
    gap: 10px;
  }

  .d20-shell--header .d20-nav-menu li {
    margin: 0;
    padding: 0;
    float: none !important;
    width: 100%;
    height: auto !important;
    display: block !important;
  }

  .d20-shell--header.is-menu-open .d20-nav-menu {
    display: flex !important;
    flex-direction: column;
  }

  .d20-shell--header .d20-nav-menu > li > a,
  .d20-shell--header .d20-nav-menu a {
    display: block !important;
    width: 100%;
    height: auto !important;
    padding: 12px;
    border-radius: 12px;
    line-height: 1.2;
    text-decoration: none;
    white-space: normal;
    float: none !important;
  }

  .d20-shell--header .d20-dropdown {
    position: static !important;
  }

  .d20-shell--header .d20-dropdown-menu {
    display: none;
    position: static !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    margin-top: 6px;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none !important;
    min-width: 0;
    width: 100%;
  }

  .d20-shell--header .d20-dropdown.is-open > .d20-dropdown-menu,
  .d20-shell--header .d20-dropdown.d20-open > .d20-dropdown-menu {
    display: block;
  }

  .d20-shell--header .d20-user-actions {
    order: 4;
    flex: 0 0 100%;
    width: 100%;
    display: none !important;
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
    margin: 10px 0 0;
    padding: 8px 12px 14px;
    border-radius: 0 0 14px 14px;
    background: rgba(20, 12, 24, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-top: 0;
    overflow: visible !important;
    max-height: none !important;
  }

  .d20-shell--header.is-menu-open .d20-user-actions {
    display: flex !important;
  }

  .d20-shell--header .d20-search-form,
  .d20-shell--header .d20-search-form input {
    width: 100% !important;
  }

  .d20-shell--header .d20-user-nav,
  .d20-shell--header .d20-lang-toggle {
    width: 100%;
  }

  /* Single scroll surface only when viewport is very short */
  .d20-shell--header.is-menu-open .d20-navbar {
    max-height: 100svh;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .d20-shell--header .d20-mobile-toggle:focus-visible,
  .d20-shell--header .d20-nav-menu a:focus-visible,
  .d20-shell--header .d20-dropdown-menu a:focus-visible,
  .d20-shell--header .d20-user-actions a:focus-visible,
  .d20-shell--header .d20-user-actions button:focus-visible,
  .d20-shell--header .d20-user-actions input:focus-visible {
    outline: 2px solid #ffc107;
    outline-offset: 2px;
  }
}
