/* =============================================
   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: 180px; }
.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;
  white-space: nowrap;
}
.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 .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: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-card .num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-card .lbl {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

/* TOP STORY CARD */
.top-story-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
}
.top-story-img {
  width: 100%;
  height: 200px;
  background-size: cover;
  background-position: center;
  background-color: #1a3a5c;
  background-image: linear-gradient(135deg, #0f2744 0%, #1a3a5c 40%, #1e4d80 70%, #2a6496 100%);
}
.top-story-body {
  padding: 18px 22px 20px;
}
.top-story-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #e67e22;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.top-story-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 10px;
}
.top-story-title a {
  color: var(--primary);
  text-decoration: none;
}
.top-story-title a:hover { text-decoration: underline; }
.top-story-summary {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 12px;
}
.top-story-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.top-story-source {
  background: #edf2f7;
  color: #2b6cb0;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
}
html.dark .top-story-source { background: #2d3748; color: #7eb8f7; }
.top-story-digest-link {
  margin-left: auto;
  color: #2b6cb0;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.82rem;
}
.top-story-digest-link:hover { text-decoration: underline; }

/* 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; }

  /* Top story card: single column on mobile */
  .top-story-img { height: 150px; }
  .top-story-body { padding: 14px 16px 16px; }
  .top-story-title { font-size: 1.1rem; }

  /* 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: #0a1a2e;
  border-bottom: 1px solid #1a3a5c;
  display: flex;
  align-items: center;
  height: 34px;
  overflow: hidden;
  position: relative;
  z-index: 98;
}

.ticker-label-box {
  background: #e84545;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0 12px;
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: uppercase;
}

.ticker-scroll-outer {
  flex: 1;
  overflow: hidden;
  height: 100%;
  position: relative;
}

.ticker-track {
  display: flex;
  align-items: center;
  height: 100%;
  width: max-content;
  animation: ticker-scroll 40s linear infinite;
}

.ticker-track:hover { animation-play-state: paused; }

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 20px;
  border-right: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  font-size: 0.78rem;
}

.ticker-sym {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.ticker-price {
  color: #c8d6e5;
  font-variant-numeric: tabular-nums;
}

.ticker-chg {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.74rem;
  font-weight: 600;
}

.ticker-chg.up   { color: #48bb78; }
.ticker-chg.down { color: #fc8181; }

.ticker-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}

.dot-up   { background: #48bb78; }
.dot-down { background: #fc8181; }

.ticker-eod {
  background: #0a1a2e;
  color: rgba(255,255,255,0.4);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0 10px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.08);
}

.ticker-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #48bb78;
  display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}
