/* 
  Navigation Stability Fix
  Ensures the top navigation doesn't flicker or shift when navigating 
  between pages or when login/logout buttons are dynamically updated.
*/

@media (min-width: 861px) {
  .nav {
    display: grid !important;
    /* Fixed 250px side columns ensure the center menu is perfectly balanced and stable */
    grid-template-columns: 250px 1fr 250px !important;
    gap: 12px;
    align-items: center;
    height: 74px;
    width: min(1120px, calc(100% - 40px)) !important;
    margin: 0 auto;
  }

  .brand {
    min-width: 250px;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .nav-menu {
    justify-self: center;
    display: flex !important;
    gap: 4px;
    align-items: center;
    background: rgba(255, 255, 255, 0.52);
    border: 1px solid rgba(196, 230, 213, 0.65);
    border-radius: 999px;
    padding: 5px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    flex-wrap: nowrap;
  }

  .nav-menu a {
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 800;
    white-space: nowrap;
    flex: 0 0 auto;
    transition: background 0.2s;
  }

  .nav-actions {
    justify-self: end;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 6px !important;
    background: rgba(45, 96, 75, 0.8) !important;
    border: 1px solid rgba(45, 96, 75, 0.15) !important;
    border-radius: 999px;
    padding: 3px 6px !important;
    min-width: 0 !important;
    box-shadow: 0 6px 18px rgba(45, 96, 75, 0.08) !important;
  }

  .nav-actions .button,
  .nav-actions button:not(.nav-toggle),
  .nav-actions a {
    position: relative;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 999px !important;
    padding: 5px 10px !important;
    min-height: 0 !important;
    font-size: 11.5px !important;
    font-weight: 800 !important;
    color: white !important;
    display: inline-flex !important;
    align-items: center;
    gap: 4px !important;
    margin: 0 !important;
    transition: background 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Reduce icon size proportionally */
  .nav-actions svg {
    width: 13px !important;
    height: 13px !important;
  }

  .nav-actions .button:hover,
  .nav-actions button:not(.nav-toggle):hover,
  .nav-actions a:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    transform: none !important;
  }

  /* Divider line: pseudo-element on all items except the first visible child */
  .nav-actions > *:not(:first-child):not(.nav-toggle)::before {
    content: "" !important;
    position: absolute !important;
    left: -3px !important;
    top: 25% !important;
    height: 50% !important;
    width: 1px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    pointer-events: none !important;
  }
}

/* Mobile & Tablet - ensure consistent height to prevent layout jump */
@media (max-width: 860px) {
  .nav {
    display: flex !important;
    height: 74px;
    align-items: center;
    justify-content: space-between;
  }
}

/* Prevent nav-actions flickering during initial JS auth check */
.nav-actions {
  opacity: 0;
  transition: opacity 0.12s ease-in-out;
}
.nav-actions.is-loaded {
  opacity: 1 !important;
}

