/* ============================================
   terancejiang.com — Unified Design System
   ============================================ */

/* --- Font Face --- */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/assets/fonts/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/assets/fonts/JetBrainsMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --- CSS Custom Properties --- */
:root {
  /* Colors — unified from report palette */
  --bg:          #fafaf7;
  --bg2:         #f0efe9;
  --bg3:         #e8e7e0;
  --text:        #1c1c1a;
  --text2:       #5c5c58;
  --text3:       #8a8a84;
  --border:      rgba(0,0,0,0.08);
  --accent:      #1a1a18;

  /* Semantic colors */
  --green:       #1a7a5a;
  --green-bg:    #e6f4ee;
  --red:         #c0392b;
  --red-bg:      #fceaea;
  --amber:       #a06c1a;
  --amber-bg:    #faf0d8;
  --blue:        #2563a0;
  --blue-bg:     #e8f0fa;
  --purple:      #6c5ce7;
  --purple-bg:   #f0eefa;

  /* Category badge colors */
  --cat-stock:   #c0392b;
  --cat-essay:   #2563a0;
  --cat-sector:  #1a7a5a;

  /* Typography */
  --font:  -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', system-ui, sans-serif;
  --mono:  'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Layout */
  --max-width:   820px;
  --padding-x:   32px;
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #161614;
    --bg2:       #1e1e1b;
    --bg3:       #2a2a26;
    --text:      #e8e7e0;
    --text2:     #a0a098;
    --text3:     #6a6a64;
    --border:    rgba(255,255,255,0.08);
    --accent:    #e8e7e0;
    --green:     #3dbb8a;
    --green-bg:  #1a2e24;
    --red:       #e86050;
    --red-bg:    #2e1a1a;
    --amber:     #d4a03a;
    --amber-bg:  #2e2610;
    --blue:      #5a9fd4;
    --blue-bg:   #1a2430;
    --purple:    #a29bfe;
    --purple-bg: #1e1a2e;
    --cat-stock: #e86050;
    --cat-essay: #5a9fd4;
    --cat-sector:#3dbb8a;
  }
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  overflow-y: scroll; /* prevent layout shift from scrollbar */
}

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

a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--text2);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

::selection {
  background-color: rgba(26, 26, 24, 0.1);
  color: var(--text);
}

/* --- Layout --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--padding-x);
}

.report-body {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--padding-x) 80px;
}

/* --- Navigation --- */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.nav-logo:hover {
  color: var(--text);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 14px;
}

.nav-links a {
  color: var(--text3);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

/* --- Page Header / Tagline --- */
.page-tagline {
  text-align: center;
  padding: 40px 0 24px;
  color: var(--text2);
  font-size: 16px;
  font-weight: 300;
}

/* --- Category Filter Tabs --- */
.category-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-bottom: 40px;
  list-style: none;
}

.category-tabs button {
  font-family: var(--font);
  font-size: 13px;
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.15s ease;
}

.category-tabs button:hover {
  border-color: var(--text2);
  color: var(--text2);
}

.category-tabs button.active {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}

/* --- Article List (Homepage) --- */
.article-list {
  list-style: none;
}

.date-group {
  margin-bottom: 40px;
}

.date-label {
  font-size: 13px;
  color: var(--text3);
  padding-bottom: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.article-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  text-decoration: none;
  color: inherit;
  transition: opacity 0.15s ease;
}

a.article-item:hover {
  opacity: 0.7;
}

.article-item.hidden {
  display: none;
}

.article-num {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--red);
  flex-shrink: 0;
  width: 2em;
  padding-top: 1px;
}

.article-body {
  flex: 1;
  min-width: 0;
}

.article-title {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--text);
  margin: 0;
}

.article-title strong {
  font-weight: 600;
  color: var(--text);
}

.article-meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.cat-badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 3px;
  font-weight: 500;
}

.cat-badge.stock {
  background: var(--red-bg);
  color: var(--cat-stock);
}

.cat-badge.essay {
  background: var(--blue-bg);
  color: var(--cat-essay);
}

.cat-badge.sector {
  background: var(--green-bg);
  color: var(--cat-sector);
}

.article-ticker {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text3);
}

/* --- View All / Archive Link --- */
.view-all {
  text-align: center;
  padding: 24px 0 48px;
}

.view-all a {
  font-size: 14px;
  color: var(--text3);
}

.view-all a:hover {
  color: var(--red);
}

/* --- About Section (Homepage) --- */
.about-section {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

.about-section h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.about-section p {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.7;
}

/* --- Footer --- */
.site-footer {
  padding: 40px 0 64px;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}

.footer-links a {
  font-size: 13px;
  color: var(--text3);
}

.footer-links a:hover {
  color: var(--red);
}

.footer-copy {
  font-size: 12px;
  color: var(--bg3);
}

/* ============================================
   Article Detail Pages
   ============================================ */

/* --- Breadcrumb --- */
.breadcrumb {
  font-size: 12px;
  color: var(--text3);
  padding: 16px 0;
}

.breadcrumb a { color: var(--text3); }
.breadcrumb a:hover { color: var(--red); }
.breadcrumb .sep { margin: 0 4px; }

/* --- Article Header --- */
.article-header {
  padding: 24px 0 40px;
}

.article-header .meta {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 8px;
}

.article-header .meta .cat-badge {
  margin-left: 8px;
  position: relative;
  top: -1px;
}

.article-header h1 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* --- Article Content (Prose) --- */
.article-content h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.article-content h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin: 24px 0 8px;
}

.article-content p {
  margin-bottom: 1.5em;
}

.article-content ul,
.article-content ol {
  margin-bottom: 1.5em;
  padding-left: 1.5em;
}

.article-content li {
  margin-bottom: 0.5em;
}

.article-content blockquote {
  border-left: 3px solid var(--red);
  padding-left: 24px;
  margin: 24px 0;
  color: var(--text2);
  font-style: italic;
}

.article-content .num {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--red);
}

/* --- Share Bar --- */
.share-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px 0;
  margin: 40px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.share-bar span {
  font-size: 13px;
  color: var(--text3);
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text3);
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  transition: color 0.15s ease;
}

.share-btn:hover {
  color: var(--red);
}

/* --- Prev-Next Navigation --- */
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0;
}

.article-nav a {
  font-size: 14px;
  color: var(--text3);
}

.article-nav a:hover { color: var(--red); }
.article-nav .prev::before { content: '← '; }
.article-nav .next::after { content: ' →'; }

/* --- Overview Section --- */
.section-overview {
  margin-bottom: 40px;
  padding: 24px;
  background: var(--bg2);
  border-radius: 6px;
}

.section-overview h2 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  padding-bottom: 0;
  border-bottom: none;
}

.section-overview ul {
  list-style: none;
  padding-left: 0;
}

.section-overview li {
  position: relative;
  padding-left: 1.5em;
  margin-bottom: 0.75em;
  font-size: 14px;
}

.section-overview li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--red);
  font-weight: 700;
}

/* --- Stock Meta Bar --- */
.stock-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg2);
  border-radius: 6px;
  margin-bottom: 40px;
}

.stock-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stock-meta-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stock-meta-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.stock-meta-value.rating-buy { color: var(--green); }
.stock-meta-value.rating-hold { color: var(--blue); }
.stock-meta-value.rating-sell { color: var(--red); }

/* --- Sector Meta Bar --- */
.sector-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 16px 24px;
  background: var(--bg2);
  border-radius: 6px;
  margin-bottom: 40px;
  font-size: 14px;
}

.sector-meta strong { color: var(--text); }

/* ============================================
   Archive Page
   ============================================ */
.archive-list { list-style: none; }

.archive-year {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 40px 0 16px;
}

.archive-item {
  display: flex;
  gap: 16px;
  padding: 8px 0;
  align-items: baseline;
}

.archive-date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text3);
  flex-shrink: 0;
  width: 5em;
}

.archive-title { font-size: 14px; }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 640px) {
  :root {
    --padding-x: 16px;
  }

  .site-nav {
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-links {
    gap: 16px;
    font-size: 13px;
  }

  .page-tagline {
    font-size: 15px;
    padding: 24px 0 16px;
  }

  .category-tabs {
    flex-wrap: wrap;
  }

  .article-header h1 {
    font-size: 22px;
  }

  .stock-meta-item {
    min-width: calc(50% - 8px);
  }

  .article-nav {
    flex-direction: column;
    gap: 16px;
  }
}
