@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --ground: #E8E4D9;
  --cream: #F2EFE5;
  --ink: #1B1B1B;
  --sage: #7A8470;
  --amber: #7A4623;
  --muted: #6B7280;
  --accent: #7A4623;
  --card-bg: #FFFFFF;
  --border: #D4D0C8;
}
[data-theme="dark"] {
  --ground: #1A1A1A;
  --cream: #2D2D2D;
  --ink: #F2EFE5;
  --sage: #7A8470;
  --amber: #C67C4E;
  --muted: #9CA3AF;
  --accent: #C67C4E;
  --card-bg: #2D2D2D;
  --border: #404040;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--ground);
  color: var(--ink);
  line-height: 1.8;
  transition: background 0.3s, color 0.3s;
}
.header {
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.45s ease-out, border-color 0.45s ease-out;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.5rem;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95em;
}
.back-link:hover { text-decoration: underline; }
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}
.post-hero {
  margin-bottom: 3rem;
}
.post-cover {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 2rem;
}
.hero-image {
  width: 100%;
}
.hero-image img {
  width: 100%;
  height: auto;
  display: block;
}
.post-header {
  padding: 2rem 2rem 1.5rem;
  margin-bottom: 0;
}
.post-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 2.5em;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 1rem;
}
.post-meta {
  color: var(--muted);
  font-size: 0.95em;
  font-family: 'Inter', sans-serif;
  margin-bottom: 1rem;
}
.nav-links {
  display: flex;
  justify-content: space-between;
  margin-top: 4rem;
  padding: 2rem 2rem 1.5rem;
  border-top: 2px solid var(--border);
  gap: 1rem;
}
.nav-link {
  color: var(--accent);
  text-decoration: none;
  padding: 1rem 1.5rem;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  flex: 1;
  max-width: 48%;
}
.nav-link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.post-tags a.tag {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  background: var(--ink);
  color: var(--cream);
  border-radius: 9999px;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  transition: all 0.3s ease;
  font-family: 'Inter', sans-serif;
}
.post-tags a.tag:hover {
  background: var(--accent);
  color: var(--cream);
}
.markdown-body {
  font-family: 'Inter', sans-serif;
  font-size: 1.1em;
  line-height: 1.9;
  color: var(--ink);
  padding: 2rem 2rem 1.5rem;
  margin-bottom: 0;
}
.markdown-body h1 {
  display: none;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-family: 'Noto Serif TC', serif;
  color: var(--ink);
  margin-top: 2.5em;
  margin-bottom: 1em;
  font-weight: 600;
  line-height: 1.4;
}
.markdown-body h2 {
  font-size: 1.75em;
  border-bottom: none;
  padding-bottom: 0;
}
.markdown-body h3 {
  font-size: 1.4em;
  color: var(--accent);
}
.markdown-body p {
  margin-bottom: 1.5em;
}
.markdown-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.markdown-body a:hover {
  border-bottom-color: var(--accent);
}
.markdown-body strong {
  font-weight: 600;
  color: var(--ink);
}
.markdown-body ul, .markdown-body ol {
  padding-left: 1.5em;
  margin-bottom: 1.5em;
}
.markdown-body li {
  margin-bottom: 0.75em;
}
.markdown-body blockquote {
  padding: 1.5em;
  margin: 2em 0;
  background: var(--card-bg);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--muted);
}
.markdown-body blockquote p {
  margin-bottom: 0;
}
.markdown-body hr {
  display: none;
}
.markdown-body code {
  background: var(--card-bg);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: monospace;
  color: var(--accent);
}
.markdown-body pre {
  background: var(--card-bg);
  padding: 1.5em;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1.5em;
  border: 1px solid var(--border);
}
.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: var(--ink);
}
.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 1.5em;
}
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  background: var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.markdown-body th, .markdown-body td {
  padding: 1em;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.markdown-body th {
  background: var(--cream);
  font-weight: 600;
  color: var(--ink);
}
.markdown-body tr:last-child td {
  border-bottom: 0;
}
footer {
  margin-top: 4rem;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9em;
  border-top: 1px solid var(--border);
  font-family: 'Inter', sans-serif;
}
/* Theme toggle */
.theme-toggle {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Inter', sans-serif;
  color: var(--ink);
}
.theme-toggle:hover {
  border-color: var(--accent);
}
@media (max-width: 768px) {
  .container { padding: 2rem 1.5rem; }
  .post-title { font-size: 1.8em; }
  .markdown-body { font-size: 1em; }
  .markdown-body h2 { font-size: 1.4em; }
  .nav-links { flex-direction: column; }
  .nav-link { max-width: 100%; }
}

/* ============================================
   Homepage Styles
   ============================================ */

/* Hero Section */
.hero {
  padding: 4rem 2rem 3rem;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: var(--ink);
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.hero p {
  font-size: 1.1rem;
  color: var(--muted);
  font-family: 'Noto Serif TC', serif;
  letter-spacing: 0.02em;
}

/* Tag Filter */
.tag-filter {
  max-width: 1200px;
  margin: 0 auto 3rem;
  padding: 0 2rem;
}
.tag-filter-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin-bottom: 1rem;
  font-weight: 500;
}
.tag-filter a {
  display: inline-block;
  padding: 0.4rem 1rem;
  margin: 0 0.5rem 0.5rem 0;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.3s ease;
  font-family: 'Inter', sans-serif;
}
.tag-filter a:hover,
.tag-filter a.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--cream);
}

/* Post Grid */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 3rem;
}

/* Post Card */
.post-card {
  background: var(--card-bg);
  border: none;
  text-decoration: none;
  color: inherit;
  display: block;
  overflow: hidden;
  transition: all 0.45s ease-out;
  position: relative;
  border-radius: 10px;
  box-shadow: 5px 0px 5px rgba(0, 0, 0, 0.1);
}
.post-card:hover {
  transform: translateY(-2px);
}
.post-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  filter: saturate(0.9) contrast(1.05);
  transition: filter 0.45s ease-out;
}
.post-card:hover img {
  filter: saturate(1) contrast(1.1);
}
.post-card-content {
  padding: 1rem;
}
.post-card h2 {
  font-size: clamp(1rem, 2vw, 1.15rem);
  font-weight: 400;
  margin-bottom: 0.75rem;
  color: var(--ink);
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.post-card:hover h2 {
  color: var(--accent);
}
.post-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.post-meta svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}
.post-summary {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 0.75rem;
  font-family: 'Noto Serif TC', serif;
}
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.post-tags span.tag {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  background: var(--ink);
  color: var(--cream);
  border-radius: 9999px;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.3s ease;
  font-family: 'Inter', sans-serif;
  border: none;
  text-decoration: none;
}
.post-tags span.tag:hover {
  background: var(--accent);
  color: var(--cream);
}

/* Footer */
.footer {
  background: var(--cream);
  border-top: 1px solid var(--border);
  padding: 3rem 2rem;
  text-align: center;
  margin-top: 4rem;
  transition: background 0.45s ease-out, border-color 0.45s ease-out;
}
.footer p {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
}

/* Responsive */
@media (max-width: 768px) {
  .header { padding: 1rem; }
  .hero { padding: 3rem 1.5rem 2rem; }
  .hero h1 { font-size: 2rem; }
  .tag-filter { padding: 0 1.5rem; margin-bottom: 2rem; }
  .container { padding: 0 1.5rem 3rem; }
  .post-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .post-card-content { padding: 1.25rem 0 0.5rem; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .post-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Hide posts that don't match selected tag */
.post-card.hidden { display: none; }

/* ============================================
   Inline Style Migration (from generate.js)
   ============================================ */

/* Header */
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Breadcrumb */
.breadcrumb {
  padding: 1rem 0;
  font-size: 0.875rem;
  color: var(--text-secondary, var(--muted));
}
.breadcrumb ol {
  list-style: none;
  display: flex;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
}
.breadcrumb a {
  color: inherit;
  text-decoration: none;
}
.breadcrumb li[aria-current="page"] {
  color: var(--text-muted, var(--muted));
}

/* Post Article */
article.post {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 2rem;
}

/* Source Section */
.source-section {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--cream);
  border-radius: 8px;
  border-left: 4px solid var(--accent);
}
.source-section h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary, var(--ink));
}
.source-section p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-secondary, var(--muted));
}

/* Email CTA */
.email-cta {
  margin: 2rem 2rem 1.5rem;
  padding: 2rem 0;
  background: linear-gradient(135deg, #7A4623 0%, #A05A2C 50%, #C07A3C 100%);
  border-radius: 20px;
  color: white;
  text-align: center;
  box-shadow: 0 8px 32px rgba(122, 70, 35, 0.4), inset 0 1px 0 rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.15);
}
.email-cta h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.email-cta p {
  margin: 0 0 2rem 0;
  opacity: 0.95;
  font-size: 1.1rem;
  font-weight: 400;
}
.email-cta form {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 560px;
  margin: 0 auto;
}
.email-cta input {
  padding: 1rem 1.5rem;
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 12px;
  font-size: 1.05rem;
  min-width: 300px;
  background: rgba(255,255,255,0.95);
  color: #1B1B1B;
  outline: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.2s;
}
.email-cta input:focus {
  border-color: rgba(255,255,255,0.8);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.email-cta button {
  padding: 1rem 2.5rem;
  background: #1B1B1B;
  color: #F2EFE5;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.email-cta button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.email-cta > p:last-child {
  margin: 1.25rem 0 0 0;
  font-size: 0.9rem;
  opacity: 0.85;
  font-weight: 400;
}

/* Related Articles */
.related-articles {
  margin: 2rem 0;
  padding: 2rem 2rem 1.5rem;
}
.related-articles h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--text-primary, var(--ink));
}
.related-articles ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}
.related-articles a {
  display: block;
  padding: 1rem;
  background: var(--bg, var(--ground));
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary, var(--ink));
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.related-articles a:hover {
  border-color: var(--accent);
  transform: translateX(4px);
}
.related-articles .title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.related-articles .date {
  font-size: 0.875rem;
  color: var(--text-secondary, var(--muted));
}

/* Post Tags */
.post-tags {
  margin-top: 0.75rem;
}

/* Hero Subtitle */
.hero-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary, var(--muted));
  margin-top: 0.5rem;
}

/* Post Grid */
.post-grid {
  list-style: none;
  padding: 0;
}

/* About Article */
.about-article {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
}
