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

   兩個角色：
     a.fx-link     中醫內科學正文裡的方名（連去方劑學真正介紹該方的小節）
     a.fx-anchor   方劑學筆記裡的落點（空元素，零高度，不影響排版）
     tr[id^=fx-]   表格行式落點（該行首格就是方名）

   用方劑學本科代表色「墨藍 #3F5E7A」，與跳去中藥學的朱砂虛線一眼可分。
   落版偏移由 [id^="fx-"] 的 scroll-margin-top 處理 —— 筆記頁的
   .note-topbar 是 position:sticky，冇呢個 margin 就會蓋住目標標題。
   ------------------------------------------------------------------ */

a.fx-link {
  color: inherit;
  text-decoration: none;
  /* 墨藍 2px 虛線：字身保持深色（color: inherit），藍線純做記號，不損可讀性 */
  border-bottom: 2px dotted #3F5E7A;
  padding-bottom: 1px;
}

a.fx-link:hover,
a.fx-link:focus-visible {
  color: #3F5E7A;
  border-bottom-style: solid;
  background: #E8EEF4;
  border-radius: 2px;
}

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

/* 落版偏移：閃開 sticky .note-topbar（桌機約 44px；手機會換行成 2 行） */
[id^="fx-"] {
  scroll-margin-top: 84px;
}

/* 到達落點時的視覺回饋（純 CSS，回到頁面時自動消失） */
a.fx-anchor:target + h3,
a.fx-anchor:target + h4 {
  box-shadow: -14px 0 0 -6px #3F5E7A;
}

tr[id^="fx-"]:target > td {
  background: #E8EEF4;
}

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

/* 列印時還原為純文字，避免虛線影響閱讀 */
@media print {
  a.fx-link {
    color: inherit;
    border-bottom: none;
    background: none;
  }
}
