/* ═══════════════════════════════════════════════════════════════════════
   全站可讀性與個人化顯示設定（2026-11-10 介面優化）。兩個版型都載入。
   搭配 js/ui-config.js（Tailwind 字級表）與 js/ui-prefs.js（字級、我的最愛）。
   規則與理由見 docs/CONVENTIONS.md 第 5 節「字級與可讀性」。
   ═══════════════════════════════════════════════════════════════════════ */

/* ── 字級倍率：個人中心「字級」（存手機 localStorage 'wn-fs'，標準是預設） ── */
:root { --fs: 1; }
html[data-fs="l"]  { --fs: 1.125; }
html[data-fs="xl"] { --fs: 1.25; }

/* ── 可讀性底線：舊頁面寫死的小字一律拉到 text-xs（14px×字級）。圖示（Material Symbols）不動 ──
   選擇器前面加 html 是為了贏過 Tailwind CDN 後插入的同名 class。新程式不要再寫小於 text-xs 的字。 */
html :is(.text-\[9px\], .text-\[10px\], .text-\[11px\], .text-\[12px\], .text-\[13px\]):not(.material-symbols-outlined) {
    font-size: calc(0.875rem * var(--fs));
}
html .text-\[15px\]:not(.material-symbols-outlined) { font-size: calc(1rem * var(--fs)); }
html .text-\[17px\]:not(.material-symbols-outlined) { font-size: calc(1.0625rem * var(--fs)); }

/* ── 主色：#ec5b13 當小字或白字底色時對比只有 3.5:1（工地日照下看不清楚）。
   文字與實心底改用加深一階的 #c2410c（5.2:1）；圖示、框線、淡底（bg-primary/10）維持亮橘。
   新程式可以直接寫 text-ink／bg-ink（ui-config.js 有這個顏色）。 */
html .text-primary:not(.material-symbols-outlined) { color: #c2410c; }
html .bg-primary { background-color: #c2410c; }
html .hover\:bg-primary\/90:hover { background-color: #9a3412; }

/* ── 表格：字放大後手機上欄位變窄，欄位標題會被擠成一字一行（人員清點報表實測）。
   外層本來就是 overflow-x-auto 的表格（全站幾乎都是），標題與標籤徽章改成不換行，讓表格變寬、左右捲。 */
.overflow-x-auto > table th { white-space: nowrap; }
.overflow-x-auto > table td :is(span.rounded, span.rounded-md, span.rounded-lg, span.rounded-full) { white-space: nowrap; }

/* ═══════════════ 我的最愛（Pages/Shared/_FavBar.cshtml＋js/ui-prefs.js） ═══════════════
   2026-11-11 起：平常只在畫面左邊露出橘色把手（A 邊緣把手），點了從左邊滑出抽屜（側邊抽屜），使用者看 demo 選的。
   版面關鍵樣式寫在這裡、不用 Tailwind class：內容是 JS 產生的，不賭 CDN 一定會生出樣式。
   這幾個元素用 hidden 屬性切換；這裡的 display:flex 會蓋過瀏覽器預設的 [hidden]，所以只對它們補 !important
  （不做全站的 [hidden] 規則，免得改變既有頁面的行為）。
   疊層：把手 40（頁首與各頁彈窗是 z-50 以上，會蓋過它）→ 遮罩 55／抽屜 56（蓋過頁首）→ 編輯浮層 z-[60]。 */
[data-wn-fav-handle][hidden], [data-wn-fav-scrim][hidden], [data-wn-fav-drawer][hidden],
[data-wn-fav-sheet][hidden], [data-wn-fav-off][hidden] { display: none !important; }
/* 把手：寬 30px，剛好落在頁面左邊 16px 留白＋卡片內距裡，不蓋到字。高度（top）由 JS 依使用者拖到的位置算 */
.wn-fav-handle {
    position: fixed; left: 0; top: 50%; z-index: 40;
    display: flex; align-items: center; justify-content: center;
    width: 30px; height: 76px; padding: 0; border: 0; border-radius: 0 16px 16px 0;
    background: #c2410c; color: #fff; box-shadow: 2px 3px 10px -3px rgba(124, 45, 18, .55);
    cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.wn-fav-handle:active { background: #9a3412; }
.wn-fav-handle.is-drag { box-shadow: 0 12px 26px -6px rgba(15, 23, 42, .55); }
.wn-fav-handle:focus-visible { outline: 3px solid #c2410c; outline-offset: 3px; }
.wn-fav-handle .material-symbols-outlined { font-size: calc(24px * min(var(--fs), 1.125)); font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.wn-fav-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 42, .45); touch-action: none; }
.wn-fav-drawer {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 56; width: min(82%, 320px);
    display: flex; flex-direction: column; background: #fff; box-shadow: 8px 0 28px -12px rgba(15, 23, 42, .5);
    transform: translateX(-100%); transition: transform .22s ease-out; touch-action: pan-y;
}
.wn-fav-drawer.is-in { transform: none; }
.wn-fav-drawer.is-swipe { transition: none; }
.wn-fav-dhd { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 0 6px 0 16px; border-bottom: 1px solid #e2e8f0; }
.wn-fav-dhd h2 {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; margin: 0;
    font-size: calc(1.1875rem * var(--fs)); line-height: 1.3; font-weight: 700; color: #0f172a;
}
.wn-fav-dhd h2 .material-symbols-outlined { font-size: calc(24px * min(var(--fs), 1.125)); color: #ec5b13; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.wn-fav-x {
    display: flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px;
    border: 0; border-radius: 9999px; background: none; color: #334155; cursor: pointer;
}
.wn-fav-x:hover { background: #f1f5f9; }
.wn-fav-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 2px; padding: 8px; }
.wn-fav-row {
    display: flex; align-items: center; gap: 14px; flex: none; min-height: 56px; padding: 6px 12px; border-radius: 12px;
    color: #1e293b; text-decoration: none; font-size: calc(1.0625rem * var(--fs)); line-height: 1.35; font-weight: 500;
    -webkit-tap-highlight-color: transparent;
}
.wn-fav-row:hover { background: #f8fafc; }
.wn-fav-row .material-symbols-outlined { flex: none; font-size: calc(24px * min(var(--fs), 1.125)); color: #ec5b13; font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.wn-fav-name { min-width: 0; }
.wn-fav-row[aria-current="page"] { background: #fff7ed; color: #c2410c; font-weight: 700; }
.wn-fav-row[aria-current="page"] .material-symbols-outlined { color: #c2410c; }
.wn-fav-empty { margin: 0; padding: 12px; font-size: calc(1rem * var(--fs)); line-height: 1.6; color: #475569; }
.wn-fav-dft { padding: 12px 16px; border-top: 1px solid #e2e8f0; }
/* iOS 主畫面 App：沒開 viewport-fit=cover 時 env(safe-area-inset-bottom) 是 0，
   但畫面照樣延伸到 Home 指示條（見 CONVENTIONS「貼齊螢幕四邊的全螢幕頁」），自己讓開 */
.wn-ios-pwa .wn-fav-dft { padding-bottom: 32px; }
.wn-fav-editbtn {
    display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 52px;
    border: 1.5px solid #c2410c; border-radius: 9999px; background: #fff; color: #c2410c;
    font-size: calc(1.0625rem * var(--fs)); font-weight: 700; cursor: pointer;
}
.wn-fav-editbtn:hover { background: #fff7ed; }
.wn-fav-editbtn .material-symbols-outlined { font-size: calc(22px * min(var(--fs), 1.125)); }
.wn-fav-row:focus-visible, .wn-fav-x:focus-visible, .wn-fav-editbtn:focus-visible { outline: 3px solid #c2410c; outline-offset: -3px; }

/* 首頁磁磚名稱：最長 5 個字（領料／歸還），360px 寬三欄在特大字級會從字中間斷行，所以放大到 1.15 倍就停 */
.wn-tile-lbl { font-size: calc(1rem * min(var(--fs), 1.15)); line-height: 1.3; }

/* ═══════════════ 個人中心「顯示設定」 ═══════════════ */
.wn-switch { position: relative; flex: none; width: 52px; height: 32px; border-radius: 9999px; background: #94a3b8; transition: background .15s; }
.wn-switch::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 9999px;
    background: #fff; box-shadow: 0 1px 3px rgba(15, 23, 42, .35); transition: transform .15s;
}
[aria-checked="true"] > .wn-switch { background: #c2410c; }
[aria-checked="true"] > .wn-switch::after { transform: translateX(20px); }
.wn-fs-pick { min-height: 52px; border: 2px solid #cbd5e1; border-radius: 12px; background: #fff; color: #0f172a; font-weight: 700; cursor: pointer; }
.wn-fs-pick[aria-pressed="true"] { border-color: #ec5b13; background: #fff7ed; color: #c2410c; }

@media (prefers-reduced-motion: reduce) {
    .wn-switch, .wn-switch::after, .wn-fav-drawer { transition: none; }
}

/* 兩欄的表單格（收工回報作業列、日期起訖等）：字級放大到兩欄塞不下時自動改一欄，最多兩欄（間距最大 gap-3）；
   col-span-2 的欄位一律整列。用法：class="wn-grid-2"（不必再加 grid／grid-cols-2）。 */
.wn-grid-2{display:grid;gap:.5rem;grid-template-columns:repeat(auto-fit,minmax(max(calc(8rem * var(--fs,1)),calc(50% - .375rem)),1fr))}
.wn-grid-2 > .col-span-2{grid-column:1 / -1}

/* 後台（_AdminLayout 的 <main>）的表格：手機寬度時欄位會被擠成一字一行（例：「排序」直排）。
   表格至少 32rem 寬（隨字級放大），直接包住表格的那層改成可左右捲；標題不換行。
   已經自己寫 min-w-[…] 的表格照它自己的寬度。 */
.wn-admin-main :has(> table) { overflow-x: auto; }
.wn-admin-main table th { white-space: nowrap; }
.wn-admin-main td :is(button, a, span.rounded, span.rounded-md, span.rounded-lg, span.rounded-full) { white-space: nowrap; }
:where(.wn-admin-main) table:not([class*="min-w-"]) { min-width: calc(32rem * var(--fs, 1)); }
