/* ══════════════════════════════════════════════════════════════
   DearLep — 樣式

   材質是玻璃，底是白紙。

   玻璃本身沒有顏色，它只折射底下的光。所以底層鋪了一層極淡的粉彩暈染
   (.luminance)—— 淡到單看幾乎是白的，但玻璃層壓上去之後會透出一點
   顏色的呼吸，不至於變成一片死白。

   材質三要素：
     1. backdrop-filter 的模糊 + 飽和度提升 —— 折射
     2. 頂緣的高光內陰影 —— 玻璃邊緣受光
     3. 極細的暗色描邊 + 遠距柔和陰影 —— 厚度與懸浮

   但玻璃只用在「大區塊」上。籌碼、標籤、輸入框一律不做成一片片的小玻璃，
   否則整頁都是浮動的框，反而看不出層級。沒有圓角 —— 是玻璃板，不是藥丸。

   只有亮色一種樣貌：標本影像的顏色判讀需要一致的白底。
   ══════════════════════════════════════════════════════════════ */

:root {
  --paper:      #ffffff;
  --wash:       #f7f8fa;   /* 極淡，只用於表格 hover 與去背圖襯底 */

  /* 底層暈染：白底上刷三團粉彩，淡到幾乎看不見，只為了讓玻璃有東西可折射 */
  --glow-rose:  rgba(246, 208, 222, .17);
  --glow-sky:   rgba(198, 220, 243, .18);
  --glow-mint:  rgba(206, 232, 220, .15);

  /* 玻璃 */
  --glass:      rgba(255, 255, 255, .58);
  --glass-hi:   rgba(255, 255, 255, .80);
  --glass-lo:   rgba(255, 255, 255, .40);
  --specular:   rgba(255, 255, 255, .95);
  --hairline:   rgba(22, 32, 52, .07);
  --shade:      rgba(28, 40, 66, .09);
  --shade-2:    rgba(28, 40, 66, .05);
  --blur:       24px;

  --ink:        #16181d;
  --ink-2:      #454b57;
  --ink-3:      #6e7683;
  --ink-4:      #9aa1ad;

  --rule:       #e5e7eb;   /* 細線 */
  --rule-2:     #cdd2d9;   /* 需要更明確的分界時 */

  /* 強調色：標本針的黃銅。用得極省，幾乎只出現在 kicker 與連結。 */
  --accent:     #8a6534;

  /* 語意色與強調色分離 */
  --ok:         #2f6b4f;
  --warn:       #8a6a1f;
  --thin:       #9a5340;   /* 資料稀疏 */

  /* 地圖：陸塊是安靜的底，採集點才是內容 */
  --map-land:   #f2f4f7;
  --map-coast:  #b9c0ca;
  --map-site:   #4a6f96;
  --map-halo:   rgba(74, 111, 150, .45);

  --sans:  "Noto Sans TC", "PingFang TC", "Noto Sans CJK TC", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --serif: "Songti TC", "Noto Serif CJK TC", "Source Han Serif TC", "Iowan Old Style", Georgia, serif;
  --mono:  "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;

  --pad: 20px;
}

/* 這份設計只有一種樣貌。不跟隨系統深色模式 —— 標本影像的判讀
   需要一致的白底，換成深色會改變使用者對顏色的感知。 */
:root { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* 最小字級 1.1rem —— 標本影像旁的說明文字常常是判讀的依據，
   縮到 11px 那種「後設資料尺寸」等於預設沒人要看。 */
:root { --fs-min: 1.1rem; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  position: relative;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.2rem;
  line-height: 1.7;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

/* ── 底層暈染 ─────────────────────────────────────────────
   固定不捲動，玻璃在其上移動時折射會跟著變化。
   顏色壓得極淡 —— 目的是「不死白」,不是「有顏色」。        */
.luminance {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: var(--paper);
}
.orb { position: absolute; border-radius: 50%; filter: blur(150px); }
.orb-a { width: 52vw; height: 52vw; left: -12vw; top: -16vw;    background: var(--glow-rose); }
.orb-b { width: 44vw; height: 44vw; right: -10vw; top: 18vh;    background: var(--glow-sky); }
.orb-c { width: 48vw; height: 48vw; left: 22vw;  bottom: -20vw; background: var(--glow-mint); }

/* ── 玻璃材質 ───────────────────────────────────────────
   只掛在大區塊上。沒有圓角 —— 是一片玻璃板，不是藥丸。   */
.glass {
  position: relative;
  background: linear-gradient(152deg, var(--glass-hi), var(--glass) 45%, var(--glass-lo));
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  box-shadow:
    inset 0 1px 0 0 var(--specular),      /* 頂緣受光 */
    inset 0 0 0 .5px var(--hairline),      /* 厚度描邊 */
    0 8px 30px -10px var(--shade),         /* 懸浮 */
    0 2px 8px -3px var(--shade-2);
}
/* 底緣的反射光 —— 玻璃下沿會把底下的光帶上來 */
.glass::after {
  content: ""; position: absolute; inset: auto 10% 0 10%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--specular), transparent);
  opacity: .55; pointer-events: none;
}

/* ── 頁首 ───────────────────────────────────────────────── */
.chrome {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(180deg, var(--glass-hi), var(--glass));
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  box-shadow: inset 0 -.5px 0 var(--hairline), 0 1px 14px -6px var(--shade);
}
.chrome-inner {
  max-width: 1160px; margin: 0 auto;
  padding: 12px var(--pad);
  padding-top: calc(12px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 22px;
}

.wordmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.wordmark-mark { width: 42px; height: 42px; object-fit: contain; flex: none; }
.wordmark-text { display: flex; flex-direction: column; gap: 2px; line-height: 1; }
/* 字標已裁到墨跡邊界（原檔左側有 44px 透明留白）,
   因此圖片左緣就是「台」的左緣，下方的 DearLep 直接切齊即可。 */
.wordmark-zh { width: 176px; height: auto; display: block; }
.wordmark-text small { font-size: 1.1rem; color: var(--ink-4); letter-spacing: .14em; }

/* 桌機：選單項目在剩餘空間裡水平置中 */
.nav { display: flex; gap: 20px; flex: 1; justify-content: center; }
.nav::-webkit-scrollbar { display: none; }

/* 漢堡鈕只在窄螢幕出現 */
.burger { display: none; }
.nav a {
  font-size: 1.12rem; color: var(--ink-2); text-decoration: none;
  white-space: nowrap; padding: 2px 0;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

.quick { position: relative; flex: none; width: min(220px, 30vw); }
.quick-icon {
  position: absolute; left: 0; top: 50%; translate: 0 -50%;
  width: 13px; height: 13px; color: var(--ink-4); pointer-events: none;
}
.quick input {
  width: 100%; font: inherit; font-size: 1.1rem;
  padding: 5px 0 5px 20px;
  border: 0; border-bottom: 1px solid var(--rule); border-radius: 0;
  background: none; color: var(--ink);
}
.quick input::placeholder { color: var(--ink-4); }
.quick input:focus { outline: 0; border-bottom-color: var(--ink); }

/* ── 版面 ───────────────────────────────────────────────── */
.shell {
  max-width: 1160px; margin: 0 auto;
  padding: 32px var(--pad) 56px;
  display: flex; flex-direction: column; gap: 34px;
}

/* 玻璃只給最外層的大區塊 —— 由 CSS 指定，而不是在 markup 上到處掛 class。
   巢狀在裡面的區塊自動維持平面，不會變成「玻璃裡還有玻璃」。
   標題與前言不掛，它們該直接落在紙上。 */
.shell > .panel,
.shell > .panel-tight,
.shell > .map-layout {
  background: linear-gradient(152deg, var(--glass-hi), var(--glass) 45%, var(--glass-lo));
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  box-shadow:
    inset 0 1px 0 0 var(--specular),
    inset 0 0 0 .5px var(--hairline),
    0 8px 30px -10px var(--shade),
    0 2px 8px -3px var(--shade-2);
  padding: 24px 26px;
}
.shell > .panel-tight { padding: 14px 20px; }
.shell > .map-layout { padding: 24px 26px; }

.footnote {
  border-top: 1px solid var(--rule);
  padding: 20px var(--pad) calc(48px + env(safe-area-inset-bottom));
  font-size: 1.1rem; color: var(--ink-3); gap: 4px;
}
.footnote p { margin: 0; }
.footnote .dim { color: var(--ink-4); }

/* ── 文字 ───────────────────────────────────────────────── */
h1 {
  font-family: var(--serif); font-size: clamp(25px, 4.4vw, 34px);
  font-weight: 600; margin: 0; line-height: 1.28; letter-spacing: -.012em;
  text-wrap: balance;
}
h2 { font-family: var(--serif); font-size: 1.52rem; font-weight: 600; margin: 0; text-wrap: balance; }
h3 { font-size: 1.1rem; font-weight: 600; margin: 0; color: var(--ink-2); }
p { margin: 0; }

.kicker { font-family: var(--mono); font-size: 1.1rem; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.lede { font-size: 1.24rem; color: var(--ink-2); max-width: 44rem; margin: 0; }
/* 學名與中文名的主次關係。
   中文名是讀者認得的那個，學名是識別碼 —— 所以中文名黑、學名淺灰且小一號。
   用 em 而不是絕對值，任何字級的上下文裡都維持同一個比例。 */
.sci { font-style: italic; color: var(--ink-3); font-size: .88em; font-weight: 400; }
.zh-name { color: var(--ink); font-weight: 600; }

/* 沒有中文名的物種（本庫約三成），學名就是主要標籤，不能也淡掉 */
.sci.solo { color: var(--ink); font-size: 1em; font-weight: 600; }
.dim { color: var(--ink-3); }

a { color: var(--accent); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: .92em; color: var(--ink-2); }

/* ── 結構 ───────────────────────────────────────────────── */
.panel { display: flex; flex-direction: column; gap: 15px; }
.panel-tight { display: flex; flex-direction: column; gap: 10px; }
/* 兩個 class 同時掛在一個元素上時，橫向排列優先 —— 否則 margin-left:auto
   會在 column 方向上把元素推到右邊，整組資訊就靠右散開了 */
.panel-tight.row, .panel.row { flex-direction: row; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spread { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-cards { display: grid; gap: 22px 20px; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }

/* ── 覆蓋率標記 ──────────────────────────────────────────
   稀疏維度必須誠實揭露。舊站最大的問題是設計投入與資料密度
   反向 —— 這個標記是修正它的機制，所以即使版面極簡也保留。 */
.coverage {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 1.1rem; letter-spacing: .03em;
  color: var(--ink-3); white-space: nowrap;
}
.coverage::before {
  content: ""; width: 26px; height: 2px;
  background: linear-gradient(90deg, var(--bar-fill, var(--ok)) var(--pct, 0%), var(--rule) var(--pct, 0%));
}
.coverage.thin { color: var(--thin); --bar-fill: var(--thin); }

/* ── 統計數字 ───────────────────────────────────────────── */
.figures { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.figure { display: flex; flex-direction: column; gap: 2px; }
.figure b {
  font-family: var(--mono); font-size: 1.92rem; font-weight: 500;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15;
}
.figure span { font-size: 1.1rem; color: var(--ink-3); }

/* ── 影像格 ─────────────────────────────────────────────── */
.plate { display: grid; gap: 20px 16px; grid-template-columns: repeat(auto-fill, minmax(min(155px, 100%), 1fr)); }
.spec { display: flex; flex-direction: column; gap: 7px; }
/* 標本照多半是白底或去背，不畫一條線就會浮在頁面上分不出邊界 */
.spec img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block;
  border: 1px solid var(--rule); background: var(--paper);
}
.spec img.cutout { object-fit: contain; padding: 8px; background: var(--wash); }
.spec a { display: block; line-height: 0; }
.spec a:hover img { border-color: var(--rule-2); }
.spec .cap { font-size: 1.1rem; color: var(--ink-3); line-height: 1.55; display: flex; flex-direction: column; gap: 2px; }
/* 顏色交給 .zh-name / .sci 決定 —— 卡片不該自己蓋掉名稱的主次關係 */
.spec .cap b { font-weight: 600; font-size: 1.16rem; }

/* ── 標籤 ───────────────────────────────────────────────
   純文字，不做膠囊。多個標籤靠間距分開就夠了。         */
.tag { font-size: 1.1rem; color: var(--ink-3); white-space: nowrap; }
.tag.accent { color: var(--accent); }
.tag.warn { color: var(--warn); }

/* ── 表格 ───────────────────────────────────────────────── */
.sheet { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 1.1rem; }
th, td { text-align: left; padding: 9px 14px 9px 0; vertical-align: top; }
th:last-child, td:last-child { padding-right: 0; }
thead th {
  font-size: 1.1rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap;
  border-bottom: 1px solid var(--rule-2); padding-bottom: 7px;
}
tbody td { border-bottom: 1px solid var(--rule); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--wash); }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── 表單元件 ───────────────────────────────────────────── */
.field {
  width: 100%; font: inherit; font-size: 1.2rem;
  padding: 9px 0; border: 0; border-bottom: 1px solid var(--rule-2); border-radius: 0;
  background: none; color: var(--ink);
}
.field:focus { outline: 0; border-bottom-color: var(--ink); }

.btn {
  font: inherit; font-size: 1.12rem; font-weight: 500;
  padding: 9px 20px; border: 0; border-radius: 0;
  background: var(--ink); color: var(--paper); cursor: pointer;
  min-height: 40px;
}
.btn:hover { background: var(--ink-2); }
.btn-quiet {
  background: none; color: var(--ink);
  border: 1px solid var(--rule-2);
}
.btn-quiet:hover { background: var(--wash); border-color: var(--ink-4); }

/* ── 篩選籌碼 ───────────────────────────────────────────
   沒有底色、沒有外框。選取狀態用墨色底線標示 ——
   在一整片灰字裡，一條實線比一塊淺色底更容易被找到。   */
.chips { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.chip {
  font-size: 1.1rem; color: var(--ink-2);
  text-decoration: none; cursor: pointer; border: 0; background: none;
  font-family: inherit; padding: 2px 0;
  display: inline-flex; align-items: baseline; gap: 5px;
  border-bottom: 2px solid transparent;
}
.chip:hover { color: var(--ink); text-decoration: none; }
.chip.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.chip .ct { font-family: var(--mono); font-size: 1.1rem; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.chip.on .ct { color: var(--ink-3); }
.chip.zero { color: var(--ink-4); pointer-events: none; }

/* ── Mega Menu 抽屜 ─────────────────────────────────────── */
.drawer { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.drawer > summary {
  list-style: none; cursor: pointer;
  padding: 12px 0; display: flex; align-items: center; gap: 10px;
  font-size: 1.12rem; font-weight: 500;
}
.drawer > summary::-webkit-details-marker { display: none; }
.drawer > summary .caret { margin-left: auto; color: var(--ink-4); transition: rotate .2s ease; }
.drawer[open] > summary .caret { rotate: 180deg; }
.drawer > summary:hover { color: var(--accent); }
.drawer-body { padding: 4px 0 22px; display: grid; gap: 26px; }
@media (min-width: 60rem) { .drawer-body { grid-template-columns: repeat(3, 1fr); } }

.dim-group { display: flex; flex-direction: column; gap: 9px; }
/* 標題、＋/－ 開關與覆蓋率標記在同一行，但覆蓋率可以換行掉下去 ——
   欄寬只有三分之一，硬擠會把「停棲外形」折成「停棲外／形」 */
.dim-group > header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.dim-group > header h3 {
  font-size: 1.1rem; letter-spacing: .11em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap;
}
.dim-group > header .coverage { margin-left: auto; }

/* ── 包含／排除開關 ────────────────────────────────────────
   舊站的 ＋/－。切的是整個維度：勾選的項目從「只顯示這些」翻成
   「濾掉這些」。全形符號的字寬與中文一致，兩種狀態不會讓標題左右跳。 */
.ex-toggle {
  font-family: var(--mono); font-size: 1.1rem; line-height: 1;
  width: 1.5em; text-align: center; flex: none;
  text-decoration: none; color: var(--ink-4);
  border: 1px solid var(--rule-2); padding: 3px 0;
}
.ex-toggle:hover { color: var(--ink); border-color: var(--ink-3); text-decoration: none; }
.ex-toggle.on { color: var(--warn); border-color: currentColor; font-weight: 700; }

/* 整個維度翻成排除時，選項讀起來的意思也反了 —— 用刪除線讓
   「這些會被濾掉」在掃視時就看得出來，不必先讀到標題上的 － */
.dim-group.excluded .chip.on,
.dim-group.excluded .shape-pick.on .nm { text-decoration: line-through; }
.chip.neg { color: var(--warn); font-weight: 600; border-bottom-color: currentColor; }

/* ── 「還有 N 項」：收起來，但打得開 ────────────────────────
   關著的時候是行末的一顆籌碼；打開之後獨佔一整列，
   裡面的項目才有寬度可以橫向排列，而不是擠成一條細柱。 */
.more { flex: none; }
.more[open] { flex: 1 0 100%; margin-top: 2px; }
.more > summary {
  list-style: none; cursor: pointer;
  font-size: 1.1rem; color: var(--ink-4);
  border-bottom: 2px dotted var(--rule-2); padding: 2px 0; width: max-content;
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary:hover { color: var(--ink-2); border-bottom-color: var(--ink-4); }
.more[open] > summary { color: var(--ink-3); margin-bottom: 6px; }
.more[open] > summary::after { content: "　收合"; color: var(--ink-4); }

/* ── 分類階層樹 ─────────────────────────────────────────── */
.tree { display: flex; flex-direction: column; }
.tree details { border-bottom: 1px solid var(--rule); }
.tree details:last-child { border-bottom: 0; }
.tree summary {
  list-style: none; cursor: pointer; padding: 9px 0;
  display: flex; align-items: center; gap: 9px; font-size: 1.12rem;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary:hover { color: var(--accent); }
.tree summary .ct { margin-left: auto; font-family: var(--mono); font-size: 1.1rem; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.tree .depth-2 { padding-left: 22px; }
.tree .depth-3 { padding-left: 44px; }
.tree .leaves { padding: 2px 0 12px 44px; display: flex; flex-direction: column; gap: 2px; }
.tree .leaf { font-size: 1.1rem; padding: 2px 0; text-decoration: none; color: var(--ink-2); display: flex; gap: 8px; align-items: baseline; }
.tree .leaf:hover { color: var(--accent); }
.tree .leaf .zh { color: var(--ink-3); font-size: 1.1rem; }

/* ── 分頁 ───────────────────────────────────────────────── */
/* 頁碼橫排。先前這個 <nav> 同時掛了 panel-tight，
   而那個 class 設 flex-direction: column，把整排頁碼豎成一直行。 */
.pager { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; justify-content: center; font-size: 1.1rem; }
.pager > a, .pager > span { padding: 2px 4px; }
.pager a, .pager span { text-decoration: none; color: var(--ink-3); border-bottom: 2px solid transparent; padding-bottom: 1px; }
.pager a:hover { color: var(--ink); }
.pager .cur { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

/* ── 空狀態 ─────────────────────────────────────────────── */
.empty { padding: 48px 0; text-align: center; color: var(--ink-3); font-size: 1.12rem; display: flex; flex-direction: column; gap: 6px; align-items: center; }

/* ── 定義列表 ───────────────────────────────────────────── */
dl.kv { margin: 0; display: grid; gap: 8px 26px; font-size: 1.12rem; }
dl.kv dt { color: var(--ink-3); font-size: 1.1rem; }
dl.kv dd { margin: 0; }
@media (min-width: 40rem) {
  dl.kv { grid-template-columns: max-content 1fr; align-items: baseline; }
  dl.kv dt { font-size: 1.12rem; }
}

/* ══════════════════════════════════════════════════════════
   生態地圖
   ══════════════════════════════════════════════════════════ */

.map-layout { display: grid; gap: 30px; }
@media (min-width: 62rem) { .map-layout { grid-template-columns: minmax(0, 400px) minmax(0, 1fr); align-items: start; } }

.map-figure { margin: 0; position: relative; }
.map-canvas { width: 100%; height: auto; max-height: 74vh; display: block; }

/* 陸塊只提供「這裡是台灣」的空間感，不參與資訊層級 */
.coast { fill: var(--map-land); stroke: var(--map-coast); stroke-width: 1.4; stroke-linejoin: round; }

.site {
  fill: var(--map-site); fill-opacity: .55;
  stroke: var(--map-site); stroke-width: 1;
  transition: fill-opacity .16s ease;
}
.site.ok { fill: var(--ok); stroke: var(--ok); }
a:hover .site, a:focus-visible .site { fill-opacity: .95; }

.site-label {
  font: 500 1.1rem/1 var(--sans); fill: var(--ink-2);
  paint-order: stroke; stroke: var(--paper); stroke-width: 3.5px; stroke-linejoin: round;
  pointer-events: none;
}

/* 左上角是台灣海峽以北的空海域，插圖放這裡不會壓到本島 */
.map-inset { position: absolute; left: 0; top: 10px; width: 122px; height: auto; }
.inset-frame { fill: none; stroke: var(--rule); stroke-width: 1; }
.inset-label { font: 500 1.1rem/1 var(--sans); fill: var(--ink-4); }

.map-figure figcaption { margin-top: 14px; font-size: 1.1rem; line-height: 1.7; color: var(--ink-3); }

.site-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
/* 一列一個地點：名稱 / 資料條 / 筆數 / 精確度。
   資料條固定寬度 —— 讓它滿版會看起來像分隔線而不是數量。 */
/* 兩列一個地點：
     第一列  地名              ｜ 精確度
     第二列  縣市 · 海拔       ｜ 張數 · 種數
     第三列  資料條（滿版）

   先前把地名、縣市、海拔全塞進同一格，內容需要 250px 而欄寬只有 200px，
   於是後設資料溢出去蓋住資料條。分成兩列之後，每一格的內容都短到不會
   互相擠壓，任何寬度下地名都完整顯示。 */
.site-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name tag"
    "meta n"
    "bar  bar";
  gap: 1px 14px;
  align-items: baseline;
}
.site-list .site-name {
  grid-area: name;
  text-decoration: none; color: inherit;
  font-weight: 500; font-size: 1.16rem;
  min-width: 0; overflow-wrap: anywhere;
}
.site-list .site-name:hover { color: var(--accent); }
.site-meta { grid-area: meta; font-size: 1.1rem; }
.site-list .tag { grid-area: tag; font-size: 1.1rem; white-space: nowrap; justify-self: end; }
.site-n { grid-area: n; font-size: 1.1rem; color: var(--ink-3); white-space: nowrap; justify-self: end; }
.site-bar { grid-area: bar; height: 2px; margin-top: 5px; background: var(--rule); position: relative; }
.site-bar::before { content: ""; position: absolute; inset: 0; width: var(--pct); background: var(--map-site); }

.pending-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; font-size: 1.1rem; }
.pending-list li { display: grid; gap: 2px; }
.pending-list .note { font-size: 1.1rem; line-height: 1.65; }

/* ── 海拔帶與樣線 ───────────────────────────────────────── */
.bands { display: grid; gap: 6px; }
.band { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 1.1rem; }
.band-label { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.band-n { color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.band-bar { height: 10px; background: var(--wash); position: relative; }
.band-bar::before { content: ""; position: absolute; inset: 0; width: var(--pct); background: var(--map-site); opacity: .7; }
.transect-title { font-size: 1.1rem; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; margin: 16px 0 4px; }

/* ── 發生期 ─────────────────────────────────────────────── */
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 120px; }
.month { display: grid; grid-template-rows: 1fr auto; gap: 6px; height: 100%; align-items: end; }
.month-bar { height: var(--pct); min-height: 1px; background: var(--map-site); opacity: .7; }
.month-label { text-align: center; font-size: 1.1rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ── 物種頁的分布區塊 ───────────────────────────────────── */
.dist { display: grid; gap: 20px 26px; align-items: start; }
@media (min-width: 46rem) { .dist { grid-template-columns: 132px minmax(0, 1fr); } }
@media (min-width: 68rem) { .dist { grid-template-columns: 140px minmax(200px, 290px) minmax(0, 1fr); } }
.dist-season { min-width: 0; }
.dist-map { width: 100%; height: auto; max-height: 310px; }
.dist-map .site { fill-opacity: .6; }
.dist-sites { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 1.1rem; }
.dist-sites li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.dist-sites a { color: inherit; text-decoration: none; font-weight: 500; }
.dist-sites a:hover { color: var(--accent); }
.dist-sites .dim { font-size: 1.1rem; }
.dist-sites .ct { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 1.1rem; }
.dist-months { height: 68px; }

/* ── 共通 ───────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 52rem) {
  .chrome-inner { flex-wrap: wrap; gap: 10px 14px; }

  .burger {
    display: grid; place-items: center;
    width: 40px; height: 40px; margin-left: auto;
    cursor: pointer; color: var(--ink-2);
  }
  .burger svg { width: 22px; height: 22px; }
  .burger:hover { color: var(--ink); }

  /* 收起時完全不佔位；展開後成為橫幅式的清單，一項一行才點得準 */
  .nav {
    display: none; order: 4; width: 100%;
    flex-direction: column; gap: 0;
    border-top: 1px solid var(--rule);
    margin-top: 4px; padding-top: 4px;
  }
  .nav-toggle:checked ~ .nav { display: flex; }
  .nav a { padding: 11px 2px; border-bottom: 0; border-left: 2px solid transparent; padding-left: 10px; }
  .nav a.on { border-bottom: 0; border-left-color: var(--ink); }

  .quick { width: 100%; order: 3; }
  .band { grid-template-columns: 4.5rem minmax(0, 1fr); }
  .band-n { grid-column: 2; font-size: 1.1rem; }
  .map-inset { width: 92px; }
}
.nav-toggle:checked ~ .burger { color: var(--ink); }

/* ── 分類群搜尋（舊版的 屬↑ / 種↓）───────────────────────── */
.taxon-search { display: grid; gap: 8px; }
.taxon-search label { display: grid; grid-template-columns: 2.6rem 1fr; gap: 8px; align-items: center; }
.taxon-search label span { font-size: 1.1rem; color: var(--ink-3); font-family: var(--mono); }
.taxon-search input {
  font: inherit; font-size: 1.1rem; padding: 5px 0;
  border: 0; border-bottom: 1px solid var(--rule-2); border-radius: 0;
  background: none; color: var(--ink); width: 100%;
}
.taxon-search input:focus { outline: 0; border-bottom-color: var(--ink); }
.taxon-search input::placeholder { color: var(--ink-4); }
.taxon-search .btn { justify-self: start; padding: 5px 14px; min-height: 30px; font-size: 1.1rem; }

/* ── 停棲姿勢剪影 ───────────────────────────────────────── */
.shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 8px; }
.shape-pick {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: var(--ink-3); padding: 6px 2px 5px;
  border-bottom: 2px solid transparent;
}
.shape-pick:hover { color: var(--ink); text-decoration: none; }
.shape-pick:hover .silhouette .wing-front path,
.shape-pick:hover .silhouette .wing-back path { fill: var(--ink-3); }
.shape-pick.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.shape-pick.on .silhouette .wing-front path,
.shape-pick.on .silhouette .wing-back path { fill: var(--ink); }
.shape-pick .nm { font-size: 1.1rem; line-height: 1.3; text-align: center; }
.shape-pick .ct { font-family: var(--mono); font-size: 1.1rem; color: var(--ink-4); }
.shape-pick.zero { opacity: .35; pointer-events: none; }

.silhouette { width: 100%; max-width: 62px; height: auto; display: block; }
.silhouette .wing-front path { fill: var(--wing-front, #b9c0ca); }
.silhouette .wing-back path  { fill: var(--wing-back, #cdd2d9); }
.silhouette .body path { fill: var(--ink-2); }
.silhouette .antenna { fill: none; stroke: var(--ink-2); stroke-width: 2.2; stroke-linecap: round; }

/* 蝶蛾印象：剪影放大，可以直接在上面塗色 */
.paint-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 16px 12px; }
.paint-grid .silhouette { max-width: 100%; }
.paint-grid .shape-pick { padding: 10px 6px 8px; }

/* 色票：沿用原站的 8 張圖 */
.tickets { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket { display: flex; flex-direction: column; align-items: center; gap: 3px; text-decoration: none; }
/* 第一個色票是純白，在白底上必須有實體邊框才看得見它存在 */
.ticket img {
  width: 34px; height: 34px; display: block;
  border: 1px solid var(--rule-2); box-sizing: border-box;
}
.ticket.on img { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.ticket .ct { font-family: var(--mono); font-size: 1.1rem; color: var(--ink-4); }
.ticket.zero { opacity: .38; }

/* ── 配色矩陣：主色調／次色調各一組 背腹 × 前後翅 ──────────
   舊站的八個格子。用 grid 而不是兩個並排的表格，是因為欄頭
   （背／腹）與列頭（前翅／後翅）要能對齊到格子上，讀的人才不必
   自己在腦中配對。 */
.colour-matrix { display: flex; flex-wrap: wrap; gap: 28px 40px; align-items: flex-start; }
.cm-block { display: flex; flex-direction: column; gap: 8px; }
.cm-title { font-size: 1.1rem; font-weight: 600; color: var(--ink-2); }
.cm-grid { display: grid; grid-template-columns: auto 1fr 1fr; gap: 5px 7px; align-items: center; }
.cm-head { font-size: 1.05rem; color: var(--ink-4); text-align: center; }
.cm-grid .cm-head:first-of-type ~ .cm-head { text-align: center; }

.cm-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-width: 52px; min-height: 46px; padding: 5px 8px;
  border: 1px solid var(--rule-2); background: var(--surface);
  text-decoration: none; color: inherit;
}
.cm-cell.wide { min-width: 116px; }
/* 目前正在塗的格子。用實心外框而不是底色 —— 格子裡本來就會放色票，
   底色一改就分不清那是選取狀態還是使用者塗的顏色 */
.cm-cell.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.cm-cell.zero { opacity: .42; }
.cm-cell img { display: block; border: 1px solid var(--rule-2); box-sizing: border-box; }
.cm-n { font-family: var(--mono); font-size: 1.05rem; color: var(--ink-4); line-height: 1; }
/* 空格子要留住色票的高度，否則選了顏色之後整列會往下跳 */
.cm-cell:not(.filled)::before { content: ""; display: block; width: 26px; height: 26px; }

/* ══════════════════════════════════════════════════════════
   等比例圖版

   排版不用 Isotope。CSS Grid 的 dense 自動填補會把每一塊磚塞進
   最近的空隙，效果與 masonry 相同，但少一個 35KB 的相依，而且
   關掉 JS 也看得到 —— 只是不會自動載入下一頁。

   每塊磚佔幾格由展翅長決定（一格 8 mm）,因此整片畫面上的大小
   關係是真的，不是視覺上的錯落。
   ══════════════════════════════════════════════════════════ */

.plate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--cell, 26px));
  grid-auto-rows: var(--cell, 26px);
  grid-auto-flow: row dense;
  justify-content: center;
  background: var(--paper);
  padding: 6px;
}
@media (min-width: 60rem) { .plate-grid { --cell: 30px; } }
@media (max-width: 34rem) { .plate-grid { --cell: 20px; } }

.tile {
  grid-column: span var(--cols);
  grid-row: span var(--rows);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 2px;
  text-decoration: none;
}
.tile img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  display: block;
}

/* 說明只在滑過時出現 —— 平時整片畫面應該只有標本 */
.tile-cap {
  position: absolute; inset: auto 0 0 0;
  display: none; flex-direction: column; gap: 0;
  padding: 3px 5px 4px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.92) 40%);
  font-size: 1.1rem; line-height: 1.35; color: var(--ink-3);
  pointer-events: none;
}
.tile-cap b { font-size: 1.1rem; font-weight: 600; }
.tile-cap .mm { font-family: var(--mono); font-size: 1.1rem; color: var(--ink-4); }
.tile:hover { outline: 1px solid var(--rule-2); z-index: 2; }
.tile:hover .tile-cap, .tile:focus-visible .tile-cap { display: flex; }
/* 磚太小時放不下說明，滑過時放大顯示反而擋住鄰居 —— 直接不顯示 */
.tile[style*="--cols:2"] .tile-cap, .tile[style*="--cols:3"] .tile-cap { display: none !important; }

.plate-more { grid-column: 1 / -1; height: 1px; }

/* ── 比例尺與可信度 ─────────────────────────────────────── */
.plate-legend {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-size: 1.1rem; color: var(--ink-3);
}
.ruler { display: inline-flex; align-items: flex-end; height: 10px; }
.ruler i {
  width: var(--cell, 30px); height: 10px;
  border-left: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2);
}
.ruler i:last-child { border-right: 1px solid var(--rule-2); }

/* 代表標本壓成剪影：只留輪廓，翅面花紋會干擾形狀的判讀 */
.silhouette.real { display: block; width: 100%; max-width: 62px; }
.silhouette.real img {
  width: 100%; height: auto; display: block;
  filter: brightness(0) opacity(.42);
}
.shape-pick:hover .silhouette.real img,
.shape-pick.on .silhouette.real img { filter: brightness(0) opacity(.82); }
.paint-grid .silhouette.real { max-width: 100%; }
/* 繪製的示意圖用虛線底標示，與依標本產生的區分開 */
.shape-pick .silhouette.drawn { border-bottom: 1px dotted var(--rule-2); padding-bottom: 2px; }

/* ══════════════════════════════════════════════════════════
   燈箱
   ══════════════════════════════════════════════════════════ */

.lightbox {
  width: 100vw; max-width: 100vw;
  height: 100dvh; max-height: 100dvh;
  margin: 0; padding: 0; border: 0;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  color: var(--ink);
  overscroll-behavior: contain;
}
.lightbox::backdrop { background: rgba(255, 255, 255, .5); }

.lb-stage {
  margin: 0; height: 100%;
  display: grid; grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px; padding: 40px 56px 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.lb-stage img {
  min-height: 0; max-width: 100%; max-height: 100%;
  margin: 0 auto; object-fit: contain; display: block;
  opacity: 0; transition: opacity .22s ease;
}
.lb-stage img.ready { opacity: 1; }

.lb-cap {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px;
  justify-content: center; text-align: center;
  font-size: 1.1rem; color: var(--ink-3);
}
.lb-cap .lb-title { font-size: 1.28rem; color: var(--ink); font-weight: 600; }
.lb-cap .lb-sci { font-size: 1.15rem; }
.lb-cap .lb-link { font-size: 1.1rem; }
.lb-cap .lb-count { font-family: var(--mono); font-size: 1.1rem; color: var(--ink-4); }

.lb-close, .lb-nav {
  position: absolute; z-index: 2;
  border: 0; background: none; cursor: pointer;
  color: var(--ink-3); font-family: var(--sans); line-height: 1;
  padding: 10px 14px;
}
.lb-close:hover, .lb-nav:not(:disabled):hover { color: var(--ink); }
.lb-close { top: 6px; right: 10px; font-size: 2.4rem; }
.lb-nav { top: 50%; translate: 0 -50%; font-size: 3.2rem; }
.lb-prev { left: 4px; }
.lb-next { right: 4px; }
.lb-nav:disabled { opacity: .2; cursor: default; }

@media (max-width: 40rem) {
  .lb-stage { padding: 46px 12px 20px; }
  .lb-nav { font-size: 2.56rem; padding: 8px 6px; }
}

/* ── 圖版的全螢幕模式 ───────────────────────────────────── */
.plate-wrap { background: var(--paper); }
.plate-wrap:fullscreen {
  overflow: auto;
  padding: 8px;
  /* 全螢幕時格子放大 —— 整片畫面的目的就是看得更清楚 */
  --cell: 38px;
}
.plate-wrap:fullscreen .plate-grid { padding: 0; }
#plate-fullscreen { padding: 4px 12px; min-height: 28px; font-size: 1.1rem; }


/* ── 停棲外形剪影（來自原始 SVG sprite）────────────────────
   <use> 建立的 shadow DOM 選不到裡面的 .wing-front,但自訂屬性會繼承進去，
   所以只要在外層設 --wing-front 就能上色 —— 而且可以直接指向原檔那幾個
   放射狀漸層（色票 ct2–ct8）,維持原有的質感而不是平塗。 */
.moth-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* 預設值定在 :root 而不是 .silhouette —— 上色的行內樣式設在外層的
   .shape-pick 上，若 .silhouette 自己也宣告一次，元素自身的宣告會贏過
   繼承，顏色就永遠傳不進去。 */
:root {
  --moth-body: #8b93a1;
  --moth-shade: #b6bcc6;
  --wing-front: #c3c9d2;
  --wing-back: #d2d7de;
}
.silhouette { width: 100%; max-width: 74px; height: auto; display: block; }
.shape-pick:hover, .shape-pick.on { --moth-body: #4a5261; --moth-shade: #97a0ad; }
/* 補繪的那一個標示出來，不讓它被當成原作 */
.silhouette.authored { border-bottom: 1px dotted var(--rule-2); padding-bottom: 2px; }

.paint-grid .silhouette { max-width: 100%; }

/* ── 首頁的區域介紹卡 ───────────────────────────────────── */
.section-card {
  display: flex; flex-direction: column; gap: 6px;
  text-decoration: none; color: inherit; min-height: 118px;
}
.section-card h2 { font-size: 1.28rem; }
.section-card p { font-size: 1.1rem; line-height: 1.6; }
.section-card:hover h2 { color: var(--accent); }

/* 中名篩選：與兩格搜尋框同一列，用核取方塊而不是按鈕 ——
   它是「限縮比對範圍」的開關，不是另一個送出動作。 */
.taxon-search .zh-only { grid-template-columns: auto 1fr; gap: 6px; cursor: pointer; }
.taxon-search .zh-only span { font-family: var(--sans); }

/* ── 關於網站 ──────────────────────────────────────────── */
.goals { margin: 0; padding-left: 1.5em; font-size: 1.14rem; color: var(--ink-2); }
.goals li { margin-bottom: 6px; }
/* 引用格式要能整段選取複製，因此保留換行與空白 */
.cite {
  margin: 0; padding: 12px 14px; background: var(--wash);
  border-left: 2px solid var(--rule-2);
  font-family: var(--mono); font-size: 1.1rem; line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

/* 片段定位時的留白。頁首是 sticky 的，不留這個空間，
   捲到的那一區會剛好躲在頁首底下。 */
[id="shapes"], [id="colour"], [id="plate-top"], [id="results"],
[id^="dim-"] { scroll-margin-top: 84px; }

/* ── 食草紀錄：一種植物一個區塊 ────────────────────────────
   資料是一張二部圖（1,369 種植物 × 1,252 種蝶蛾），772 種植物被兩種
   以上的蛾利用。攤成一列一筆關聯會把這個結構讀不出來，也會讓同一種
   植物在畫面上重複幾十次。 */
.host-list { display: flex; flex-direction: column; gap: 12px; }
.host-card { display: flex; flex-direction: column; gap: 10px; }
.host-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; }

/* 取食者用多欄排 —— 一種植物動輒十幾種蛾，單欄會拉得很長 */
.host-leps {
  margin: 0; padding: 0; list-style: none;
  columns: 2; column-gap: 26px;
  border-top: 1px solid var(--rule); padding-top: 9px;
}
@media (min-width: 60rem) { .host-leps { columns: 3; } }
.host-leps li {
  break-inside: avoid; padding: 2px 0; font-size: 1.1rem;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
}
.host-leps a { text-decoration: none; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.host-leps a:hover .zh-name, .host-leps a:hover .sci { color: var(--accent); }
/* 取食部位是這批資料裡少見的細節，只有兩成有，值得標出來 */
.host-part { font-size: 1.05rem; color: var(--ok); }
.host-ref { font-size: 1.05rem; color: var(--ink-4); }
