/* ============================================================
   themes/industrial/base.css —— 主題:工業信號 / 物流標籤(舊版保留)
   語言:倉庫現場的視覺母語 —— 貨運嘜頭、物流標籤、黃黑警示膠帶。
   骨架:紙面底色 + 白卡 + 2px 墨邊 + 硬位移陰影 + 安全黃強調。
   單號/料號/儲位一律 mono;大數字用窄體工業字;中文落系統黑體。
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@500;600;700&family=Saira+Condensed:wght@600;700;800&display=swap");

:root {
  /* 紙與墨 */
  --paper: #eceae3;
  --surface: #fffdf8;
  --ink: #171410;
  --ink-soft: #57534a;
  --ink-faint: #8f8a7d;
  --line: #171410;
  --line-soft: #cfcabc;

  /* 信號色 */
  --hazard: #ffd100;        /* 工業安全黃:品牌強調 */
  --hazard-tint: #fff8d6;
  --danger: #c92a2a;
  --ok: #2f9e44;
  --warn: #e8590c;

  /* 狀態 8 態(信號燈語言) */
  --st-pending: #d9480f;           /* 待處理 橙紅:backlog 要跳出來 */
  --st-processing: #1971c2;        /* 處理中 作業藍 */
  --st-need_second_round: #e8a000; /* 待二次 琥珀(配黑字) */
  --st-need_judgement: #9c36b5;    /* 待判定 紫:需要決策 */
  --st-completed: #2f9e44;         /* 已完成 信號綠 */
  --st-returned_to_flow: #0c8599;  /* 退回 青 */
  --st-scrapped: #343a40;          /* 報廢 炭黑 */
  --st-paused: #868e96;            /* 擱置 灰 */

  /* 字體 */
  --font-body: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --font-disp: "Saira Condensed", "Noto Sans TC", "Microsoft JhengHei", sans-serif;

  /* 形 */
  --bw: 2px;
  --radius: 2px;
  --shadow-sm: 3px 3px 0 rgba(23, 20, 16, .9);
  --shadow: 4px 4px 0 rgba(23, 20, 16, .9);
  --shadow-lg: 7px 7px 0 rgba(23, 20, 16, .85);
  --gap: 16px;
  --tap: 46px;

  /* 黃黑警示斜紋 */
  --hazard-stripe: repeating-linear-gradient(-45deg,
      var(--hazard) 0 10px, var(--ink) 10px 20px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* 倉庫地板:淡格線 = 儲位劃線 */
  background:
    linear-gradient(rgba(23, 20, 16, .055) 1px, transparent 1px) 0 0 / 100% 56px,
    linear-gradient(90deg, rgba(23, 20, 16, .055) 1px, transparent 1px) 0 0 / 56px 100%,
    var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* 右下角巨型「倉」嘜頭浮水印:蓋在地板上的整區印字 */
body::before {
  content: "倉";
  position: fixed;
  right: -36px;
  bottom: -70px;
  z-index: 0;
  font-size: 330px;
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
  opacity: .05;
  pointer-events: none;
  user-select: none;
}

/* 細噪點:紙的質感(蓋在最上但不擋事件) */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.045'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }

/* ---------- 頂欄:倉庫標示牌(黑底黃字,貨櫃波紋+鉚釘) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 10px 18px;
  background:
    repeating-linear-gradient(90deg,
      rgba(255, 255, 255, .07) 0 3px, transparent 3px 26px,
      rgba(0, 0, 0, .85) 26px 30px, transparent 30px 52px),
    var(--ink);
  color: #fff;
  border-bottom: 3px solid var(--hazard);
}
/* 鉚釘:標示牌是「鎖」上去的 */
.topbar::before, .topbar::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 11px; height: 11px;
  margin-top: -6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8a8578, #45412f 55%, #16130e);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, .45), 0 0 0 2px rgba(255, 209, 0, .35);
  pointer-events: none;
}
.topbar::before { left: 8px; }
.topbar::after { right: 8px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--hazard);
  color: var(--ink);
  font-weight: 900;
  font-size: 20px;
  border-radius: var(--radius);
  box-shadow: 2px 2px 0 rgba(255, 209, 0, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text b { font-size: 16px; font-weight: 800; white-space: nowrap; }
.brand-text i {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .28em;
  color: var(--hazard);
  white-space: nowrap;
}
/* 品牌下緣:一小截條碼,物流標籤的簽名 */
.brand-text::after {
  content: "";
  height: 8px;
  margin-top: 3px;
  background:
    repeating-linear-gradient(90deg, #fff 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, #fff 0 2px, transparent 2px 9px),
    repeating-linear-gradient(90deg, #fff 0 1px, transparent 1px 5px);
  opacity: .85;
}
.topnav { display: flex; align-items: center; gap: 6px; }
.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 12px;
  color: rgba(255, 255, 255, .75);
  font-weight: 700;
  white-space: nowrap;
  border-radius: var(--radius);
  border-bottom: 3px solid transparent;
}
.topnav a:hover { color: #fff; }
.topnav a.active { color: var(--hazard); border-bottom-color: var(--hazard); }
.topnav a.btn-new {
  background: var(--hazard);
  color: var(--ink);
  font-weight: 800;
  border: none;
  padding: 8px 16px 8px 14px;
  transition: transform .1s;
  clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 0 100%); /* 標籤斜切角 */
}
.topnav a.btn-new:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 rgba(255, 209, 0, .35); }
.topnav a.btn-new:active { transform: translate(1px, 1px); box-shadow: none; }

/* 頂欄下緣:警示膠帶(非 sticky,捲動即離場),極慢流動 = 廠區還活著 */
@keyframes tape-drift {
  from { background-position: 0 0; }
  to { background-position: 28.284px 0; } /* -45° 條紋沿 x 一個週期 = 20/sin45° */
}
.hazard-bar {
  height: 8px;
  background: var(--hazard-stripe);
  border-bottom: 2px solid var(--ink);
  animation: tape-drift 9s linear infinite;
}

/* ---------- 頁面容器 ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 22px 16px 72px; position: relative; z-index: 2; }
.page-narrow { max-width: 660px; margin: 0 auto; }

/* h1 = 區位看板:巨型窄體 + 黃色區位方塊 + 量尺 */
h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-disp);
  font-size: 38px;
  font-weight: 800;
  margin: 0 0 4px;
  letter-spacing: .06em;
  line-height: 1.1;
  text-transform: uppercase;
}
h1::before {
  content: "";
  flex: 0 0 auto;
  width: 18px; height: 34px;
  background: var(--hazard);
  border: var(--bw) solid var(--ink);
  box-shadow: 3px 3px 0 rgba(23, 20, 16, .9);
}
h2 { font-size: 16px; font-weight: 800; margin: 0 0 8px; letter-spacing: .02em; }

/* h1 下緣:量尺刻度,現場丈量的手感 */
h1::after {
  content: "";
  flex: 1;
  max-width: 220px;
  height: 9px;
  align-self: flex-end;
  margin-bottom: 7px;
  border-bottom: 2px solid var(--ink);
  background:
    repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 44px),
    repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 11px);
  opacity: .85;
}

/* 反白選取 = 安全黃 */
::selection { background: var(--hazard); color: var(--ink); }

/* ---------- 卡片 / 面板:標籤紙 ---------- */
.card, .panel {
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 16px; position: relative; }

/* 面板對角:木箱角鐵記號 */
.panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  opacity: .7;
  pointer-events: none;
}
.panel::before { top: 5px; left: 5px; border-top: 3px solid var(--ink); border-left: 3px solid var(--ink); }
.panel::after { bottom: 5px; right: 5px; border-bottom: 3px solid var(--ink); border-right: 3px solid var(--ink); }

/* 面板標題列:貨架標籤 —— 黑條黃字斜切尾 */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 5px 22px 5px 12px;
  background: var(--ink);
  color: var(--hazard);
  letter-spacing: .1em;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 100%, 0 100%);
}
.panel-head h2::before {
  content: "";
  width: 9px; height: 9px;
  background: var(--hazard);
  flex: 0 0 auto;
}

/* ---------- 按鈕:按下去有實體位移 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 10px 16px;
  border: var(--bw) solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 rgba(23, 20, 16, .9); }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn:disabled { cursor: default; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-hazard { background: var(--hazard); border-color: var(--ink); color: var(--ink); font-weight: 800; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-lg { min-height: 54px; font-size: 17px; padding: 12px 22px; }
.btn-block { width: 100%; }

/* ---------- 表單 ---------- */
label { font-weight: 700; font-size: 13px; color: var(--ink-soft); letter-spacing: .04em; }
input:not([type]), input[type=text], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: var(--bw) solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px; /* ≥16 防 iOS 自動放大 */
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--hazard);
}
.field { margin-bottom: 16px; }
.field.disabled { opacity: .45; }
.required::after { content: " *"; color: var(--danger); }
.field-error input, .field-error select, .field-error textarea {
  border-color: var(--danger);
  box-shadow: 3px 3px 0 rgba(201, 42, 42, .3);
}

/* ---------- 狀態標籤:信號色塊 ---------- */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  letter-spacing: .04em;
}
.status-tag::before {
  content: "";
  width: 7px; height: 7px;
  background: rgba(255, 255, 255, .9);
  flex: 0 0 auto;
}
.status-pending { background: var(--st-pending); }
.status-processing { background: var(--st-processing); }
.status-need_second_round { background: var(--st-need_second_round); color: var(--ink); }
.status-need_second_round::before { background: rgba(23, 20, 16, .75); }
.status-need_judgement { background: var(--st-need_judgement); }
.status-completed { background: var(--st-completed); }
.status-returned_to_flow { background: var(--st-returned_to_flow); }
.status-scrapped { background: var(--st-scrapped); }
.status-paused { background: var(--st-paused); }

/* ---------- 一般標籤 chip(料號/tags/來源) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line-soft);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--ink-soft);
}
.chip-warn {
  background: var(--hazard-tint);
  border: 1px dashed var(--warn);
  color: #9a3412;
  font-weight: 700;
}

/* 操作者:人 / AI */
.actor-agent, .actor-human {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
}
.actor-agent { background: var(--hazard); color: var(--ink); border: 1px solid var(--ink); }
.actor-human { background: transparent; color: var(--ink-faint); border: 1px solid var(--line-soft); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  border-left: 6px solid var(--hazard);
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }

/* ---------- 頁腳 ---------- */
.foot {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-faint);
  font-size: 12px;
  position: relative;
  z-index: 2;
}
/* 嘜頭指示:外箱印字的儀式感 */
.foot::before {
  content: "↑ THIS SIDE UP · KEEP DRY · HANDLE WITH CARE";
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  white-space: nowrap;
  color: var(--ink-soft);
}
.foot-mono {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .28em;
  border: 1px solid var(--line-soft);
  padding: 2px 8px;
  white-space: nowrap;
}
.foot-theme { margin-left: auto; color: var(--ink-soft); font-weight: 700; white-space: nowrap; }
.foot-theme:hover { color: var(--ink); text-decoration: underline; }

/* ---------- 進場動效:卡片逐一浮起 ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.rise { animation: rise .32s cubic-bezier(.2, .7, .3, 1) backwards; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- 手機 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand-mark { width: 36px; height: 36px; font-size: 19px; }
  .brand-text { display: none; } /* 手機只留「倉」方塊,讓出 nav 空間 */
  .topbar::before, .topbar::after { display: none; } /* 鉚釘讓位 */
  .topnav { gap: 2px; }
  .topnav a { padding: 6px 8px; font-size: 14px; }
  .topnav a.btn-new { padding: 8px 12px 8px 10px; font-size: 14px; white-space: nowrap; }
  .page { padding: 16px 10px 72px; }
  h1 { font-size: 29px; gap: 9px; }
  h1::before { width: 14px; height: 26px; }
  h1::after { max-width: 132px; margin-bottom: 5px; }
  body::before { font-size: 240px; right: -30px; bottom: -50px; }
  .foot { flex-direction: column; align-items: flex-start; gap: 6px; }
}
