/* Palette taken from puma.taipei's --brand-* tokens. Light only, like the official site. */
:root {
  --bg: #fff8f4;          /* brand-surface */
  --surface: #ffffff;
  --ink: #211d1d;         /* brand-ink */
  --muted: #665b57;       /* brand-muted */
  --line: #efc5ad;        /* brand-border */
  --brand: #db6a41;       /* brand-primary: fills and large text only */
  --accent: #ad4d2a;      /* brand-action: small text and buttons (AA on white) */
  --accent-hover: #963f24;
  --accent-ink: #ffffff;
  --highlight: #fcea8b;   /* brand-yellow */
  --chip: #fdeee5;
  /* HEART pillar colors, as on puma.taipei/heart. All pass AA as text on our light surfaces. */
  --heart-h: #b00201;
  --heart-e: #5d3188;
  --heart-a: #0753a7;
  --heart-r: #21586c;
  --heart-t: #13744b;
  --radius: 12px;
  color-scheme: light;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

.top, .searchbar, .controls, .summary, main, .foot {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}
.top-band { background: var(--brand); }
.top { padding-top: 40px; padding-bottom: 28px; }
.eyebrow {
  display: inline-block;
  margin: 0;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
}
/* keep-all: wrap only at the spaces, so 導覽器 never splits on phones. */
h1 { margin: 10px 0 10px; font-size: clamp(30px, 6vw, 48px); font-weight: 900; line-height: 1.15; color: #fff; word-break: keep-all; }
.top .lede { margin: 0 0 6px; max-width: 46em; font-weight: 500; }
.top .meta { margin: 0; font-size: 13px; }
.top a { color: var(--ink); font-weight: 700; }
/* Invitation to the official island, where Puma walks the islands (he starts at 01 市府核心).
   Loud in the header band, which scrolls away before the policies start. */
.top .cta { margin: 14px 0 12px; }
.top .cta a {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
}
.top .cta a:hover { background: #000; }
.top .cta a:focus-visible { outline: 3px solid var(--highlight); outline-offset: 2px; }

/* The search bar is always pinned. The filter pills wrap instead of scrolling sideways; on phones
   they're too tall to pin, so they stick (under the search bar) only on wider screens. */
:root { --search-h: 64px; }
.searchbar {
  position: sticky;
  top: 0;
  z-index: 3;
  height: var(--search-h);
  padding-top: 12px;
  padding-bottom: 8px;
  background: var(--bg);
}
.controls {
  background: var(--bg);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
}
#q {
  width: 100%;
  height: 44px;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
#q:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
@media (max-width: 719px) {
  .searchbar { border-bottom: 2px solid var(--line); padding-bottom: 6px; }
  .controls { padding-top: 4px; }
}
@media (min-width: 720px) {
  .controls { position: sticky; top: var(--search-h); z-index: 2; }
}
.filter { display: flex; gap: 4px 10px; align-items: baseline; margin-top: 6px; }
.filter-label { flex: none; width: 7.5em; white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--muted); }
@media (max-width: 540px) {
  .filter { flex-direction: column; }
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  font: inherit;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--ink);
  cursor: pointer;
}
.chips button:hover:enabled { border-color: var(--brand); }
.chips button:disabled { opacity: .35; cursor: default; }
.chips button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
/* HEART pills follow the official site's HEART cards: white, letter and word in the pillar color;
   selected fills with it. */
[data-h="H"] { --heart: var(--heart-h); }
[data-h="E"] { --heart: var(--heart-e); }
[data-h="A"] { --heart: var(--heart-a); }
[data-h="R"] { --heart: var(--heart-r); }
[data-h="T"] { --heart: var(--heart-t); }
.chips button[data-h] { background: var(--surface); color: var(--heart); font-weight: 700; }
.chips button[data-h] .heart-l { font-weight: 900; }
.chips button[data-h]:hover:enabled { border-color: var(--heart); }
.chips button[data-h][aria-pressed="true"] { background: var(--heart); border-color: var(--heart); color: #fff; }
/* Topic pills lead with the island number, like the official map labels. */
.chips .num { font-weight: 700; color: var(--accent); }
.chips button[aria-pressed="true"] .num { color: inherit; }
@media (max-width: 540px) {
  .chips { gap: 4px; }
  .chips button { padding: 4px 8px; }
}

/* Summary: one labelled group per metric (任期期程 / 分階段推動 / 貫穿任期), side by side on wide
   screens. Group widths follow their tile counts so all tiles come out the same size. */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-top: 16px;
}
.sum-group { flex: 3 1 300px; min-width: 0; }
.sum-group:last-child { flex: 1 1 96px; }
.sum-label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.sum-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sum-group:last-child .sum-tiles { grid-template-columns: 1fr; }
@media (max-width: 540px) {
  .sum-group:last-child { flex: 0 0 calc((100% - 12px) / 3); }
}
.summary a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
}
.summary a.empty { opacity: .45; }
.summary a:hover { border-color: var(--brand); }
.summary b { font-size: 22px; font-weight: 900; color: var(--brand); margin-right: 4px; }
.summary .bar { height: 4px; margin-top: 4px; border-radius: 2px; background: var(--brand); }

.bucket { margin-top: 36px; scroll-margin-top: calc(var(--search-h) + 16px); }
@media (min-width: 720px) {
  .bucket { scroll-margin-top: 220px; }
}
.bucket > h2 {
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 4px solid var(--brand);
  font-size: 28px;
  font-weight: 900;
}
.bucket > h2 small { font-size: 14px; font-weight: normal; color: var(--muted); margin-left: 8px; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 -4px 0 0 var(--brand);
}
/* Wraps so a card with three HEART badges keeps its topic name on narrow cards. */
.card .tag { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 8px; font-size: 12px; color: var(--muted); }
/* One badge per HEART letter: letter and name, white on the pillar color. */
.card .heart { display: inline-flex; flex-wrap: wrap; gap: 3px; margin-left: auto; }
.card .heart-b {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--heart);
  color: #fff;
  font-size: 11px;
  line-height: 1;
}
.card .heart-b b { font-weight: 900; }
.card h3 { margin: 0; font-size: 17px; font-weight: 700; }
.card .steps { margin: 0; padding: 0; list-style: none; }
.card .steps li { font-size: 14px; }
.card .when {
  display: inline;
  background: var(--highlight);
  padding: 0 4px;
  border-radius: 4px;
  font-size: 12px;
  margin-right: 4px;
}
.card .desc { margin: 0; font-size: 14px; }
.card .who { margin: 0; font-size: 12px; color: var(--muted); }
.card details { font-size: 13px; color: var(--muted); }
.card details ul { margin: 4px 0 0; padding-left: 18px; }
.card .links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin-top: auto; padding-top: 6px; font-size: 13px; }
/* 分享: a link-styled toggle whose menu opens upward, over the card, so it never runs off the
   bottom of the last card. */
.share { position: relative; }
.share-copy { padding: 0; border: 0; background: none; font: inherit; }
/* 複製並分享 (the menu's stand-in while it's hidden) shares the 分享 toggle's look. */
.share summary, .share-copy {
  list-style: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.share summary::-webkit-details-marker { display: none; }
.share summary::after { content: "▼"; margin-left: 3px; font-size: .6em; vertical-align: .15em; }
.share[open] summary::after { content: "▲"; }
.share summary:hover, .share-copy:hover { color: var(--accent-hover); }
.share-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 9em;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 6px 18px rgb(33 29 29 / .18);
}
.share-menu.flip { left: auto; right: 0; }
.share-menu a, .share-menu button {
  display: block;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.share-menu a:hover, .share-menu button:hover { background: var(--chip); color: var(--ink); }
/* Touch screens: 分享 becomes a pill button and menu items get 44px rows, so each is an easy tap. */
@media (pointer: coarse) {
  .card .links { align-items: center; }
  .share summary, .share-copy {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--chip);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
  }
  .share-menu { min-width: 11em; }
  .share-menu a, .share-menu button {
    display: flex;
    align-items: center;
    min-height: 44px;
    font-size: 16px;
  }
}
/* Card opened from a shared p/<id>/ link: clears the pinned search bar (and filters on wide screens). */
.card { scroll-margin-top: calc(var(--search-h) + 16px); }
@media (min-width: 720px) {
  .card { scroll-margin-top: 220px; }
}
.card.linked { outline: 3px solid var(--highlight); outline-offset: 2px; animation: linked 1.2s ease-out 2; }
@keyframes linked { 50% { outline-color: var(--brand); } }
@media (prefers-reduced-motion: reduce) {
  .card.linked { animation: none; }
}

/* Bottom padding clears the floating back-to-top button. */
.foot { margin-top: 56px; padding-bottom: 88px; font-size: 12px; color: var(--muted); }
.foot .credit a { color: inherit; }
.foot .credit a:hover { color: var(--accent); }
.no-match { margin-top: 32px; color: var(--muted); }

/* Confirmation after 複製並分享, above the back-to-top button. */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px);
  z-index: 4;
  width: max-content;
  max-width: min(92vw, 560px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 6px 18px rgb(33 29 29 / .3);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

/* Back-to-top shortcut: hidden until the header scrolls out of view. */
.to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 3;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgb(33 29 29 / .25);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--accent-hover); }
.to-top:focus-visible { outline: 3px solid var(--highlight); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .to-top { transition: none; }
}
