/* ==========================================================================
   首頁 —— 港都作業看板（bento）
   只在首頁載入。版面邏輯寫在 resources/views/front/home.blade.php 的開頭註解。

   RWD 的三個地雷（前幾站都踩過，這裡預先處理）：
     1. grid / flex 子項預設 min-width: auto，會把最長的字串往上撐，
        overflow-x: auto 擋不住。所有會放長字的子項一律 min-width: 0。
     2. 橫向軌道（.kh-track）自己捲，外層一定要 min-width: 0，否則整頁一起變寬。
     3. 黃色在淺底上只當填色（見 site.css 權杖區），文字一律墨色。
   ========================================================================== */

/* ─────────────────────────── 主視覺 + 狀態看板 ─────────────────────────── */
.kh-hero {
  position: relative;
  background: var(--ink-800);
  color: var(--text-invert);
  padding-block: clamp(2.5rem, 6vw, 5rem);
  --btn-ghost-fg: var(--text-invert);
  --btn-ghost-border: rgba(236, 238, 239, 0.34);
  --btn-ghost-border-hover: var(--signal);
  --btn-ghost-bg-hover: rgba(236, 238, 239, 0.06);
}
/* 底部警示斜紋，跟內頁頁首一致 */
.kh-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 8px;
  background: repeating-linear-gradient(-45deg, var(--signal) 0 10px, var(--ink-900) 10px 20px);
}

.kh-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: center;
}
.kh-hero__main { min-width: 0; }

.kh-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 1.4rem;
  padding: 6px 14px;
  border: 1px solid rgba(236, 238, 239, 0.22);
  border-radius: var(--tag-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--text-invert);
}
.kh-status__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 0 rgba(245, 192, 0, 0.6);
  animation: kh-pulse 2.2s infinite;
}
@keyframes kh-pulse {
  70%  { box-shadow: 0 0 0 10px rgba(245, 192, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 192, 0, 0); }
}
@media (prefers-reduced-motion: reduce) { .kh-status__dot { animation: none; } }

.kh-hero__title {
  margin: 0 0 1.2rem;
  font-size: clamp(1.9rem, 4.6vw, 3.4rem);
  line-height: 1.3;
  color: var(--text-invert);
}
.kh-hero__title em {
  font-style: normal;
  color: var(--ink-900);
  background: var(--signal);
  padding: 0 0.18em;
  border-radius: 6px 0 6px 0;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.kh-hero__lead {
  max-width: 36em;
  margin: 0 0 2rem;
  color: var(--text-invert-muted);
  font-size: 1.02rem;
}

.kh-hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* 狀態看板 */
.kh-board { min-width: 0; display: grid; gap: 14px; }

.kh-board__grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.kh-board__grid > div {
  min-width: 0;
  padding: 14px 16px;
  background: var(--ink-900);
  border: 1px solid rgba(236, 238, 239, 0.08);
  border-radius: var(--tag);
}
.kh-board__grid dt {
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: 0.08em;
  color: var(--text-invert-muted);
}
.kh-board__grid dd { margin: 0; display: flex; align-items: baseline; gap: 6px; }
.kh-board__grid .num {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 3.4vw, 2.5rem);
  font-weight: 700;
  line-height: 1;
  color: var(--signal);
}
.kh-board__grid small { font-size: 0.8rem; color: var(--text-invert-muted); }

.kh-board__figure { margin: 0; }
.kh-board__figure img {
  width: 100%;
  height: auto;
  border-radius: var(--tag);
}

/* ─────────────────────────── 章節骨架 ─────────────────────────── */
.kh-sec { padding-block: clamp(3rem, 7vw, 5.5rem); }
.kh-sec--steel { background: var(--paper-100); }
.kh-sec--dark { background: var(--ink-900); color: var(--text-invert-muted); }

.kh-head { max-width: 820px; margin-bottom: clamp(1.8rem, 4vw, 2.8rem); }

.kh-head__code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 3px 10px;
  background: var(--ink-900);
  color: var(--signal);
  border-radius: var(--tag-sm);
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: 0.06em;
}
.kh-head__title { margin: 0 0 0.6rem; font-size: clamp(1.45rem, 3.2vw, 2.2rem); }
.kh-head__lead { margin: 0; color: var(--text-muted); max-width: 46em; }

.kh-sec--dark .kh-head__code { background: var(--signal); color: var(--ink-900); }
.kh-sec--dark .kh-head__title { color: var(--text-invert); }
.kh-sec--dark .kh-head__lead { color: var(--text-invert-muted); }

.kh-note { margin: clamp(1.6rem, 4vw, 2.4rem) 0 0; color: var(--text-muted); }
.kh-note__sep { margin-inline: 10px; color: var(--line-mid); }
.kh-sec--dark .kh-note { color: var(--text-invert-muted); }
.kh-sec--dark .link-more { color: var(--signal); }
.kh-sec--dark .kh-note__sep { color: rgba(236, 238, 239, 0.3); }

/* ─────────────────────────── KHH-01 對號入座 ─────────────────────────── */
.kh-sym {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.kh-sym li {
  min-width: 0;
  padding: 20px 20px 22px;
  background: var(--paper-000);
  border: 1px solid var(--line-soft);
  border-radius: var(--tag);
  box-shadow: inset 0 3px 0 var(--signal);
}
.kh-sym__tag {
  display: inline-block;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-strong);
}
.kh-sym p { margin: 0; color: var(--text-body); line-height: 1.8; }

/* ─────────────────────────── KHH-02 貨櫃磚 ─────────────────────────── */
.kh-crates {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.kh-crates a {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 96px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--paper-000);
  border: 1px solid var(--line-soft);
  border-radius: var(--tag);
  color: var(--text-strong);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), border-color 0.18s var(--ease);
}
/* 左側黃色封條，hover 時從 0 長到滿高 */
.kh-crates a::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 14px;
  bottom: 14px;
  width: 4px;
  background: var(--signal);
  transform: scaleY(0.35);
  transform-origin: top;
  transition: transform 0.22s var(--ease);
}
.kh-crates a:hover {
  border-color: var(--ink-700);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: var(--text-strong);
}
.kh-crates a:hover::before { transform: scaleY(1); }
.kh-crates__code {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.kh-crates__name { font-weight: 700; line-height: 1.45; }

@media (prefers-reduced-motion: reduce) {
  .kh-crates a:hover { transform: none; }
}

/* ─────────────────────────── KHH-03/04 bento ─────────────────────────── */
.kh-bento {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}
.kh-tile {
  min-width: 0;
  padding: clamp(22px, 3.5vw, 36px);
  background: var(--paper-000);
  border: 1px solid var(--line-soft);
  border-radius: var(--tag);
}
.kh-tile .kh-head__title { font-size: clamp(1.3rem, 2.6vw, 1.8rem); }

.kh-tile--dark {
  display: flex;
  flex-direction: column;
  background: var(--ink-800);
  border-color: var(--ink-700);
  color: var(--text-invert-muted);
}
.kh-tile--dark .kh-head__code { background: var(--signal); color: var(--ink-900); }
.kh-tile--dark .kh-head__title { color: var(--text-invert); }
.kh-tile__lead { color: var(--text-invert-muted); }

.kh-quote {
  margin: 1.2rem 0;
  padding: 16px 18px;
  background: var(--paper-100);
  border-left: 5px solid var(--signal);
  border-radius: 0 10px 0 10px;
  color: var(--text-strong);
  line-height: 1.85;
}

.kh-points {
  margin: 1.4rem 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
}
.kh-points > div { min-width: 0; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.kh-points dt { font-weight: 700; color: var(--text-strong); margin-bottom: 4px; }
.kh-points dd { margin: 0; font-size: 0.92rem; color: var(--text-muted); line-height: 1.75; }

.kh-checks {
  list-style: none;
  margin: 0.6rem 0 1.8rem;
  padding: 0;
  display: grid;
  gap: 14px;
  flex: 1;
}
.kh-checks li {
  position: relative;
  padding-left: 28px;
  font-size: 0.93rem;
  line-height: 1.75;
}
.kh-checks li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 14px;
  height: 14px;
  background: var(--signal);
  border-radius: 4px 0 4px 0;
}
.kh-checks strong { display: block; color: var(--text-invert); }

/* ─────────────────────────── KHH-05 橫向軌道 ─────────────────────────── */
.kh-track {
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding-bottom: 10px;
}
.kh-track:focus-visible { outline: 3px solid var(--signal); outline-offset: 4px; }

.kh-track__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(210px, 1fr));
  gap: 0;
  counter-reset: none;
}
.kh-track__list li {
  position: relative;
  min-width: 0;
  padding: 44px 20px 0 0;
  scroll-snap-align: start;
}
/* 軌道線：每一格上方一條，最後一格收短 */
.kh-track__list li::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 15px;
  height: 2px;
  background: var(--ink-900);
}
.kh-track__list li:last-child::before { right: 50%; }
.kh-track__no {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--signal);
  color: var(--ink-900);
  border: 2px solid var(--ink-900);
  border-radius: 8px 0 8px 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
}
.kh-track__list h3 { margin: 0 0 6px; font-size: 1.05rem; }
.kh-track__text { font-size: 0.92rem; color: var(--text-muted); }
.kh-track__text > :last-child { margin-bottom: 0; }

/* ─────────────────────────── KHH-06 看板列 ─────────────────────────── */
.kh-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--ink-900);
}
.kh-rows li { border-bottom: 1px solid var(--line-soft); }
.kh-rows a {
  display: grid;
  grid-template-columns: 110px 96px minmax(0, 1fr);
  align-items: baseline;
  gap: 16px;
  padding: 15px 8px;
  color: var(--text-strong);
}
.kh-rows a:hover { background: var(--paper-000); box-shadow: inset 4px 0 0 var(--signal); }
.kh-rows time { font-family: var(--font-mono); font-size: 0.84rem; color: var(--text-muted); }
.kh-rows__kind {
  justify-self: start;
  padding: 1px 8px;
  background: var(--seal-050);
  border-radius: var(--tag-sm);
  font-size: 0.76rem;
  font-weight: 500;
}
.kh-rows__title { min-width: 0; line-height: 1.65; }

/* ─────────────────────────── KHH-07 問與答 ─────────────────────────── */
.kh-qa {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.kh-qa details {
  min-width: 0;
  background: var(--paper-000);
  border: 1px solid var(--line-soft);
  border-radius: var(--tag);
}
.kh-qa details[open] { border-color: var(--ink-700); box-shadow: inset 4px 0 0 var(--signal); }
.kh-qa summary {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 16px;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  color: var(--text-strong);
}
.kh-qa summary::-webkit-details-marker { display: none; }
.kh-qa summary::after { content: "+"; font-family: var(--font-mono); font-size: 1.1rem; }
.kh-qa details[open] summary::after { content: "−"; }
.kh-qa__q { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); }
.kh-qa__a { padding: 0 18px 18px 70px; font-size: 0.94rem; }

/* ─────────────────────────── KHH-08 行政區 ─────────────────────────── */
.kh-districts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.kh-districts li {
  padding: 5px 11px;
  border: 1px solid rgba(236, 238, 239, 0.18);
  border-radius: var(--tag-sm);
  font-size: 0.86rem;
  color: var(--text-invert);
}

/* ─────────────────────────── 響應式 ─────────────────────────── */
@media (max-width: 1100px) {
  .kh-crates { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kh-sym { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .kh-hero__grid { grid-template-columns: minmax(0, 1fr); }
  .kh-bento { grid-template-columns: minmax(0, 1fr); }
  .kh-qa { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .kh-hero__actions .btn { flex: 1 1 100%; }
  .kh-sym { grid-template-columns: minmax(0, 1fr); }
  .kh-crates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kh-crates a { min-height: 84px; padding: 12px; }
  .kh-points { grid-template-columns: minmax(0, 1fr); }

  .kh-rows a { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px 4px; }
  .kh-rows time { grid-row: 1; grid-column: 1; }
  .kh-rows__kind { grid-row: 1; grid-column: 2; justify-self: end; }
  .kh-rows__title { grid-column: 1 / -1; }

  .kh-qa summary { padding: 14px; grid-template-columns: 36px minmax(0, 1fr) 14px; }
  .kh-qa__a { padding: 0 14px 16px; }
}

@media (max-width: 380px) {
  .kh-board__grid > div { padding: 12px; }
  .kh-crates { grid-template-columns: minmax(0, 1fr); }
}
