/* ============================================================
   行動階段 — 平板兩欄式骨架(原始尺寸,小字最低 13px,不爆版)
   左 .hd-main  : 上=地圖, 下=底列三張卡(棲地詳情 / 族群分布+性狀 / AI 對話)
   右 .hd-side  : 行動選擇 4 張卡 + 已選擇佇列 + 展開行動
   ============================================================ */

.hd-shell {
  position: relative;
  z-index: 1;
  height: calc(100% - var(--hd-topbar-h));
  display: grid;
  grid-template-columns: 1fr 366px;
  gap: 10px;
  padding: 8px 10px 10px;
  overflow: hidden;
}

/* ---------- 左大欄 ---------- */
.hd-main {
  display: grid;
  /* 上(地圖)大、下(底列三卡)小,1.4/1 */
  grid-template-rows: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  min-width: 0;
}

/* 底列 — 三張卡(左:棲地詳情 / 中:性狀 / 右:行動選擇) */
.hd-botrow {
  display: grid;
  grid-template-columns: 1.1fr 0.72fr 1.34fr;
  gap: 10px;
  min-height: 0;
  min-width: 0;
}
.hd-card {
  background: var(--hd-card);
  border: 1px solid var(--hd-line-soft);
  border-radius: var(--hd-radius-lg);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* ── 棲地詳情卡(對齊 mockup ①)── */
.hd-detail__head { display: flex; align-items: center; gap: 10px; }
.hd-detail__icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: var(--hd-habitat-color, var(--hd-color-wetland));
  color: white;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.hd-detail__name {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 25px;
  color: var(--hd-ink); line-height: 1.05;
  white-space: nowrap;
}
.hd-detail__capacity {
  font-size: 17px; color: var(--hd-ink-muted);
  margin-top: 2px; white-space: nowrap;
}
.hd-detail__capacity strong {
  font-family: var(--hd-font-display);
  font-size: 20px; font-weight: 700;
  color: var(--hd-ink-soft);
  margin: 0 2px;
}

/* 資源色塊:整條圓角塊,底=淺 tint、左側填充=同色較深、label 左值右 */
.hd-resources { display: flex; flex-direction: column; gap: 6px; }
.hd-resource {
  position: relative;
  height: 34px;
  border-radius: 9px;
  overflow: hidden;
  display: flex; align-items: center;
  padding: 0 14px;
  justify-content: space-between;
}
.hd-resource__fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 9px 0 0 9px;
}
.hd-resource--water { background: rgba(74, 123, 166, .16); }
.hd-resource--water .hd-resource__fill { background: rgba(74, 123, 166, .34); }
.hd-resource--veg { background: rgba(107, 158, 71, .16); }
.hd-resource--veg .hd-resource__fill { background: rgba(107, 158, 71, .36); }
.hd-resource--pol { background: rgba(181, 60, 46, .13); }
.hd-resource--pol .hd-resource__fill { background: rgba(181, 60, 46, .30); }
.hd-resource__label {
  position: relative; z-index: 1;
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 21px;
  color: var(--hd-ink);
}
.hd-resource__pct {
  position: relative; z-index: 1;
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 25px;
  color: var(--hd-ink);
  font-variant-numeric: tabular-nums;
}

/* ── 族群分佈(底列左卡內) ── */
.hd-popmini {
  display: flex; flex-direction: column;
  gap: 3px;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px dashed var(--hd-line);
}
.hd-popmini__title {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 19px;
  color: var(--hd-ink); margin: 0 0 3px;
}
.hd-popmini__rows { display: flex; flex-direction: column; gap: 2px; min-height: 0; }
/* 2 欄版(底列左卡用):列以 grid 平均填兩欄,自動換行 */
.hd-popmini__rows--2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
  row-gap: 2px;
}
.hd-popmini__row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.hd-popmini__dot { width: 13px; height: 13px; border-radius: 999px; flex-shrink: 0; }
.hd-popmini__name {
  font-size: 18px; color: var(--hd-ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hd-popmini__num {
  font-family: var(--hd-font-mono);
  font-weight: 600; font-size: 18px;
  color: var(--hd-ink);
  font-variant-numeric: tabular-nums;
}

/* ── 性狀卡(底列中卡;對齊 mockup ②)── */
.hd-traits__title {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 28px;
  color: var(--hd-ink); margin: 0;
}
.hd-traits__list {
  display: flex; flex-direction: column; gap: 7px;
  flex: 1; min-height: 0;
  overflow-y: auto;
}
.hd-trait {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 9px;
  min-height: 40px;
  padding: 0 16px;
  background: var(--hd-card-soft);
  border: 1px solid var(--hd-line);
  border-radius: 999px;
  font-size: 20px; color: var(--hd-ink-soft);
  white-space: nowrap;
}
.hd-trait__dot {
  width: 10px; height: 10px; border-radius: 999px;
  background: var(--hd-success); flex-shrink: 0;
}
.hd-trait--empty { color: var(--hd-ink-muted); justify-content: center; }
.hd-trait--locked { opacity: .45; border-style: dashed; }
.hd-trait--locked .hd-trait__dot { background: var(--hd-ink-muted); }

/* ============================================================
   右側欄 — 行動選擇 + 佇列
   ============================================================ */
.hd-side {
  display: flex; flex-direction: column;
  gap: 10px;
  min-height: 0;
}
/* 右欄上方:AI 對話卡拿較多空間;下方:佇列 / 等待面板;展開行動固定高 */
.hd-side > .hd-chat { flex: 1.4; min-height: 0; }
/* 2026-06-03 §E:回滾橫向遮罩,等待面板回右欄原位(直立卡),分到下方空間 */
.hd-side > .hd-waiting { flex: 1; min-height: 0; }

/* ── 行動選擇卡(底列右卡;對齊 mockup ③)── */
/* root = .hd-card hd-actions;4 列垂直填滿、列間細線分隔 */
.hd-actions { gap: 0; justify-content: space-between; }

/* 2026-06-03 §E 等待態:在「選擇行動」卡上疊半透明鎖定遮罩,攔點擊並提示已送出。
   純 CSS(不量位):卡身設 relative,::after 蓋滿全卡攔點;卡內子元素不可點。 */
.hd-actions--locked { position: relative; }
.hd-actions--locked > * { pointer-events: none; }
.hd-actions--locked::after {
  content: "行動已送出";
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .72);
  border-radius: inherit;
  color: var(--hd-ink-soft, #6b665e);
  font-size: 14px;
  font-weight: 600;
  pointer-events: auto;   /* 蓋層自己攔截點擊 */
  cursor: not-allowed;
}
.hd-action {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 14px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--hd-line-soft);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  background: transparent;
  transition: background .15s;
  min-width: 0;
}
.hd-action:last-child { border-bottom: 0; }
.hd-action:hover:not(.hd-action--disabled):not(.hd-action--migrate) {
  background: var(--hd-card-soft);
}
.hd-action--disabled { opacity: .4; cursor: not-allowed; }
.hd-action__name {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 30px;
  color: var(--hd-ink);
  white-space: nowrap;
}
.hd-action__desc {
  font-size: 21px;
  color: var(--hd-ink-muted);
}
.hd-action__cost {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 24px;
  color: var(--hd-ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* v5:行動性價比變色(成本/數量受性狀×棲地修正後變好變差) */
.hd-action__cost--good { color: var(--hd-success); }
.hd-action__cost--bad  { color: var(--hd-danger); }
.hd-action__cost--cool { color: var(--hd-ink-muted); }
.hd-action--explore.hd-action--disabled { opacity: .55; }

/* 遷移卡:本體不可點(點擊只綁子鈕);目的地子鈕佔滿整列寬度 */
.hd-action--migrate { cursor: default; }
.hd-action__subs {
  grid-column: 1 / 4;
  display: flex; gap: 10px;
  margin-top: 7px;
}
.hd-action__sub {
  background: var(--hd-paper);
  border: 1px solid var(--hd-line);
  border-radius: 9px;
  padding: 4px 14px;
  font-family: inherit;
  font-size: 21px;
  color: var(--hd-ink);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .15s;
}
.hd-action__sub:hover:not(:disabled) {
  background: var(--hd-ink); color: var(--hd-paper);
  border-color: var(--hd-ink);
  transform: translateY(-1px);
}
.hd-action__sub:disabled { opacity: .4; cursor: not-allowed; }
.hd-action__sub-arrow { font-weight: 700; color: var(--hd-ink-muted); }
.hd-action__sub:hover:not(:disabled) .hd-action__sub-arrow { color: var(--hd-paper); }
.hd-action__sub-name { font-family: var(--hd-font-display); font-weight: 700; }

/* ── 已選擇行動(右欄中段;對齊 mockup ⑤)── */
.hd-queue {
  flex: 1;
  display: flex; flex-direction: column;
  gap: 8px;
  min-height: 0;
}
/* 表頭:一行(標題 + 右側用量),整列底色塊 */
.hd-queue__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  background: var(--hd-paper-dark);
  border-radius: 10px;
  padding: 10px 14px;
  flex-shrink: 0;
}
.hd-queue__title {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 23px;
  color: var(--hd-ink);
  white-space: nowrap;
}
.hd-queue__meta {
  font-family: var(--hd-font-display);
  font-weight: 600; font-size: 18px;
  color: var(--hd-ink-soft);
  white-space: nowrap;
}
.hd-queue__meta b {
  font-family: var(--hd-font-mono);
  font-weight: 700; color: var(--hd-ink);
}

/* AP 用量色塊 */
.hd-queue__bar {
  height: 9px;
  background: var(--hd-line-soft);
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
}
.hd-queue__bar-fill {
  height: 100%;
  background: var(--hd-accent);
  border-radius: 5px;
  transition: width .3s ease;
}

/* 條目:2 欄膠囊網格 */
.hd-qgrid {
  flex: 1; min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: min-content;
  gap: 5px;
  padding-right: 2px;
}
.hd-qitem {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 8px 0 11px;
  background: var(--hd-card);
  border: 1.5px solid var(--hd-line-soft);
  border-radius: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s, background .15s;
}
.hd-qitem:hover {
  border-color: var(--hd-danger);
  background: rgba(181, 60, 46, .05);
}
.hd-qitem:hover .hd-qitem__x { color: var(--hd-danger); opacity: 1; }
/* 文字稍縮 + 右側 -NAP/✕ 收窄,讓「公園→埤塘」完整顯示不被截斷 */
.hd-qitem__text {
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 15px;
  color: var(--hd-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hd-qitem--migrate .hd-qitem__text { color: var(--hd-color-pond, var(--hd-ink-soft)); }
.hd-qitem__ap {
  font-family: var(--hd-font-mono);
  font-size: 13px; font-weight: 600;
  color: var(--hd-ink-muted);
  font-variant-numeric: tabular-nums;
}
.hd-qitem__x {
  font-size: 16px; line-height: 1;
  color: var(--hd-ink-muted);
  opacity: .55;
  transition: color .15s, opacity .15s;
}

/* 空狀態(沿用單欄清單外觀) */
.hd-queue__list {
  flex: 1; min-height: 0;
  overflow-y: auto;
}
.hd-queue__empty {
  background: var(--hd-card);
  border: 1px dashed var(--hd-line);
  border-radius: var(--hd-radius);
  padding: 18px 14px;
  text-align: center;
  font-size: 15px;
  color: var(--hd-ink-muted);
  line-height: 1.6;
}

/* 展開行動(置中、無徽章;高 −15%、字距拉寬) */
.hd-execute {
  background: var(--hd-ink);
  color: var(--hd-paper);
  border: 0;
  border-radius: var(--hd-radius);
  padding: 12px;
  font-family: var(--hd-font-display);
  font-weight: 700; font-size: 33px;
  letter-spacing: .32em;
  text-align: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .18s, background .18s;
}
.hd-execute:hover:not(:disabled) { transform: translateY(-1px); background: #16120c; }
.hd-execute:disabled { opacity: .35; cursor: not-allowed; transform: none; }
