/* Desktop navigation spans the reading column; mobile keeps its bottom bar. */
.desktop-nav-anchor { display: contents; }
.navbar-tools { display: none; }

.navbar .navbar-link { font-weight: 600; }

/* Keep one row with equal space between the destination labels. */
@media (max-width: 1023px) {
  .navbar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .navbar .navbar-list {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: clamp(4px, 1vw, 10px);
    padding: 0 clamp(8px, 2vw, 16px);
  }

  .navbar-list > .navbar-item { flex: 0 0 auto; }

  .navbar .navbar-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 48px;
    padding: 12px 2px;
    font-size: clamp(8.5px, 3.2vw, 14px);
    line-height: 1.35;
    letter-spacing: -.2px;
    white-space: nowrap;
  }
}

@media (min-width: 1024px) {
  .desktop-nav-anchor {
    display: block;
    position: sticky;
    top: 0;
    height: 64px;
    z-index: 5;
  }

  .desktop-nav-anchor .navbar {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr) 104px;
    align-items: center;
    left: 0;
    right: 0;
    width: 100%;
    height: 64px;
    padding: 0 20px;
    background: var(--theme-surface);
    backdrop-filter: none;
    border-radius: 20px 20px 0 0;
    border-bottom: 1px solid var(--jet);
    box-shadow: none;
  }

  .desktop-nav-anchor .navbar-list {
    grid-column: 2;
    flex-wrap: nowrap;
    gap: 22px;
    padding: 0;
  }

  /* Override the legacy translucent navbar in both themes. */
  :root .desktop-nav-anchor .navbar { background: var(--theme-surface); }

  .desktop-nav-anchor .navbar-tools {
    grid-column: 3;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  /* This empty, non-interactive slot is for the future Chinese/English switch. */
  .navbar-language-slot {
    flex: 0 0 52px;
    height: 40px;
  }

  .navbar-tools .theme-toggle-btn {
    position: relative;
    inset: auto;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 10px;
    box-shadow: none;
    color: var(--theme-body);
    cursor: pointer;
  }

  .navbar-tools .theme-toggle-btn::before { display: none; }

  .navbar-tools .theme-toggle-btn:hover {
    background: rgba(var(--theme-accent-rgb), 0.1);
    transform: none;
  }

  .navbar-tools .theme-toggle-btn:focus-visible {
    outline: 2px solid var(--theme-accent);
    outline-offset: 2px;
  }

  .navbar-tools .theme-toggle-btn .icon {
    font-size: 21px;
    line-height: 1;
    color: var(--theme-accent);
  }

  .navbar-tools .icon-moon { display: none; }
  .navbar-tools .icon-sun { display: block; }
  [data-theme="light"] .navbar-tools .icon-moon { display: block; }
  [data-theme="light"] .navbar-tools .icon-sun { display: none; }

  .desktop-nav-anchor.is-stuck .navbar {
    border-radius: 0;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  }

  .main-content > article {
    border-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }

  /* The separate navbar already supplies the space above the homepage video. */
  .main-content > article.about { padding-top: 8px; }
  .main-content > article.about > .videobox:first-child { margin-top: 0; }

  .main-content [id] { scroll-margin-top: 80px; }
}
