/* ============================================================
   style.css — SmartSavings 全站样式
   设计方向：editorial magazine，沉稳可信，衬线字体为主
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────── */
:root {
  --bg:           #f8f5f0;
  --surface:      #ffffff;
  --surface-alt:  #f2ede6;
  --border:       #e5dfd6;
  --border-soft:  #ede8e0;

  --text:         #1c1917;
  --text-2:       #57534e;
  --text-3:       #a8a29e;

  --accent:       #b5341a;
  --accent-soft:  #fdf2ef;
  --accent-hover: #941f0e;

  --tag-bg:       #ede8e0;
  --tag-text:     #44403c;
  --tag-hover-bg: #b5341a;
  --tag-hover-tx: #ffffff;

  --cat-color:    #b5341a;

  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body:    'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-ui:      system-ui, -apple-system, sans-serif;

  --radius:       8px;
  --radius-sm:    4px;
  --max-content:  740px;
  --max-wide:     1100px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --shadow-card:  0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);

  --transition:   150ms ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.75;
  min-height: 100vh;
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button { cursor: pointer; font-family: inherit; }

/* ── Progress bar ──────────────────────────────────────── */
#progress-bar {
  position: fixed; top: 0; left: 0;
  height: 3px; width: 0%;
  background: var(--accent);
  z-index: 9999;
  transition: width .1s linear;
  pointer-events: none;
}

/* ── Site Header ───────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex; align-items: center; gap: 32px;
}
.site-logo {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 800;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.site-logo:hover { color: var(--accent-hover); }

.site-nav {
  display: flex; gap: 4px; flex: 1;
}
.site-nav a {
  font-family: var(--font-ui);
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.site-nav a:hover {
  background: var(--surface-alt);
  color: var(--text);
}

/* Header search */
.header-search {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}
.header-search input {
  border: none; background: transparent;
  padding: 7px 14px;
  font-size: 13px; font-family: var(--font-ui);
  color: var(--text); outline: none;
  width: 200px;
}
.header-search button {
  background: none; border: none;
  padding: 7px 12px;
  color: var(--text-2);
  display: flex; align-items: center;
  transition: color var(--transition);
}
.header-search button:hover { color: var(--accent); }

/* ── Page main wrapper ─────────────────────────────────── */
.page-main { outline: none; }

/* ── Homepage ──────────────────────────────────────────── */
.homepage {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.home-hero {
  text-align: center;
  padding: 40px 0 56px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 56px;
}
.home-hero-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 16px;
}
.home-hero-sub {
  font-size: 18px;
  color: var(--text-2);
  max-width: 520px;
  margin: 0 auto 28px;
}
/* Hero search */
.hero-search {
  display: flex;
  max-width: 500px;
  margin: 0 auto;
  border: 2px solid var(--border);
  border-radius: 28px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.hero-search input {
  flex: 1; border: none; background: transparent;
  padding: 12px 20px;
  font-size: 15px; font-family: var(--font-ui);
  color: var(--text); outline: none;
}
.hero-search button {
  background: var(--accent); border: none;
  color: #fff;
  padding: 12px 22px;
  font-size: 14px; font-weight: 600;
  font-family: var(--font-ui);
  transition: background var(--transition);
}
.hero-search button:hover { background: var(--accent-hover); }

/* Category section */
.cat-section { margin-bottom: 56px; }
.cat-header {
  display: flex; align-items: baseline;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--text);
}
.cat-title {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 800;
  color: var(--text);
}
.cat-count {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: .5px;
}

/* Article card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}
.article-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  display: flex; flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition);
}
.article-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.card-img-wrap {
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--surface-alt);
}
.card-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.article-card:hover .card-img-wrap img { transform: scale(1.04); }
.card-body {
  padding: 18px 20px 20px;
  flex: 1; display: flex; flex-direction: column;
}
.card-cat {
  font-family: var(--font-ui);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--accent);
  margin-bottom: 8px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 10px;
}
.card-lead {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px;
  font-family: var(--font-ui);
  font-size: 12px; color: var(--text-3);
}
.card-meta .sep { color: var(--border); }

/* ── Article Detail Page ───────────────────────────────── */
.article-wrap {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* Cover */
.article-cover {
  width: 100%;
  aspect-ratio: 16/7;
  object-fit: cover;
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: 36px;
  background: var(--surface-alt);
}
.article-cover-placeholder {
  width: 100%;
  aspect-ratio: 16/7;
  background: linear-gradient(135deg, var(--surface-alt) 0%, var(--border) 100%);
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  font-family: var(--font-ui);
  font-size: 13px;
}

/* Article meta */
.article-meta-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  font-family: var(--font-ui);
  font-size: 13px; color: var(--text-2);
  margin-bottom: 18px;
}
.article-meta-bar .cat-badge {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  text-decoration: none;
}
.article-meta-bar .cat-badge:hover { background: var(--accent); color: #fff; }
.article-meta-bar .sep { color: var(--border); }

/* Article title */
.article-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 4.5vw, 40px);
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 22px;
}

/* Lead */
.article-lead {
  font-size: 19px;
  line-height: 1.65;
  color: var(--text-2);
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 18px;
  margin-bottom: 36px;
}

/* Body content */
.article-body { color: var(--text); }
.article-body h2 {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin: 40px 0 14px;
}
.article-body h3 {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700;
  margin: 28px 0 10px;
}
.article-body p { margin-bottom: 20px; }
.article-body ul, .article-body ol {
  padding-left: 24px; margin-bottom: 20px;
}
.article-body li { margin-bottom: 8px; }
.article-body strong { font-weight: 600; }
.article-body a { color: var(--accent); text-decoration: underline; }
.article-body a:hover { color: var(--accent-hover); }
.article-body blockquote {
  border-left: 3px solid var(--border);
  padding: 4px 0 4px 18px;
  color: var(--text-2);
  margin: 24px 0;
  font-style: italic;
}
.article-body img {
  border-radius: var(--radius-sm);
  margin: 20px 0;
}

/* ── Ad Slots ──────────────────────────────────────────── */
.ad-slot {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 36px 0;
}
.ad-slot-label {
  font-family: var(--font-ui);
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-3);
  margin-bottom: 12px;
}
/* Mode A: AFS container */
.afs-container { min-height: 60px; }

/* Mode B: keyword tags */
.kw-row {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.kw-tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font-ui);
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.kw-tag:hover {
  background: var(--tag-hover-bg);
  color: var(--tag-hover-tx);
  border-color: var(--tag-hover-bg);
}

/* Related tags (bottom of article) */
.related-tags {
  border-top: 1px solid var(--border);
  padding-top: 28px;
  margin-top: 44px;
}
.related-tags-label {
  font-family: var(--font-ui);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-3);
  margin-bottom: 14px;
}

/* ── Search Results Page ───────────────────────────────── */
.search-wrap {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.search-header { margin-bottom: 36px; }
.search-query-label {
  font-family: var(--font-ui);
  font-size: 13px; color: var(--text-3);
  margin-bottom: 6px;
}
.search-query-text {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 700;
  color: var(--text);
}

/* AFS block on search page */
.afs-search-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 40px;
}
.afs-search-label {
  font-family: var(--font-ui);
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* Article list on search page */
.search-results-title {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.search-article-list { display: flex; flex-direction: column; gap: 20px; }
.search-article-item {
  display: flex; gap: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  padding: 16px;
  text-decoration: none;
  transition: box-shadow var(--transition), transform var(--transition);
}
.search-article-item:hover {
  box-shadow: var(--shadow);
  transform: translateX(3px);
}
.search-item-img {
  width: 120px; height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--surface-alt);
}
.search-item-body { flex: 1; min-width: 0; }
.search-item-cat {
  font-family: var(--font-ui);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--accent);
  margin-bottom: 6px;
}
.search-item-title {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 700;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 6px;
}
.search-item-lead {
  font-size: 13px; color: var(--text-2);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-item-pinned {
  border-left: 3px solid var(--accent);
}

/* ── Static pages (privacy, terms, etc.) ──────────────── */
.static-page {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 48px 20px 80px;
}
.static-page h1 {
  font-family: var(--font-display);
  font-size: 36px; font-weight: 800;
  margin-bottom: 8px;
}
.static-page .updated {
  font-family: var(--font-ui);
  font-size: 13px; color: var(--text-3);
  margin-bottom: 36px;
}
.static-page h2 {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  margin: 32px 0 12px;
}
.static-page p { margin-bottom: 18px; }
.static-page ul { padding-left: 22px; margin-bottom: 18px; }
.static-page li { margin-bottom: 6px; }
.static-page a { color: var(--accent); }

/* ── Footer ────────────────────────────────────────────── */
.site-footer {
  background: var(--text);
  color: rgba(255,255,255,.7);
  padding: 48px 24px 32px;
  margin-top: auto;
}
.footer-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px 48px;
}
.footer-logo {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 800;
  color: #fff;
  text-decoration: none;
  display: block; margin-bottom: 8px;
}
.footer-tagline {
  font-size: 13px;
  color: rgba(255,255,255,.5);
  line-height: 1.6;
}
.footer-nav, .footer-legal {
  display: flex; flex-wrap: wrap;
  gap: 6px 16px; align-content: flex-start;
}
.footer-nav-label {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: rgba(255,255,255,.4);
  margin-bottom: 4px;
}
.footer-nav a, .footer-legal a {
  font-family: var(--font-ui);
  font-size: 13px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  transition: color var(--transition);
}
.footer-nav a:hover, .footer-legal a:hover { color: #fff; }
.footer-copy {
  grid-column: 1 / -1;
  font-family: var(--font-ui);
  font-size: 12px;
  color: rgba(255,255,255,.35);
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,.1);
}

/* ── Admin ─────────────────────────────────────────────── */
.admin-wrap {
  max-width: 960px; margin: 0 auto;
  padding: 32px 20px 80px;
  font-family: var(--font-ui);
}
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 32px; padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.admin-title {
  font-size: 24px; font-weight: 700; color: var(--text);
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  text-decoration: none; border: none;
  transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* Form elements */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.form-label .required { color: var(--accent); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 14px; font-family: var(--font-ui);
  color: var(--text); background: var(--surface);
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
}
.form-hint {
  font-size: 11px; color: var(--text-3);
  margin-top: 4px;
}
.form-error {
  font-size: 11px; color: var(--accent);
  margin-top: 4px;
}

/* Admin table */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-3);
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
}
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  vertical-align: middle;
}
.admin-table tr:hover td { background: var(--surface-alt); }
.badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-ai     { background: #dbeafe; color: #1d4ed8; }
.badge-manual { background: #dcfce7; color: #15803d; }
.badge-hidden { background: var(--surface-alt); color: var(--text-3); }

/* Alert messages */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 20px;
  border-left: 3px solid;
}
.alert-success { background: #f0fdf4; border-color: #22c55e; color: #15803d; }
.alert-error   { background: #fef2f2; border-color: #ef4444; color: #dc2626; }
.alert-info    { background: #eff6ff; border-color: #3b82f6; color: #1d4ed8; }

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 2px solid var(--border); }
.tab-btn {
  padding: 10px 20px;
  font-size: 13px; font-weight: 600;
  color: var(--text-2); background: none; border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .site-nav { display: none; }
  .header-search input { width: 140px; }
  .card-grid { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr; }
  .search-article-item { flex-direction: column; }
  .search-item-img { width: 100%; height: 160px; }
  body { font-size: 17px; }
  .article-lead { font-size: 17px; }
  .admin-wrap { padding: 20px 16px 60px; }
}
@media (max-width: 480px) {
  .header-inner { gap: 12px; padding: 0 16px; }
  .hero-search { margin: 0 -4px; }
  .article-wrap { padding: 0 16px 60px; }
}
