/* AI控·週報 — HN/Substack 風格 CSS */

:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #6b7280;
  --color-link: #1e40af;
  --color-link-hover: #1e3a8a;
  --color-border: #e5e7eb;
  --color-card-bg: #fafafa;
  --color-accent: #1e40af;
  --color-success-bg: #ecfdf5;
  --color-success-text: #065f46;
  --color-error-bg: #fef2f2;
  --color-error-text: #991b1b;
  --max-width: 760px;
  --max-width-wide: 1100px;
  --font-sans: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}
a:hover { border-bottom-color: currentColor; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.muted { color: var(--color-muted); }

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.92);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  max-width: var(--max-width-wide);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--color-text);
  border-bottom: none;
}
.brand-logo {
  width: 40px;
  height: 40px;
  display: block;
  /* 輕微陰影讓白底 logo 在白色 nav 上略有區隔感 */
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.05));
}
.brand:hover .brand-logo {
  transform: scale(1.04);
  transition: transform 0.15s ease-out;
}

@media (max-width: 640px) {
  .brand-logo { width: 32px; height: 32px; }
  .brand-name { font-size: 1rem; }
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.site-nav a {
  color: var(--color-muted);
  font-size: 0.95rem;
  border-bottom: none;
}
.site-nav a:hover { color: var(--color-text); }
.site-nav a.cta {
  background: var(--color-accent);
  color: #fff;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-weight: 500;
}
.nav-search { display: inline-block; }
.nav-search input[type=search] {
  width: 140px;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.88rem;
  background: #fafafa;
  font-family: inherit;
  transition: width 0.2s, background 0.2s, border-color 0.15s;
}
.nav-search input[type=search]:focus {
  width: 220px;
  background: #fff;
  border-color: var(--color-accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(30,64,175,0.1);
}
.site-nav a.cta:hover { background: var(--color-link-hover); color: #fff; }

/* === Nav dropdown === */
.nav-has-dropdown { position: relative; }
.nav-has-dropdown .nav-toggle { display: inline-flex; align-items: center; gap: 0.2rem; }
.nav-has-dropdown .nav-toggle .caret { font-size: 0.7em; opacity: 0.6; }
/* 透明 hover bridge — 填補 nav 與 dropdown 之間的 0.5rem 視覺 gap，
   讓滑鼠經過不會中斷 hover state */
.nav-has-dropdown::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 0.6rem;
  pointer-events: none;     /* 預設不接收事件 */
}
.nav-has-dropdown:hover::after,
.nav-has-dropdown:focus-within::after { pointer-events: auto; }
.nav-has-dropdown .dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  padding: 0.4rem 0;
  z-index: 200;
}
.nav-has-dropdown .dropdown a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--color-text);
  font-size: 0.92rem;
  border-bottom: none;
  white-space: nowrap;
}
.nav-has-dropdown .dropdown a:hover {
  background: var(--color-card-bg);
  color: var(--color-accent);
}
.nav-has-dropdown .dropdown .dropdown-empty {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--color-muted);
  font-size: 0.85rem;
}
.nav-has-dropdown:hover .dropdown,
.nav-has-dropdown:focus-within .dropdown { display: block; }

/* === Topic / Feature index pages === */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.topic-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
  text-decoration: none;
  border-bottom: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.topic-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  border-color: var(--color-accent);
}
.topic-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  color: var(--color-text);
}
.topic-card .topic-desc {
  color: var(--color-muted);
  font-size: 0.88rem;
  margin: 0 0 0.5rem;
  line-height: 1.5;
}
.topic-card .topic-count {
  color: var(--color-accent);
  font-size: 0.85rem;
  font-weight: 500;
}

/* === Pagination (prev/next) === */
.pagination {
  display: flex;
  justify-content: space-between;
  margin: 2rem 0;
  font-size: 0.95rem;
}
.pagination a, .pagination span {
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  border-bottom: 1px solid var(--color-border);
}
.pagination a:hover {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.pagination .disabled {
  color: var(--color-muted);
  background: var(--color-card-bg);
}

/* === Feature badge === */
.feature-badge {
  display: inline-block;
  background: linear-gradient(135deg, #1e40af, #7c3aed);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  margin-right: 0.5rem;
  letter-spacing: 0.05em;
}

@media (max-width: 640px) {
  .nav-has-dropdown .dropdown {
    left: 0; transform: none; right: 0;
  }
  .topic-grid { grid-template-columns: 1fr; }
  .nav-search input[type=search] { width: 100px; }
  .nav-search input[type=search]:focus { width: 140px; }
}

/* === Search results highlight === */
.search-highlight {
  background: #fef3c7;
  padding: 0.05rem 0.2rem;
  border-radius: 3px;
  font-weight: 500;
}
.search-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-muted);
}

/* ===== Main ===== */
.site-main { padding: 2.5rem 0 4rem; }

/* ===== Flash ===== */
.flash {
  padding: 0.875rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}
.flash-success { background: var(--color-success-bg); color: var(--color-success-text); }
.flash-error   { background: var(--color-error-bg); color: var(--color-error-text); }

/* ===== Hero (首頁) ===== */
.hero {
  padding: 1rem 0 2.5rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 2rem;
}
.hero h1 {
  font-size: 1.875rem;
  margin: 0 0 0.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.hero p {
  margin: 0;
  color: var(--color-muted);
  font-size: 1rem;
}

/* ===== Post list ===== */
.post-list { list-style: none; padding: 0; margin: 0; }
.post-list-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--color-border);
}
.post-list-item:first-child { padding-top: 0.5rem; }
.post-meta {
  font-size: 0.82rem;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.post-meta .dot { opacity: 0.5; }
.post-meta .source-name { font-weight: 500; color: var(--color-text); }
.post-meta .category {
  padding: 0.05rem 0.5rem;
  background: var(--color-card-bg);
  border-radius: 4px;
  font-size: 0.78rem;
}
.post-list-item h2 {
  font-size: 1.3rem;
  margin: 0 0 0.5rem;
  font-weight: 600;
  line-height: 1.35;
}
.post-list-item h2 a { color: var(--color-text); border-bottom: none; }
.post-list-item h2 a:hover { color: var(--color-accent); }
.post-summary { color: var(--color-muted); font-size: 0.97rem; margin: 0 0 0.6rem; }
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.78rem;
}
.tag-pill {
  background: var(--color-card-bg);
  color: var(--color-muted);
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border-bottom: none;
}
.tag-pill:hover { background: var(--color-accent); color: #fff; }

/* Tag cloud (tags 索引頁) */
.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.7rem;
  margin: 1rem 0;
}
.tag-pill-cloud {
  font-size: 0.95rem;
  padding: 0.35rem 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.tag-pill-cloud .tag-count {
  font-size: 0.8em;
  opacity: 0.55;
}

/* ===== Single post ===== */
.post-article header { margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--color-border); }
.post-article h1 { font-size: 2rem; margin: 0.5rem 0 0.75rem; line-height: 1.3; }
.post-article .post-meta { margin-bottom: 0.5rem; }
.post-article .post-summary { font-size: 1.05rem; color: var(--color-muted); font-style: italic; }
.post-content { font-size: 1.05rem; }
.post-content h2 { font-size: 1.4rem; margin: 2rem 0 0.75rem; }
.post-content p { margin: 0.85rem 0; }
.post-content ul, .post-content ol { padding-left: 1.5rem; margin: 0.85rem 0; }
.post-content li { margin: 0.3rem 0; }
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--color-card-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.post-content pre {
  background: #0f172a;
  color: #e5e7eb;
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1rem 0;
}
.post-content pre code { background: none; color: inherit; padding: 0; }
.post-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 1rem;
  color: var(--color-muted);
  margin: 1rem 0;
}
.post-source-note {
  margin-top: 2.5rem;
  padding: 1rem 1.25rem;
  background: var(--color-card-bg);
  border-radius: 6px;
  font-size: 0.92rem;
  color: var(--color-muted);
}

/* ===== Forms ===== */
.form-card {
  max-width: 460px;
  margin: 1rem auto;
  padding: 2rem;
  background: var(--color-card-bg);
  border-radius: 10px;
}
.form-card h1 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.form-card p.intro { color: var(--color-muted); margin: 0 0 1.5rem; }
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-size: 0.9rem; margin-bottom: 0.35rem; font-weight: 500; }
.form-row input[type=email],
.form-row input[type=text] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
}
.form-row input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(30,64,175,0.12);
}
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-link-hover); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.88rem; }

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-card-bg);
  margin-top: 4rem;
}
.footer-inner {
  max-width: var(--max-width-wide);
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.5fr;
  gap: 2.5rem;
  padding: 2.5rem 1.25rem 1.5rem;
}
.footer-col h4 { font-size: 0.9rem; margin: 0 0 0.6rem; color: var(--color-text); }
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin: 0.3rem 0; font-size: 0.92rem; }
.footer-col a { color: var(--color-muted); border-bottom: none; }
.footer-col a:hover { color: var(--color-text); }
.footer-bottom {
  max-width: var(--max-width-wide);
  display: flex;
  justify-content: space-between;
  padding: 1rem 1.25rem 1.5rem;
  font-size: 0.82rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.5rem; }
  .post-list-item h2 { font-size: 1.1rem; }
  .post-article h1 { font-size: 1.5rem; }
  .footer-inner { grid-template-columns: 1fr; gap: 1.5rem; }
  .footer-bottom { flex-direction: column; gap: 0.5rem; }
  .site-nav { gap: 0.75rem; }
  .site-nav a:not(.cta) { font-size: 0.88rem; }
}
