/* 無人機標案觀測站 — editorial print, zero build */

:root {
  color-scheme: light dark;

  --bg: #f4f3f0;
  --paper: #efedea;
  --fg: #1a1a18;
  --muted: #6c6862;
  --faint: #918c85;
  --rule: #ddd8d0;
  --hair: #e8e4dd;
  --accent: #2b4f6f;

  /* 原產地／類別用色，深淺色各一套 */
  --c1: #2b4f6f;
  --c2: #a8763e;
  --c3: #7d3b3b;
  --c4: #4f6b4a;
  --c5: #9a958c;

  --sans: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  --serif: "Noto Serif TC", "Songti TC", "Source Han Serif TC", Georgia, serif;
  --mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;

  --pad: 22px;
  --col: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131412;
    --paper: #191a18;
    --fg: #e9e6e0;
    --muted: #948f88;
    --faint: #7b766f;
    --rule: #2b2d2a;
    --hair: #232522;
    --accent: #9dc0dc;

    --c1: #7fa9cc;
    --c2: #d8a86a;
    --c3: #c98585;
    --c4: #91b089;
    --c5: #8b867e;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.75;
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
a:hover { color: var(--accent); }

h1, h2, h3, p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

.serif { font-family: var(--serif); font-weight: 700; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.sr-only {
  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;
}

:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

/* ---------- 版面 ---------- */

.site-head, .col, .site-foot {
  max-width: var(--col);
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.site-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 20px;
  padding-top: 18px;
  padding-bottom: 14px;
}

.brand {
  font-size: 15px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.brand:hover { color: var(--fg); }

.site-name {
  flex: 1 1 auto;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.06em;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 18px;
  width: 100%;
  padding: 10px 0 0;
  border-top: 1px solid var(--hair);
}

.nav a {
  padding: 2px 0;
  font-size: 16px;
  color: var(--muted);
  text-decoration: none;
}

.nav a:hover { color: var(--fg); }

.nav a[aria-current="page"] {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 1px;
}

.col > section { padding-block: 52px; }
.col > section + section { border-top: 1px solid var(--rule); }
.col > section.hero { padding-top: 26px; }
.col > section.tight { padding-top: 30px; border-top: 0; }

.sec-h {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 12px;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.sec-h .sec-n { font-family: var(--mono); font-size: 14px; color: var(--accent); }
.sec-h::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--rule); }

.note {
  margin: 0 0 28px;
  max-width: 42em;
  font-size: 16px;
  color: var(--muted);
}

h3 {
  margin: 0 0 14px;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* ---------- hero ---------- */

.lede {
  margin: 0;
  font-size: clamp(28px, 5.2vw, 46px);
  line-height: 1.45;
  letter-spacing: 0.005em;
  max-width: 17em;
}

.lede b { font-weight: 700; }

.page-title {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(26px, 4.4vw, 38px);
  line-height: 1.4;
}

.meta { margin: 18px 0 0; font-size: 16px; color: var(--muted); }
.meta .sep { padding: 0 9px; color: var(--rule); }
.meta time { font-family: var(--mono); font-size: 15px; }

.totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 26px 20px;
  margin: 40px 0 0;
}

.total { border-top: 1px solid var(--rule); padding-top: 8px; }
.total dt { font-size: 14px; letter-spacing: 0.16em; color: var(--muted); }
.total dd {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.1;
}

.total dd .u { font-size: 0.5em; letter-spacing: 0.06em; color: var(--muted); padding-left: 2px; }

/* ---------- 堆疊條 ---------- */

.sbar {
  display: flex;
  width: 100%;
  height: 30px;
  margin: 4px 0 0;
  overflow: hidden;
}

.sbar > span { display: block; height: 100%; min-width: 1px; }
.sbar > span + span { box-shadow: inset 1px 0 0 var(--bg); }

.sbar-big { height: 46px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 26px;
  margin: 16px 0 0;
  font-size: 16px;
}

.legend li { display: flex; align-items: baseline; gap: 8px; }

.legend .sw {
  flex: none;
  width: 22px;
  height: 3px;
  transform: translateY(-4px);
}

.legend .k { color: var(--fg); }
.legend .v { font-size: 15px; color: var(--muted); }

.c1 { background: var(--c1); }
.c2 { background: var(--c2); }
.c3 { background: var(--c3); }
.c4 { background: var(--c4); }
.c5 { background: var(--c5); }
.c6 { background: var(--faint); }

/* ---------- 逐年小圖 ---------- */

.years {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 30px 0 0;
}

.years .yr { min-width: 0; }

.years .col-bar {
  display: flex;
  flex-direction: column-reverse;
  max-width: 130px;
  height: 120px;
  margin: 0 auto;
  background: var(--hair);
}

.years .col-bar > span { display: block; width: 100%; }
.years .col-bar > span + span { box-shadow: inset 0 -1px 0 var(--bg); }

.years .yl {
  display: block;
  padding-top: 7px;
  border-top: 1px solid var(--rule);
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.years .yv {
  display: block;
  font-size: 12px;
  color: var(--faint);
  text-align: center;
}

/* ---------- 長條圖（SVG） ---------- */

.chart { width: 100%; margin-top: 8px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }

.bar { fill: var(--accent); transition: opacity 150ms ease; }
.bar-open { fill: var(--rule); }
.bar:hover, .bar.on { opacity: 1; }
.chart.dim .bar { opacity: 0.42; }
.axis { stroke: var(--rule); stroke-width: 1; }
.tickline { stroke: var(--hair); stroke-width: 1; }
.tlabel {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
.hit { fill: transparent; cursor: default; }

/* ---------- 橫條排行 ---------- */

.hbars { margin-top: 4px; }

.hbar {
  display: grid;
  grid-template-columns: minmax(0, 15em) minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  border-top: 1px solid var(--hair);
  font-size: 17px;
}

.hbar:last-child { border-bottom: 1px solid var(--hair); }
.hbar .k { min-width: 0; overflow-wrap: anywhere; }
.hbar .t { height: 8px; background: var(--accent); min-width: 1px; }
.hbar .v { font-size: 16px; color: var(--muted); }

/* ---------- 最近 ---------- */

.recent li {
  display: grid;
  grid-template-columns: 7.5em minmax(0, 1fr) auto;
  gap: 6px 16px;
  padding: 11px 0;
  border-top: 1px solid var(--hair);
}

.recent li:last-child { border-bottom: 1px solid var(--hair); }
.recent .d { font-family: var(--mono); font-size: 15px; color: var(--muted); }
.recent .t { min-width: 0; font-size: 17px; overflow-wrap: anywhere; }
.recent .t .ag { display: block; font-size: 15px; color: var(--muted); }
.recent .a { font-size: 16px; color: var(--muted); text-align: right; white-space: nowrap; }
.recent .a .ty { display: block; font-size: 14px; color: var(--faint); }

.more { margin-top: 22px; font-size: 16px; }
.more a { text-underline-offset: 5px; }

/* ---------- 圖片 ---------- */

figure.photo { margin: 0; }
figure.photo img { display: block; width: 100%; height: auto; background: var(--hair); }

figure.photo figcaption {
  padding-top: 10px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
}

figure.photo figcaption a { text-underline-offset: 3px; }

/* ---------- 篩選器（細框／底線，無膠囊無陰影） ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 26px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--rule);
}

.field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.field label {
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.field select,
.field input {
  appearance: none;
  min-width: 7em;
  max-width: 100%;
  padding: 3px 18px 3px 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
}

.field select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 8px) calc(50% + 1px), calc(100% - 3px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.field select:hover, .field input:hover { border-bottom-color: var(--fg); }
.field input::placeholder { color: var(--faint); }
.field option { background: var(--bg); color: var(--fg); }

.field-wide input { min-width: 13em; }

.linkish {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 16px;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1px;
  cursor: pointer;
}

.linkish:hover { color: var(--accent); }

.btn {
  appearance: none;
  padding: 5px 14px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.btn:hover { border-color: var(--fg); }

.result-line {
  margin: 16px 0 0;
  font-size: 16px;
  color: var(--muted);
}

.result-line .n { color: var(--fg); }
.result-line .sep { color: var(--rule); }

.more-wrap { margin-top: 22px; }

/* ---------- 表格 ---------- */

.table-wrap { margin-top: 18px; }

table { width: 100%; border-collapse: collapse; font-size: 16px; table-layout: fixed; }

thead th {
  padding: 0 10px 8px 0;
  border-bottom: 1px solid var(--rule);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: 11px 10px 11px 0;
  border-bottom: 1px solid var(--hair);
  vertical-align: baseline;
  overflow-wrap: anywhere;
}

tbody tr:nth-child(4n + 3) td { background: var(--paper); }
tbody td:last-child, thead th:last-child { padding-right: 0; }

.t-date { width: 6.6em; font-family: var(--mono); font-size: 15px; color: var(--muted); white-space: nowrap; }
.t-agency { width: 15%; }
.t-title { width: auto; }
.t-num { width: 5.8em; text-align: right; white-space: nowrap; }
.t-vendor { width: 14%; color: var(--muted); }
.t-status { width: 4.2em; white-space: nowrap; color: var(--muted); }

th.t-num { text-align: right; }

.t-title .open-btn {
  font: inherit;
  text-align: left;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.t-title .open-btn:hover { border-bottom-color: var(--accent); }
.t-title .flag { font-size: 14px; color: var(--faint); padding-left: 8px; white-space: nowrap; }

tr.detail > td { padding: 0 0 18px; border-bottom: 1px solid var(--hair); background: none !important; }

.detail-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 32px;
  padding: 4px 0 0;
  font-size: 16px;
}

.detail-box dl { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 2px 12px; }
.detail-box dt { font-size: 14px; letter-spacing: 0.1em; color: var(--muted); }
.detail-box dd { margin: 0; overflow-wrap: anywhere; }
.detail-box .tl li { font-size: 15px; color: var(--muted); }
.detail-box .tl b { font-family: var(--mono); font-weight: 400; color: var(--fg); padding-right: 10px; }

.empty { padding: 40px 0; color: var(--muted); }
.loading { padding: 40px 0; color: var(--faint); }

/* ---------- 排行（廠商／機關） ---------- */

.rank-group + .rank-group { margin-top: 40px; }

.rank-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

.rank-head h3 { margin: 0; }
.rank-head .s { font-size: 15px; color: var(--muted); }

.rows > li { border-bottom: 1px solid var(--hair); }

.row-btn {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) 8em 5em;
  align-items: baseline;
  gap: 14px;
  width: 100%;
  padding: 12px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 17px;
  text-align: left;
  cursor: pointer;
}

.row-btn:hover .nm { color: var(--accent); }
.row-btn .i { font-family: var(--mono); font-size: 14px; color: var(--faint); }
.row-btn .nm { min-width: 0; overflow-wrap: anywhere; }
.row-btn .nm .tag { font-size: 13px; letter-spacing: 0.08em; color: var(--faint); padding-left: 10px; }
.row-btn .amt { text-align: right; font-size: 16px; }
.row-btn .cnt { text-align: right; font-size: 15px; color: var(--muted); }

.row-body { padding: 2px 0 20px 3.3em; }
.row-body .sub { font-size: 15px; color: var(--muted); margin-bottom: 10px; }

.mini-list li {
  display: grid;
  grid-template-columns: 6.5em minmax(0, 1fr) 7em;
  gap: 4px 14px;
  padding: 6px 0;
  border-top: 1px solid var(--hair);
  font-size: 16px;
}

.mini-list .d { font-family: var(--mono); font-size: 14px; color: var(--muted); }
.mini-list .k { min-width: 0; overflow-wrap: anywhere; }
.mini-list .k .ag { color: var(--muted); font-size: 15px; }
.mini-list .v { text-align: right; font-size: 15px; color: var(--muted); }
.mini-list.two li { grid-template-columns: minmax(0, 1fr) auto; }

/* ---------- 關係圖 ---------- */

.graph { width: 100%; margin-top: 8px; }
.graph svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }

.ribbon {
  fill: var(--accent);
  fill-opacity: 0.22;
  stroke: none;
  transition: fill-opacity 150ms ease;
}

.graph svg.dim .ribbon { fill-opacity: 0.07; }
.ribbon.on { fill-opacity: 0.5; }

.node-v { fill: var(--accent); }
.node-a { fill: var(--c2); }

.node-label {
  fill: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
}

.graph-key {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 26px;
  margin-top: 18px;
  font-size: 15px;
  color: var(--muted);
}

.graph-key li { display: flex; align-items: baseline; gap: 8px; }
.graph-key .sw { flex: none; width: 18px; height: 7px; transform: translateY(-2px); }
.sw-v { background: var(--accent); }
.sw-a { background: var(--c2); }

/* ---------- 提示 ---------- */

.tip {
  position: fixed;
  z-index: 5;
  transform: translate(-50%, -145%);
  padding: 5px 9px;
  background: var(--bg);
  border: 1px solid var(--rule);
  font-size: 15px;
  line-height: 1.55;
  white-space: nowrap;
  pointer-events: none;
}

.tip b { font-weight: 500; }
.tip .m { color: var(--muted); }

/* ---------- 內文（about） ---------- */

.prose { max-width: 40em; font-size: 17px; }
.prose code, .deflist code {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--muted);
}
.prose p + p { margin-top: 18px; }
.prose a { text-underline-offset: 4px; }

.deflist { margin-top: 4px; font-size: 16px; }

.deflist > div {
  display: grid;
  grid-template-columns: 9em minmax(0, 1fr);
  gap: 4px 20px;
  padding: 10px 0;
  border-top: 1px solid var(--hair);
}

.deflist dt { font-size: 15px; color: var(--muted); }
.deflist dd { margin: 0; }

.kwlist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  font-size: 16px;
}

.kwlist li { color: var(--fg); }

.limits { max-width: 44em; font-size: 17px; }
.limits li { padding: 10px 0; border-top: 1px solid var(--hair); }
.limits li:last-child { border-bottom: 1px solid var(--hair); }

/* ---------- 頁尾 ---------- */

.site-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px 24px;
  padding-top: 22px;
  padding-bottom: 56px;
  border-top: 1px solid var(--rule);
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
}

.site-foot a { text-underline-offset: 3px; }
.site-foot .fr { text-align: right; }

/* ---------- 寬螢幕 ---------- */

@media (min-width: 760px) {
  :root { --pad: 44px; }
  .col > section { padding-block: 72px; }
  .col > section.hero { padding-top: 40px; }
  .sec-h { margin-bottom: 14px; }

  .site-head { gap: 6px 26px; padding-top: 22px; }
  .nav { width: auto; margin-left: auto; padding-top: 0; border-top: 0; }
  .site-name { flex: 0 0 auto; }
}

/* ---------- 窄螢幕 ---------- */

@media (max-width: 640px) {
  body { font-size: 17px; }

  .totals { grid-template-columns: repeat(2, 1fr); gap: 22px 18px; }
  .site-foot { grid-template-columns: minmax(0, 1fr); }
  .site-foot .fr { text-align: left; }

  .hbar { grid-template-columns: minmax(0, 1fr) auto; row-gap: 5px; }
  .hbar .t { grid-column: 1 / -1; }

  .recent li { grid-template-columns: minmax(0, 1fr) auto; }
  .recent .d { grid-column: 1 / -1; }

  .years { gap: 5px; }
  .years .col-bar { height: 90px; }
  .years .yl { font-size: 11px; letter-spacing: -0.02em; }
  .years .yv { display: none; }

  .row-btn { grid-template-columns: 2em minmax(0, 1fr) auto; row-gap: 2px; }
  .row-btn .cnt { grid-column: 2 / -1; text-align: left; }
  .row-body { padding-left: 0; }
  .mini-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .mini-list .d { grid-column: 1 / -1; }

  /* 表格轉卡片 */
  table, tbody, tr, td { display: block; width: 100%; }
  table { table-layout: auto; }
  thead { display: none; }

  tbody tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--hair);
  }

  tbody tr:nth-child(4n + 3) td { background: none; }

  tbody td {
    padding: 0;
    border: 0;
    width: auto;
  }

  td.t-date { width: auto; font-size: 14px; }
  td.t-title { width: auto; padding: 3px 0 5px; font-size: 17px; }
  td.t-agency { width: auto; font-size: 15px; color: var(--muted); }

  td.t-num, td.t-vendor, td.t-status {
    display: inline;
    width: auto;
    text-align: left;
    font-size: 15px;
    color: var(--muted);
  }

  td.t-num::before { content: attr(data-l) " "; color: var(--faint); }
  td.t-num + td.t-num::before { content: " · " attr(data-l) " "; }
  td.t-vendor::before { content: " · "; color: var(--rule); }
  td.t-status::before { content: " · "; color: var(--rule); }

  tr.detail > td { padding: 0 0 16px; }
  .detail-box dl { grid-template-columns: 6em minmax(0, 1fr); }
}

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