/* ==========================================================================
   Jason's Finance Blog - Modern Financial Aesthetics (finance.css)
   Theme: Slate Dark / Emerald Gains / Crimson Losses / Tabular Figures
   ========================================================================== */

:root {
  /* Core Color Palette */
  --bg-primary: #0f172a;       /* Slate 900 */
  --bg-secondary: #1e293b;     /* Slate 800 */
  --bg-tertiary: #334155;      /* Slate 700 */
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.8);
  
  --text-main: #f8fafc;        /* Slate 50 */
  --text-muted: #94a3b8;       /* Slate 400 */
  --text-dim: #64748b;         /* Slate 500 */
  
  --border-color: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.2);

  /* Financial Status Accents */
  --color-gain: #10b981;       /* Emerald 500 */
  --color-gain-bg: rgba(16, 185, 129, 0.12);
  --color-loss: #ef4444;       /* Red 500 */
  --color-loss-bg: rgba(239, 68, 68, 0.12);
  --color-neutral: #3b82f6;    /* Blue 500 */
  --color-accent: #f59e0b;     /* Amber 500 */
  --color-teal: #14b8a6;       /* Teal 500 */

  /* Glassmorphism & Shadow */
  --backdrop-blur: blur(12px);
  --box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.15);

  /* Layout & Spacing */
  --max-width: 1200px;
  --header-height: 72px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --border-color: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.18);

  --color-gain: #059669;
  --color-gain-bg: rgba(5, 150, 105, 0.1);
  --color-loss: #dc2626;
  --color-loss-bg: rgba(220, 38, 38, 0.1);
  --color-neutral: #2563eb;
  --color-accent: #d97706;

  --box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(5, 150, 105, 0.1);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Numeric Financial Data Formatting */
.num, .stock-price, .calc-num, td.tabular {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition);
}

/* Container */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header & Navigation */
.header-wrapper {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

[data-theme="light"] .header-wrapper {
  background: rgba(248, 250, 252, 0.88);
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #f8fafc 0%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .brand-logo {
  background: linear-gradient(135deg, #0f172a 0%, #059669 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-gain), var(--color-teal));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: bold;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav-link {
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.5rem 0;
  position: relative;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-main);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-gain);
  border-radius: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-toggle-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-tertiary);
}

/* Stock Ticker Bar */
.ticker-bar-wrapper {
  background: #090d16;
  border-bottom: 1px solid var(--border-color);
  overflow: hidden;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

[data-theme="light"] .ticker-bar-wrapper {
  background: #f1f5f9;
}

.ticker-track {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  padding: 0.6rem 0;
  animation: ticker-scroll 35s linear infinite;
  width: max-content;
}

.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: 0.6rem;
  cursor: pointer;
}

.ticker-symbol {
  font-weight: 700;
  color: var(--text-main);
}

.ticker-price {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.ticker-change {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.ticker-change.up {
  color: var(--color-gain);
  background: var(--color-gain-bg);
}

.ticker-change.down {
  color: var(--color-loss);
  background: var(--color-loss-bg);
}

/* Hero Section */
.hero-section {
  padding: 4rem 0 3rem;
  position: relative;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 3rem;
  align-items: center;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  background: var(--color-gain-bg);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--color-gain);
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.2rem;
}

.hero-title {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 1.2rem;
}

.hero-title span.accent {
  background: linear-gradient(135deg, var(--color-gain), var(--color-teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 580px;
}

.hero-stats-row {
  display: flex;
  gap: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.stat-item .stat-num {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.stat-item .stat-label {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Core-Satellite Asset Allocation Widget */
.asset-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--box-shadow);
  backdrop-filter: var(--backdrop-blur);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.allocation-bar {
  display: flex;
  height: 24px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  background: var(--bg-tertiary);
}

.alloc-segment {
  height: 100%;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.alloc-tech { background: #10b981; }
.alloc-etf { background: #3b82f6; }
.alloc-bonds { background: #f59e0b; }
.alloc-cash { background: #64748b; }

.allocation-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-val {
  margin-left: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Compound Interest / DCA Calculator Section */
.calc-section {
  padding: 3rem 0;
  background: linear-gradient(180deg, transparent 0%, rgba(16, 185, 129, 0.03) 50%, transparent 100%);
}

.calc-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  box-shadow: var(--box-shadow);
}

.calc-inputs {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.form-label .val-display {
  color: var(--color-gain);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.range-input {
  width: 100%;
  accent-color: var(--color-gain);
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  cursor: pointer;
}

.number-input {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: var(--transition);
}

.number-input:focus {
  border-color: var(--color-gain);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.calc-result-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.result-principal {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.result-total {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--color-gain);
  line-height: 1.1;
  margin-bottom: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.result-interest {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.result-badge {
  display: inline-flex;
  padding: 0.4rem 1rem;
  background: var(--color-gain-bg);
  color: var(--color-gain);
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.85rem;
}

/* Search & Categories Filter Bar */
.content-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin: 3rem 0 2rem;
  flex-wrap: wrap;
}

.categories-list {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  list-style: none;
  flex-wrap: wrap;
}

.category-btn {
  padding: 0.5rem 1.1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.category-btn:hover, .category-btn.active {
  background: var(--color-gain);
  color: #ffffff;
  border-color: var(--color-gain);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.search-box {
  position: relative;
  min-width: 280px;
}

.search-input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--color-gain);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

/* Articles Grid */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 2rem;
  margin-bottom: 4rem;
}

.article-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.article-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: var(--box-shadow);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.8rem;
}

.article-category {
  padding: 0.2rem 0.6rem;
  background: var(--bg-tertiary);
  color: var(--color-gain);
  border-radius: 4px;
  font-weight: 600;
}

.article-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 0.8rem;
  color: var(--text-main);
}

.article-card:hover .article-title {
  color: var(--color-gain);
}

.article-excerpt {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.article-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-dim);
}

.read-time {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.read-more-btn {
  font-weight: 600;
  color: var(--color-gain);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Stocks Watchlist / Valuation Page Styling */
.stocks-header {
  text-align: center;
  padding: 3.5rem 0 2rem;
}

.stocks-table-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin-bottom: 4rem;
  box-shadow: var(--box-shadow);
}

.stocks-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

.stocks-table th {
  background: rgba(15, 23, 42, 0.4);
  padding: 1.2rem 1.5rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

[data-theme="light"] .stocks-table th {
  background: #f1f5f9;
}

.stocks-table td {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.stocks-table tr:hover td {
  background: var(--bg-card-hover);
}

.stock-symbol-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: var(--bg-tertiary);
  color: var(--text-main);
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.85rem;
}

.val-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 700;
}

.val-undervalued {
  background: var(--color-gain-bg);
  color: var(--color-gain);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.val-fair {
  background: rgba(59, 130, 246, 0.12);
  color: var(--color-neutral);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.val-overvalued {
  background: var(--color-loss-bg);
  color: var(--color-loss);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Article Detail Page Layout */
.article-container {
  max-width: 820px;
  margin: 3rem auto 5rem;
  padding: 0 1.5rem;
}

.article-header {
  margin-bottom: 2.5rem;
}

.article-header-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.article-main-title {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.author-box {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.author-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-gain), var(--color-teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #ffffff;
  font-size: 1.2rem;
}

.author-info .name {
  font-weight: 700;
}

.author-info .bio {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.article-content {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-main);
}

.article-content p {
  margin-bottom: 1.75rem;
}

.article-content h2 {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 2.5rem 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.article-content h3 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 2rem 0 1rem;
}

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

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

.callout-box {
  background: var(--bg-secondary);
  border-left: 4px solid var(--color-gain);
  padding: 1.5rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 2rem 0;
  font-size: 1.05rem;
}

.callout-box.warning {
  border-left-color: var(--color-accent);
}

.financial-table-wrapper {
  margin: 2rem 0;
  overflow-x: auto;
}

/* Disclaimer Banner */
.disclaimer-banner {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  margin-top: 3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.disclaimer-banner strong {
  color: var(--color-accent);
}

/* Footer */
.site-footer {
  margin-top: auto;
  background: #090d16;
  border-top: 1px solid var(--border-color);
  padding: 3.5rem 0 2rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

[data-theme="light"] .site-footer {
  background: #f1f5f9;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr;
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-brand p {
  margin-top: 1rem;
  color: var(--text-muted);
  max-width: 320px;
}

.footer-title {
  color: var(--text-main);
  font-weight: 700;
  margin-bottom: 1.2rem;
  font-size: 1rem;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.footer-bottom {
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 992px) {
  .hero-grid, .calc-card {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
  }

  .hero-title {
    font-size: 2.1rem;
  }
  
  .footer-grid {
    grid-template-columns: 1fr;
  }
  
  .articles-grid {
    grid-template-columns: 1fr;
  }
  
  .content-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    width: 100%;
  }
}
