/* 通用狀態元件（規格頁 states.html）：讀取、頁面內提醒、欄位錯誤、確認對話框、空狀態、錯誤頁、連線中斷、登入逾時。
   各頁一律用這裡的 class，不在頁面裡手刻。Toast 在 ui.css。 */

/* ---------- 讀取：滾筒（品牌讀取圖示） ---------- */
.ld-drum { --s: 44px; position: relative; width: var(--s); height: var(--s); border-radius: 50%; display: inline-block; flex: none;
  background: radial-gradient(circle at 32% 28%, #FFFFFF, #DCE3EB 55%, #AEB8C4); box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .18), 0 2px 6px rgba(18, 26, 38, .18); }
.ld-drum::before { content: ""; position: absolute; inset: 16%; border-radius: 50%; background: #0F2232; box-shadow: inset 0 0 0 2px #3B4452; overflow: hidden; }
.ld-drum i { position: absolute; inset: 16%; border-radius: 50%; overflow: hidden; }
.ld-drum i::before { content: ""; position: absolute; left: -30%; right: -30%; top: 48%; bottom: -40%; border-radius: 42% 46% 40% 48%; background: linear-gradient(180deg, #5DB8F5, #1C8CDB); animation: drum-water 1.6s linear infinite; transform-origin: 50% 0; }
.ld-drum i::after { content: ""; position: absolute; width: 22%; height: 22%; left: 28%; top: 30%; border-radius: 40%; background: #EEF3F8; opacity: .9; animation: drum-cloth 1.6s linear infinite; transform-origin: 90% 90%; }
@keyframes drum-water { 0% { transform: rotate(0); } 100% { transform: rotate(360deg); } }
@keyframes drum-cloth { 0% { transform: rotate(0) translateX(0); } 100% { transform: rotate(360deg) translateX(0); } }
.ld-drum.sm { --s: 20px; }
.ld-drum.lg { --s: 88px; }
@media (prefers-reduced-motion: reduce) { .ld-drum i::before, .ld-drum i::after { animation: none; } }

/* 全螢幕讀取（只用在登入後進總覽） */
.st-full { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(4px); }
.st-full .in { display: grid; justify-items: center; gap: 14px; color: var(--ink-2); font-weight: 600; }

/* 內容區讀取：蓋在內容區上，側欄與頁首不動 */
.st-area { position: relative; min-height: 160px; }
/* 不用旋轉圖示：上方一條細線來回跑（同登入中「極簡細線」），內容變淡，右上角小字「讀取中」 */
.st-area > .st-cover { position: absolute; inset: 0; z-index: 2; border-radius: inherit; background: color-mix(in srgb, var(--surface) 55%, transparent); pointer-events: none; }
.st-area > .st-cover .st-line { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--line); overflow: hidden; }
.st-area > .st-cover .st-line::after { content: ""; position: absolute; top: 0; bottom: 0; width: 30%; background: var(--brand); animation: fs-sweep2 1.1s ease-in-out infinite; }
.st-area > .st-cover .st-tag { position: absolute; top: 8px; right: 10px; font-size: var(--t-xs); color: var(--ink-3); font-weight: 600; background: var(--surface); padding: 1px 8px; border-radius: var(--r-pill); }
@media (prefers-reduced-motion: reduce) { .st-area > .st-cover .st-line::after { animation: none; width: 100%; opacity: .5; } }

/* 按鈕讀取中 */
.btn.is-busy { position: relative; pointer-events: none; opacity: .85; }
.btn.is-busy .ld-drum { --s: 16px; box-shadow: none; }

/* 表格骨架 */
.st-skel { display: grid; gap: 10px; }
.st-skel i { display: block; height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: skel 1.3s ease infinite; }
.st-skel i:nth-child(3n+1) { width: 92%; } .st-skel i:nth-child(3n+2) { width: 76%; } .st-skel i:nth-child(3n) { width: 84%; }
.st-skel-row { display: grid; grid-template-columns: 1.2fr 1fr .8fr 1fr .6fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.st-skel-row i { display: block; height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: skel 1.3s ease infinite; }
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .st-skel i, .st-skel-row i { animation: none; } }

/* ---------- 頁面內提醒 ---------- */
.st-alert { --ac: var(--st-wash); --ab: var(--st-wash-soft); display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 12px 14px; border-radius: var(--r-md); background: var(--ab); border: 1px solid color-mix(in srgb, var(--ac) 35%, transparent); color: var(--ink); font-size: var(--t-sm); line-height: 1.6; }
.st-alert > .ic { color: var(--ac); margin-top: 1px; }
.st-alert b { font-weight: 800; margin-right: 6px; }
.st-alert .lnk { border: 0; background: none; padding: 0; margin-left: 8px; color: var(--ac); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.st-alert .x { border: 0; background: none; color: var(--ink-3); width: 28px; height: 28px; margin: -4px -6px -4px 0; border-radius: 4px; display: grid; place-items: center; cursor: pointer; }
.st-alert .x:hover { background: color-mix(in srgb, var(--ac) 14%, transparent); color: var(--ink); }
.st-alert .lnk:focus-visible, .st-alert .x:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
.st-alert.warn { --ac: var(--st-maint); --ab: var(--st-maint-soft); }
.st-alert.err { --ac: var(--st-err); --ab: var(--st-err-soft); }
.st-alert.ok { --ac: var(--st-free); --ab: var(--st-free-soft); }

/* ---------- 欄位錯誤 ---------- */
.fld.bad .input, .fld .input[aria-invalid="true"] { border-color: var(--st-err); }
.fld .err { display: flex; align-items: flex-start; gap: 4px; color: var(--st-err); font-size: var(--t-xs); font-weight: 600; }
.fld .err .ic { font-size: 15px; margin-top: 1px; }
.req { color: var(--st-err); font-weight: 800; }

/* ---------- 確認對話框（危險操作要多勾一步） ---------- */
.dlg .dlg-ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); }
.dlg.danger .dlg-ic { background: var(--st-err-soft); color: var(--st-err); }
.dlg .ack { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--t-sm); cursor: pointer; }
.dlg .ack input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--st-err); flex: none; }
.dlg .fld { display: grid; gap: 6px; }

/* ---------- 空狀態 ---------- */
.st-empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 40px 20px; color: var(--ink-2); }
.st-empty > .ic { font-size: 40px; width: auto; color: var(--ink-3); margin-bottom: 4px; }
.st-empty b { color: var(--ink); font-size: var(--t-md); }
.st-empty p { margin: 0; max-width: 34em; font-size: var(--t-sm); line-height: 1.7; }
.st-empty .btn { margin-top: 8px; }

/* ---------- 錯誤頁（取代內容區，側欄頁首還在） ---------- */
.st-errpage { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 36px 20px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.st-errpage .code { font-family: var(--f-num); font-weight: 800; font-size: var(--t-3xl); line-height: 1; color: var(--line-strong); letter-spacing: .04em; }
.st-errpage > .ic { font-size: 30px; width: auto; color: var(--ink-3); }
.st-errpage.err > .ic, .st-errpage.err .code { color: var(--st-err); }
.st-errpage b { font-size: var(--t-md); }
.st-errpage p { margin: 0; color: var(--ink-2); font-size: var(--t-sm); line-height: 1.7; max-width: 26em; }
.st-errpage .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }

/* 連線中斷：固定在畫面最上方 */
.st-off { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 14px; background: #3A1F10; color: #FFE2C7; font-size: var(--t-sm); font-weight: 600; }
.st-off .ic { color: #FFB27A; }
.st-off.fixed { position: fixed; left: 0; right: 0; top: 0; z-index: 96; padding-top: calc(8px + env(safe-area-inset-top, 0px)); }
.st-off .bs-dots i { background: #FFB27A; }

/* ---------- 全螢幕「登入中」10 種（App.FULL，規格頁第 1 段挑選） ----------
   .fs-screen 是畫面本體（絕對定位），全螢幕時包在 .st-full 裡，縮圖時包在 .fs-thumb 裡縮小顯示 */
.fs-screen { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--f-ui); }
.fs-screen .lab { font-size: 20px; font-weight: 700; color: var(--ink-2); letter-spacing: .04em; }
.fs-screen .stack { display: grid; justify-items: center; gap: 18px; position: relative; z-index: 2; }
.fs-screen .logo { width: 72px; height: 72px; border-radius: 16px; box-shadow: var(--shadow-pop); }
.st-full.fs { background: none; backdrop-filter: none; }
/* 2 照片圓窗 */
.fs-porthole .door { width: 260px; height: 260px; border-radius: 50%; padding: 14px; background: radial-gradient(circle at 30% 25%, #FFFFFF, #DDE3EA 45%, #9AA5B2); box-shadow: 0 24px 50px rgba(18, 26, 38, .25); }
.fs-porthole .glass { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; position: relative; box-shadow: inset 0 0 0 8px #3B4452, inset 0 0 30px rgba(0, 0, 0, .5); }
.fs-porthole .glass i { position: absolute; inset: -14%; background: url("img/login-drum.jpg") 30% 50% / cover; animation: fs-spin 2.4s linear infinite; }
@keyframes fs-spin { to { transform: rotate(360deg); } }
/* 3 登入步驟 */
.fs-steps ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; min-width: 280px; }
.fs-steps li { display: flex; align-items: center; gap: 12px; font-size: 19px; color: var(--ink-3); transition: color .3s; }
.fs-steps li .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; border: 2px solid var(--line-strong); color: transparent; transition: all .3s; }
.fs-steps li.on { color: var(--ink); font-weight: 700; }
.fs-steps li.on .ic { border-color: var(--brand-bright); }
.fs-steps li.done { color: var(--ink-2); }
.fs-steps li.done .ic { background: var(--brand-bright); border-color: var(--brand-bright); color: #06233A; }
/* 4 泡泡上升 */
.fs-bubbles { background: linear-gradient(180deg, var(--bg), var(--brand-soft)); }
.fs-bubbles b { position: absolute; bottom: -60px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .95), rgba(150, 210, 255, .35) 40%, rgba(50, 170, 255, .12) 70%); box-shadow: inset 0 0 6px rgba(255, 255, 255, .7); animation: fs-rise linear infinite; }
@keyframes fs-rise { to { transform: translateY(-115vh) translateX(var(--dx, 20px)); } }
/* 5 品牌藍滿版 */
.fs-brand { background: #0C77C3; color: #FFFFFF; }
.fs-brand .lab { color: #DDEFFC; }
.fs-brand .word { font-family: var(--f-num); font-weight: 800; font-size: 72px; letter-spacing: -.02em; }
.fs-brand .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .2); overflow: hidden; }
.fs-brand .bar::after { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: #FFFFFF; animation: fs-sweep 1.2s ease-in-out infinite; }
@keyframes fs-sweep { from { left: -35%; } to { left: 100%; } }
/* 6 毛玻璃背景（沿用 09 選的背景照） */
.fs-glass { background-color: var(--bg); background-position: center; background-size: cover; background-repeat: no-repeat; }
.fs-glass::before { content: ""; position: absolute; inset: -20px; backdrop-filter: blur(18px) saturate(1.1); -webkit-backdrop-filter: blur(18px) saturate(1.1); background: color-mix(in srgb, var(--bg) 35%, transparent); }
.fs-glass .card { position: relative; z-index: 2; display: grid; justify-items: center; gap: 14px; padding: 32px 44px; border-radius: 20px; background: color-mix(in srgb, var(--surface) 82%, transparent); box-shadow: var(--shadow-pop); }
/* 7 門市點名 */
.fs-roll ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; min-width: 340px; }
.fs-roll li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 18px; opacity: .45; transition: opacity .3s; }
.fs-roll li .ic { margin-left: auto; color: var(--st-free); visibility: hidden; }
.fs-roll li .n { color: var(--ink-3); font-size: 13px; }
.fs-roll li.done { opacity: 1; }
.fs-roll li.done .ic { visibility: visible; }
.fs-roll li.on { opacity: 1; border-color: var(--brand-bright); }
/* 8 水位上升 */
.fs-water .lvl { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: linear-gradient(180deg, rgba(93, 184, 245, .85), rgba(28, 140, 219, .95)); animation: fs-fill 2.6s cubic-bezier(.4, 0, .2, 1) infinite; }
.fs-water .lvl::before { content: ""; position: absolute; left: -10%; right: -10%; top: -14px; height: 28px; border-radius: 50%; background: rgba(93, 184, 245, .85); animation: fs-wave 1.8s ease-in-out infinite alternate; }
@keyframes fs-wave { from { transform: translateX(-6%) scaleY(.8); } to { transform: translateX(6%) scaleY(1.15); } }
@keyframes fs-fill { to { height: 100%; } }
.fs-water .stack { mix-blend-mode: normal; }
/* 9 打字問候 */
.fs-hello .greet { font-size: 52px; font-weight: 800; letter-spacing: .02em; min-height: 1.3em; }
.fs-hello .greet::after { content: ""; display: inline-block; width: 3px; height: .9em; margin-left: 4px; vertical-align: -.08em; background: var(--brand-bright); animation: fs-caret .8s steps(1) infinite; }
@keyframes fs-caret { 50% { opacity: 0; } }
.fs-hello .dots { display: flex; gap: 6px; }
.fs-hello .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); animation: fs-dot 1s ease-in-out infinite; }
.fs-hello .dots i:nth-child(2) { animation-delay: .15s; } .fs-hello .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes fs-dot { 50% { transform: translateY(-6px); opacity: .4; } }
/* 10 極簡細線 */
.fs-line .word { font-family: var(--f-num); font-weight: 800; font-size: 48px; letter-spacing: -.02em; }
.fs-line .rule { width: 160px; height: 2px; background: var(--line); position: relative; overflow: hidden; }
.fs-line .rule::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; background: var(--brand); animation: fs-sweep2 1.1s ease-in-out infinite; }
@keyframes fs-sweep2 { from { left: -40%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .fs-screen *, .fs-screen *::before, .fs-screen *::after { animation: none !important; } .fs-water .lvl { height: 40%; } }

/* 規格頁的縮圖格 */
.fs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.fs-card { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; display: grid; }
.fs-card[aria-current="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-bright); }
.fs-thumb { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--bg); max-width: 100%; }
.fs-thumb > .scale { position: absolute; left: 0; top: 0; width: 1280px; height: 800px; transform-origin: 0 0; }
.fs-meta { padding: 10px 12px 12px; display: grid; gap: 6px; }
.fs-meta b { font-size: var(--t-sm); }
.fs-meta p { margin: 0; font-size: var(--t-xs); color: var(--ink-3); line-height: 1.55; min-height: 3.1em; }
.fs-meta .row { gap: 6px; }
.fs-meta .btn { min-height: 30px; padding: 0 10px; font-size: var(--t-xs); }

/* ---------- 按鈕讀取中 10 種（App.BUSY，規格頁第 1 段挑選）：一律鎖住寬度，讀取時按鈕不變寬變窄 ---------- */
.btn.is-busy { position: relative; overflow: hidden; justify-content: center; }
.bs-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; flex: none; animation: fs-spin .7s linear infinite; }
.bs-dots { display: inline-flex; gap: 3px; margin-left: 2px; }
.bs-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: fs-dot .9s ease-in-out infinite; }
.bs-dots i:nth-child(2) { animation-delay: .12s; } .bs-dots i:nth-child(3) { animation-delay: .24s; }
.btn.bs-bar::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 35%; background: currentColor; opacity: .85; animation: bs-sweep 1s ease-in-out infinite; }
@keyframes bs-sweep { from { left: -35%; } to { left: 100%; } }
.btn.bs-fill { isolation: isolate; }
.btn.bs-fill::before { content: ""; position: absolute; inset: 0; z-index: -1; transform-origin: 0 50%; transform: scaleX(0); background: color-mix(in srgb, currentColor 22%, transparent); animation: bs-fill 1.4s cubic-bezier(.3, .6, .4, 1) forwards; }
@keyframes bs-fill { to { transform: scaleX(.92); } }
.btn.bs-pulse { animation: bs-pulse 1s ease-in-out infinite; }
@keyframes bs-pulse { 50% { opacity: .55; } }
.btn.bs-done { background: var(--st-free); border-color: var(--st-free); color: #FFFFFF; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.bs-done { color: #06231A; } }
:root[data-theme="dark"] .btn.bs-done { color: #06231A; }
.bs-shine { background: linear-gradient(90deg, currentColor 30%, color-mix(in srgb, currentColor 30%, transparent) 50%, currentColor 70%); background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: bs-shine 1.3s linear infinite; }
@keyframes bs-shine { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.btn.bs-ring { border-color: transparent; }
.btn.bs-ring::before { content: ""; position: absolute; inset: -40%; background: conic-gradient(from 0deg, transparent 0 70%, var(--brand-bright) 85%, transparent 100%); animation: fs-spin 1.1s linear infinite; z-index: 0; }
.btn.bs-ring::after { content: ""; position: absolute; inset: 2px; border-radius: calc(var(--r-sm) - 2px); background: inherit; z-index: 0; }
.btn.primary.bs-ring::after { background: var(--brand); }
.btn.bs-ring > * { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .btn.is-busy, .btn.is-busy *, .btn.is-busy::before, .btn.is-busy::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; } }
.bs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.bs-card { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; display: grid; gap: 8px; background: var(--surface); align-content: start; }
.bs-card[aria-current="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-bright); }
.bs-card b { font-size: var(--t-sm); }
.bs-card p { margin: 0; font-size: var(--t-xs); color: var(--ink-3); line-height: 1.5; min-height: 3em; }
.bs-card .row { gap: 6px; }
.bs-card .use { min-height: 28px; padding: 0 10px; font-size: var(--t-xs); }
.fs-mini-rule { display: block; width: 120px; height: 2px; background: var(--line); position: relative; overflow: hidden; }
.fs-mini-rule::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; background: var(--brand); animation: fs-sweep2 1.1s ease-in-out infinite; }
