/* style.css */
:root {
    --bg: #ffffff;
    --panel: rgb(246, 246, 246);
    --border: rgb(203, 203, 203);
    --text: rgb(29, 29, 29);
    --muted: rgb(62, 62, 62);
    --accent: #2380e5;
    --danger: #e52d23;

    --cell-w-em: 2;
    --cell-h-em: 1.4486;
}

html,
body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    overflow: hidden;
    /* font-family: Arial, Helvetica, 'WikilauidL700mapServiceFont', '源樣黑體', system-ui, -apple-system, 'GenYoGothic', "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; */
    color: var(--text);
}

html[data-lang="zh-hant"] body {
    font-family: Arial, Helvetica, 'WikilauidL700mapServiceFont', '源樣黑體', system-ui, -apple-system, 'GenYoGothic', "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

html[data-lang="jp"] body {
    font-family: Arial, Helvetica, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif, 'WikilauidL700mapServiceFont', '源樣黑體';
}

html[data-lang="en-us"] body {
    font-family: Arial, Helvetica, system-ui, sans-serif;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    cursor: grab;
    user-select: none;
}

canvas.panning {
    cursor: grabbing;
}

.footer {
    text-align: end;
    font-weight: 400;
    font-size: 90%;
}

a {
    color: rgb(35, 128, 229);
    text-decoration: none;
}

/* 右上角小提示 */
.hud {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 12px;
    right: 12px;
    background: rgb(255, 255, 255);
    border: 1px solid rgb(198, 198, 198);
    backdrop-filter: blur(10px);
    padding: 10px 12px;
    border-radius: 2px;
    font-size: 12px;
    line-height: 1.4;
    max-width: 380px;
    pointer-events: auto;
    /* 需要能點按鈕 */
}



/* ===== HUD 展開/收起按鈕 ===== */
.hud-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 50px;
    height: 22px;
}

.hud-title {
    display: flex;
    align-items: center;
    min-width: 0;
}

.hud-toggle {
    appearance: none;
    border: none !important;
    background: transparent !important;
    padding: 2px;
    margin: 0;
    cursor: pointer;
    color: #000;
    line-height: 0;
}

.hud-toggle-icon {
    width: 22px;
    height: 22px;
    display: block;
}

.hud.collapsed {
    padding-bottom: 8px;
}

.hud-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hud.collapsed .hud-body {
    display: none;
}

/* 收起時把箭頭翻轉成向下 */
.hud.collapsed .hud-toggle-icon {
    transform: rotate(180deg);
}


.hud b {
    color: #1a1a1a;
}

.hud .hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

.hud .rowline {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgb(220, 220, 220);
}

.hud button {
    appearance: none;
    border: 1px solid rgb(198, 198, 198);
    background: rgb(246, 246, 246);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 2px;
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
}

.hud button:hover {
    border-color: rgb(160, 160, 160);
}

.hud button.primary {
    background: rgba(35, 128, 229, 0.10);
    border-color: rgba(35, 128, 229, 0.45);
}

/* ===== HUD 分頁切換 ===== */
.hud-tabs {
    display: flex;
    height: 28px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.hud-tab-btn {
    font-weight: 400;
    background-color: #fff !important;
    border: 0px !important;
    flex: 0 0 auto;
}

.hud-tab-btn.active {
    font-weight: 600;
}

.hud-tabpanels {
    margin-top: 5px;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
}

/* 面板內容沿用 rowline 的分隔線，但第一塊不要多一條上邊線 */
.hud-panel-inner.rowline {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.hud-fixed {
    margin-top: 8px;
}

.hud code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace, 'GenYoGothic';
    font-size: 11px;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.307);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal {
    box-sizing: border-box;
    width: min(520px, calc(100vw - 24px));
    background: var(--panel);
    border: 1px solid rgb(216, 216, 216);
    border-radius: 3px;
    box-shadow: 0 15px 60px rgba(0, 0, 0, 0.157);
    overflow: hidden;
}

.modal header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.modal header .title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.modal header button {
    appearance: none;
    border: 1px solid rgb(190, 190, 190);
    background: transparent;
    color: var(--text);
    padding: 6px 10px;
    border-radius: 2px;
    cursor: pointer;
}

.modal header button:hover {
    border-color: rgb(150, 150, 150);
}

.modal .content {
    padding: 14px 16px 16px;
    display: grid;
    gap: 12px;
}

.row {
    display: grid;
    gap: 6px;
}

label {
    font-size: 12px;
    color: var(--muted);
}

input[type="text"] {
    box-sizing: border-box;
    max-width: 100%;
    width: 100%;
    padding: 10px 12px;
    border-radius: 3px;
    border: 1px solid rgb(199, 199, 199);
    background: rgb(242, 242, 242);
    color: var(--text);
    outline: none;
    font-size: 14px;
}

input[type="text"]:focus {
    border-color: rgba(35, 128, 229, 0.65);
    box-shadow: 0 0 0 3px rgba(35, 128, 229, 0.15);
}

.modal footer {
    display: flex;
    gap: 10px;
    padding: 12px 16px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    flex-wrap: wrap;
}

.btn {
    appearance: none;
    border: 1px solid rgb(198, 198, 198);
    background: rgb(255, 255, 255);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 2px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
}

.btn:hover {
    border-color: rgb(160, 160, 160);
}

.btn.primary {
    background: rgba(35, 128, 229, 0.12);
    border-color: rgba(35, 128, 229, 0.45);
}

.btn.danger {
    background: rgba(229, 45, 35, 0.12);
    border-color: rgba(229, 45, 35, 0.45);
}

.hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: -4px;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* ===== 圖號專用樣式 ===== */
.input-mapno {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    padding-left: 0;
    padding-right: 0;
    font-weight: 400;
}

/* 防止 input 超出 modal 寬度 */
.modal .content input[type="text"] {
    box-sizing: border-box;
    max-width: 100%;
}

/* 圖號（只讀）特殊樣式：透明背景/邊界 */
.mapno-field .mapno-input {
    background: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    padding-left: 0;
    padding-right: 0;
}

.mapno-field .mapno-input:focus {
    border-color: transparent !important;
    box-shadow: none !important;
}

/* ===== 經緯度即時提示 ===== */
.coord-tip {
    position: fixed;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 12px;
    padding: 4px 6px;
    border-radius: 2.5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    white-space: nowrap;
    z-index: 100;
    display: none;
    line-height: 1.25;
    white-space: pre-line;
}

/* ===== 搜尋列（Ctrl/Cmd+F）===== */
.searchbar {
    position: fixed;
    top: 10px;
    left: 12px;
    right: 12px;
    z-index: 80;
    display: none;
    pointer-events: none;
}

.searchbar[aria-hidden="false"] {
    display: block;
}

.searchbar-inner {
    width: min(980px, calc(100vw - 24px));
    margin: 0 auto;
    display: flex;
    gap: 10px;
    align-items: center;
    pointer-events: auto;
}

.searchbar-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 12px 14px;
    border-radius: 3px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    outline: none;
    font-size: 16px;
}

.searchbar-input:focus {
    border-color: rgba(35, 128, 229, 0.65);
    box-shadow: 0 0 0 3px rgba(35, 128, 229, 0.15);
}

.searchbar-btn {
    appearance: none;
    border: 1px solid var(--border);
    background: rgb(246, 246, 246);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
}

.searchbar-btn:hover {
    border-color: rgb(160, 160, 160);
}

.searchbar-btn.primary {
    background: rgba(35, 128, 229, 0.12);
    border-color: rgba(35, 128, 229, 0.45);
}

/* ===== 搜尋對話框（Cmd/Ctrl+F）===== */
/* 需求：至少要有一個 div.modal 包住，並且 input / 搜尋 / 關閉 高度一致 */
.search-modal-backdrop {
    position: fixed;
    top: 10px;
    left: 12px;
    right: 12px;
    z-index: 80;
    display: none;
    pointer-events: none;
}

.search-modal-backdrop[aria-hidden="false"] {
    display: block;
}

.search-modal {
    width: min(980px, calc(100vw - 24px));
    margin: 0 auto;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
    border-color: var(--border);
}

.search-modal-body {
    display: flex;
    gap: 10px;
    align-items: stretch;
    /* 讓 input / button 同高 */
    padding: 10px 10px;
}

.search-modal .searchbar-input,
.search-modal .searchbar-btn {
    height: 44px;
    padding-top: 0;
    padding-bottom: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-modal .searchbar-input {
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.92);
}

.search-modal .searchbar-btn {
    min-width: 84px;
}

.search-modal .searchbar-btn[title*="關閉"] {
    min-width: 44px;
    width: 44px;
    font-size: 22px;
    font-weight: 700;
    padding-left: 0;
    padding-right: 0;
}

@font-face {
    font-family: "WikilauidL700mapServiceFont";
    src:
        url("https://wiki.lilauid.com/fonts/WikilauidL700mapServiceFont.woff2") format("woff2"),
        url("https://wiki.lilauid.com/fonts/WikilauidL700mapServiceFont.woff") format("woff");
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}


/* ===== 語言切換（原生 select 無邊界樣式）===== */
.lang-switcher {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    border: none;
    background: transparent;
    padding: 0;
    margin-left: 8px;

    font-size: 12px;
    color: #555;
    cursor: pointer;
}

.lang-switcher:focus {
    outline: none;
}

/* ===== 語言切換 ===== */
.lang-switcher {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    border: none;
    background: transparent;
    padding: 0;
    margin-left: 10px;

    font-size: 11px;
    color: #555;
    cursor: pointer;
}

.lang-switcher:focus {
    outline: none;
}