/* ==========================================================================
   AlgoFinance - Premium Web App Design
   ========================================================================== */

:root {
  --primary-color: #0d1b2a;
  --secondary-color: #1b263b;
  --accent-color: #10b2fe;
  --accent-glow: rgba(16, 178, 254, 0.2);
  --text-main: #2b2d42;
  --text-muted: #6c757d;
  --bg-main: #f8f9fa;
  --bg-card: #ffffff;
  --border-color: #e9ecef;
  
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 12px;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
  --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

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

body {
  font-family: var(--font-main);
  color: var(--text-main);
  background: var(--bg-main);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.3;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--primary-color);
  letter-spacing: -0.02em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p { margin-bottom: 1.25rem; }

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

a:hover {
  color: #0d96d9;
}

/* ---------- Layout & Container ---------- */
.site-wrapper {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.content-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 40px;
  margin: 40px 0;
}

.article-layout {
  display: grid;
  grid-template-columns: 1fr minmax(auto, 1100px) 1fr;
  gap: 40px;
  margin: 40px 0;
}

.article-main {
  grid-column: 2;
}

.ad-margin-left {
  grid-column: 1;
  display: flex;
  justify-content: flex-end;
}

.ad-margin-right {
  grid-column: 3;
  display: flex;
  justify-content: flex-start;
}

.ad-margin-left .ad-slot, .ad-margin-right .ad-slot {
  width: 160px;
  height: 600px;
  position: sticky;
  top: 100px;
  margin: 0;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 30px;
}

@media (max-width: 1500px) {
  .article-layout {
    grid-template-columns: 1fr;
  }
  .ad-margin-left, .ad-margin-right {
    display: none;
  }
  .article-main {
    grid-column: 1;
  }
}

@media (max-width: 850px) {
  .content-layout {
    grid-template-columns: 1fr;
  }
  .articles-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Header ---------- */
.site-header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 15px 0;
  box-shadow: var(--shadow-sm);
}

.site-header .site-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.site-brand {
  display: flex;
  flex-direction: column;
}

/* Logo specific styling */
.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.header-icon {
  height: 24px;
  width: auto;
  transition: transform 0.4s ease;
}

.header-logo {
  height: 24px;
  width: auto;
}

.logo-link:hover .header-icon {
  transform: rotate(15deg) scale(1.1);
}

.site-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
  margin-left: 50px; /* Aligns roughly under the logo text */
}

/* Navigation */
.site-nav {
  display: flex;
  gap: 24px;
}

.site-nav a {
  color: var(--secondary-color);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 6px 0;
  position: relative;
}

.site-nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent-color);
  transition: width 0.3s ease;
}

.site-nav a:hover {
  color: var(--accent-color);
}

.site-nav a:hover::after {
  width: 100%;
}

/* Mobile Menu Button */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 101;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn span {
  width: 100%;
  height: 2px;
  background: var(--secondary-color);
  border-radius: 2px;
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }
  
  .mobile-menu-btn.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
  }
  
  .mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
  }
  
  .mobile-menu-btn.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
  }

  .site-header .site-wrapper {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    padding: 10px 0;
    gap: 15px;
    border-top: 1px solid var(--border-color);
    margin-top: 10px;
  }

  .site-nav.active {
    display: flex;
  }

  .site-nav a {
    font-size: 1.1rem;
    padding: 10px 0;
  }
  
  .site-tagline {
    margin-left: 0;
  }
}

/* ---------- Hero Section (Index) ---------- */
.hero-section {
  text-align: center;
  padding: 60px 20px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border-radius: var(--radius);
  margin-top: 40px;
  margin-bottom: 40px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(16,178,254,0.15) 0%, transparent 60%);
  z-index: 0;
}

.hero-section * {
  position: relative;
  z-index: 1;
}

.hero-section h1 {
  color: white;
  font-size: 3rem;
  margin-bottom: 15px;
}

.hero-section p {
  font-size: 1.2rem;
  color: rgba(255,255,255,0.8);
  max-width: 600px;
  margin: 0 auto;
}

/* ---------- Sections & Spacing ---------- */
.content-section {
  margin-bottom: 80px;
}

.section-heading {
  font-size: 2rem;
  margin-bottom: 30px;
  color: var(--primary-color);
  text-align: center;
}

.category-links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  margin-bottom: 40px;
}

.category-links a {
  background: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.category-links a:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ---------- Article Feature Image ---------- */
.article-feature-image {
  width: 100%;
  max-height: 450px;
  object-fit: cover;
  border-radius: var(--border-radius);
  margin: 1.5rem 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: block;
}

/* ---------- Article Cards ---------- */
.article-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 40px;
  margin-bottom: 60px;
}

.article-list.grid-4x4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
  .article-list.grid-4x4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .article-list.grid-4x4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .article-list.grid-4x4 {
    grid-template-columns: 1fr;
  }
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 40px 0 60px;
  flex-wrap: wrap;
}

.pagination a, .pagination span {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  background: white;
  transition: all 0.2s ease;
}

.pagination a:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.pagination span.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.pagination span.ellipsis {
  border: none;
  background: transparent;
}

.article-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.article-card-image {
  width: calc(100% + 48px);
  margin: -24px -24px 16px -24px;
  height: 200px;
  object-fit: cover;
  border-bottom: 1px solid var(--border-color);
}

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

.article-category {
  color: var(--accent-color);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.article-card h3 {
  font-size: 1.3rem;
  margin: 0 0 12px 0;
  line-height: 1.4;
}

.article-card h3 a {
  color: var(--primary-color);
  text-decoration: none;
}

.article-card:hover h3 a {
  color: var(--accent-color);
}

.article-excerpt {
  color: var(--text-muted);
  font-size: 0.95rem;
  flex-grow: 1;
  margin-bottom: 20px;
}

.article-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  font-size: 0.8rem;
  color: #999;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

/* ---------- Article Page ---------- */
.article-header {
  margin-bottom: 40px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
}

.article-header h1 {
  font-size: 2.8rem;
  margin: 15px 0;
}

.article-meta {
  display: flex;
  gap: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  align-items: center;
}

.article-body {
  font-size: 1.1rem;
}

.article-body h2 {
  margin-top: 2em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--border-color);
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin: 20px 0;
}

/* Verify Markers */
.verify-marker {
  background: #fff3cd;
  color: #856404;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  margin: 0 4px;
  box-shadow: 0 0 0 1px #ffeeba;
}

/* ---------- Sidebar & Widgets ---------- */
.sidebar-widget {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 30px;
}

.sidebar-widget h4 {
  margin-bottom: 15px;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar-widget ul {
  list-style: none;
}

.sidebar-widget li {
  margin-bottom: 12px;
}

.sidebar-widget a {
  color: var(--primary-color);
  font-weight: 500;
  display: flex;
  align-items: center;
  transition: var(--transition);
}

.sidebar-widget a::before {
  content: '→';
  margin-right: 8px;
  color: var(--accent-color);
  opacity: 0;
  transform: translateX(-10px);
  transition: var(--transition);
}

.sidebar-widget a:hover {
  color: var(--accent-color);
  transform: translateX(5px);
}

.sidebar-widget a:hover::before {
  opacity: 1;
  transform: translateX(0);
}

/* ---------- Table of Contents (.toc) ---------- */
.toc {
  margin: 30px 0;
  background: white;
  padding: 20px 25px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.toc h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.2rem;
}

.toc ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc li {
  margin-bottom: 12px;
  padding-left: 20px;
  position: relative;
}

.toc li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent-color);
  font-weight: bold;
}

.toc a {
  text-decoration: none;
  color: var(--secondary-color);
  font-weight: 500;
  transition: color 0.2s ease;
}

.toc a:hover {
  color: var(--accent-color);
}

/* ---------- Adsense Placeholders ---------- */
.ad-slot {
  background: #f1f3f5;
  border: 2px dashed #dee2e6;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #adb5bd;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 30px 0;
}

.ad-leaderboard {
  width: 100%;
  height: 90px;
}

.ad-sidebar {
  width: 100%;
  height: 250px;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--primary-color);
  color: rgba(255, 255, 255, 0.7);
  padding: 60px 0 30px;
  margin-top: auto;
}

.site-footer .site-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 40px;
}

.footer-brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  margin-bottom: 10px;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.7);
}

.footer-links a:hover {
  color: white;
}

.footer-copy {
  grid-column: 1 / -1;
  text-align: center;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
}
