/* Single navigation implementation - v49 */
.profile-menu {
  position: relative;
}

/* v50 unified brand asset */
.app-brand{display:flex;align-items:center;height:100%;margin:0!important;flex-shrink:0}
.app-brand img{display:block;width:132px;height:auto;max-height:72px;object-fit:contain;object-position:left center}
@media(max-width:760px){.app-brand img{width:102px;max-height:54px}}

/* Mobile-only Messages/Notifications cluster in the top bar (v77);
   hidden on desktop, where they stay in the existing top-right nav. */
.header-icons{display:none}

.profile-menu-trigger {
  appearance: none;
  cursor: pointer;
}

.profile-menu-panel {
  display: none;
}

.profile-menu.is-open > .profile-menu-panel {
  display: grid;
}

body > .app-nav {
  position: fixed;
  inset: 0 max(24px, calc((100% - 1240px) / 2)) auto auto;
  z-index: 100;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
  height: 84px;
  background: rgba(6, 7, 10, .82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom-left-radius: 12px;
}

body > .app-nav > a,
body > .app-nav > .profile-menu > .profile-menu-trigger {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 92px;
  height: 100%;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: #b8bdc7;
  font: 900 11px/1 Arial, sans-serif;
  letter-spacing: .12em;
  text-decoration: none;
  text-transform: uppercase;
}

body > .app-nav svg {
  display: block;
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

/* Logged-out language toggle (see language_toggle_badge_html() in bootstrap.php) - a pill instead
   of a plain nav link so it reads as its own control next to Sign In, not another nav item. */
body > .app-nav > a.lang-toggle-badge {
  min-width: 0;
  margin: auto 0;
  height: auto;
  padding: 9px 14px;
  border: 1px solid #3a4668;
  border-radius: 20px;
  background: #161d33;
  color: #a9bcff;
}

body > .app-nav > a.lang-toggle-badge:hover {
  background: #1f2a4a;
  border-color: #5278ff;
  color: #fff;
}

body > .app-nav > a.lang-toggle-badge svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

body > .app-nav .profile-menu {
  height: 100%;
}

body > .app-nav .profile-menu-panel {
  position: absolute;
  top: calc(100% + 1px);
  right: 0;
  z-index: 1000;
  width: 230px;
  padding: 8px;
  border: 1px solid #30343d;
  background: #0a0a0a;
  box-shadow: 0 18px 50px #000;
}

@media (max-width: 900px) {
  :root {
    --mobile-nav-height: 68px;
  }

  html {
    overflow-x: clip;
    scroll-padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
  }

  body:not(.landing-body) {
    overflow-x: clip;
    padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)) !important;
  }

  /* Messages and Notifications move up into the top bar on mobile so
     the bottom bar keeps room for five icons instead of seven. */
  body:not(.landing-body) > .app-nav > a.mobile-header-icon {
    display: none !important;
  }

  .header-icons {
    display: flex !important;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .header-icon-link {
    position: relative;
    display: flex;
    flex-shrink: 0;
    color: #d7dae3;
    text-decoration: none;
  }

  .header-icon-link svg {
    display: block;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
  }

  .header-icon-link .notification-badge {
    top: -7px;
    right: -2px;
  }

  body:not(.landing-body) > .app-nav {
    position: fixed !important;
    inset: auto 0 0 !important;
    z-index: 10000 !important;
    isolation: isolate;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    align-items: stretch !important;
    width: auto !important;
    max-width: none !important;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left) !important;
    gap: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    border-top: 1px solid #30343d !important;
    border-radius: 0 !important;
    background: rgba(7, 8, 11, .98) !important;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .72) !important;
    transform: none !important;
    pointer-events: auto !important;
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }

  body:not(.landing-body) > .app-nav > a,
  body:not(.landing-body) > .app-nav > .profile-menu,
  body:not(.landing-body) > .app-nav > .profile-menu > .profile-menu-trigger {
    width: 100% !important;
    min-width: 0 !important;
    height: var(--mobile-nav-height) !important;
    margin: 0 !important;
  }

  body:not(.landing-body) > .app-nav > a,
  body:not(.landing-body) > .app-nav > .profile-menu > .profile-menu-trigger {
    position: relative !important;
    z-index: 1;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    padding: 6px 2px !important;
    border: 0 !important;
    background: transparent !important;
    color: #b8bdc7 !important;
    font: 900 8px/1 Arial, sans-serif !important;
    letter-spacing: .02em !important;
    text-align: center !important;
    text-decoration: none !important;
    text-transform: uppercase !important;
    pointer-events: auto !important;
    touch-action: manipulation;
  }

  body:not(.landing-body) > .app-nav svg {
    display: block !important;
    flex: 0 0 23px !important;
    width: 23px !important;
    height: 23px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.9 !important;
  }

  body:not(.landing-body) > .app-nav span {
    display: block !important;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body:not(.landing-body) > .app-nav > .profile-menu {
    position: static !important;
    display: block !important;
    pointer-events: auto !important;
  }

  body:not(.landing-body) > .app-nav > .profile-menu > .profile-menu-trigger > i {
    display: none !important;
  }

  body:not(.landing-body) > .app-nav > .profile-menu > .profile-menu-panel {
    position: fixed !important;
    inset: auto 10px calc(var(--mobile-nav-height) + 8px + env(safe-area-inset-bottom)) !important;
    z-index: 10001 !important;
    width: auto !important;
    max-height: calc(100dvh - 100px) !important;
    padding: 8px !important;
    overflow-y: auto !important;
    border: 1px solid #383e49 !important;
    background: #0d0f14 !important;
    box-shadow: 0 22px 65px #000 !important;
    pointer-events: auto !important;
  }

  body:not(.landing-body) > .app-nav > .profile-menu > .profile-menu-panel a,
  body:not(.landing-body) > .app-nav > .profile-menu > .profile-menu-panel button {
    min-height: 52px !important;
    pointer-events: auto !important;
  }
}

/* Narrow phones (iPhone SE and similar, <=400px wide): the header row of
   logo + streak/points pill + 4 icons is tight enough that a couple of
   unread badges can crowd right off the edge unless the logo and pill
   shrink a bit further than the general <=760px mobile treatment. */
@media (max-width: 400px) {
  .app-brand img {
    width: 84px;
  }
  .gamification-badge {
    padding: 4px 7px !important;
    font-size: 10px !important;
    gap: 4px !important;
  }
}
