/* ============================================================
   style.css — 共用設計系統（所有頁共用）
   載入順序：放在 <head> 既有 <style> 之前，
   咁現有頁嘅 inline style 仍然對 .container 等共用 class 生效
   ============================================================ */

:root {
  --bg: #fafafb;
  --surface: #ffffff;
  --surface-2: #f4f4f7;
  --text: #18181b;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: #eef2ff;
  --hardware: #10b981;
  --software: #3b82f6;
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow: 0 4px 16px -2px rgba(24, 24, 27, 0.06), 0 2px 4px -2px rgba(24, 24, 27, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(24, 24, 27, 0.12), 0 4px 8px -2px rgba(24, 24, 27, 0.04);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(139, 92, 246, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(99, 102, 241, 0.06), transparent);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ============================================================
   SITE HEADER (sticky nav + search bar) — every page
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.site-header .header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand .logo { font-size: 22px; line-height: 1; }
.brand-text {
  white-space: nowrap;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav { display: flex; gap: 2px; align-items: center; }

.nav-link {
  padding: 7px 13px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ============================================================
   SEARCH BAR — dropdown results
   ============================================================ */
.search-wrap {
  margin-left: auto;
  position: relative;
  width: 280px;
  max-width: 60%;
}

.search-input {
  width: 100%;
  padding: 8px 14px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: all 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

.search-input:focus {
  outline: none;
  background-color: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  width: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E");
  cursor: pointer;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 480px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}
.search-results.active { display: block; }

.search-empty {
  padding: 24px 18px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.search-result {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--surface-2); text-decoration: none; }

.result-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 4px;
  color: var(--text);
}
.result-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.result-snippet {
  font-size: 13px;
  color: #52525b;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

mark {
  background: #fef08a;
  padding: 0 2px;
  border-radius: 2px;
  color: inherit;
}

/* ============================================================
   PAGE HERO (for topics/search pages)
   ============================================================ */
.page-hero {
  padding: 64px 0 40px;
  text-align: center;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 20px;
}
.eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}
.page-hero .title {
  font-size: clamp(32px, 5.5vw, 52px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #18181b 0%, #6366f1 60%, #8b5cf6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.page-hero .subtitle {
  font-size: clamp(15px, 2vw, 17px);
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin: 32px auto 0;
  padding: 18px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  color: var(--text-muted);
  flex-wrap: wrap;
  max-width: fit-content;
}
.stats strong { color: var(--text); font-weight: 700; font-size: 16px; }
.stats .sep { color: var(--border); }

/* ============================================================
   TOPICS PAGE
   ============================================================ */
main { padding: 24px 0 60px; }
main.narrow { padding: 0 0 60px; }

.section {
  margin-bottom: 48px;
}
.section h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section h2 .accent-bar {
  width: 4px;
  height: 22px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 2px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.tag-pill {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 7px 14px;
  border-radius: 999px;
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}
.tag-pill:hover {
  background: var(--accent);
  color: white;
  text-decoration: none;
  transform: translateY(-1px);
}
.tag-pill .count {
  opacity: 0.6;
  margin-left: 6px;
  font-size: 12px;
}

.tag-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s ease;
  gap: 16px;
}
.tag-row:last-child { border-bottom: none; }
.tag-row:hover { background: var(--surface-2); text-decoration: none; }

.tag-row .tag-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  font-family: "Inter", monospace;
}
.tag-row .tag-name::before { content: "#"; opacity: 0.5; margin-right: 1px; }

.tag-row .tag-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.tag-row .arrow {
  color: var(--accent);
  font-weight: 600;
  transition: transform 0.15s ease;
}
.tag-row:hover .arrow { transform: translateX(3px); }

/* ============================================================
   SEARCH PAGE
   ============================================================ */
.search-page-wrap {
  max-width: 820px;
  margin: 0 auto;
}

.search-page-input {
  position: relative;
  margin-bottom: 18px;
}

.search-page-input input {
  width: 100%;
  padding: 16px 22px 16px 52px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-size: 17px;
  font-family: inherit;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 20px center;
}
.search-page-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-stats {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-left: 4px;
}
.search-stats strong { color: var(--text); font-weight: 600; }

.search-results-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-result-card {
  display: block;
  padding: 22px 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}
.search-result-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #c7d2fe;
  text-decoration: none;
}

.search-result-card .result-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.search-result-card .type-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.search-result-card .type-pill.hardware { background: var(--accent-soft); color: var(--hardware); }
.search-result-card .type-pill.software { background: #dbeafe; color: var(--software); }

.search-result-card h3 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 10px;
  color: var(--text);
}

.search-result-card p {
  font-size: 14.5px;
  color: #3f3f46;
  line-height: 1.65;
  margin-bottom: 12px;
}

.search-result-card .result-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.search-result-card .tag-small {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 999px;
}

.empty-message {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  padding: 40px 0 56px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 60px;
}
.site-footer p { margin: 4px 0; }
.site-footer a { color: var(--accent); text-decoration: none; font-weight: 500; }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 768px) {
  .site-header .header-inner { gap: 12px; padding: 10px 16px; }
  .brand-text { display: none; }
  .nav-link { padding: 6px 9px; font-size: 13px; }
  .search-wrap { width: 180px; }
  .page-hero { padding: 48px 0 32px; }
  .stats { gap: 18px; padding: 14px 18px; font-size: 13px; }
  .tag-cloud { padding: 16px; }
  .tag-row { padding: 14px 18px; }
}
@media (max-width: 480px) {
  .search-wrap { width: 140px; }
  .nav-link { padding: 5px 7px; font-size: 12px; }
}

/* ============================================================
   Direct Article View — clicking 閱讀全文 skips the menu
   When a card is :target via URL hash, hide other cards and
   expand the targeted one to full width.
   ============================================================ */

.back-link {
  display: none;
  align-items: center;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto 20px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .2s ease;
  box-shadow: var(--shadow-sm);
}
.back-link::before { content: "90"; font-size: 16px; }
.back-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateX(-2px);
}

/* When any card is targeted, show the back link */
main:has(.card:target) .back-link { display: inline-flex; }

/* Hide other cards; show only the targeted one full-width */
main:has(.card:target) .card:not(:target) { display: none; }

main:has(.card:target) .articles-grid {
  grid-template-columns: minmax(0, 800px);
  max-width: 800px;
  margin: 0 auto;
}

main:has(.card:target) .card:target .card-image-link {
  aspect-ratio: 21/9;
  max-height: 360px;
}

main:has(.card:target) .card:target .card-body {
  padding: 28px 32px 32px;
}

main:has(.card:target) .card:target .summary {
  font-size: 15.5px;
  line-height: 1.75;
  -webkit-line-clamp: unset;
  display: block;
  overflow: visible;
}

main:has(.card:target) .card:target h2 {
  font-size: 24px;
  line-height: 1.35;
  margin-bottom: 14px;
}

main:has(.card:target) .card:target .read-more {
  font-size: 14px;
  padding: 12px 22px;
  margin-top: 16px;
}

main:has(.card:target) .card:target .source-row {
  font-size: 13px;
  margin-bottom: 12px;
}
