/**
 * AI SEO AutoPublish — Article Front-end Typography
 *
 * Injected into WordPress front-end for AI-generated articles.
 * Uses !important to override theme styles (GeneratePress, Astra, etc.)
 *
 * @version 3.1
 */

/* ══════════════════════════════════════════
   Base Article Typography
   ══════════════════════════════════════════ */

.aiseo-article {
  font-family: "Noto Sans TC", "Noto Sans SC", "Microsoft JhengHei", "PingFang TC", "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  font-size: 17px !important;
  line-height: 1.9 !important;
  color: #2c2c2c !important;
  word-break: break-word;
  overflow-wrap: break-word;
  letter-spacing: 0.02em !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Headings ── */

.aiseo-article h2 {
  font-size: 1.55em !important;
  font-weight: 700 !important;
  color: #1a1a1a !important;
  margin: 2.2em 0 0.8em !important;
  padding-bottom: 0.45em !important;
  border-bottom: 3px solid #3b82f6 !important;
  line-height: 1.4 !important;
  position: relative;
}

.aiseo-article h2::before {
  content: "";
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, #8b5cf6, #3b82f6);
  border-radius: 2px;
}

.aiseo-article h3 {
  font-size: 1.3em !important;
  font-weight: 600 !important;
  color: #222222 !important;
  margin: 1.8em 0 0.6em !important;
  padding-left: 14px !important;
  border-left: 4px solid #8b5cf6 !important;
  line-height: 1.45 !important;
}

.aiseo-article h4 {
  font-size: 1.1em !important;
  font-weight: 600 !important;
  color: #2c2c2c !important;
  margin: 1.5em 0 0.5em !important;
}

/* First heading — no top margin */
.aiseo-article > h2:first-child,
.aiseo-article > h3:first-child {
  margin-top: 0 !important;
}

/* ── Paragraphs ── */

.aiseo-article p {
  margin: 0 0 1.3em !important;
  color: #2c2c2c !important;
  text-align: left !important;
  line-height: 1.9 !important;
}

/* Lead paragraph (first after h2) — same size as normal paragraphs */
.aiseo-article h2 + p {
  color: #333333 !important;
}

/* ── Strong & Emphasis ── */

.aiseo-article strong {
  font-weight: 700 !important;
  color: #1a1a1a !important;
}

.aiseo-article em {
  font-style: italic;
  color: #333333 !important;
}

/* ── Highlight Mark ── */

.aiseo-article mark {
  background: linear-gradient(180deg, transparent 55%, #ffe0e0 55%) !important;
  color: inherit !important;
  padding: 0 2px !important;
  border-radius: 2px;
}

/* ── Links ── */

.aiseo-article a {
  color: #2563eb !important;
  text-decoration: underline !important;
  text-decoration-color: rgba(37, 99, 235, 0.3) !important;
  text-underline-offset: 3px;
  transition: all 0.2s ease;
}

.aiseo-article a:hover {
  color: #1d4ed8 !important;
  text-decoration-color: #1d4ed8 !important;
}

.aiseo-article a[target="_blank"]::after {
  content: " ↗";
  font-size: 0.75em;
  vertical-align: super;
  opacity: 0.5;
}

/* ══════════════════════════════════════════
   Lists
   ══════════════════════════════════════════ */

.aiseo-article ul,
.aiseo-article ol {
  margin: 1em 0 1.5em !important;
  padding-left: 1.5em;
  color: #2c2c2c !important;
}

.aiseo-article ul {
  list-style: none !important;
  padding-left: 0 !important;
}

.aiseo-article ul li {
  position: relative;
  padding-left: 1.6em !important;
  margin-bottom: 0.6em !important;
  line-height: 1.7 !important;
  color: #2c2c2c !important;
}

.aiseo-article ul li::before {
  content: "" !important;
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6) !important;
}

.aiseo-article ol {
  counter-reset: aiseo-ol;
  list-style: none !important;
  padding-left: 0 !important;
}

.aiseo-article ol li {
  counter-increment: aiseo-ol;
  position: relative;
  padding-left: 2.4em !important;
  margin-bottom: 0.7em !important;
  line-height: 1.7 !important;
  color: #2c2c2c !important;
}

.aiseo-article ol li::before {
  content: counter(aiseo-ol) !important;
  position: absolute;
  left: 0;
  top: 0.1em;
  width: 1.7em;
  height: 1.7em;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6) !important;
  color: #fff !important;
  font-size: 0.8em;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ══════════════════════════════════════════
   Tables — Zebra Stripe + Responsive
   ══════════════════════════════════════════ */

.aiseo-article .aiseo-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5em 0 !important;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.aiseo-article table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  margin: 1.5em 0 !important;
  font-size: 0.93em !important;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.aiseo-article thead {
  background: linear-gradient(135deg, #1e3a5f, #2563eb) !important;
}

.aiseo-article thead th {
  padding: 14px 18px !important;
  text-align: left !important;
  font-weight: 600 !important;
  font-size: 0.9em !important;
  letter-spacing: 0.03em;
  color: #fff !important;
  border: none !important;
  white-space: nowrap;
}

.aiseo-article tbody td {
  padding: 13px 18px !important;
  border-bottom: 1px solid #e5e7eb !important;
  color: #2c2c2c !important;
  vertical-align: top;
  line-height: 1.7 !important;
}

.aiseo-article tbody tr:nth-child(even) {
  background-color: #f9fafb !important;
}

.aiseo-article tbody tr:hover {
  background-color: #eff6ff !important;
  transition: background-color 0.15s ease;
}

.aiseo-article tbody tr:last-child td {
  border-bottom: none !important;
}

/* ══════════════════════════════════════════
   Blockquote — Expert Quote Style
   ══════════════════════════════════════════ */

.aiseo-article blockquote {
  margin: 1.8em 0 !important;
  padding: 1.2em 1.5em 1.2em 1.8em !important;
  background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%) !important;
  border-left: 5px solid !important;
  border-image: linear-gradient(to bottom, #3b82f6, #8b5cf6) 1 !important;
  border-radius: 0 12px 12px 0;
  font-style: italic;
  color: #2c2c2c !important;
  position: relative;
}

.aiseo-article blockquote::before {
  content: "\201C";
  position: absolute;
  top: -8px;
  left: 12px;
  font-size: 3em;
  color: rgba(59, 130, 246, 0.15) !important;
  font-family: Georgia, serif;
  line-height: 1;
}

.aiseo-article blockquote p {
  margin-bottom: 0.5em !important;
  color: #2c2c2c !important;
}

.aiseo-article blockquote p:last-child {
  margin-bottom: 0 !important;
}

/* ══════════════════════════════════════════
   FAQ Section — Collapsible
   ══════════════════════════════════════════ */

.aiseo-article .aiseo-faq {
  margin: 2em 0 !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px;
  overflow: hidden;
}

.aiseo-article .aiseo-faq-item {
  border-bottom: 1px solid #e2e8f0;
}

.aiseo-article .aiseo-faq-item:last-child {
  border-bottom: none;
}

.aiseo-article .aiseo-faq-item summary,
.aiseo-article .aiseo-faq h3 {
  cursor: pointer;
  padding: 16px 20px !important;
  font-size: 1.05em !important;
  font-weight: 600 !important;
  color: #1a1a1a !important;
  background: #f8fafc !important;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s ease;
  list-style: none;
  border-left: none !important;
  padding-left: 20px !important;
  margin: 0 !important;
}

.aiseo-article .aiseo-faq-item summary:hover,
.aiseo-article .aiseo-faq h3:hover {
  background: #eff6ff !important;
}

.aiseo-article .aiseo-faq-item summary::before {
  content: "▸";
  font-size: 0.9em;
  color: #3b82f6 !important;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.aiseo-article .aiseo-faq-item[open] summary::before {
  transform: rotate(90deg);
}

.aiseo-article .aiseo-faq-answer {
  padding: 12px 20px 16px 46px !important;
  color: #333333 !important;
  line-height: 1.8 !important;
}

.aiseo-article .aiseo-faq-answer p {
  color: #333333 !important;
}

/* ══════════════════════════════════════════
   Images — Placeholder + Alt Text
   ══════════════════════════════════════════ */

.aiseo-article img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 10px;
  margin: 1.5em 0 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Image placeholder — for AI-generated empty src */
.aiseo-article img[src=""],
.aiseo-article img:not([src]) {
  display: block !important;
  width: 100% !important;
  min-height: 200px;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%) !important;
  border: 2px dashed #94a3b8 !important;
  border-radius: 10px;
  position: relative;
}

.aiseo-article img[src=""]::after,
.aiseo-article img:not([src])::after {
  content: "📷 請在此新增圖片 — " attr(alt);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #555555 !important;
  font-size: 0.85em;
  font-style: italic;
  text-align: center;
  padding: 0 20px;
  max-width: 80%;
}

.aiseo-article figure {
  margin: 1.5em 0 !important;
}

.aiseo-article figure.aiseo-image {
  margin: 2em 0 !important;
  text-align: center !important;
}

.aiseo-article figure.aiseo-image img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08) !important;
}

.aiseo-article figcaption {
  text-align: center;
  font-size: 0.85em !important;
  color: #555555 !important;
  margin-top: 0.5em !important;
  font-style: italic;
}

.aiseo-article figure.aiseo-image figcaption {
  font-size: 0.78em !important;
  color: #888888 !important;
  margin-top: 0.6em !important;
}

.aiseo-article figure.aiseo-image figcaption a {
  color: #6b7280 !important;
  text-decoration: underline !important;
}

/* ══════════════════════════════════════════
   Callout Boxes — Tip, Warning, Key Takeaway
   ══════════════════════════════════════════ */

/* Shared base */
.aiseo-article .aiseo-tip,
.aiseo-article .aiseo-warning,
.aiseo-article .aiseo-key-point,
.aiseo-article .aiseo-example {
  margin: 1.8em 0 !important;
  padding: 18px 22px 18px 56px !important;
  border-radius: 10px !important;
  position: relative;
  line-height: 1.75 !important;
  font-size: inherit !important;
}

.aiseo-article .aiseo-tip::before,
.aiseo-article .aiseo-warning::before,
.aiseo-article .aiseo-key-point::before,
.aiseo-article .aiseo-example::before {
  position: absolute;
  left: 18px;
  top: 18px;
  font-size: 1.3em;
  line-height: 1;
}

.aiseo-article .aiseo-tip p,
.aiseo-article .aiseo-warning p,
.aiseo-article .aiseo-key-point p,
.aiseo-article .aiseo-example p {
  margin-bottom: 0.5em !important;
}

.aiseo-article .aiseo-tip p:last-child,
.aiseo-article .aiseo-warning p:last-child,
.aiseo-article .aiseo-key-point p:last-child,
.aiseo-article .aiseo-example p:last-child {
  margin-bottom: 0 !important;
}

/* Tip box (green) */
.aiseo-article .aiseo-tip {
  background: #f0fdf4 !important;
  border: 1px solid #bbf7d0 !important;
  border-left: 4px solid #22c55e !important;
  color: #1a3a1a !important;
}

.aiseo-article .aiseo-tip::before {
  content: "💡";
}

/* Warning box (amber) */
.aiseo-article .aiseo-warning {
  background: #fffbeb !important;
  border: 1px solid #fde68a !important;
  border-left: 4px solid #f59e0b !important;
  color: #3a2a0a !important;
}

.aiseo-article .aiseo-warning::before {
  content: "⚠️";
}

/* Key takeaway box (blue) */
.aiseo-article .aiseo-key-point {
  background: #eff6ff !important;
  border: 1px solid #bfdbfe !important;
  border-left: 4px solid #3b82f6 !important;
  color: #1a2a4a !important;
}

.aiseo-article .aiseo-key-point::before {
  content: "🎯";
}

/* Example box (purple) */
.aiseo-article .aiseo-example {
  background: #faf5ff !important;
  border: 1px solid #e9d5ff !important;
  border-left: 4px solid #8b5cf6 !important;
  color: #2a1a4a !important;
}

.aiseo-article .aiseo-example::before {
  content: "📌";
}

/* ══════════════════════════════════════════
   CTA Button
   ══════════════════════════════════════════ */

.aiseo-article .aiseo-cta {
  display: inline-block;
  padding: 14px 32px !important;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6) !important;
  color: #fff !important;
  font-weight: 600 !important;
  font-size: 1.05em !important;
  border-radius: 10px;
  text-decoration: none !important;
  transition: all 0.25s ease;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.aiseo-article .aiseo-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
  color: #fff !important;
}

/* ══════════════════════════════════════════
   Table of Contents (TOC)
   ══════════════════════════════════════════ */

.aiseo-article .aiseo-toc {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px;
  padding: 20px 24px !important;
  margin: 1.5em 0 2em !important;
}

.aiseo-article .aiseo-toc .aiseo-toc-title {
  font-size: 0.95em !important;
  font-weight: 700 !important;
  color: #1a1a1a !important;
  margin-bottom: 12px !important;
  display: flex;
  align-items: center;
  gap: 6px;
}

.aiseo-article .aiseo-toc .aiseo-toc-title::before {
  content: "📑";
}

.aiseo-article .aiseo-toc ol {
  list-style: none !important;
  counter-reset: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.aiseo-article .aiseo-toc li {
  counter-increment: none !important;
  padding: 0 !important;
  padding-left: 0 !important;
  margin: 0 !important;
  position: static !important;
}

.aiseo-article .aiseo-toc li::before {
  display: none !important;
  content: none !important;
  width: 0 !important;
  height: 0 !important;
}

.aiseo-article .aiseo-toc a {
  display: block;
  padding: 6px 0 !important;
  color: #2563eb !important;
  text-decoration: none !important;
  font-size: 0.9em !important;
  border-bottom: 1px solid #f1f5f9 !important;
  transition: all 0.15s ease;
}

.aiseo-article .aiseo-toc a:hover {
  color: #1d4ed8 !important;
  padding-left: 8px !important;
}

.aiseo-article .aiseo-toc a::after {
  display: none !important;
}

.aiseo-article .aiseo-toc .toc-h3 {
  padding-left: 1.2em !important;
  font-size: 0.9em !important;
}

.aiseo-article .aiseo-toc .toc-h3::before {
  display: none !important;
  content: none !important;
}

/* ══════════════════════════════════════════
   Code Blocks (for technical tone)
   ══════════════════════════════════════════ */

.aiseo-article code {
  font-family: "JetBrains Mono", "Fira Code", "Source Code Pro", Consolas, monospace !important;
  font-size: 0.88em !important;
  padding: 2px 6px !important;
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 4px;
  color: #c2410c !important;
}

.aiseo-article pre {
  margin: 1.5em 0 !important;
  padding: 20px !important;
  background: #1e293b !important;
  border-radius: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.aiseo-article pre code {
  background: none !important;
  border: none !important;
  color: #e2e8f0 !important;
  font-size: 0.88em !important;
  line-height: 1.7 !important;
  padding: 0 !important;
}

/* ══════════════════════════════════════════
   Horizontal Rule
   ══════════════════════════════════════════ */

.aiseo-article hr {
  border: none !important;
  height: 1px !important;
  background: linear-gradient(90deg, transparent, #cbd5e1, transparent) !important;
  margin: 2.5em 0 !important;
}

/* ══════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════ */

@media (max-width: 768px) {
  .aiseo-article {
    font-size: 15.5px !important;
    line-height: 1.8 !important;
  }

  .aiseo-article h2 {
    font-size: 1.35em !important;
  }

  .aiseo-article h3 {
    font-size: 1.15em !important;
  }

  .aiseo-article table {
    font-size: 0.85em !important;
  }

  .aiseo-article thead th,
  .aiseo-article tbody td {
    padding: 10px 12px !important;
  }

  .aiseo-article blockquote {
    padding: 1em 1em 1em 1.2em !important;
  }

  .aiseo-article ol li {
    padding-left: 2.2em !important;
  }
}

/* ══════════════════════════════════════════
   Dark Mode Support — DISABLED
   Theme controls background, not OS preference.
   If theme has dark mode, use theme's body class instead.
   ══════════════════════════════════════════ */

/* ══════════════════════════════════════════
   Reading Time Badge
   ══════════════════════════════════════════ */

.aiseo-article .aiseo-reading-meta {
  display: flex !important;
  align-items: center;
  gap: 16px;
  padding: 12px 20px !important;
  margin-bottom: 24px !important;
  background: linear-gradient(135deg, #f0f4ff 0%, #faf5ff 100%) !important;
  border: 1px solid #e0e7ff !important;
  border-radius: 12px;
  font-size: 0.88em !important;
  color: #444444 !important;
}

.aiseo-article .aiseo-reading-meta .aiseo-reading-time {
  display: flex;
  align-items: center;
  font-weight: 600 !important;
  color: #1a1a1a !important;
}

.aiseo-article .aiseo-reading-meta .aiseo-reading-time svg {
  color: #3b82f6 !important;
  flex-shrink: 0;
}

.aiseo-article .aiseo-reading-meta .aiseo-reading-meta-info {
  color: #555555 !important;
  font-size: 0.92em !important;
}

@media (max-width: 768px) {
  .aiseo-article .aiseo-reading-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 16px !important;
  }
}

/* Dark mode for reading meta — disabled (theme controls background) */

@media print {
  .aiseo-article .aiseo-reading-meta {
    border: 1px solid #ccc !important;
    background: none !important;
  }
}

/* ══════════════════════════════════════════
   Print Optimization
   ══════════════════════════════════════════ */

@media print {
  .aiseo-article {
    font-size: 12pt !important;
    color: #000 !important;
  }

  .aiseo-article p,
  .aiseo-article li,
  .aiseo-article td {
    color: #000 !important;
  }

  .aiseo-article a {
    color: #000 !important;
    text-decoration: underline !important;
  }

  .aiseo-article a[target="_blank"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }

  .aiseo-article table {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }

  .aiseo-article blockquote {
    border-left: 3px solid #666 !important;
    background: none !important;
  }

  .aiseo-article .aiseo-toc {
    page-break-inside: avoid;
  }
}

/* ══════════════════════════════════════════
   Ad Containers
   ══════════════════════════════════════════ */

.aiseo-ad-container {
  margin: 2em 0 !important;
  text-align: center;
  clear: both;
}

.aiseo-ad-container img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.aiseo-ad-container .aiseo-ad-label {
  display: block;
  font-size: 0.7em;
  color: #999;
  margin-top: 4px;
  letter-spacing: 0.05em;
}

.aiseo-ad-container a {
  text-decoration: none !important;
  display: inline-block;
}

.aiseo-ad-container a:hover img {
  opacity: 0.92;
  transition: opacity 0.2s ease;
}

/* Archive page ads */
.aiseo-archive-ad {
  margin: 1.5em auto !important;
  padding: 1em;
  text-align: center;
  max-width: 728px;
}

@media (max-width: 768px) {
  .aiseo-ad-container {
    margin: 1.5em 0 !important;
  }
}

@media print {
  .aiseo-ad-container,
  .aiseo-archive-ad {
    display: none !important;
  }
}
