/* ARKO Open 前台樣式（WP-05a 搬入 apps/open）。
   LEATHER tokens 由 @arko/design-tokens 提供（/tokens.css，早於本檔載入），
   本檔不再自帶變數定義，消除漂移。 */

/* ARKO 前台樣式 — Flat 皮革／紅色版（依 v2 交付稿，車縫線細節） */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background-color: var(--leather);
  /* 皮革紋理 + 上下打光 */
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -10%, oklch(0.26 0.018 48) 0%, transparent 55%),
    radial-gradient(ellipse 100% 60% at 50% 110%, var(--leather-lo) 0%, transparent 50%),
    url('/leather.webp');
  background-size: auto, auto, 384px 384px;
  background-attachment: fixed, fixed, scroll;
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.7;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.mono { font-family: var(--font-mono); }
.container { max-width: 1200px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 56px); }
.section { padding: clamp(40px, 6vw, 68px) clamp(20px, 5vw, 56px); }
h1 { font-family: var(--display-font); font-weight: 900; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.12; letter-spacing: -0.8px; margin: 0 0 14px; color: var(--fg-strong); }
h2 { font-family: var(--display-font); font-weight: 700; font-size: clamp(1.5rem, 3vw, 2.2rem); margin: 0 0 16px; color: var(--fg-strong); }
.sep { color: var(--text-faint); margin: 0 4px; }

/* 皮革面板：內陰影塑形（凸起頂邊 + 內凹暗底 + 落影）+ 內縮車縫線 */
.panel,
.risk-card,
.domain-card,
.hero-stat,
.framework-card,
.filter-bar,
.legend-item {
  position: relative;
  background: var(--panel);
  border-radius: 16px;
  box-shadow:
    0 2px 0 var(--leather-hi) inset,
    0 -3px 8px oklch(0.12 0.01 40 / 0.5) inset,
    0 14px 30px -18px #000;
  outline: 1.5px dashed var(--thread);
  outline-offset: -8px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in oklch, var(--leather) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--leather-lo);
  box-shadow: 0 1px 0 var(--leather-hi) inset;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 15px clamp(20px, 5vw, 56px);
}
.brand { text-decoration: none; display: flex; align-items: baseline; gap: 11px; }
.brand-mark {
  font-family: var(--display-font);
  font-weight: 900;
  letter-spacing: 0.03em;
  color: var(--fg-strong);
  font-size: 1.4rem;
  text-shadow: 0 1px 1px var(--leather-lo);
}
.brand-sub { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.site-nav { display: flex; gap: 22px; flex: 1; }
.site-nav a { text-decoration: none; color: var(--fg); font-size: 0.95rem; font-weight: 500; }
.site-nav a:hover { color: var(--fg-strong); }
.header-actions { display: flex; align-items: center; gap: 12px; }
.lang-switch {
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border: 1px solid var(--leather-hi);
  border-radius: 8px;
  padding: 5px 11px;
  color: var(--muted);
  background: var(--leather-lo);
}
.lang-switch:hover { color: var(--fg-strong); border-color: var(--red); }
/* 縫線白/紅切換 */
.thread-seg { display: flex; align-items: center; gap: 8px; }
.thread-seg .thread-label { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.08em; color: var(--muted); }
.thread-seg .thread-btns {
  display: flex; align-items: center; gap: 3px; padding: 3px;
  border: 1px solid var(--leather-hi); border-radius: 10px; background: var(--leather-lo);
}
.thread-seg button {
  font: inherit; font-size: 0.8rem; font-weight: 700;
  border: none; border-radius: 7px; padding: 4px 13px;
  background: none; color: var(--muted); cursor: pointer;
}
.thread-seg button.active { background: var(--red); color: #fff; box-shadow: 0 1px 0 oklch(0.72 0.18 30) inset; }

/* Hero */
.hero { padding: clamp(56px, 9vw, 104px) 0 clamp(36px, 6vw, 64px); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  color: var(--thread);
  font-weight: 500;
  opacity: 0.9;
  margin: 0 0 28px;
}
.hero h1 { font-family: var(--display-font); font-weight: 900; font-size: clamp(2.6rem, 7vw, 5.6rem); line-height: 1.08; letter-spacing: -1.5px; max-width: 20ch; margin: 0 0 26px; text-shadow: 0 2px 3px var(--leather-lo); }
.hero-sub { color: var(--muted); max-width: 640px; margin: 0 0 38px; font-size: clamp(1rem, 1.3vw, 1.35rem); line-height: 1.7; }
.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  color: #fff;
  border-radius: 13px;
  padding: 16px 32px;
  font-size: 1.05rem;
  font-weight: 700;
  outline: 1.5px dashed var(--thread);
  outline-offset: -7px;
  box-shadow: 0 10px 26px -12px var(--red), 0 1px 0 oklch(0.72 0.18 30) inset;
  transition: transform 0.2s ease;
}
.cta:hover { transform: translateY(-2px); }

/* Hero 統計磚（縫線面板） */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 18px;
  margin-top: 60px;
}
.hero-stat { padding: 26px 24px; display: flex; flex-direction: column; gap: 10px; }
.hero-stat .num { font-family: var(--font-mono); font-size: 3rem; font-weight: 600; color: var(--fg-strong); line-height: 1; }
.hero-stat .label { font-size: 0.95rem; color: var(--muted); }

/* 箭頭流生命週期（首頁） */
.arrow-flow-wrap { overflow-x: auto; padding-bottom: 4px; }
.arrow-flow { display: flex; min-width: 940px; }
.arrow-seg {
  position: relative;
  flex: 1;
  min-width: 132px;
  height: 138px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 14px 0 38px;
  margin-left: -18px;
  text-decoration: none;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%, 18px 50%);
}
.arrow-seg:first-child {
  margin-left: 0;
  padding-left: 24px;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%);
}
.arrow-seg:last-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 18px 50%);
}
.arrow-seg .idx { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; color: var(--fg-strong); opacity: 0.5; }
.arrow-seg .name { font-size: 1rem; font-weight: 700; color: var(--fg-strong); margin: 5px 0 3px; }
.arrow-seg .count { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 700; color: var(--fg-strong); }
.arrow-seg.active {
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  box-shadow: 0 12px 30px -14px var(--red);
}
.arrow-seg.active .idx { color: #fff; opacity: 0.7; }
.arrow-seg.active .name { color: #fff; }
.arrow-seg.active .count { color: #fff; font-size: 1.9rem; }

/* 六大領域卡 */
.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}
.domain-card {
  text-decoration: none;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  transition: transform 0.2s ease;
}
.domain-card:hover { transform: translateY(-3px); }
.domain-card .code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg-strong);
  background: color-mix(in oklch, var(--red) 22%, var(--leather-lo));
  padding: 5px 12px;
  border-radius: 7px;
  outline: 1px dashed var(--thread);
  outline-offset: -3px;
  align-self: flex-start;
}
.domain-name { font-size: 1.25rem; font-weight: 700; color: var(--fg-strong); }
.domain-count { font-family: var(--font-mono); font-size: 0.9rem; color: var(--muted); }

/* 嚴重度分布條 */
.severity-bar {
  display: flex;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  outline: 1.5px dashed var(--thread);
  outline-offset: -6px;
}
.severity-bar.mini { height: 10px; margin: 8px 0; outline: none; border-radius: 4px; }
.sev-seg { min-width: 2px; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 600; font-size: 0.9rem; color: #fff; }
.sev-bg-critical { background: var(--sev-critical); }
.sev-bg-significant { background: var(--sev-high); }
.sev-bg-moderate { background: var(--sev-medium); color: oklch(0.25 0.05 90); }
.sev-bg-minor { background: var(--sev-low); color: oklch(0.25 0.06 155); }
.severity-legend { display: flex; gap: 14px; margin-top: 24px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 10px; padding: 14px 18px; flex: 1; min-width: 170px; font-size: 0.95rem; color: var(--fg); border-radius: 12px; outline-offset: -6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend-item .mono { margin-left: auto; color: var(--fg-strong); font-weight: 600; }

/* 篩選列 */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 18px;
  margin-bottom: 20px;
}
.filter-bar label { display: flex; flex-direction: column; gap: 5px; font-size: 0.78rem; color: var(--muted); }
.filter-bar select, .filter-bar input {
  font: inherit;
  font-size: 0.88rem;
  padding: 9px 11px;
  border: 1px solid var(--leather-hi);
  border-radius: 9px;
  background: var(--leather-lo);
  color: var(--fg);
  min-width: 130px;
}
.filter-keyword { flex: 1; min-width: 180px; }
.filter-keyword input { width: 100%; }
.filter-actions { display: flex; align-items: center; gap: 12px; }
.filter-actions button {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  background: linear-gradient(180deg, var(--red-bright), var(--red));
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 10px 22px;
  cursor: pointer;
}
.filter-actions a { font-size: 0.85rem; color: var(--muted); }
.result-count { color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* 風險卡 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.risk-card {
  text-decoration: none;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s ease;
}
.risk-card:hover { transform: translateY(-3px); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-top .code { font-family: var(--font-mono); font-size: 0.78rem; color: var(--fg-strong); font-weight: 600; }
.sev-pill {
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 99px;
  padding: 3px 11px;
  color: #fff;
  white-space: nowrap;
}
.sev-critical { background: var(--sev-critical); }
.sev-significant { background: var(--sev-high); }
.sev-moderate { background: var(--sev-medium); color: oklch(0.25 0.05 90); }
.sev-minor { background: var(--sev-low); color: oklch(0.25 0.06 155); }
.card-title { margin: 0; font-family: var(--display-font); font-size: 1.2rem; font-weight: 700; line-height: 1.4; color: var(--fg-strong); }
.card-domain { margin: 0; font-size: 0.85rem; color: var(--muted); flex: 1; }
.card-bottom { display: flex; justify-content: space-between; align-items: center; }
.mappings { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); letter-spacing: 0.05em; }

/* 七格階段軌跡 */
.stage-track { display: inline-flex; gap: 3px; }
.stage-cell { width: 9px; height: 9px; border-radius: 2px; background: var(--stage-off); }
.stage-cell.on { background: var(--red); }
.stage-track-lg .stage-cell { width: 15px; height: 15px; border-radius: 4px; }

/* 分頁 */
.pagination { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 30px; font-size: 0.9rem; }
.pagination a { color: var(--red-bright); text-decoration: none; }
.pagination .disabled { color: var(--text-faint); }
.page-info { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); }

/* 詳情頁 */
.breadcrumb { font-size: 0.85rem; color: var(--muted); margin: 0 0 20px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--fg-strong); }
.detail-header { margin-bottom: 30px; }
.detail-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.detail-meta .code { font-family: var(--font-mono); color: var(--fg-strong); font-weight: 600; }
.detail-stages { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.stage-names { font-size: 0.85rem; color: var(--muted); }
.detail-section { margin-bottom: 34px; }
.detail-desc { max-width: 760px; white-space: pre-line; font-size: 1.05rem; }
.detail-columns { display: grid; grid-template-columns: 1fr 300px; gap: 30px; }
.framework-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.framework-card {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-radius: 12px;
  outline-offset: -6px;
}
.fw-name { font-family: var(--font-mono); font-size: 0.78rem; color: var(--red-bright); }
.fw-ref { font-size: 0.9rem; color: var(--fg); }
.tag-group { margin-bottom: 20px; }
.tag-group h3 { font-size: 0.8rem; color: var(--muted); margin: 0 0 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 0.78rem;
  border: 1px solid var(--leather-hi);
  background: var(--leather-lo);
  border-radius: 99px;
  padding: 4px 12px;
  color: var(--fg);
}

/* 控制措施（綠色語意） */
.controls-section h2, .controls-section h3 { color: var(--accent-control); }
.controls-list { list-style: none; padding: 0; margin: 0 0 22px; display: flex; flex-wrap: wrap; gap: 8px; }
.controls-list li {
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  border-radius: 8px;
  padding: 7px 15px;
  font-size: 0.9rem;
  color: var(--fg-strong);
}
.steps-list { padding: 0; margin: 0; counter-reset: step; list-style: none; max-width: 760px; }
.steps-list li {
  counter-increment: step;
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  border-radius: 10px;
  padding: 11px 15px 11px 48px;
  margin-bottom: 8px;
  position: relative;
  font-size: 0.92rem;
  color: var(--fg-strong);
}
.steps-list li::before {
  content: counter(step);
  position: absolute;
  left: 15px;
  top: 11px;
  font-family: var(--font-mono);
  color: var(--accent-control);
  font-weight: 700;
}
.pending-badge {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--muted);
  border: 1px dashed var(--leather-hi);
  border-radius: 99px;
  padding: 2px 10px;
  margin-left: 8px;
  vertical-align: middle;
  font-weight: 400;
}
.detail-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--leather-hi);
  padding-top: 20px;
  font-size: 0.88rem;
  gap: 12px;
}
.detail-nav a { color: var(--red-bright); text-decoration: none; }

/* 生命週期頁 */
.page-sub { color: var(--muted); max-width: 640px; margin-bottom: 30px; font-size: 1.05rem; }
.lifecycle-flow { display: flex; flex-direction: column; gap: 16px; }
.lifecycle-stage { padding: 20px 24px; }
.stage-head { display: flex; align-items: baseline; gap: 12px; }
.stage-head h2 { margin: 0; font-size: 1.25rem; }
.stage-head .stage-count { font-family: var(--font-mono); font-size: 0.85rem; color: var(--muted); }
.stage-desc { color: var(--muted); font-size: 0.92rem; margin: 6px 0 0; }
.top-risks-label { font-size: 0.78rem; color: var(--text-faint); margin: 12px 0 4px; }
.top-risks { list-style: none; padding: 0; margin: 0 0 10px; }
.top-risks li { font-size: 0.9rem; padding: 2px 0; }
.top-risks a { text-decoration: none; color: var(--fg); }
.top-risks a:hover { color: var(--red-bright); }
.top-risks .mono { color: var(--muted); font-size: 0.78rem; margin-right: 6px; }
.stage-all { font-size: 0.85rem; color: var(--red-bright); text-decoration: none; }

/* 首頁生命週期地圖用的 stage-node（沿用箭頭流則不需要，保留為 fallback） */
.lifecycle-map { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stage-node { text-decoration: none; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.stage-index { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-faint); font-weight: 600; }
.stage-name { font-size: 0.88rem; font-weight: 700; color: var(--fg-strong); }
.stage-count { font-family: var(--font-mono); font-size: 1.25rem; font-weight: 700; color: var(--fg-strong); }

/* 關於頁 */
.about section { max-width: 760px; margin-bottom: 28px; }
.about h2 { font-size: 1.3rem; }
.about p { color: var(--muted); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--leather-lo);
  box-shadow: 0 1px 0 var(--leather-hi) inset;
  margin-top: 48px;
  padding: 40px 0 44px;
  font-size: 0.82rem;
  color: var(--muted);
}
.footer-note { color: var(--text-faint); font-size: 0.78rem; margin: 6px 0 0; }

/* 響應式 */
@media (max-width: 900px) {
  .detail-columns { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .framework-grid { grid-template-columns: 1fr; }
  .header-inner { flex-wrap: wrap; gap: 10px; }
  .site-nav { order: 3; width: 100%; }
  .hero h1 { white-space: normal; }
}

/* ── WP-05a: RWD 加固（手機不破版；細節視覺留後微調）───────────── */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video { max-width: 100%; height: auto; }
.arrow-flow-wrap { -webkit-overflow-scrolling: touch; }

@media (max-width: 640px) {
  .header-inner { flex-wrap: wrap; gap: 10px; }
  .site-nav { order: 3; width: 100%; flex-wrap: wrap; gap: 12px 16px; }
  .header-actions { margin-left: auto; }
  .hero h1 { font-size: clamp(1.6rem, 8vw, 2.2rem); }
  .hero-stats { gap: 12px; }
  .domain-grid { grid-template-columns: 1fr 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .detail-columns { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-keyword { grid-column: 1 / -1; }
  .detail-nav { flex-wrap: wrap; gap: 12px; }
  .tags { flex-wrap: wrap; }
}

@media (max-width: 400px) {
  .domain-grid { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr; }
}
