/* 4.17: authenticated mobile navigation. Entry dialogs keep their full viewport. */
#mobile-navigation {
  display: none;
}

#mobile-navigation[hidden], #mobile-navigation [hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  body.mobile-nav-ready > main {
    padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }

  body.mobile-nav-ready .heading-actions .scorecards-button,
  body.mobile-nav-ready #play-round,
  body.mobile-nav-ready #friends-button {
    display: none;
  }

  body.mobile-nav-ready #mobile-navigation:not([hidden]) {
    position: fixed;
    inset: auto 0 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 6px max(8px, env(safe-area-inset-right, 0px))
      max(6px, env(safe-area-inset-bottom, 0px))
      max(8px, env(safe-area-inset-left, 0px));
    background: var(--surface-dialog);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 24px #00000040;
  }

  #mobile-navigation[data-friends='false'] {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  #mobile-navigation .mobile-nav-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    min-width: 0;
    min-height: 56px;
    margin: 0;
    padding: 4px 2px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0;
    text-align: center;
    box-shadow: none;
  }

  #mobile-navigation .mobile-nav-item:hover {
    background: var(--surface2);
    color: var(--text);
  }

  #mobile-navigation .mobile-nav-item[aria-current] {
    background: #c5ef6b12;
    color: var(--green);
  }

  #mobile-navigation .mobile-nav-item:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: -2px;
  }

  .mobile-nav-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 32px;
    height: 28px;
    flex: none;
  }

  .mobile-nav-icon svg {
    display: block;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  #mobile-friends-badge {
    position: absolute;
    top: -3px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 2px 4px;
    border: 2px solid var(--surface-dialog);
    border-radius: 10px;
    background: var(--red);
    color: var(--bg);
    font-size: 10px;
    font-weight: 800;
    line-height: 10px;
  }

  /* Also hide synchronously before the dialog observer runs. */
  body.import-open #mobile-navigation,
  body:has(dialog[open]) #mobile-navigation {
    display: none !important;
  }
}
