/* ============================================================
   UI 風格範例站（根目錄 index.html）的樣式
   - 這一頁只是入口：中性的白底、細線與單一藍色，讓 30 套風格的縮圖當主角
   - 不依賴 Bootstrap，也不需要編譯；直接改這支檔案即可
   - 預覽頁（preview.html）也載入這支，再加上自己的 preview.css
   ============================================================ */

:root {
  /* 色票（括號內是對白底的對比度） */
  --ink: #15171a;        /* 主文字（18.0:1） */
  --muted: #5b616b;      /* 次要文字（6.2:1） */
  --rule: #e2e4e8;       /* 細線、卡片框（裝飾用） */
  --rule-strong: #c9cdd3;
  --panel: #f4f5f7;      /* 區塊底（次要文字在上面 5.7:1） */
  --accent: #2348d8;     /* 連結、主要按鈕、焦點（7.0:1） */
  --accent-deep: #1d3bb8;
  --paper: #ffffff;

  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --wrap: 1280px;
  --gutter: 20px;
  --radius: 6px;
}

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

html { scroll-padding-top: 88px; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: .25em; }
a:hover { color: var(--accent-deep); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
code {
  padding: .1em .35em;
  border-radius: 4px;
  background: var(--panel);
  font-size: .875em;
}

/* 詞組換行：標題與短句只在空白、標點與 <wbr> 處換行 */
.text-phrase { word-break: keep-all; overflow-wrap: anywhere; }
.num { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--gutter);
  z-index: 10;
  padding: .5rem 1rem;
  background: var(--ink);
  color: #fff;
}
.skip-link:focus { top: 12px; color: #fff; }

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
@media (min-width: 768px) { :root { --gutter: 32px; } }

/* ---------- 頁首 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}
.site-title {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.site-title small { color: var(--muted); font-size: .875rem; font-weight: 400; }
.site-nav { display: flex; gap: 1.25rem; font-size: .9375rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--ink); }
@media (max-width: 767.98px) {
  .site-title small,
  .site-nav .hide-sm { display: none; }
}

/* ---------- 開場 ---------- */
.hero { padding-block: 56px 40px; }
@media (min-width: 992px) { .hero { padding-block: 64px 48px; } }
.hero h1 {
  font-size: clamp(2.25rem, 5vw, 3.75rem);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: .02em;
}
.hero-lead {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 1.125rem;
}

/* ---------- 總目錄（index.html 與預覽頁的側欄共用，內容由 directory.js 產生） ---------- */
.dir { display: grid; gap: 1.5rem; margin: 0; padding: 0; list-style: none; }
.dir-theme {
  display: grid;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.dir-theme > * { min-width: 0; }
.dir-head h3 { font-size: 1.125rem; font-weight: 700; line-height: 1.5; }
.dir-head h3 .num { color: var(--accent); }
.dir-brand { color: var(--muted); font-size: .9375rem; }
.dir-more { display: inline-flex; align-items: center; min-height: 32px; font-size: .9375rem; }

/* 縮圖：手機一列 3 套，平板以上一列 6 套 */
.dir-styles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 768px) { .dir-styles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.dir-style { display: block; color: var(--ink); text-decoration: none; }
.dir-style img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--panel);
}
.dir-name { display: block; margin-top: .375rem; font-size: .875rem; line-height: 1.5; }
.dir-name .num { color: var(--muted); }
.dir-style:hover { color: var(--accent); }
.dir-style:hover img { border-color: var(--accent); }
/* 預覽頁目前的風格 */
.dir-style[aria-current] { color: var(--accent); font-weight: 700; }
.dir-style[aria-current] img { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* index.html 的桌機寬度：主題在左，6 套在右 */
@media (min-width: 1200px) {
  .section-directory .dir-theme { grid-template-columns: 13rem minmax(0, 1fr); gap: 2rem; }
}

/* ---------- 區塊 ---------- */
.section { padding-block: 64px; border-top: 1px solid var(--rule); }
@media (min-width: 992px) { .section { padding-block: 88px; } }
.section-alt { background: var(--panel); }
/* 總目錄緊接在開場後面 */
.section.section-directory { padding-top: 0; border-top: 0; }
.section-head { margin-bottom: 1.5rem; }
.section-head h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 700; line-height: 1.35; }
.section-head p { margin-top: .75rem; color: var(--muted); }
.section-head h3 { margin-top: 1.5rem; font-size: 1.125rem; }
.section-head .usage-lead {
  color: var(--ink);
  font-size: 1.0625rem;
}

/* 「什麼時候用」「題材」兩段說明 */
.usage-facts {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0 0;
}
.usage-facts div {
  display: grid;
  gap: .25rem 1.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--rule-strong);
}
@media (min-width: 768px) { .usage-facts div { grid-template-columns: 8rem 1fr; } }
.usage-facts dt { font-weight: 700; }
.usage-facts dd { color: var(--muted); }

/* 怎麼使用：使用步驟 → 三個入口 → 下載原始碼，由上往下讀 */
.usage-block + .usage-block {
  margin-top: 3rem;
  padding-top: 3rem;
  border-top: 1px solid var(--rule);
}
.usage-block h3 { margin-bottom: 1.25rem; font-size: 1.125rem; }

/* 使用步驟：手機一欄、平板兩欄、桌機四欄 */
.steps {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 768px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.steps > li {
  padding: 1.25rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
}
.steps .step-no { color: var(--accent); font-size: .875rem; font-weight: 700; }
.steps h4 { margin: .25rem 0 .5rem; font-size: 1.0625rem; font-weight: 700; }
.steps > li > p:not(.step-no),
.steps > li > ul { color: var(--muted); }
/* 步驟內的分項（例如第四步的里程碑分工） */
.steps ul { margin: .5rem 0 0; padding-left: 1.25rem; }
.steps ul li + li { margin-top: .25rem; }

/* 三個入口：按鈕在上、說明在下，桌機三欄 */
.button-guide {
  display: grid;
  gap: 1.5rem 2rem;
  margin: 0;
}
@media (min-width: 992px) { .button-guide { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.button-guide div { display: grid; gap: .75rem; align-content: start; }
.button-guide dt { justify-self: start; }
.button-guide dd { margin: 0; color: var(--muted); }

/* 下載原始碼：說明＋指令，桌機左右並排 */
.download { display: grid; gap: 1.5rem; }
@media (min-width: 992px) { .download { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; } }
/* grid 子元素預設不會比內容窄，程式碼框的長指令會把欄位撐寬；設 0 讓它在欄內橫向捲動 */
.download > *,
.steps > *,
.button-guide > *,
.theme-head > * { min-width: 0; }
.download p + p { margin-top: .75rem; }
.download pre { margin-top: .5rem; }
pre {
  margin: 1rem 0 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--ink);
  color: #e8eaee;
  font-size: .875rem;
  line-height: 1.7;
}
pre code { padding: 0; background: none; font-size: inherit; }
.usage-note { margin-top: 1rem; color: var(--muted); font-size: .875rem; }
.download .usage-note:first-child { margin-top: 0; }

/* ---------- 主題 ---------- */
.theme-head {
  display: grid;
  gap: 2rem;
  margin-bottom: 2.5rem;
}
/* 右側 .theme-aside 先隱藏，theme-head 改為單欄占滿；恢復時一併打開這行
@media (min-width: 992px) { .theme-head { grid-template-columns: 7fr 5fr; gap: 4rem; } }
*/
.theme-no {
  color: var(--accent);
  font-size: .9375rem;
  font-weight: 700;
}
.theme-head h2 {
  margin-top: .25rem;
  font-size: clamp(1.75rem, 3.6vw, 2.5rem);
  font-weight: 900;
  line-height: 1.25;
}
.theme-brand { margin-top: .5rem; font-size: 1.125rem; font-weight: 500; }
.theme-desc { margin-top: 1rem; color: var(--muted); }
.theme-facts { display: grid; gap: .75rem; margin-top: 1.5rem; font-size: .9375rem; }
.theme-facts div { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem; }
.theme-facts dt { color: var(--muted); }

.theme-aside {
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
}
.theme-aside h3 { font-size: 1rem; }
.page-list { margin-top: .75rem; padding-left: 1.5rem; font-size: .9375rem; }
.page-list li + li { margin-top: .25rem; }
.page-list code { margin-left: .25rem; color: var(--muted); }
.resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.25rem;
  margin: 1.25rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--rule);
  list-style: none;
  font-size: .9375rem;
}
.resource-links a { display: inline-flex; align-items: center; min-height: 32px; }

/* 風格卡：三欄（lg）、兩欄（md）、一欄（手機） */
.style-grid {
  display: grid;
  gap: 2rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 768px) { .style-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .style-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.style-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.style-shot {
  display: block;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
}
.style-shot img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  transition: transform .3s ease;
}
@media (prefers-reduced-motion: no-preference) {
  .style-shot:hover img { transform: scale(1.02); }
}
.style-body { display: flex; flex: 1; flex-direction: column; padding-top: 1.25rem; }
.style-no { color: var(--muted); font-size: .875rem; }
.style-card h3 { font-size: 1.375rem; font-weight: 700; line-height: 1.4; }
.style-colors { margin-top: .5rem; font-size: .9375rem; }
.style-feature { margin-top: .5rem; color: var(--muted); font-size: .9375rem; }

.style-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
  margin-top: auto;
  padding-top: 1.25rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  min-height: 44px;
  padding: .5rem .75rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-size: .9375rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn-primary:hover { border-color: var(--accent-deep); background: var(--accent-deep); color: #fff; }
.btn svg { flex: 0 0 auto; width: 14px; height: 14px; }

/* 全部頁面（展開） */
.style-pages { margin-top: .75rem; font-size: .9375rem; }
.style-pages summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent);
  cursor: pointer;
}
.style-pages ul {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  margin: 0;
  padding: .25rem 0 0;
  list-style: none;
}
.style-pages a { display: inline-flex; align-items: center; min-height: 32px; }

.planned {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: .9375rem;
}
.planned strong { color: var(--ink); font-weight: 500; }

/* ---------- 名詞清單 ---------- */
.glossary {
  display: grid;
  margin: 0;
  border-top: 1px solid var(--rule-strong);
}
.glossary div {
  display: grid;
  gap: .25rem 2rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--rule);
}
@media (min-width: 768px) { .glossary div { grid-template-columns: 12rem 1fr; } }
.glossary dt { font-weight: 700; }
.glossary dd { color: var(--muted); }

.notes { padding-left: 1.25rem; color: var(--muted); }
.notes li + li { margin-top: .5rem; }

/* ---------- 頁尾 ---------- */
.site-footer {
  padding-block: 40px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: .875rem;
}
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 2rem; }
