/* ═══════════════════════════════════════════════
   Good News v2 — Social Media Feed Design
   1080×1350 cover images, 4-column masonry grid
   ═══════════════════════════════════════════════ */

/* ─── Reset & Tokens ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #ffffff;
  --color-surface: #f7f6f5;
  --color-surface-hover: #efeeed;
  --color-border: #e6e4e2;
  --color-text: #1a1a1a;
  --color-text-secondary: #6b6b6b;
  --color-text-muted: #9a9a9a;
  --color-accent: #e85d4a;
  --color-accent-hover: #d44a3a;
  --color-accent2: #0075de;
  --color-danger: #dc2626;
  --color-success: #16a34a;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  --card-ratio: 4/5;
  --max-width: 1280px;
  --header-height: 56px;

  /* Category colors */
  --cat-hk: #3b82f6;
  --cat-cross: #d97706;
  --cat-intl: #059669;
  --cat-sport: #16a34a;
  --cat-tech: #7c3aed;
  --cat-finance: #dc2626;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ─── Header ─── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
  display: flex;
  align-items: center;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--color-accent), #f08a7a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
}

.header-nav {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.header-nav::-webkit-scrollbar { display: none; }

.header-nav a {
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.header-nav a:hover { color: var(--color-text); background: var(--color-surface); }
.header-nav a.active { color: var(--color-text); font-weight: 600; background: var(--color-surface); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.search-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.search-btn:hover { background: var(--color-surface); color: var(--color-text); }

.btn-primary-sm {
  font-size: 13px;
  font-weight: 600;
  background: var(--color-accent);
  color: #fff;
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  transition: all 0.2s;
  border: none;
  cursor: pointer;
}
.btn-primary-sm:hover { background: var(--color-accent-hover); }

.btn-outline-sm {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  transition: all 0.2s;
  background: transparent;
  cursor: pointer;
}
.btn-outline-sm:hover { border-color: var(--color-text-muted); color: var(--color-text); }

/* User dropdown */
.user-menu { position: relative; }
.user-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 28px rgba(0,0,0,0.08);
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
}
.user-dropdown.show { display: block; }
.user-dropdown a {
  display: block;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--color-text-secondary);
  transition: all 0.15s;
}
.user-dropdown a:hover { background: var(--color-surface); color: var(--color-text); }

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

/* ─── Stories Bar ─── */
.stories-bar {
  padding: 20px 0 16px;
  display: flex;
  gap: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.stories-bar::-webkit-scrollbar { display: none; }

.story {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.story-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(var(--color-accent), var(--color-accent2), var(--color-accent));
  transition: transform 0.2s;
}
.story:hover .story-ring { transform: scale(1.05); }

.story-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  overflow: hidden;
}

.story-label {
  font-size: 11px;
  color: var(--color-text-secondary);
  max-width: 70px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
}

/* ─── Section Headers ─── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 14px;
}

.section-header h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.section-header a {
  font-size: 13px;
  color: var(--color-text-muted);
  transition: color 0.2s;
}
.section-header a:hover { color: var(--color-accent); }

/* ─── Trending Scroll ─── */
.trending-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.trending-scroll::-webkit-scrollbar { display: none; }

.trending-card {
  flex-shrink: 0;
  width: 170px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all 0.2s;
}

.trending-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  border-color: #d0cdc9;
}

.trending-img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #e8e4df 0%, #d6d0c8 100%);
}

.trending-body { padding: 8px 10px 10px; }

.trending-body h4 {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.trending-rank {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: 3px;
}

/* ─── Feed Grid ─── */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding-bottom: 40px;
}

.feed-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  flex-direction: column;
}

.feed-card:hover {
  box-shadow: 0 8px 28px rgba(0,0,0,0.07);
  border-color: #d0cdc9;
  transform: translateY(-2px);
}

.feed-card-img {
  width: 100%;
  aspect-ratio: var(--card-ratio);
  object-fit: cover;
  display: block;
  background: var(--color-surface);
}

.feed-card-body {
  padding: 12px 12px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.feed-card-category {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 5px;
}

.cat-港聞 { color: var(--cat-hk); }
.cat-兩岸 { color: var(--cat-cross); }
.cat-國際 { color: var(--cat-intl); }
.cat-體育 { color: var(--cat-sport); }
.cat-科技 { color: var(--cat-tech); }
.cat-財經 { color: var(--cat-finance); }

.feed-card-body h3 {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.1px;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--color-text);
  flex: 1;
}

.feed-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: auto;
}

.feed-card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.feed-card-actions span {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--color-text-muted);
}

/* Card height variations */
.feed-card.tall .feed-card-img { aspect-ratio: 3/5; }
.feed-card.short .feed-card-img { aspect-ratio: 4/5; }

/* ─── Pagination ─── */
.load-more {
  text-align: center;
  padding: 20px 0 40px;
}

.load-more-btn {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent);
  background: transparent;
  border: 1px solid var(--color-accent);
  padding: 10px 32px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s;
}
.load-more-btn:hover { background: var(--color-accent); color: #fff; }
.load-more-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Article Detail Page ─── */
.article-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.article-category {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.article-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.article-image {
  width: 100%;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.article-content {
  font-size: 16px;
  line-height: 1.8;
  color: var(--color-text);
}
.article-content p { margin-bottom: 16px; }
.article-content h2 { font-size: 20px; font-weight: 700; margin: 24px 0 12px; }
.article-content h3 { font-size: 17px; font-weight: 600; margin: 20px 0 10px; }
.article-content img { max-width: 100%; border-radius: var(--radius-sm); }
.article-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--color-text-secondary);
  font-style: italic;
}

/* Article tags */
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.article-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  transition: all 0.2s;
}
.article-tag:hover { background: var(--color-surface-hover); color: var(--color-text); }

/* Bookmark button */
.bookmark-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  transition: transform 0.2s;
}
.bookmark-btn:hover { transform: scale(1.1); }

/* ─── Comments ─── */
.comments-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
}

.comments-section h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
}

.comment-form {
  margin-bottom: 24px;
}

.comment-input {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.2s;
}
.comment-input:focus { outline: none; border-color: var(--color-accent); }

.comment-submit {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
}

.comment-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.comment-author {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.comment-text {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.comment-time {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.comment-reply {
  margin-left: 24px;
  padding-left: 12px;
  border-left: 2px solid var(--color-border);
}

/* ─── Search Page ─── */
.search-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px;
}

.search-box {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.search-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}
.search-input:focus { outline: none; border-color: var(--color-accent); }

.search-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-filter {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.search-filter.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.search-filter:hover:not(.active) { border-color: var(--color-text-muted); }

.search-results { margin-top: 16px; }
.search-count { font-size: 13px; color: var(--color-text-muted); margin-bottom: 16px; }

/* ─── User Dashboard ─── */
.dashboard {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 20px;
}

.dashboard-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0;
}

.dashboard-tab {
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
}
.dashboard-tab.active { color: var(--color-text); border-bottom-color: var(--color-accent); font-weight: 600; }

/* ─── Auth Pages ─── */
.auth-page {
  max-width: 400px;
  margin: 60px auto;
  padding: 0 20px;
}

.auth-page h1 {
  font-size: 24px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
}

.auth-page p {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.auth-form { display: flex; flex-direction: column; gap: 12px; }

.auth-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  display: block;
  margin-bottom: 4px;
}

.auth-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}
.auth-field input:focus { outline: none; border-color: var(--color-accent); }

.auth-submit {
  margin-top: 8px;
  width: 100%;
}

.auth-link {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
}
.auth-link a { color: var(--color-accent); font-weight: 500; }

/* ─── Toast Notifications ─── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(0,0,0,0.15);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-danger); }

/* ─── Footer ─── */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 32px 0 24px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-links { display: flex; gap: 20px; }
.footer-links a { font-size: 12px; color: var(--color-text-muted); }
.footer-links a:hover { color: var(--color-text); }
.footer-copy { font-size: 12px; color: var(--color-text-muted); }

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 17px; font-weight: 600; color: var(--color-text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ─── Responsive ─── */
@media (max-width: 800px) {
  .feed-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .header-nav { display: none; }
  .article-title { font-size: 22px; }
  .stories-bar { gap: 12px; padding: 12px 0; }
  .story { min-width: 60px; }
  .section-header h2 { font-size: 20px; }
}
@media (max-width: 500px) {
  .feed-grid { grid-template-columns: 1fr; gap: 12px; }
  .trending-card { width: 140px; }
  .trending-scroll { gap: 8px; }
  .container { padding: 0 12px; }
}

/* See all link */
.see-all {
  color: #E74C3C;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-left: auto;
}
.see-all:hover {
  text-decoration: underline;
}
