@charset "utf-8";
/* ==========================================================================
   快工具POS v0.1 — assets/css/base.css
   reset ＋ 字體堆疊 ＋ iPad 橫向平放規則 ＋ 通用工具 class（u- 前綴）
   載入順序：第 2 支（tokens.css → base.css → ui.css → ...）

   本檔「不」定義任何元件樣式：
   ui- / sh- / lg- / od- / ct- / tm- / td- / co- / st- 前綴皆不屬於本檔。
   唯一例外是 SPEC 第 4 節明文指定的 `button, .ui-btn{touch-action:manipulation}`，
   該行只處理觸控行為，不含任何視覺樣式。

   顏色／間距／圓角／陰影／字級一律取自 tokens.css 的變數。
   ========================================================================== */

/* ==========================================================================
   1. reset
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body, div, span, p,
h1, h2, h3, h4, h5, h6,
ul, ol, li, dl, dt, dd,
figure, blockquote, pre,
fieldset, legend, label, form,
table, thead, tbody, tfoot, tr, th, td {
  margin: 0;
  padding: 0;
  border: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: var(--fw-b);
}

ul, ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

th {
  text-align: left;
  font-weight: var(--fw-b);
}

a {
  color: var(--c-primary);
  text-decoration: none;
}

b, strong {
  font-weight: var(--fw-b);
}

small {
  font-size: var(--fs-sm);
}

pre, code {
  font-family: var(--ff-mono);
}

hr {
  border: 0;
  border-top: 1px solid var(--c-line);
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   2. iPad 規則（SPEC 第 4 節）
   ========================================================================== */
html,
body {
  height: 100%;
  overflow: hidden;                 /* 不得出現頁面捲軸（含橫向） */
  overscroll-behavior: none;        /* 關閉整頁橡皮筋 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html {
  font-size: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  width: 100%;
  max-width: 100%;
  font-family: var(--ff-base);
  font-size: var(--fs-md);
  font-weight: var(--fw-n);
  line-height: 1.45;
  color: var(--c-fg);
  background-color: var(--c-bg);
  touch-action: manipulation;       /* 關閉雙擊縮放延遲 */
  -webkit-touch-callout: none;      /* 長按不跳系統選單（明細行長按手勢用） */
  -webkit-user-select: none;        /* 文字不可選取 */
  user-select: none;
}

/* 輸入類元素例外：允許選取與長按游標 */
input,
textarea,
select,
[contenteditable],
[contenteditable] *,
.u-selectable,
.u-selectable * {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* 所有可點擊元素最小 44×44（--touch） */
button,
[role="button"],
input[type="button"],
input[type="submit"],
input[type="reset"] {
  min-width: var(--touch);
  min-height: var(--touch);
}

/* SPEC 第 4 節指定：button 與 .ui-btn 皆須 touch-action: manipulation */
button,
.ui-btn {
  touch-action: manipulation;
}

/* ==========================================================================
   3. 表單元素（繼承字體、移除 iOS 預設外觀）
   ========================================================================== */
button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
  margin: 0;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: inherit;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled,
[aria-disabled="true"] {
  cursor: default;
}

input[type="text"],
input[type="search"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="email"],
textarea,
select {
  width: 100%;
  min-height: var(--touch);
  font-size: max(16px, var(--fs-md));   /* ≥16px：避免 iOS 聚焦時整頁放大 */
  background: none;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}

textarea {
  resize: none;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: var(--c-fg-3);
  opacity: 1;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

input[type="checkbox"],
input[type="radio"] {
  flex: none;
  width: 22px;
  height: 22px;
  accent-color: var(--c-primary);
}

/* ==========================================================================
   4. 捲動條（細、半透明；淺深兩主題皆可讀）
   iPad 原生為覆蓋式捲軸，此處主要讓桌機預覽一致
   ========================================================================== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background-color: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--c-scroll-thumb);
  border-radius: var(--r-pill);
}

::-webkit-scrollbar-thumb:active {
  background-color: var(--c-fg-3);
}

::-webkit-scrollbar-corner {
  background-color: transparent;
}

/* ==========================================================================
   5. 可見焦點框
   ========================================================================== */
*:focus {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

/* ==========================================================================
   6. 通用工具 class
   ========================================================================== */

/* ---------- 版面 ---------- */
.u-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  min-width: 0;
}

.u-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.u-grow {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.u-wrap {
  flex-wrap: wrap;
}

.u-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.u-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.u-right {
  margin-left: auto;
  text-align: right;
}

.u-fill {
  width: 100%;
  height: 100%;
}

.u-touch {
  min-width: var(--touch);
  min-height: var(--touch);
}

/* ---------- 間距 ---------- */
.u-gap-1 { gap: var(--sp-1); }
.u-gap-2 { gap: var(--sp-2); }
.u-gap-3 { gap: var(--sp-3); }
.u-gap-4 { gap: var(--sp-4); }
.u-gap-5 { gap: var(--sp-5); }
.u-gap-6 { gap: var(--sp-6); }
.u-gap-8 { gap: var(--sp-8); }
.u-gap-10 { gap: var(--sp-10); }

/* ---------- 文字 ---------- */
.u-muted {
  color: var(--c-fg-2);
}

.u-bold {
  font-weight: var(--fw-b);
}

.u-num {
  font-variant-numeric: tabular-nums;
  -webkit-font-feature-settings: "tnum" 1;
  font-feature-settings: "tnum" 1;
}

.u-mono {
  font-family: var(--ff-mono);
  font-variant-numeric: tabular-nums;
  -webkit-font-feature-settings: "tnum" 1;
  font-feature-settings: "tnum" 1;
  letter-spacing: 0;
}

.u-ellipsis {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.u-nowrap {
  white-space: nowrap;
}

.u-strike {
  color: var(--c-fg-3);
  text-decoration: line-through;
}

/* ---------- 捲動容器 ---------- */
.u-scroll,
.u-scroll-y,
.u-scroll-x {
  min-width: 0;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.u-scroll {
  overflow: auto;
}

.u-scroll-y {
  overflow-x: hidden;
  overflow-y: auto;
}

.u-scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
}

/* ---------- 顯示／隱藏 ---------- */
.u-hidden {
  display: none !important;
}

.u-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- 區塊 ---------- */
.u-card {
  background-color: var(--c-bg-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-3);
  box-shadow: var(--sh-1);
}

.u-divider {
  flex: none;
  height: 1px;
  background-color: var(--c-line);
}

.u-divider-v {
  flex: none;
  align-self: stretch;
  width: 1px;
  background-color: var(--c-line);
}

.u-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  background-color: var(--c-bg-3);
  color: var(--c-fg-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: var(--fw-m);
  line-height: 1.25;
  white-space: nowrap;
}

/* ==========================================================================
   7. 直立方向提示（.u-rotate-hint）
   橫向：display:none；直立：全螢幕覆蓋（--z-rotate，蓋過鎖定層）

   契約：**旋轉圖示與副標「本系統為橫向介面設計」由本檔以容器的
         ::before / ::after 自動產生，markup 不需要（也不應該）自備**，
         所以外殼只要給一個標題文字元素就夠了：

     <div class="u-rotate-hint" aria-hidden="true">
       <span class="u-rotate-hint-title">請將 iPad 橫向平放使用</span>
     </div>

   - 標題元素用任何 class 都可以（pos.html 目前用 .sh-rotate-text，
     由 shell.css 自行上字級），本檔另外提供 .u-rotate-hint-title 可直接套用。
   - 若容器完全沒有子節點（真正的 <div class="u-rotate-hint"></div>），
     ::after 會自動補上「標題＋副標」兩行，整段提示仍然完整。
   - 請勿在 markup 內自備圖示或副標元素，否則會與 ::before / ::after 重複。
   ========================================================================== */
.u-rotate-hint {
  display: none;
}

@media (orientation: portrait) {
  .u-rotate-hint {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: var(--z-rotate);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-4);
    padding:
      calc(var(--sp-10) + env(safe-area-inset-top, 0px))
      var(--sp-8)
      calc(var(--sp-10) + env(safe-area-inset-bottom, 0px));
    background-color: var(--c-bg);
    color: var(--c-fg);
    text-align: center;
  }

  /* 旋轉圖示：一律由容器的 ::before 產生；inline SVG 以 mask 上色，自動跟隨主題 */
  .u-rotate-hint::before {
    content: "";
    display: block;
    flex: none;
    width: 112px;
    height: 112px;
    margin-bottom: var(--sp-2);
    background-color: var(--c-primary);
    -webkit-mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'><g transform='rotate(-20 32 40)'><rect x='21' y='22' width='22' height='36' rx='4.5'/><line x1='28' y1='54' x2='36' y2='54'/></g><path d='M9.5 21 A26 26 0 0 1 54.5 21'/><path d='M55.3 12 L54.5 21 L46.3 17.2'/></svg>");
    mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64' fill='none' stroke='black' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'><g transform='rotate(-20 32 40)'><rect x='21' y='22' width='22' height='36' rx='4.5'/><line x1='28' y1='54' x2='36' y2='54'/></g><path d='M9.5 21 A26 26 0 0 1 54.5 21'/><path d='M55.3 12 L54.5 21 L46.3 17.2'/></svg>");
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    animation: u-rotate-hint-wobble 2.6s var(--ease) infinite;
  }

  .u-rotate-hint-title {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-xb);
    line-height: 1.4;
    color: var(--c-fg);
  }

  /* 副標：一律由容器的 ::after 產生 */
  .u-rotate-hint::after {
    content: "本系統為橫向介面設計";
    display: block;
    font-size: var(--fs-lg);
    font-weight: var(--fw-n);
    line-height: 1.5;
    color: var(--c-fg-2);
  }

  /* 容器完全沒有子節點時：::after 同時補上標題與副標（兩行） */
  .u-rotate-hint:empty::after {
    content: "請將 iPad 橫向平放使用\A 本系統為橫向介面設計";
    white-space: pre-line;
    font-size: var(--fs-xl);
    font-weight: var(--fw-b);
    line-height: 2;
    color: var(--c-fg);
  }
}

@keyframes u-rotate-hint-wobble {
  0%,
  100% {
    transform: rotate(0deg);
  }
  40% {
    transform: rotate(-10deg);
  }
  70% {
    transform: rotate(5deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .u-rotate-hint::before {
    animation: none;
  }
}
