/* ------------------------------------------------------------------
   儒濟生 · 中醫學習 — 方劑學 → 中醫內科學 反向跨科方名超連結
   build-time 注入（_build/build_fx_links.py 內 reverse 段落），全程零 JavaScript。

   對稱設計：
     a.fn-link     方劑學正文裡的方名（連去中醫內科學真正使用該方的臨床章節）
     a.nf-anchor   中醫內科學筆記裡的落點（空元素，零高度，不影響排版）

   用中醫內科學代表色「青綠 #2E7D5B」——與跳去中藥學的朱砂、跳去方劑學的墨藍
   一眼可分（同一頁方劑學會同時有：紅=去中藥的藥名、綠=去內科的方名）。
   落版偏移由 [id^="nf-"] 的 scroll-margin-top 處理，閃開 sticky .note-topbar。
   ------------------------------------------------------------------ */

a.fn-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 2px dotted #2E7D5B;
  padding-bottom: 1px;
}

a.fn-link:hover,
a.fn-link:focus-visible {
  color: #2E7D5B;
  border-bottom-style: solid;
  background: #E6F2EC;
  border-radius: 2px;
}

/* 落點錨點：空元素，不佔位 */
a.nf-anchor {
  display: inline;
  font-size: 0;
  line-height: 0;
}

[id^="nf-"] {
  scroll-margin-top: 84px;
}

a.nf-anchor:target + h3,
a.nf-anchor:target + h4 {
  box-shadow: -14px 0 0 -6px #2E7D5B;
}

/* 內科筆記正文裡的落點係行內（錨點緊貼 fx-link 之前），到達時高亮該方名 */
a.nf-anchor:target + a.fx-link {
  box-shadow: 0 0 0 2px #2E7D5B;
  border-radius: 2px;
}

@media (max-width: 640px) {
  [id^="nf-"] {
    scroll-margin-top: 104px;
  }
}

@media print {
  a.fn-link {
    color: inherit;
    border-bottom: none;
    background: none;
  }
}
