/* PoE 2 宅道場 前台樣式：直式內容主欄、低飽和配色、深淺主題 */
:root {
    --bg: #f4f2ee;
    --surface: #ffffff;
    --surface-2: #ebe7e0;
    --text: #23211d;
    --muted: #6b665d;
    --border: #d8d2c7;
    --accent: #8a5a24;
    --accent-ink: #ffffff;
    --link: #7a4a14;
    --notice-bg: #fbf1dc;
    --gem-r: #b24a3c;
    --gem-g: #4e8a3e;
    --gem-b: #3d63a8;
    --gem-w: #8b8b8b;
    --radius: 8px;
    --wrap: 1080px;
    --wide: 1440px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #15130f;
        --surface: #1e1b16;
        --surface-2: #29251e;
        --text: #e9e3d7;
        --muted: #a39b8c;
        --border: #3a342a;
        --accent: #c8954f;
        --accent-ink: #15130f;
        --link: #dcae6c;
        --notice-bg: #33291a;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #15130f;
    --surface: #1e1b16;
    --surface-2: #29251e;
    --text: #e9e3d7;
    --muted: #a39b8c;
    --border: #3a342a;
    --accent: #c8954f;
    --accent-ink: #15130f;
    --link: #dcae6c;
    --notice-bg: #33291a;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.65 system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", "Hiragino Sans", "Noto Sans JP", sans-serif;
}
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1 { font-size: 1.75rem; line-height: 1.3; margin: .4em 0 .3em; }
h2 { font-size: 1.2rem; margin: 1.6em 0 .5em; }
h3 { font-size: 1.05rem; }
code { font-size: .9em; background: var(--surface-2); padding: 0 .3em; border-radius: 4px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5em 1em; z-index: 10; }
.skip-link:focus { left: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 8px; padding-bottom: 48px; min-height: 60vh; }
main.wide { max-width: var(--wide); }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 6px; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.main-nav a { color: var(--text); text-decoration: none; padding: 4px 10px; border-radius: 6px; }
.main-nav a:hover, .main-nav a[aria-current="page"] { background: var(--surface-2); }
.header-tools { display: flex; gap: 8px; align-items: center; }
.lang-switch, .theme-toggle { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font: inherit; font-size: .9rem; }
.theme-toggle { cursor: pointer; }

.site-search { position: relative; display: flex; gap: 8px; padding: 6px 0 12px; }
.site-search input { flex: 1; min-width: 0; font: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); }
.site-search button, .filters button, .btn, .tree-toolbar button {
    font: inherit; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--radius); padding: 8px 16px; cursor: pointer; text-decoration: none; display: inline-block;
}
.suggest { position: absolute; top: 100%; left: 0; right: 0; margin: -6px 0 0; padding: 4px 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); z-index: 20; box-shadow: 0 6px 20px rgb(0 0 0 / .15); }
.suggest li a { display: flex; justify-content: space-between; gap: 12px; padding: 6px 12px; color: var(--text); text-decoration: none; }
.suggest li a:hover, .suggest li a.active { background: var(--surface-2); }

/* Common blocks */
.hero { padding: 24px 0 8px; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 68ch; }
.breadcrumb { font-size: .875rem; color: var(--muted); margin-top: 12px; }
.data-meta { color: var(--muted); font-size: .9rem; margin-top: 0; }
.notice { background: var(--notice-bg); border-left: 3px solid var(--accent); padding: 8px 12px; border-radius: 4px; }
.empty { color: var(--muted); padding: 24px 0; }
.badge { display: inline-block; font-size: .72rem; line-height: 1.5; padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); vertical-align: middle; }

.card-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card > a, .card-disabled { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; height: 100%; color: var(--text); text-decoration: none; }
.card > a:hover { background: var(--surface-2); border-radius: var(--radius); }
.card-title { font-weight: 600; }
.card-meta, .card-desc { color: var(--muted); font-size: .875rem; }
.card-disabled { opacity: .65; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 12px 0 16px; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 2px; }
.filters input, .filters select, .tree-toolbar select, .tree-toolbar input { font: inherit; font-size: .95rem; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); min-width: 140px; max-width: 100%; }
.btn-link { align-self: center; font-size: .9rem; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: .95rem; }
.data-table th, .data-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { background: var(--surface-2); font-weight: 600; font-size: .85rem; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table.compact th, .data-table.compact td { padding: 5px 10px; font-size: .9rem; }

.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 20px 0; }

.gem { display: inline-block; min-width: 1.6em; text-align: center; border-radius: 4px; color: #fff; font-size: .8rem; font-weight: 700; padding: 0 4px; background: var(--gem-w); }
.gem-r { background: var(--gem-r); } .gem-g { background: var(--gem-g); } .gem-b { background: var(--gem-b); }

/* Entity page */
.entity-head .eyebrow { margin: 16px 0 0; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.alt-name { margin: 0; color: var(--muted); }
.entity-desc p { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; word-break: break-word; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.internal-types { margin-top: 6px; }
.internal-types summary { cursor: pointer; }
.internal-types code { display: block; margin-top: 4px; white-space: normal; word-break: break-word; }
.tag { font-size: .8rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.link-list { columns: 2 220px; padding-left: 1.2em; }
.link-list li { break-inside: avoid; }
.entity-source { margin-top: 32px; border-top: 1px solid var(--border); font-size: .9rem; }
.entity-facts .summary { font-size: 1.02rem; max-width: 72ch; margin-bottom: 4px; }
.entity-faq .faq { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin: 0; }
.entity-faq .faq dt { font-weight: 600; }
.entity-faq .faq dt:not(:first-child) { margin-top: 12px; }
.entity-faq .faq dd { margin: 4px 0 0; }
.prose { max-width: 80ch; }
.prose li + li { margin-top: 4px; }
.result-list { list-style: none; padding: 0; }
.result-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.patch { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px 12px; margin-bottom: 12px; }

.item-mods { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; text-align: center; }
.item-mods p { margin: 0; }
.item-mods .implicit { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.item-mods .explicit { color: var(--link); }

/* Passive tree */
.tree-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 8px; }
.tree-toolbar label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 2px; }
.tree-toolbar .grow { flex: 1; min-width: 180px; }
.tree-toolbar .grow input { width: 100%; }
.tree-points { align-self: center; }
.tree-stage { position: relative; height: min(75vh, 820px); min-height: 380px; background: #0d0c0a; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; touch-action: none; }
.tree-stage canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.tree-stage canvas.dragging { cursor: grabbing; }
.tree-tooltip { position: absolute; pointer-events: none; max-width: 320px; background: rgb(20 18 14 / .95); color: #eee4d2; border: 1px solid #5b4a2f; border-radius: 6px; padding: 8px 10px; font-size: .85rem; line-height: 1.45; z-index: 5; }
.tree-tooltip strong { color: #f0c27a; display: block; margin-bottom: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.lg-normal { background: #8d8576; } .lg-notable { background: #d8a24a; } .lg-keystone { background: #e05d3d; } .lg-jewel { background: #59a6c9; } .lg-asc { background: #a77bd6; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 16px 0 24px; font-size: .85rem; }

@media (max-width: 640px) {
    h1 { font-size: 1.4rem; }
    .header-row { gap: 8px; }
    .main-nav { order: 3; flex-basis: 100%; }
    .props { grid-template-columns: 1fr; }
    .props dt { font-weight: 600; }
    .filters input, .filters select { min-width: 0; width: 100%; }
    .filters label { flex: 1 1 140px; }
}

/* 技能搭配檢查 */
.gem-head h2 { display: flex; align-items: center; gap: 8px; }
.gem-filter { width: 100%; font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); margin: 8px 0; }
.gem-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 16px; }
.gem-list li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 0; border-bottom: 1px solid var(--border); }
.gem-action { margin-left: auto; font-size: .85rem; }
.gem-incompatible { margin-top: 24px; }
.gem-incompatible summary { cursor: pointer; font-weight: 600; font-size: 1.1rem; }
.tag-added { border-style: dashed; color: var(--link); }
.tag-bad { border-color: #b24a3c; }
.badge-good { color: var(--link); border-color: var(--link); }
.linklike { background: none; border: 0; padding: 0; color: var(--link); text-decoration: underline; cursor: pointer; font: inherit; }
#gem-result[aria-busy="true"] { opacity: .6; }

/* 圖示 */
.entity-link { display: inline-flex; align-items: center; gap: 8px; }
.icon { object-fit: contain; image-rendering: auto; }
.icon-sm { width: auto; height: 32px; max-width: 48px; }
.icon-lg { float: right; width: auto; max-height: 160px; max-width: 120px; margin: 12px 0 8px 16px; }
@media (max-width: 640px) { .icon-lg { max-height: 96px; } }

.tree-limit input { width: 80px; min-width: 0; }
.tree-points .over-limit, .tree-points strong.over-limit { color: #e05d3d; }
.tree-cost { color: #7fd3ff; margin-top: 4px; }

/* 官方公告內文 */
.patch-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 20px; overflow-wrap: anywhere; }
.patch-body ul { padding-left: 1.3em; }
.patch-body li { margin: 3px 0; }
.patch-body h3, .patch-body h4 { margin-top: 1.2em; }
.patch-body table { border-collapse: collapse; }
.patch-body td, .patch-body th { border: 1px solid var(--border); padding: 4px 8px; }
