/* =============================================
   Asia Tech News Feed — Jekyll Theme
   ============================================= */

:root {
  --primary: #1a3a5c;
  --accent: #e84545;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --border: #dde3ec;
  --text: #2d3748;
  --muted: #718096;
  --tag-bg: #edf2f7;
  --tag-text: #2b6cb0;
  --row-hover: #f8faff;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Dark mode — manual toggle (.dark on <html>) */
html.dark {
  --primary: #2a5298;
  --accent: #e84545;
  --bg: #0f1923;
  --card-bg: #162031;
  --border: #243449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --tag-bg: #1e3a5f;
  --tag-text: #90cdf4;
  --row-hover: #1c2e45;
}

/* Dark mode — respect OS preference when no manual toggle */
@media (prefers-color-scheme: dark) {
  html:not(.light) {
    --primary: #2a5298;
    --accent: #e84545;
    --bg: #0f1923;
    --card-bg: #162031;
    --border: #243449;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --tag-bg: #1e3a5f;
    --tag-text: #90cdf4;
    --row-hover: #1c2e45;
  }
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 15px;
}

/* HEADER */
header.site-header {
  background: var(--primary);
  color: #fff;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-title { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.3px; text-decoration: none; color: #fff; }
.site-title span { color: #f6c90e; }
.header-meta { font-size: 1.05rem; color: rgba(255,255,255,0.8); font-style: italic; letter-spacing: 0.2px; }

/* DARK MODE TOGGLE */
.dark-toggle {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background .2s;
  white-space: nowrap;
}
.dark-toggle:hover { background: rgba(255,255,255,0.22); }

/* NAV — sticky beneath header */
nav.site-nav { background: #132d4a; position: sticky; top: 49px; z-index: 99; box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
.nav-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; display: flex; gap: 0; }
nav a { color: rgba(255,255,255,0.75); text-decoration: none; font-size: 0.87rem; padding: 10px 16px; display: inline-block; transition: all .2s; }
nav a:hover, nav a.active { color: #fff; background: rgba(255,255,255,0.08); }

/* MAIN */
main { max-width: 1280px; margin: 0 auto; padding: 28px 24px; }

/* FILTER BAR */
.filter-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 24px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar label { font-size: 0.82rem; color: var(--muted); font-weight: 600; margin-right: 4px; }
.filter-btn {
  border: 1px solid var(--border);
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 500;
  transition: all .2s;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ARTICLE TABLE */
.news-table-wrapper { overflow-x: auto; }
.news-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  font-size: 0.875rem;
}
.news-table thead {
  background: var(--primary);
  color: #fff;
}
.news-table th {
  padding: 13px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.news-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.news-table tr:last-child td { border-bottom: none; }
.news-table tr:hover td { background: var(--row-hover); }

/* Column widths */
.col-num   { width: 40px; text-align: center; color: var(--muted); font-weight: 700; }
.col-source { width: 130px; }
.col-title  { width: 220px; }
.col-summary { min-width: 260px; }
.col-tags  { width: 140px; }
.col-date  { width: 95px; white-space: nowrap; color: var(--muted); font-size: 0.8rem; }
.col-link  { width: 80px; text-align: center; }

.article-title { font-weight: 600; color: var(--primary); line-height: 1.4; }
.source-badge {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--primary);
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  margin: 2px 2px 2px 0;
}
.tag.ai     { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.tag.semi   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.tag.bio    { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.tag.auto   { background: #fef9c3; color: #a16207; border: 1px solid #fde047; }
.tag.logis  { background: #ede9fe; color: #6d28d9; border: 1px solid #c4b5fd; }

html.dark .tag.ai   { background: #1e3a5f; color: #90cdf4; border-color: #2a5298; }
html.dark .tag.semi { background: #3b1a1a; color: #fca5a5; border-color: #7f1d1d; }
html.dark .tag.bio  { background: #14351e; color: #86efac; border-color: #166534; }
html.dark .tag.auto { background: #2d2506; color: #fde047; border-color: #713f12; }
html.dark .tag.logis{ background: #1f1244; color: #c4b5fd; border-color: #4c1d95; }

/* Dark mode: lighten text elements that use --primary as foreground color */
html.dark .article-title { color: #7eb8f7; }
html.dark .source-badge  { color: #7eb8f7; }
html.dark .stat-card .num { color: #7eb8f7; }
html.dark .post-header h1 { color: #7eb8f7; }
html.dark .pagination a, html.dark .pagination span { color: #7eb8f7; }

@media (prefers-color-scheme: dark) {
  html:not(.light) .tag.ai   { background: #1e3a5f; color: #90cdf4; border-color: #2a5298; }
  html:not(.light) .tag.semi { background: #3b1a1a; color: #fca5a5; border-color: #7f1d1d; }
  html:not(.light) .tag.bio  { background: #14351e; color: #86efac; border-color: #166534; }
  html:not(.light) .tag.auto { background: #2d2506; color: #fde047; border-color: #713f12; }
  html:not(.light) .tag.logis{ background: #1f1244; color: #c4b5fd; border-color: #4c1d95; }
  html:not(.light) .article-title { color: #7eb8f7; }
  html:not(.light) .source-badge  { color: #7eb8f7; }
  html:not(.light) .stat-card .num { color: #7eb8f7; }
  html:not(.light) .post-header h1 { color: #7eb8f7; }
  html:not(.light) .pagination a, html:not(.light) .pagination span { color: #7eb8f7; }
}

.btn-link {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 5px 12px;
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background .2s;
}
.btn-link:hover { background: #c0392b; }

/* SUMMARY BAR */
.summary-bar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  flex: 1;
  min-width: 130px;
  text-align: center;
}
.stat-card .num { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.stat-card .lbl { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

/* PAGINATION */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 28px; }
.pagination a, .pagination span {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.85rem;
  color: var(--primary);
  background: var(--card-bg);
}
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* POST DETAIL */
.post-header { margin-bottom: 28px; }
.post-header h1 { font-size: 1.5rem; color: var(--primary); margin-bottom: 10px; }
.post-meta { font-size: 0.85rem; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.post-body { background: var(--card-bg); border-radius: 10px; padding: 28px; box-shadow: 0 1px 4px rgba(0,0,0,0.07); }

/* FOOTER */
footer {
  text-align: center;
  padding: 22px;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}
.visitor-counter { margin-top: 10px; }
.visitor-counter img { vertical-align: middle; border-radius: 3px; }

/* CSV DOWNLOAD */
.actions-bar {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 14px;
}
.btn-download {
  background: #276749;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-download:hover { background: #1e4d35; }

/* =============================================
   FEATURED HERO CARD
   ============================================= */

.featured-hero {
  display: flex;
  gap: 24px;
  align-items: stretch;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.featured-hero__img-wrap {
  flex: 0 0 260px;
  max-width: 260px;
  overflow: hidden;
  background: var(--tag-bg);
}

.featured-hero__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  min-height: 180px;
}

.featured-hero__body {
  flex: 1;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.featured-hero__label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.featured-hero__title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
  color: var(--primary);
}

.featured-hero__title a {
  color: inherit;
  text-decoration: none;
}

.featured-hero__title a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.featured-hero__summary {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
  flex: 1;
}

.featured-hero__meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.featured-hero__source {
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
}

.featured-hero__cta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  margin-left: auto;
}

.featured-hero__cta:hover { text-decoration: underline; }

/* Dark mode overrides for hero */
html.dark .featured-hero,
@media (prefers-color-scheme: dark) {
  html:not(.light) .featured-hero {
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  }
}

/* Responsive hero */
@media (max-width: 768px) {
  .featured-hero {
    flex-direction: column;
  }
  .featured-hero__img-wrap {
    flex: none;
    max-width: 100%;
    max-height: 200px;
  }
  .featured-hero__img { min-height: unset; height: 200px; }
  .featured-hero__body { padding: 16px; }
  .featured-hero__title { font-size: 1rem; }
}

/* =============================================
   MOBILE & RESPONSIVE STYLES
   ============================================= */

/* ── Tablet (≤900px) ── */
@media (max-width: 900px) {
  .col-tags { display: none; }
}

/* ── Mobile (≤768px) ── */
@media (max-width: 768px) {

  /* Header: stack title + meta vertically */
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 16px;
  }
  .site-title { font-size: 1.1rem; }
  .header-meta { font-size: 0.9rem; }

  /* Nav: recalculate sticky offset; make links fill row */
  nav.site-nav { top: 62px; }
  .nav-inner { padding: 0 8px; }
  nav a { padding: 10px 14px; font-size: 0.85rem; flex: 1; text-align: center; }

  /* Main content padding */
  main { padding: 14px 12px; }

  /* Stat cards: 2-column grid */
  .summary-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card { min-width: 0; padding: 12px 10px; }
  .stat-card .num { font-size: 1.35rem; }

  /* Keyword stats bar in post: horizontal scroll (8 cards → don't use grid) */
  .keyword-bar {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .keyword-bar::-webkit-scrollbar { display: none; }
  .keyword-bar .stat-card { min-width: 90px; flex-shrink: 0; }

  /* Filter bar: horizontal scroll, no wrap */
  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
    gap: 8px;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-bar label { white-space: nowrap; }
  .filter-btn { white-space: nowrap; flex-shrink: 0; padding: 7px 14px; font-size: 0.82rem; min-height: 36px; }

  /* Actions bar */
  .actions-bar { justify-content: stretch; }
  .btn-download { width: 100%; justify-content: center; padding: 11px 18px; font-size: 0.88rem; min-height: 44px; }

  /* ── Article table → card layout ── */
  .news-table-wrapper { overflow-x: unset; }

  .news-table,
  .news-table tbody,
  .news-table tr { display: block; width: 100%; }

  /* Hide the table header row */
  .news-table thead { display: none; }

  /* Each row becomes a card */
  .news-table tr {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }
  .news-table tr:hover td { background: transparent; }

  /* Hide dense/redundant columns on mobile */
  .col-num   { display: none; }
  .col-date  { display: none; }
  .col-tags  { display: none; }

  /* All visible cells: block */
  .news-table td {
    display: block;
    padding: 4px 0;
    border-bottom: none;
    width: 100%;
  }

  /* Source badge: top of card */
  .col-source { margin-bottom: 6px; }

  /* Title: prominent */
  .col-title { margin-bottom: 8px; }
  .article-title { font-size: 0.95rem; line-height: 1.45; }

  /* Summary: readable */
  .col-summary { font-size: 0.85rem; color: var(--text); line-height: 1.55; margin-bottom: 10px; }

  /* Read link: full-width button */
  .col-link {
    text-align: left;
    margin-top: 4px;
  }
  .btn-link {
    display: block;
    text-align: center;
    padding: 9px 16px;
    font-size: 0.85rem;
    min-height: 40px;
    line-height: 1.4;
  }

  /* Post header */
  .post-header h1 { font-size: 1.2rem; line-height: 1.4; }
  .post-meta { gap: 8px; font-size: 0.8rem; }

  /* Post body: no excess padding */
  .post-body { padding: 0; background: transparent; box-shadow: none; border-radius: 0; }

  /* Digest list items in index.html */
  .digest-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px;
  }
  .digest-item a.view-link {
    margin-left: 0 !important;
    align-self: flex-start;
  }

  /* Footer */
  footer { padding: 18px 12px; font-size: 0.75rem; }
  footer p { margin-bottom: 6px; }
}

/* ── Small mobile (≤480px) ── */
@media (max-width: 480px) {
  .site-title { font-size: 1rem; }
  .summary-bar { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card .num { font-size: 1.2rem; }
  .stat-card .lbl { font-size: 0.72rem; }
  .article-title { font-size: 0.9rem; }
  .col-summary { font-size: 0.82rem; }
}


/* ── Stock ticker ─────────────────────────────────────── */
.ticker-wrap { background: #0a1628; border-bottom: 1px solid rgba(255,255,255,0.07); display: flex; align-items: stretch; overflow: hidden; height: 34px; }
.ticker-label-box { background: #4a90d9; color: #fff; font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; padding: 0 14px; display: flex; align-items: center; white-space: nowrap; flex-shrink: 0; }
.ticker-scroll-outer { flex: 1; overflow: hidden; position: relative; }
.ticker-scroll-outer::before { content: ''; position: absolute; left: 0; top: 0; width: 24px; height: 100%; background: linear-gradient(to right, #0a1628, transparent); z-index: 1; pointer-events: none; }
.ticker-scroll-outer::after { content: ''; position: absolute; right: 0; top: 0; width: 24px; height: 100%; background: linear-gradient(to left, #0a1628, transparent); z-index: 1; pointer-events: none; }
.ticker-track { display: flex; align-items: center; height: 34px; white-space: nowrap; animation: ticker-scroll 40s linear infinite; }
.ticker-track:hover { animation-play-state: paused; }
.ticker-item { display: inline-flex; align-items: center; gap: 7px; padding: 0 18px; border-right: 1px solid rgba(255,255,255,0.08); font-size: 13px; height: 100%; }
.ticker-sym { color: #fff; font-weight: 600; letter-spacing: 0.3px; }
.ticker-price { color: rgba(255,255,255,0.6); font-size: 12px; }
.ticker-chg { font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 3px; }
.ticker-chg.up { color: #4cdb8a; }
.ticker-chg.down { color: #ff6b6b; }
.ticker-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.dot-up { background: #4cdb8a; }
.dot-down { background: #ff6b6b; }
.ticker-eod { display: flex; align-items: center; gap: 6px; padding: 0 12px; flex-shrink: 0; font-size: 11px; color: rgba(255,255,255,0.35); border-left: 1px solid rgba(255,255,255,0.07); white-space: nowrap; }
.ticker-pulse { width: 6px; height: 6px; border-radius: 50%; background: #4cdb8a; animation: ticker-pulse 2s ease-in-out infinite; display: inline-block; }
@keyframes ticker-scroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
@keyframes ticker-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
