/* Chase's Keyword Crawler 全站樣式：顏色、字級、間距都從這裡的變數來，改主題色只要改 --accent。 */

:root {
  --accent: #2F5BD3;       /* 主要按鈕、排名、品牌圖示 */
  --accent-ink: #2446A8;   /* 連結、選取狀態文字 */
  --accent-soft: #EAF0FD;  /* 標籤、目前頁底色 */
  --accent-muted: #A9BCEB; /* 第 4 名之後的長條 */
  --danger: #D92D20;
  --danger-ink: #B42318;
  --danger-soft: #FEF3F2;
  --ink: #111827;
  --ink-2: #4B5563;
  --muted: #5B6474;
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #EEF1F5;
  --line: #E3E7ED;
  --line-soft: #EEF1F5;
  --field: #CBD2DC;
  --radius: 10px;
  --radius-card: 16px;
  --font: 'Noto Sans TC', system-ui, -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-ink); }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 900; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- 版面 ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container--narrow { max-width: 760px; }
.page { padding-top: 28px; padding-bottom: 64px; display: flex; flex-direction: column; gap: 24px; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split__main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.split__side { flex: 1 1 300px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 28px; }
.card--flush { padding: 0; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.page-title { font-size: 28px; }
.section-title { font-size: 20px; }
.breadcrumb { font-size: 14px; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.empty { padding: 32px 24px; text-align: center; color: var(--muted); }

/* ---------- 頂部導覽 ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-top: 12px; padding-bottom: 12px; }
.logo { display: flex; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent); }
.brand__mark { flex: none; }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; color: var(--ink); }
.brand__name { font-size: 13px; font-weight: 500; color: var(--muted); }
.brand__sub { font-size: 17px; font-weight: 900; letter-spacing: -0.01em; }
.brand--dark { color: #6F93F0; }
.brand--dark .brand__text { color: #FFFFFF; }
.brand--dark .brand__name { color: #9CA3AF; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 10px 14px; border-radius: 8px; font-weight: 500; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.search { flex: 1 1 240px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: var(--radius); padding: 0 12px; min-height: 44px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 15px; min-height: 44px; outline: none; }
.header-avatar img { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); display: block; }
.site-footer { border-top: 1px solid var(--line); padding: 24px; text-align: center; font-size: 13px; color: var(--muted); }

/* ---------- 按鈕、標籤、表單 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { color: var(--ink); border-color: var(--field); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; font-weight: 700; }
.btn--primary:hover { color: #FFFFFF; filter: brightness(0.93); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.btn--block { width: 100%; min-height: 48px; font-size: 16px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; }
.pill[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; font-weight: 700; }
.tag { display: inline-block; font-size: 13px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; }

.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field legend { font-weight: 700; }
.field input, .field select, .field textarea { font: inherit; font-size: 16px; min-height: 48px; padding: 0 14px; border: 1px solid var(--field); border-radius: var(--radius); background: var(--surface); color: var(--ink); width: 100%; }
.field textarea { padding: 12px 14px; line-height: 1.8; resize: vertical; }
.field .help { font-size: 14px; color: var(--muted); }
.field .error { font-size: 14px; color: var(--danger-ink); }
.field--error input, .field--error textarea { border-color: var(--danger); }
.field__row { display: flex; justify-content: space-between; align-items: baseline; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; }

.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.message { padding: 12px 16px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger-ink); font-weight: 500; }
.message--success { background: #ECFDF3; color: #067647; }

/* ---------- 熱門關鍵字 ---------- */
.keywords { list-style: none; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.keyword { display: grid; grid-template-columns: 32px minmax(72px, 140px) minmax(0, 1fr) 56px; align-items: center; gap: 12px; padding: 10px 8px; border-radius: var(--radius); }
.keyword:hover { background: var(--bg); }
.keyword__rank { font-size: 20px; font-weight: 900; color: var(--muted); }
.keyword__word { font-size: 20px; font-weight: 700; }
.keyword__bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.keyword__bar span { display: block; height: 100%; background: var(--accent-muted); border-radius: 5px; }
.keyword__count { font-size: 14px; color: var(--muted); text-align: right; }
.keyword--top .keyword__rank { color: var(--accent); }
.keyword--top .keyword__bar span { background: var(--accent); }

/* ---------- 話題 ---------- */
.topic-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.topic-link { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--bg); }
.topic-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.topic-link__name { display: block; font-weight: 700; font-size: 17px; }
.topic-link__count { font-size: 14px; font-weight: 700; color: var(--accent-ink); white-space: nowrap; }
.topic-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.topic-head h1 { font-size: 32px; }

/* ---------- 文章列表 ---------- */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-list > li + li { border-top: 1px solid var(--line-soft); }
.post-row { display: flex; gap: 16px; padding: 20px 24px; align-items: flex-start; }
.post-row__avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); flex: none; }
.post-row__body { flex: 1; min-width: 0; }
.post-row__title { display: block; font-size: 18px; font-weight: 700; margin-top: 2px; }
.post-row__excerpt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 15px; color: var(--ink-2); margin-top: 4px; }
.post-row__meta { font-size: 13px; color: var(--muted); }
.post-row__aside { font-size: 13px; color: var(--muted); white-space: nowrap; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 12px; }

/* ---------- 文章內頁 ---------- */
.article { padding: 36px; }
.article h1 { margin-top: 12px; font-size: 34px; }
.byline { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.byline img { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); }
.prose { margin-top: 28px; font-size: 18px; line-height: 1.85; color: var(--ink); overflow-wrap: anywhere; }
.prose p { margin: 0 0 1em; }
.prose img { height: auto; border-radius: var(--radius); }
.article__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.comments { display: flex; flex-direction: column; gap: 20px; }
.comment-form { display: flex; gap: 12px; align-items: flex-start; }
.comment-form .form { flex: 1; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment { display: flex; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line-soft); }
.comment img, .comment-form > img { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); flex: none; }
.comment p { margin-top: 4px; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- 登入 / 註冊 ---------- */
.auth { display: flex; flex-wrap: wrap; min-height: 100vh; }
.auth__brand { flex: 1 1 420px; background: var(--ink); color: var(--bg); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.auth__brand .brand__sub { font-size: 20px; }
.auth__slogan { font-size: 40px; font-weight: 900; line-height: 1.3; }
.auth__points { margin: 28px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; font-size: 17px; color: var(--line); }
.auth__points li::before { content: '✓'; color: #8FB0FF; font-weight: 900; margin-right: 10px; }
.auth__panel { flex: 1 1 480px; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth__box { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 24px; }
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--line-soft); border-radius: 12px; padding: 4px; }
.segmented a { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 9px; color: var(--ink-2); font-weight: 500; }
.segmented a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.avatar-picker { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; border: 0; margin: 0; padding: 0; }
.avatar-picker label { display: block; padding: 6px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; }
.avatar-picker input { position: absolute; opacity: 0; }
.avatar-picker input:checked + img { outline: 0; }
.avatar-picker label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.avatar-picker label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.avatar-picker img { display: block; width: 100%; height: auto; }

/* ---------- 個人頁面 ---------- */
.profile-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.profile-card > img { width: 112px; height: 112px; border-radius: 50%; background: var(--surface-2); }
.stats { margin: 12px 0 0; width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats div { background: var(--bg); border-radius: var(--radius); padding: 10px 4px; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 0; font-size: 20px; font-weight: 900; }

/* ---------- 手機 ---------- */
.tabbar { display: none; }
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .nav, .header-compose, .header-avatar { display: none; }
  .site-header__inner { gap: 10px; }
  .site-header__inner > .btn { margin-left: auto; }
  .search { flex-basis: 100%; order: 3; }
  .card, .article { padding: 20px; }
  .post-row { padding: 16px; }
  .post-row__avatar { display: none; }
  .post-row__aside { display: none; }
  .page-title { font-size: 24px; }
  .article h1 { font-size: 26px; }
  .prose { font-size: 17px; }
  .keyword { grid-template-columns: 24px 72px minmax(0, 1fr) 40px; gap: 10px; padding: 8px 4px; }
  .keyword__word { font-size: 17px; }
  .auth__brand { padding: 28px 20px; min-height: 0; gap: 20px; }
  .auth__slogan { font-size: 28px; }
  .auth__points { display: none; }
  body { padding-bottom: 76px; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; font-size: 12px; color: var(--ink-2); }
  .tabbar a[aria-current="page"] { color: var(--accent-ink); font-weight: 700; }
}

/* ---------- 技術架構頁 ---------- */
.arch { display: flex; flex-direction: column; gap: 16px; }
.flow { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: stretch; gap: 28px; }
.node { position: relative; flex: 1 1 140px; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.node--accent { background: var(--accent-soft); border-color: var(--accent-muted); }
.node__kicker { font-size: 12px; font-weight: 700; color: var(--accent-ink); letter-spacing: 0.02em; }
.node strong { font-size: 16px; }
.node + .node::before { content: '→'; position: absolute; left: -22px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.stack { margin: 0; display: grid; gap: 12px; }
.stack div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; }
.stack dt { font-weight: 700; }
.stack dd { margin: 0; color: var(--ink-2); }
.arch code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 0.9em; }
@media (max-width: 720px) {
  .flow { flex-direction: column; gap: 22px; }
  .node { flex-basis: auto; }
  .node + .node::before { content: '↓'; left: 50%; top: -20px; transform: translateX(-50%); }
  .stack div { grid-template-columns: 1fr; gap: 2px; }
}
