/* ═══════════════════════════════════════
   Good News — Magazine Style Theme
   ═══════════════════════════════════════ */

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --accent: #e74c3c;
  --accent-dark: #c0392b;
  --border: #e0e0e0;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
  --hero-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  --max-width: 1200px;
}

/* ─── Reset ─── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang HK", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ─── Header ─── */
.site-header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(10px);
  background: rgba(255,255,255,0.95);
}

.header-inner {
  display: flex; align-items: center;
  justify-content: space-between;
  height: 60px;
}

.site-logo {
  font-size: 24px; font-weight: 800; text-decoration: none;
  color: var(--text-primary); letter-spacing: -0.5px;
}
.site-logo span { color: var(--accent); }

.main-nav { display: flex; gap: 4px; }
.main-nav a {
  text-decoration: none; color: var(--text-secondary);
  padding: 8px 16px; border-radius: 20px;
  font-size: 14px; font-weight: 500;
  transition: all 0.2s;
}
.main-nav a:hover { background: var(--bg-secondary); color: var(--text-primary); }
.main-nav a.active { background: var(--accent); color: #fff; }

.menu-toggle { display: none; background: none; border: none; font-size: 24px; cursor: pointer; }

/* ─── Search Form ─── */
.search-form { display: flex; align-items: center; }
.search-form input[type="search"] {
  width: 160px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s;
}
.search-form input[type="search"]:focus {
  width: 200px;
  border-color: var(--accent);
  background: #fff;
}
.search-form input[type="search"]::placeholder {
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .search-form input[type="search"] { width: 120px; }
  .search-form input[type="search"]:focus { width: 150px; }
}

/* ─── Hero ─── */
.hero-section { padding: 30px 0; }

.hero-card {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 0;
  background: var(--hero-gradient);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
}
.hero-card:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0,0,0,0.15); }

.hero-image { height: 100%; min-height: 260px; }
.hero-image img { width: 100%; height: 100%; object-fit: cover; display: block; }

.hero-text {
  padding: 40px;
  display: flex; flex-direction: column;
  justify-content: center; color: #fff;
}
.hero-category {
  display: inline-block;
  background: var(--accent); color: #fff;
  padding: 4px 12px; border-radius: 4px;
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 16px; width: fit-content;
}
.hero-title { font-size: 28px; font-weight: 700; line-height: 1.3; margin-bottom: 12px; }
.hero-summary { font-size: 15px; opacity: 0.85; line-height: 1.5; margin-bottom: 20px; }
.hero-meta { display: flex; align-items: center; gap: 16px; }
.hero-date { font-size: 13px; opacity: 0.7; }
.read-more { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 14px; }
.read-more:hover { text-decoration: underline; }

/* ─── Category Sections ─── */
.category-section { padding: 16px 0 32px; }
.category-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
}
.category-title { font-size: 20px; font-weight: 700; }
.category-count { font-size: 13px; color: var(--text-secondary); }

/* Article Grid */
.article-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.article-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}
.article-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow);
  border-color: transparent;
}

.card-image {
  aspect-ratio: 1200 / 630;
  overflow: hidden;
  background: #f0f0f0;
}
.card-image img {
  width: 100%; height: 100%;
  object-fit: contain;
  transition: transform 0.3s;
}
.article-card:hover .card-image img { transform: scale(1.05); }

.card-body { padding: 14px 16px 16px; }
.card-category {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  color: var(--accent);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 6px;
}
.card-title {
  font-size: 16px; font-weight: 600;
  line-height: 1.4; margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card-summary {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.card-date {
  font-size: 12px; color: var(--text-secondary);
  margin-top: 8px;
}

/* ─── Article Modal ─── */
.modal-overlay {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  overflow-y: auto;
  padding: 40px 20px;
}
.modal-overlay.open { display: block; }

.modal-content {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-primary);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(0,0,0,0.6); color: #fff;
  border: none; width: 36px; height: 36px;
  border-radius: 50%; font-size: 16px;
  cursor: pointer; z-index: 10;
  transition: background 0.2s;
}
.modal-close:hover { background: rgba(0,0,0,0.8); }

.full-article { padding: 0; }
.article-header { padding: 40px 40px 0; }
.article-category {
  display: inline-block;
  background: var(--accent); color: #fff;
  padding: 4px 12px; border-radius: 4px;
  font-size: 12px; font-weight: 600;
  margin-bottom: 16px;
}
.article-header h1 { font-size: 32px; font-weight: 700; line-height: 1.3; margin-bottom: 12px; }
.article-meta {
  font-size: 14px; color: var(--text-secondary);
  margin-bottom: 24px;
}
.article-image { margin: 0 0 24px; }
.article-image img { width: 100%; max-height: 450px; object-fit: cover; }
.article-body {
  padding: 0 40px 40px;
  font-size: 17px; line-height: 1.8;
  color: var(--text-primary);
}
.article-body p { margin-bottom: 1.2em; }
.article-body img { max-width: 100%; height: auto; border-radius: 8px; }
.article-body figure.content-image { margin: 20px 0; text-align: center; }
.article-body figure.content-image img { border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.article-body .content-image-sm { max-width: 300px; margin-left: auto; margin-right: auto; }
.article-body .content-image-md { max-width: 500px; margin-left: auto; margin-right: auto; }
.article-body .content-image-lg { max-width: 100%; }

/* ─── Footer ─── */
.site-footer {
  background: var(--bg-secondary);
  padding: 24px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  border-top: 1px solid var(--border);
}

/* ─── Mobile ─── */
@media (max-width: 768px) {
  .main-nav { display: none; flex-direction: column; position: absolute; top: 60px;
    left: 0; right: 0; background: var(--bg-primary);
    border-bottom: 1px solid var(--border); padding: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 99;
  }
  .main-nav.open { display: flex; }
  .menu-toggle { display: block; }
  .hero-card { grid-template-columns: 1fr; }
  .hero-image { min-height: 200px; }
  .hero-text { padding: 24px; }
  .hero-title { font-size: 22px; }
  .article-grid { grid-template-columns: 1fr; }
  .article-header { padding: 24px 24px 0; }
  .article-body { padding: 0 24px 24px; }
  .article-header h1 { font-size: 24px; }
}

@media (max-width: 480px) {
  .article-grid { grid-template-columns: 1fr; }
  .card-image { height: 180px; }
}

/* ─── User Menu ─── */
.header-right { display: flex; align-items: center; gap: 12px; }
#userMenu { display: flex; align-items: center; }
.user-link { text-decoration: none; font-size: 14px; font-weight: 500; padding: 6px 12px; border-radius: 8px; transition: all 0.2s; }
.user-link { color: var(--text-secondary); }
.user-link:hover { color: var(--text-primary); background: var(--bg-secondary); }
.user-register { background: var(--accent); color: #fff !important; }
.user-register:hover { background: var(--accent-dark) !important; }
.user-dropdown { position: relative; display: inline-block; }
.user-btn { background: var(--bg-secondary); border: 1px solid var(--border); padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-primary); display: flex; align-items: center; gap: 4px; }
.user-btn:hover { background: var(--border); }
.dropdown-content { display: none; position: absolute; right: 0; top: 100%; margin-top: 4px; background: #fff; min-width: 160px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.12); border: 1px solid var(--border); z-index: 200; overflow: hidden; }
.dropdown-content.show { display: block; }
.dropdown-content a { display: flex; align-items: center; gap: 8px; padding: 12px 16px; text-decoration: none; color: var(--text-primary); font-size: 14px; transition: background 0.15s; }
.dropdown-content a:hover { background: var(--bg-secondary); }
.dropdown-content a span { font-size: 16px; }

/* ─── Bookmark Button ─── */
.article-actions { margin-top: 20px; display: flex; gap: 12px; }
.bookmark-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-primary); cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-secondary); transition: all 0.2s; }
.bookmark-btn:hover { border-color: var(--accent); color: var(--accent); }
.bookmark-btn.bookmarked { background: #fff0f0; border-color: var(--accent); color: var(--accent); }

/* ─── Login / Register Pages ─── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-secondary); padding: 20px; }
.auth-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.auth-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; text-align: center; }
.auth-card .auth-sub { font-size: 14px; color: var(--text-secondary); text-align: center; margin-bottom: 28px; }
.auth-card .form-group { margin-bottom: 16px; }
.auth-card label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text-secondary); }
.auth-card input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; box-sizing: border-box; }
.auth-card input:focus { outline: none; border-color: var(--accent); }
.auth-card .auth-btn { width: 100%; padding: 12px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; }
.auth-card .auth-btn:hover { background: var(--accent-dark); }
.auth-card .auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-card .auth-error { color: var(--accent); font-size: 13px; text-align: center; margin-bottom: 12px; display: none; }
.auth-card .auth-link { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-secondary); }
.auth-card .auth-link a { color: var(--accent); text-decoration: none; font-weight: 500; }
.auth-card .auth-link a:hover { text-decoration: underline; }

/* ─── User Dashboard ─── */
.dash-page { max-width: 800px; margin: 0 auto; padding: 40px 20px; }
.dash-page h1 { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.dash-page .dash-sub { font-size: 14px; color: var(--text-secondary); margin-bottom: 28px; }
.dash-cats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; align-items: center; }
.dash-cat-tab { padding: 8px 16px; border: 1px solid var(--border); border-radius: 20px; background: #fff; cursor: pointer; font-size: 13px; font-weight: 500; transition: all 0.2s; }
.dash-cat-tab:hover { border-color: var(--accent); color: var(--accent); }
.dash-cat-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.dash-cat-add { padding: 8px 14px; border: 1px dashed var(--border); border-radius: 20px; background: transparent; cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.dash-cat-add:hover { border-color: var(--accent); color: var(--accent); }
.dash-empty { text-align: center; padding: 60px 20px; color: var(--text-secondary); font-size: 15px; line-height: 1.8; }
.dash-empty a { color: var(--accent); text-decoration: none; font-weight: 500; }
.dash-empty a:hover { text-decoration: underline; }
.dash-bm-item { display: flex; align-items: center; justify-content: space-between; padding: 16px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; transition: all 0.2s; }
.dash-bm-item:hover { border-color: transparent; box-shadow: var(--card-shadow); }
.dash-bm-info { flex: 1; min-width: 0; }
.dash-bm-title { font-size: 16px; font-weight: 600; color: var(--text-primary); text-decoration: none; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-bm-title:hover { color: var(--accent); }
.dash-bm-date { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.dash-bm-actions { display: flex; gap: 8px; flex-shrink: 0; margin-left: 16px; }
.dash-bm-cat-btn, .dash-bm-del { padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 12px; transition: all 0.15s; background: #fff; }
.dash-bm-cat-btn:hover { border-color: var(--accent); color: var(--accent); }
.dash-bm-del { color: #999; }
.dash-bm-del:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 768px) {
  .header-right { gap: 8px; }
  .dash-page { padding: 24px 16px; }
  .dash-bm-item { flex-direction: column; align-items: flex-start; gap: 12px; }
  .dash-bm-actions { margin-left: 0; width: 100%; }
}

/* ─── Nested Comments ─── */
.comment-reply {
  border-left: 2px solid var(--border);
  padding-left: 12px !important;
}

.comment-form-top {
  margin-bottom: 16px;
}
