@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap');
/* ============================================
   Modern Website Styling
   ============================================ */

:root {
  --primary-color: #667eea;
  --secondary-color: #764ba2;
  --accent-color: #ec4899;
  --dark-bg: #0f172a;
  --light-bg: #f8fafc;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 2px 8px 0 rgba(0, 0, 0, 0.12);
  --shadow-md: 0 6px 16px -1px rgba(0, 0, 0, 0.18);
  --shadow-lg: 0 16px 32px -3px rgba(0, 0, 0, 0.22);
  --content-max: 900px;
  --nav-link-radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  position: relative;
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: #ffffff;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

/* Navigation */
.navbar {
  box-shadow: var(--shadow-sm);
  background-color: var(--dark-bg) !important;
}

.navbar-brand {
  font-size: 1.5rem;
  letter-spacing: -0.5px;
  color: rgba(255, 255, 255, 0.95) !important;
}

.navbar-brand:hover,
.navbar-brand:focus {
  color: #ffffff !important;
}

.nav-link {
  font-weight: 500;
  transition: color 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
  color: rgba(255, 255, 255, 0.85) !important;
}

.nav-link:hover {
  color: var(--primary-color) !important;
}

.nav-link.active {
  color: var(--primary-color) !important;
  box-shadow: inset 0 -2px 0 var(--primary-color);
}

/* Navbar layout fixes (prevents list bullets / vertical stacking when Bootstrap defaults are overridden) */
.navbar .container,
.navbar .container-fluid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.navbar-nav {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

.navbar-nav li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.navbar-nav .nav-link {
  padding: 0.5rem 0.75rem;
  border-radius: var(--nav-link-radius);
  overflow: hidden;
}

.navbar-nav .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

/* If the navbar collapses on small screens, allow vertical stacking */
@media (max-width: 768px) {
  .navbar .container,
  .navbar .container-fluid {
    flex-wrap: wrap;
  }

  .navbar-nav {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding-top: 0.5rem;
  }
}

/* Page Header Section */
.page-header-section {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  padding: 3rem 0;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.page-header-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 120"><path d="M0,50 Q300,100 600,50 T1200,50 L1200,120 L0,120 Z" fill="rgba(255,255,255,0.05)"/></svg>') no-repeat bottom;
  background-size: cover;
  pointer-events: none;
}

.page-header-section .container {
  position: relative;
  z-index: 1;
}

.page-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -1px;
}

.page-subtitle {
  font-size: 1.1rem;
  margin: 0.5rem 0 0 0;
  opacity: 0.95;
  font-weight: 300;
}

/* Ensure header text stays light even though global heading styles set dark colors */
.page-header-section .page-title,
.page-header-section .page-subtitle,
.page-header-section h1,
.page-header-section h2,
.page-header-section h3,
.page-header-section h4,
.page-header-section h5,
.page-header-section h6 {
  color: #ffffff;
}

.page-header-section p,
.page-header-section li,
.page-header-section a {
  color: rgba(255, 255, 255, 0.92);
}

.page-header-section a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* Main Content */
.main-content {
  flex: 1;
}

.container {
  max-width: var(--content-max);
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

@media (min-width: 1024px) {
  .container {
    padding-left: 1.75rem;
    padding-right: 1.75rem;
  }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2rem;
  color: var(--primary-color);
}

h2 {
  font-size: 1.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-color);
  display: inline-block;
}

h3 {
  font-size: 1.35rem;
}

h4 {
  font-size: 1.1rem;
}

p {
  color: var(--text-secondary);
  margin: 0 0 1rem 0;
  line-height: 1.7;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.3s ease;
  font-weight: 500;
}

a:hover {
  color: var(--secondary-color);
  text-decoration: underline;
}

/* If a button contains an <a>, inherit the button’s color instead of the global link color */
.btn a {
  color: inherit !important;
  text-decoration: none !important;
}

.btn a:hover {
  color: inherit !important;
  text-decoration: none !important;
}

/* Lists */
ul, ol {
  color: var(--text-secondary);
  margin: 0 0 1.5rem 0;
  padding-left: 1.5rem;
}

ul li, ol li {
  margin-bottom: 0.5rem;
  line-height: 1.8;
}

/* Code Blocks */
code {
  background-color: var(--light-bg);
  color: var(--accent-color);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: 'Space Mono', monospace;
  font-size: 0.9em;
}

pre {
  background-color: var(--dark-bg);
  color: #e0e0e0;
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
  font-size: 0.95em;
}

/* Cards & Boxes */
.card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
  overflow: hidden;
  margin-bottom: 1rem; /* spacing between stacked cards */
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5,
.card-header h6 {
  margin: 0;
  padding: 0;
  border: none;
  color: inherit;
  font-size: 1rem;
}

.card-body {
  padding: 1.25rem 1.5rem;
}

.card-body p {
  margin-top: 0;
}

/* Buttons */
.btn {
  font-weight: 600;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  transition: all 0.3s ease;
  text-transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
  border: none;
  color: #ffffff !important;
}

.btn-primary,
.btn-primary * {
  color: #ffffff !important;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  color: #ffffff !important;
}

.btn-outline-primary {
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-outline-primary:hover {
  background-color: var(--primary-color);
  color: white;
}

/* Footer */
.footer {
  margin-top: auto;
  background-color: var(--dark-bg);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
  padding: 1.5rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-left: max(1rem, calc((100vw - var(--content-max)) / 2));
  padding-right: max(1rem, calc((100vw - var(--content-max)) / 2));
}

.footer h1,
.footer h2,
.footer h3,
.footer h4,
.footer h5,
.footer h6 {
  color: #ffffff;
}

.footer p,
.footer li {
  color: inherit;
}

.footer p {
  margin: 0;
}

.footer a {
  color: rgba(255, 255, 255, 0.85);
}

.footer a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* Blockquotes */
blockquote {
  border-left: 4px solid var(--primary-color);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  background-color: var(--light-bg);
  color: var(--text-secondary);
  border-radius: 0 8px 8px 0;
}

/* Content images */
.main-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
}

.main-content img.img-fluid {
  box-shadow: var(--shadow-sm);
  border-radius: 12px !important;
  transition: all 0.3s ease;
}

.main-content img.img-fluid:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.inline-formula {
  display: inline-block;
  white-space: nowrap;
}

/* Tables */
.main-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.main-content table th,
.main-content table td {
  border: 1px solid var(--border-color) !important;
  padding: 0.65rem 0.9rem !important;
  vertical-align: top;
  color: var(--text-secondary);
}

.main-content table th {
  background-color: var(--light-bg);
  font-weight: 600;
  color: var(--text-secondary);
}

/* MathJax formulas — target container and all inner rendered elements */
.main-content .MathJax,
.main-content .MathJax *,
.main-content .MathJax_Display,
.main-content .MathJax_Display *,
.main-content .MathJax_Preview,
.main-content .MathJax_Preview *,
.main-content .mjx-chtml,
.main-content .mjx-chtml *,
.main-content .MJXc-display,
.main-content .MJXc-display * {
  color: var(--text-secondary) !important;
}

.main-content table tr:nth-child(even) td {
  background-color: #fafbfc;
}

/* Responsive Design */
@media (max-width: 768px) {
  .page-title {
    font-size: 2rem;
  }

  .page-subtitle {
    font-size: 1rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .page-header-section {
    padding: 2rem 0;
  }
}

/* Utilities */
.text-muted {
  color: var(--text-secondary) !important;
}

.text-light {
  color: #f0f0f0 !important;
}

.fw-500 {
  font-weight: 500;
}
