/* MAYA9 mobile navigation — right-side, icon-only, collapsible rail (owner directive 2026-10-26).
   Replaces the former bottom tab bar at <=820px. Loaded last so it owns every
   geometric rule for .mobile-nav; desktop (>=821px) keeps .mobile-nav hidden by
   styles.css and the desktop header nav is untouched. tokens.css variables only. */
:root {
  --phone-rail: 56px;
}

body.is-nav-rail-collapsed {
  --phone-rail: 44px;
}

@media (max-width: 820px) {
  .mobile-nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    z-index: 120;
    width: calc(var(--phone-rail) + env(safe-area-inset-right, 0px));
    height: auto;
    min-height: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: var(--m9-space-1);
    grid-template-columns: none;
    padding: max(var(--m9-space-2), env(safe-area-inset-top, 0px)) env(safe-area-inset-right, 0px) max(var(--m9-space-2), env(safe-area-inset-bottom, 0px)) 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    background: var(--m9-surface);
    border: 0;
    border-left: var(--m9-border-default);
    border-radius: 0;
    box-shadow: var(--m9-shadow-surface);
    backdrop-filter: none;
    scrollbar-width: none;
  }

  .mobile-nav::-webkit-scrollbar {
    display: none;
  }

  body .mobile-nav button {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0;
    width: 100%;
    min-width: 44px !important;
    height: 48px;
    min-height: 44px !important;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: var(--m9-text-muted);
    background: transparent;
    font-size: 0;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
  }

  .mobile-nav button:hover,
  .mobile-nav button:focus-visible {
    color: var(--m9-primary);
  }

  .mobile-nav button:focus-visible {
    outline: var(--m9-focus-width) solid var(--m9-focus-color);
    outline-offset: calc(var(--m9-focus-offset) * -1);
  }

  .mobile-nav button.is-active {
    color: var(--m9-primary);
    background: var(--m9-gradient-selected);
  }

  /* Active marker moves from the old top edge to the rail's outer edge. */
  .mobile-nav button.is-active::before {
    content: "";
    position: absolute;
    top: 50%;
    right: 0;
    bottom: auto;
    left: auto;
    width: 3px;
    height: 28px;
    transform: translateY(-50%);
    background: var(--m9-gradient-brand);
    border-radius: var(--m9-radius-pill) 0 0 var(--m9-radius-pill);
  }

  .m9-rail-toggle {
    color: var(--m9-primary);
    border-bottom: var(--m9-border-default) !important;
    border-radius: 0 !important;
  }

  .m9-rail-toggle .m9-rail-chevron {
    width: 22px;
    height: 22px;
    transform: rotate(0deg);
  }

  body.is-nav-rail-collapsed .m9-rail-toggle .m9-rail-chevron {
    transform: rotate(180deg);
  }

  body.is-nav-rail-collapsed .mobile-nav button[data-view] {
    display: none;
  }
}
