/* PubWiki — reading-focused, mobile-first */

:root {
  --ink: #1f2a37;
  --ink-light: #4b5563;
  --ink-muted: #9ca3af;
  --sage: #2f6b5f;
  --sage-light: #e8f0ed;
  --sage-bg: #f0f5f3;
  --bg: #fafbfa;
  --surface: #fff;
  --border: #e5e7eb;
  --radius: 6px;
  --max-w: 720px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 20px; }

/* ---- Header ---- */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.logo-link { display: flex; text-decoration: none; }
.logo-svg { height: 32px; width: auto; }
.nav-link { font-size: 0.875rem; color: var(--ink-light); text-decoration: none; }
.nav-link:hover { color: var(--sage); }

/* ---- Footer ---- */
.site-footer { margin-top: 3rem; padding: 1.5rem 0; border-top: 1px solid var(--border); font-size: 0.8125rem; color: var(--ink-muted); }
.footer-inner p { margin-bottom: 0.5rem; }
.footer-inner a { color: var(--ink-muted); }
.footer-inner a:hover { color: var(--sage); }
.footer-links { display: flex; gap: 1.25rem; }

/* ---- Hero ---- */
.hero { padding: 3rem 0 2rem; text-align: center; }
.hero h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; }
.hero-sub { color: var(--ink-light); margin-bottom: 1.5rem; }

/* ---- Search Form ---- */
.search-form { display: flex; gap: 0.5rem; max-width: 520px; margin: 0 auto; }
.search-input {
  flex: 1;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.15s;
}
.search-input:focus { outline: none; border-color: var(--sage); }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 0.625rem 1.125rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--sage); color: #fff; }
.btn-primary:hover { background: #265a50; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-sm:not(.btn-primary):not(.btn-muted) { background: var(--sage-light); color: var(--sage); }
.btn-muted { background: transparent; color: var(--ink-muted); border: 1px solid var(--border); }
.btn-muted:hover { border-color: var(--ink-light); color: var(--ink-light); }

/* ---- How It Works ---- */
.how-it-works { padding: 2rem 0; }
.how-it-works h2 { font-size: 1.25rem; margin-bottom: 1.25rem; text-align: center; }
.steps { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 640px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { text-align: center; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--sage-light); color: var(--sage);
  font-weight: 600; font-size: 0.875rem; margin-bottom: 0.5rem;
}
.step h3 { font-size: 0.9375rem; margin-bottom: 0.25rem; }
.step p { font-size: 0.8125rem; color: var(--ink-light); }

/* URL Demo */
.url-demo { display: flex; align-items: center; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin-top: 0.5rem; }
.url-bar {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.url-dim { color: var(--ink-muted); text-decoration: line-through; }
.url-highlight { color: var(--sage); font-weight: 600; }
.url-pmid { color: var(--ink); }
.url-arrow { color: var(--ink-muted); font-size: 1.25rem; }

/* ---- Examples ---- */
.examples { padding: 2rem 0; }
.examples h2 { font-size: 1.25rem; margin-bottom: 1rem; }

/* ---- Article Cards ---- */
.article-cards { display: flex; flex-direction: column; gap: 0.75rem; }
.article-card {
  display: block;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s;
}
.article-card:hover { border-color: var(--sage); }
.card-meta { display: flex; gap: 0.5rem; margin-bottom: 0.375rem; }
.card-title { font-size: 0.9375rem; font-weight: 500; line-height: 1.4; }
.card-info { font-size: 0.8125rem; color: var(--ink-muted); margin-top: 0.25rem; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 0.125rem 0.5rem; border-radius: 3px; font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.badge-type { background: var(--sage-light); color: var(--sage); }
.badge-oa { background: #ecfdf5; color: #047857; }

/* ---- Article Page ---- */
.breadcrumb { font-size: 0.8125rem; color: var(--ink-muted); padding: 1rem 0 0; }
.breadcrumb a { color: var(--ink-muted); }
.breadcrumb a:hover { color: var(--sage); }

.article-page { padding: 1.5rem 0 2rem; }
.article-badges { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.article-title { font-size: 1.5rem; font-weight: 700; line-height: 1.35; margin-bottom: 0.375rem; }
.article-title-en { font-size: 0.9375rem; color: var(--ink-muted); margin-bottom: 1rem; }
.article-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; font-size: 0.8125rem; color: var(--ink-light); margin-bottom: 0.75rem; }
.article-access { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.article-stats { font-size: 0.8125rem; color: var(--ink-muted); margin-bottom: 1.25rem; }

.abstract { font-size: 0.9375rem; line-height: 1.7; margin-bottom: 1.5rem; }
.abstract strong { font-weight: 600; }
.abstract-absent { color: var(--ink-muted); margin-bottom: 1.5rem; }

/* ---- Translation Loading ---- */
.translating-indicator {
  font-size: 0.8125rem;
  color: var(--sage);
  margin: 0.25rem 0 0.75rem;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Rewrite animation targets */
.rewrite-fade-out { transition: opacity 0.3s, transform 0.3s; opacity: 0; transform: translateY(-4px); }
.rewrite-fade-in { transition: opacity 0.4s 0.15s, transform 0.4s 0.15s; opacity: 1; transform: translateY(0); }

/* Translation error */
.translate-error { padding: 1rem; background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius); margin-bottom: 1.5rem; font-size: 0.9375rem; }
.translate-error a { color: var(--sage); }

/* ---- CTA Plug ---- */
.cta-plug {
  padding: 1.5rem;
  background: var(--sage-bg);
  border: 1px solid #d1ddd8;
  border-radius: var(--radius);
  margin-bottom: 2rem;
}
.cta-plug h3 { font-size: 1.0625rem; font-weight: 600; margin-bottom: 0.375rem; }
.cta-plug > p { font-size: 0.875rem; color: var(--ink-light); margin-bottom: 0.875rem; }
.cta-btn { margin-bottom: 0.875rem; }
.cta-extras { list-style: none; font-size: 0.8125rem; color: var(--ink-muted); }
.cta-extras li::before { content: '·'; margin-right: 0.375rem; }

/* ---- Related ---- */
.related { margin-bottom: 2rem; }
.related h2 { font-size: 1.125rem; margin-bottom: 0.75rem; }
.related-list { display: flex; flex-direction: column; gap: 0.5rem; }
.related-card {
  display: block;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.15s;
}
.related-card:hover { border-color: var(--sage); }
.related-title { display: block; font-size: 0.875rem; color: var(--ink); line-height: 1.4; }
.related-info { display: block; font-size: 0.75rem; color: var(--ink-muted); margin-top: 0.125rem; }

/* ---- Journal Page ---- */
.journal-page h1 { font-size: 1.5rem; margin-bottom: 0.25rem; padding-top: 0.5rem; }
.journal-count { font-size: 0.875rem; color: var(--ink-muted); margin-bottom: 1.25rem; }

/* ---- Not Found ---- */
.not-found { padding: 3rem 0; text-align: center; }
.not-found h1 { font-size: 1.5rem; margin-bottom: 0.75rem; }
.not-found ul { list-style: none; margin-bottom: 1.5rem; font-size: 0.9375rem; color: var(--ink-light); }
.not-found ul li { margin-bottom: 0.25rem; }
.back-link { margin-top: 1rem; font-size: 0.875rem; }
.back-link a { color: var(--sage); text-decoration: none; }

/* ---- Rate Limit ---- */
.rate-limit { padding: 3rem 0; text-align: center; }
.rate-limit h1 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.rate-limit p { color: var(--ink-light); }
