/* libfilter.css — 圖鑑工具列(LIBRARY_TOOLBAR_PLAN,2026-11-16 原型)
   配色沿用站上既有元件:深色半透明底(表格 rgba(0,0,0,.8))、輸入框 #1b1f27/#4a5568、
   選中＝物品標籤晶片的藍(.item-page .mob-chip.is-on)。 */

.lf-root {
    position: relative;
    z-index: 30;
    margin: 0 0 12px;
    font-family: 'huninn', sans-serif;
}

/* ── 工具列 ── */
.lf-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 12px;
}

.lf-q {
    flex: 1 1 220px;
    min-width: 0;
    padding: 7px 12px;
    font-size: 15px;
    font-family: inherit;
    color: #eeeeee;
    background: #1b1f27;
    border: 1px solid #4a5568;
    border-radius: 6px;
}

.lf-q:focus,
.lf-root input:focus,
.lf-root select:focus {
    outline: none;
    border-color: #abcdef;
}

.lf-root button {
    font-family: inherit;
    cursor: pointer;
}

.lf-open,
.lf-dir,
.lf-sort {
    height: 34px;
    padding: 0 12px;
    font-size: 14px;
    color: #dddddd;
    background: #1b1f27;
    border: 1px solid #4a5568;
    border-radius: 6px;
}

.lf-open {
    font-weight: bold;
}

.lf-open::before {
    content: "⚲ ";
}

.lf-is-open .lf-open,
.lf-open:hover,
.lf-dir:hover {
    color: #ffffff;
    border-color: #abcdef;
}

.lf-badge {
    color: #f3df00;
}

.lf-sortw {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #aaaaaa;
}

.lf-sort {
    padding: 0 6px;
    max-width: 150px;
}

.lf-dir {
    width: 34px;
    padding: 0;
}

.lf-hits {
    margin-left: auto;
    font-size: 13px;
    color: #999999;
    white-space: nowrap;
}

/* ── 已選條件 ── */
.lf-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 2px 0;
}

.lf-chips:empty {
    display: none;
}

.lf-chip {
    padding: 3px 10px;
    font-size: 13px;
    color: #ffffff;
    background: rgba(109, 169, 229, 0.8);
    border: 1px solid rgba(171, 205, 239, 0.85);
    border-radius: 12px;
}

.lf-chip span {
    margin-left: 2px;
    opacity: 0.8;
}

.lf-chip:hover {
    background: rgba(109, 169, 229, 1);
}

.lf-chip-clear {
    color: #dddddd;
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.25);
}

.lf-chip-clear:hover {
    color: #ffffff;
    background: rgba(0, 0, 0, 0.8);
}

/* ── 篩選面板(電腦:疊在表格上方)── */
.lf-panel {
    box-sizing: border-box; /* 引擎算的 max-height 要含上下內距(石器外觀的框很厚) */
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    display: flex;
    flex-direction: column;
    max-height: min(70vh, 640px);
    color: #dddddd;
    background: #0e1014;
    border: 1px solid #4a5568;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.lf-panel[hidden],
.lf-mask[hidden] {
    display: none;
}

.lf-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #2c333f;
}

.lf-panel-head b {
    color: #f3df00;
    font-size: 15px;
}

.lf-panel-note {
    flex: 1;
    font-size: 12px;
    color: #888888;
}

.lf-x {
    width: 30px;
    height: 30px;
    font-size: 15px;
    color: #cccccc;
    background: none;
    border: 0;
}

.lf-panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 14px 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
}

.lf-g {
    padding: 10px 0;
    border-bottom: 1px solid #22272f;
}

/* 選項多的組橫跨兩欄 */
.lf-g[data-g="type"],
.lf-g-stats,
.lf-g-wide,
.lf-g[data-g="feat"] {
    grid-column: 1 / -1;
}

.lf-gh {
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: bold;
    color: #eeeeee;
}

.lf-gh small {
    margin-left: 4px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: normal;
    color: #999999;
    border: 1px solid #3a4250;
    border-radius: 8px;
}

.lf-opts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lf-opt {
    padding: 4px 10px;
    font-size: 14px;
    color: #dddddd;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 14px;
}

.lf-opt:hover {
    color: #ffffff;
    border-color: #ffffff;
}

.lf-opt[aria-pressed="true"] {
    color: #ffffff;
    background: rgba(109, 169, 229, 0.8);
    border-color: rgba(171, 205, 239, 0.85);
}

.lf-opt.lf-zero {
    opacity: 0.35;
}

.lf-cnt {
    margin-left: 5px;
    font-size: 11px;
    font-style: normal;
    color: #999999;
}

.lf-opt[aria-pressed="true"] .lf-cnt {
    color: #dddddd;
}

.lf-range,
.lf-cond {
    display: flex;
    align-items: center;
    gap: 6px;
}

.lf-root input[type="number"],
.lf-root .lf-rg,
.lf-add,
.lf-esel {
    height: 32px;
    padding: 0 8px;
    font-size: 14px;
    font-family: inherit;
    color: #eeeeee;
    background: #1b1f27;
    border: 1px solid #4a5568;
    border-radius: 6px;
}

.lf-root input[type="number"] {
    width: 76px;
}

select.lf-rg {
    min-width: 110px;
}

.lf-tilde,
.lf-ge,
.lf-unit {
    color: #999999;
}

.lf-hint {
    margin: -3px 0 8px;
    font-size: 12px;
    color: #888888;
}

/* 組內小標(藥效的屬性/抗性/狀態…) */
.lf-sec {
    margin: 8px 0 4px;
    font-size: 12px;
    color: #888888;
}

.lf-gh + .lf-sec,
.lf-hint + .lf-sec {
    margin-top: 0;
}

.lf-conds {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin: 10px 0 8px;
}

.lf-conds:empty {
    display: none;
}

.lf-cond {
    padding: 4px 6px 4px 12px;
    background: rgba(109, 169, 229, 0.15);
    border: 1px solid rgba(171, 205, 239, 0.4);
    border-radius: 8px;
}

.lf-cond-l {
    color: #ffffff;
}

.lf-cond-x {
    width: 28px;
    height: 28px;
    color: #cccccc;
    background: none;
    border: 0;
}

.lf-add,
.lf-esel {
    max-width: 100%;
    margin-top: 2px;
}

.lf-tg {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.lf-tg input {
    width: 18px;
    height: 18px;
    accent-color: #6da9e5;
}

.lf-panel-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 14px;
    border-top: 1px solid #2c333f;
}

.lf-clear,
.lf-done {
    height: 36px;
    padding: 0 16px;
    font-size: 14px;
    border-radius: 8px;
}

.lf-clear {
    color: #dddddd;
    background: none;
    border: 1px solid #4a5568;
}

.lf-done {
    font-weight: bold;
    color: #ffffff;
    background: rgba(109, 169, 229, 0.85);
    border: 1px solid rgba(171, 205, 239, 0.9);
}

/* ── 表格 ── */
.lf-table th.lf-th {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.lf-table th.lf-th:hover,
.lf-table th.lf-th-on {
    color: #f3df00;
}

.lf-table td .lf-pos {
    color: #8fe08f;
}

.lf-dim {
    color: #555555;
}

.lf-m-type {
    display: none;
}

.lf-table tr.lf-sel {
    background: rgba(109, 169, 229, 0.18);
}

.lf-empty td {
    padding: 30px 10px !important;
    text-align: center !important;
    color: #aaaaaa;
}

.lf-pad td {
    padding: 4px !important;
}

/* ── 手機:面板改底部面板、遮罩、固定「顯示 N 筆」──
   .phone 由 MobileDetect 加在 body(同站上其他圖鑑頁) */
.phone .lf-root {
    margin: 0 2% 10px;
}

.phone .lf-bar {
    padding: 8px;
    gap: 6px;
}

.phone .lf-q {
    flex: 1 1 100%;
    font-size: 16px; /* < 16px 時 iOS 會自動放大頁面 */
}

.phone .lf-sortw span {
    display: none;
}

.phone .lf-sort {
    max-width: 120px;
}

.phone .lf-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.phone .lf-chip {
    flex: 0 0 auto;
}

.lf-mask {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 0, 0, 0.55);
}

.phone .lf-panel {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    z-index: 41;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* 電腦不需要遮罩(點面板外面就收起) */
body:not(.phone) .lf-mask {
    display: none;
}

.phone .lf-panel-note {
    display: none;
}

.phone .lf-panel-body {
    display: block;
    padding: 0 14px;
}

.phone .lf-opt {
    padding: 7px 12px;
    font-size: 15px;
}

.phone .lf-root input[type="number"],
.phone .lf-root .lf-rg,
.phone .lf-add,
.phone .lf-esel {
    height: 38px;
    font-size: 16px;
}

.phone .lf-root input[type="number"] {
    width: 84px;
}

.phone .lf-panel-foot {
    gap: 10px;
}

.phone .lf-clear {
    flex: 0 0 auto;
}

.phone .lf-done {
    flex: 1;
    height: 44px;
    font-size: 16px;
}

html.lf-noscroll,
html.lf-noscroll body {
    overflow: hidden;
}

/* 手機表格:類型欄併到名稱下面,省一欄 */
.phone .lf-col-type {
    display: none;
}

.phone .lf-m-type {
    display: inline;
    margin-left: 0;
    font-size: 12px;
    color: #999999;
}

.phone .lf-table td,
.phone .lf-table th {
    padding-left: 6px;
    padding-right: 6px;
}

/* ── 電腦版:工具列捲動時黏在全站導覽列下面(導覽列 sticky,高約 58px)──
   篩選、排序、筆數隨時拿得到。整塊(工具列＋已選條件)墊同一片不透明底,蓋在表格上時字不會透出來 */
body:not(.phone) .lf-root {
    position: sticky;
    top: 58px;
    background: rgba(0, 0, 0, 0.94);
    border-radius: 0 0 12px 12px;
}

body:not(.phone) .lf-bar {
    background: none;
}

body:not(.phone) .lf-chips {
    margin: 0;
    padding: 0 12px 10px;
}

/* 手機:收起鈕靠右 */
.phone .lf-panel-head b {
    flex: 1;
}

/* ===================================================================
   石器外觀(body.lf-stone,寫在模板的 <body> 上;11/17 定案為唯一外觀)
   素材全是站上既有的:
   - 石頭按鈕 /image/filter-btn.png 四顆:粉紅 0%、綠 33%、米色 66%、深灰 100%
     顏色沿用舊篩選鈕的意思 —— 米色＝任一類(type-filter)、綠＝屬性加成(apply-filter)、粉紅＝特性(feature-filter)
   - 木框 /image/eqcalc/frame.png(裝備計算機、連線器面板同一張九宮格;11/16 花崗岩框試過不合適改掉)
   選項晶片長短不一,圖片會被拉扁 → 用 CSS 畫石頭(不規則圓角＋漸層＋深色描邊)模仿那四顆;
   固定大小的大按鈕(篩選、↑)才直接用圖。
   =================================================================== */

/* ── 石板:工具列與篩選面板套花崗岩框 ── */
/* 木框:九宮格 /image/eqcalc/frame.png(裝備計算機、連線器面板同一張;角 32px 顯示一半)。
   ⚠ border 簡寫會把 border-image 重設成 none → 一定要先寫 border、再寫 border-image */
body.lf-stone .lf-root {
    padding: 2px 6px 0;
    /* 木框中間是半透明黑;工具列黏住時蓋在表格上 → 墊不透明底,只墊在框內(框的圓角外保持透明) */
    background: #15100b padding-box;
    border: 16px solid transparent;
    border-image: url('/image/eqcalc/frame.png') 32 fill / 16px round;
    border-radius: 0;
}

body.lf-stone .lf-bar,
body.lf-stone .lf-chips {
    background: none;
    padding-left: 0;
    padding-right: 0;
}

body.lf-stone .lf-panel {
    left: -16px;  /* 對齊工具列木框的外緣(面板定位在工具列框內) */
    right: -16px;
    padding: 0;
    background: #15100b padding-box; /* 木框中間是半透明黑,面板蓋在表格上 → 墊不透明底(只墊框內) */
    border: 16px solid transparent;
    border-image: url('/image/eqcalc/frame.png') 32 fill / 16px round;
    border-radius: 0;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
}

body.lf-stone .lf-panel-head,
body.lf-stone .lf-panel-foot {
    border-color: rgba(201, 164, 92, 0.3);
}

body.lf-stone .lf-g {
    border-bottom-color: rgba(201, 164, 92, 0.2);
}

body.lf-stone .lf-gh {
    color: #ecdcb4;
    text-shadow: 1px 1px 0 #000000;
}

/* 「任一/全部」標籤也做成小石頭,顏色＝那一組選中時的顏色(兼圖例) */
body.lf-stone .lf-gh small {
    display: inline-block;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: bold;
    line-height: 1.3;
    vertical-align: 1px;
    color: #3a2f25;
    border: 1px solid #1a1410;
    border-radius: 10px 12px 9px 11px / 9px 11px 10px 8px;
}

body.lf-stone .lf-g[data-g] .lf-gh small {
    background: linear-gradient(160deg, #e6dccd, #b9ab96);
}

body.lf-stone .lf-g[data-g="feat"] .lf-gh small {
    background: linear-gradient(160deg, #ecc3cf, #c98ea0);
}

/* ── 刻進石頭的輸入框 ── */
body.lf-stone .lf-q,
body.lf-stone .lf-sort,
body.lf-stone .lf-root input[type="number"],
body.lf-stone .lf-root .lf-rg,
body.lf-stone .lf-add,
body.lf-stone .lf-esel {
    color: #f1e8d8;
    background: #1c1814;
    border: 1px solid #000000;
    border-radius: 7px 9px 8px 6px;
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.85), inset -1px -1px 0 rgba(255, 255, 255, 0.07);
}

body.lf-stone .lf-q:focus,
body.lf-stone .lf-root input:focus,
body.lf-stone .lf-root select:focus {
    border-color: #c9a45c;
}

body.lf-stone .lf-q::placeholder {
    color: #8a7e6c;
}

/* ── 固定大小的大按鈕:直接用石頭圖 ── */
body.lf-stone .lf-open,
body.lf-stone .lf-dir {
    height: 38px;
    color: #e8e0d4;
    background: url('/image/filter-btn.png') 100% 0 / 400% 113% no-repeat;
    border: 0;
    text-shadow: 1px 1px 0 #000000;
}

body.lf-stone .lf-open {
    min-width: 96px;
}

body.lf-stone .lf-dir {
    width: 44px;
}

body.lf-stone .lf-is-open .lf-open,
body.lf-stone .lf-open:hover,
body.lf-stone .lf-dir:hover {
    color: #3a2f25;
    background-position: 66.6666% 0;
    text-shadow: none;
}

body.lf-stone .lf-open::before {
    content: "";
}

body.lf-stone .lf-is-open .lf-badge,
body.lf-stone .lf-open:hover .lf-badge {
    color: #7a2a00;
}

/* ── 選項晶片:CSS 石頭(長短都不變形)──
   沒選＝深灰石;選了依種類:任一＝米色、屬性＝綠、全部＝粉紅(同舊篩選鈕) */
body.lf-stone .lf-opt,
body.lf-stone .lf-chip {
    color: #e8e0d4;
    background: linear-gradient(160deg, #7d736a 0%, #5d544c 55%, #433b35 100%);
    border: 2px solid #15110d;
    /* 圓角用固定 px、不用 %:% 會跟著寬度放大,字多的鈕就被拉成細長的橄欖形(11/17 使用者回饋)。
       px 讓短的鈕仍是圓滾滾的石頭,長的變成邊緣不規則的扁石板 */
    border-radius: 15px 19px 14px 17px / 14px 12px 16px 13px;
    box-shadow:
        inset 2px 2px 0 rgba(255, 255, 255, 0.16),
        inset -2px -3px 0 rgba(0, 0, 0, 0.35),
        1px 2px 0 rgba(0, 0, 0, 0.55);
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.7);
}

/* 每顆形狀稍微不一樣,像一堆撿來的石頭 */
body.lf-stone .lf-opt:nth-child(3n+2),
body.lf-stone .lf-chip:nth-child(3n+2) {
    border-radius: 19px 14px 17px 15px / 12px 16px 13px 15px;
}

body.lf-stone .lf-opt:nth-child(3n),
body.lf-stone .lf-chip:nth-child(3n) {
    border-radius: 16px 18px 20px 13px / 15px 13px 14px 16px;
}

body.lf-stone .lf-opt:hover {
    color: #ffffff;
    border-color: #000000;
    filter: brightness(1.15);
}

body.lf-stone .lf-opt[aria-pressed="true"],
body.lf-stone .lf-chip {
    text-shadow: none;
    font-weight: bold;
}

/* 任一(類型、主材質…)＝米色 */
body.lf-stone .lf-opt.lf-k-enum[aria-pressed="true"],
body.lf-stone .lf-chip.lf-k-enum {
    color: #2e261e;
    background: linear-gradient(160deg, #eee5d8 0%, #c9bca8 55%, #a8987f 100%);
}

/* 屬性加成＝綠 */
body.lf-stone .lf-opt.lf-k-stats[aria-pressed="true"],
body.lf-stone .lf-chip.lf-k-stats {
    color: #0b3b1a;
    background: linear-gradient(160deg, #cfe2d3 0%, #a6c2ad 55%, #7f9d88 100%);
}

/* 全部(特性)＝粉紅 */
body.lf-stone .lf-opt.lf-k-flags[aria-pressed="true"],
body.lf-stone .lf-chip.lf-k-flags {
    color: #5a0f22;
    background: linear-gradient(160deg, #f1cdd7 0%, #d8a2b2 55%, #b97d8f 100%);
}

/* 區間、開關、搜尋字串的已選晶片＝深灰石 */
body.lf-stone .lf-chip.lf-k-range,
body.lf-stone .lf-chip.lf-k-toggle,
body.lf-stone .lf-chip.lf-k-q {
    color: #f1e8d8;
    font-weight: normal;
}

body.lf-stone .lf-opt[aria-pressed="true"] .lf-cnt {
    color: inherit;
    opacity: 0.7;
}

body.lf-stone .lf-cnt {
    color: #c7bba8;
}

body.lf-stone .lf-opt.lf-zero {
    opacity: 0.3;
}

body.lf-stone .lf-chip:hover {
    filter: brightness(1.1);
}

body.lf-stone .lf-chip-clear {
    color: #ecdcb4;
    font-weight: normal;
    background: none;
    border: 1px dashed rgba(201, 164, 92, 0.6);
    border-radius: 10px;
    box-shadow: none;
}

/* 屬性條件列:綠色石板 */
body.lf-stone .lf-cond {
    background: rgba(166, 194, 173, 0.13);
    border: 1px solid rgba(166, 194, 173, 0.45);
    border-radius: 10px 14px 12px 9px;
}

/* ── 面板底部:清除＝虛線、顯示 N 筆＝米色石 ── */
body.lf-stone .lf-clear {
    color: #ecdcb4;
    border: 1px dashed rgba(201, 164, 92, 0.6);
}

body.lf-stone .lf-done {
    color: #2e261e;
    background: linear-gradient(160deg, #eee5d8 0%, #c9bca8 55%, #a8987f 100%);
    border: 2px solid #15110d;
    border-radius: 18px 24px 20px 16px / 20px 16px 24px 18px;
    box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.35), inset -2px -3px 0 rgba(0, 0, 0, 0.25), 1px 2px 0 rgba(0, 0, 0, 0.55);
}

body.lf-stone .lf-done:hover {
    filter: brightness(1.08);
}

body.lf-stone .lf-tg input {
    accent-color: #c9a45c;
}

/* 藍色換成站上的金褐/琥珀 */
body.lf-stone .lf-table tr.lf-sel {
    background: rgba(201, 164, 92, 0.2);
}

body.lf-stone .lf-hits {
    color: #c7bba8;
}

/* ── 手機:木框改細(10px),底部面板的下緣貼齊螢幕不畫框 ── */
body.lf-stone.phone .lf-root {
    padding: 0 2px;
    border-width: 10px;
    border-image-width: 10px;
}

body.lf-stone.phone .lf-panel {
    left: 0;
    right: 0;
    border-width: 10px 10px 0;
    border-image-width: 10px 10px 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* 下拉旁的「看一覽」連結(動物頁的寵物技能) */
.lf-more {
    margin-left: 8px;
    font-size: 13px;
    white-space: nowrap;
    color: #8ab4f8;
}

body.lf-stone .lf-more {
    color: #e0c27e;
}

/* 藥水頁:表格裡直接列藥效(主/交互各一行),選中的藥效加亮 */
.lf-table td.lf-eff-td {
    text-align: left;
}

.lf-effs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px 6px;
    margin: 2px 0;
    font-size: 13px;
    line-height: 1.5;
}

.lf-eff-tag {
    font-size: 12px;
    font-weight: bold;
}

.lf-eff {
    white-space: nowrap;
}

.lf-eff-pos {
    color: #8fe08f;
}

.lf-eff-neg {
    color: #ff8a8a;
}

.lf-eff-hit {
    padding: 0 4px;
    border-radius: 4px;
    outline: 1px solid currentColor;
    font-weight: bold;
}

/* 藥水頁:終點方向排成九宮格(選項順序 = 左上、上、右上、左、原點、右、左下、下、右下) */
.lf-g[data-g="end"] .lf-opts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-width: 330px;
}

.lf-g[data-g="end"] .lf-opt {
    text-align: center;
    white-space: nowrap;
}
