/* MSiR Article Template Styles - Enhanced Blog Experience */

/* Import design tokens and fonts */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700;900&family=Source+Sans+Pro:wght@300;400;600&family=Source+Code+Pro:wght@400;600&display=swap');

:root {
  /* Enhanced Brand Colors */
  --mad-magenta: #ff3e8a;
  --scientific-cyan: #00a9e0;
  --experiment-orange: #ff9b42;
  --laboratory-dark: #2d3142;
  --flash-green: #57cc99;
  --paper-white: #f8f9fa;
  --midnight-dark: #1a1d2e;
  --lab-gray: #6c757d;
  
  /* Extended Color Palette */
  --accent-purple: #8b5cf6;
  --warning-yellow: #fbbf24;
  --success-green: #10b981;
  --error-red: #ef4444;
  
  /* Advanced Gradients */
  --gradient-vibrant: linear-gradient(135deg, var(--mad-magenta) 0%, var(--scientific-cyan) 100%);
  --gradient-warm: linear-gradient(135deg, var(--experiment-orange) 0%, var(--mad-magenta) 100%);
  --gradient-cool: linear-gradient(135deg, var(--scientific-cyan) 0%, var(--flash-green) 100%);
  --gradient-cosmic: linear-gradient(135deg, var(--accent-purple) 0%, var(--mad-magenta) 50%, var(--scientific-cyan) 100%);
  --gradient-sunset: linear-gradient(135deg, var(--experiment-orange) 0%, var(--warning-yellow) 100%);
  
  /* Typography Scale */
  --font-heading: 'Montserrat', sans-serif;
  --font-body: 'Source Sans Pro', sans-serif;
  --font-code: 'Source Code Pro', monospace;
  
  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: 4rem;
  --space-3xl: 6rem;
  
  /* Advanced Shadows */
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 16px rgba(0,0,0,0.15);
  --shadow-xl: 0 16px 32px rgba(0,0,0,0.2);
  --shadow-glow: 0 0 20px rgba(255, 62, 138, 0.3);
  --shadow-cyber: 0 0 30px rgba(0, 169, 224, 0.4);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.6s ease;
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --paper-white: var(--midnight-dark);
  --laboratory-dark: #e2e8f0;
  --lab-gray: #94a3b8;
}

/* Base Reset and Typography */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.article-page {
  font-family: var(--font-body);
  color: var(--laboratory-dark);
  background: var(--paper-white);
  line-height: 1.7;
  font-size: 18px;
  overflow-x: hidden;
}

/* Enhanced Navigation */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  transition: all var(--transition-normal);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.dark-mode-toggle {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform var(--transition-fast);
  padding: var(--space-sm);
  border-radius: 50%;
}

.dark-mode-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  background: rgba(0, 169, 224, 0.1);
}

/* Reading Progress Bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: var(--gradient-vibrant);
  z-index: 1001;
  transition: width 0.1s ease;
}

/* Table of Contents */
.table-of-contents {
  position: sticky;
  top: 120px;
  float: right;
  width: 280px;
  margin: 0 0 var(--space-lg) var(--space-lg);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: var(--space-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(0, 169, 224, 0.1);
  z-index: 10;
}

.table-of-contents h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--scientific-cyan);
  margin-bottom: var(--space-md);
  font-size: 1.1rem;
}

.toc-list {
  list-style: none;
  margin-bottom: var(--space-md);
}

.toc-list li {
  margin-bottom: var(--space-sm);
}

.toc-list a {
  color: var(--laboratory-dark);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.4;
  display: block;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 8px;
  transition: all var(--transition-normal);
  border-left: 3px solid transparent;
}

.toc-list a:hover,
.toc-list a.active {
  background: rgba(0, 169, 224, 0.1);
  border-left-color: var(--scientific-cyan);
  transform: translateX(4px);
}

.toc-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-size: 0.85rem;
  color: var(--lab-gray);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding-top: var(--space-md);
}

/* Article Container */
.article-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
  position: relative;
}

.article-content {
  max-width: 800px;
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--laboratory-dark);
}

/* Enhanced Typography */
.article-content h1 {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: var(--space-lg);
  background: var(--gradient-vibrant);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.article-content h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  margin: var(--space-3xl) 0 var(--space-lg);
  color: var(--laboratory-dark);
  position: relative;
  padding-left: var(--space-md);
}

.article-content h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 80%;
  background: var(--gradient-vibrant);
  border-radius: 2px;
}

.article-content h2:first-of-type {
  margin-top: var(--space-lg);
}

.article-content h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  margin: var(--space-xl) 0 var(--space-md);
  color: var(--scientific-cyan);
}

.article-content h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.25rem;
  margin: var(--space-lg) 0 var(--space-md);
  color: var(--experiment-orange);
}

.article-content p {
  margin-bottom: var(--space-lg);
  text-align: justify;
}

.article-content p:first-of-type {
  font-size: 1.25rem;
  color: var(--mad-magenta);
  font-weight: 400;
  margin-bottom: var(--space-xl);
  font-style: italic;
}

/* Enhanced Lists */
.article-content ul, 
.article-content ol {
  margin: var(--space-lg) 0;
  padding-left: var(--space-xl);
}

.article-content li {
  margin-bottom: var(--space-md);
  position: relative;
}

.article-content ul li::before {
  content: '▸';
  color: var(--mad-magenta);
  font-weight: bold;
  position: absolute;
  left: -1.5rem;
  top: 0;
  font-size: 1.2em;
}

.article-content ol li {
  counter-increment: step-counter;
}

.article-content ol li::before {
  content: counter(step-counter);
  background: var(--gradient-vibrant);
  color: white;
  font-weight: bold;
  border-radius: 50%;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: -2.5rem;
  top: 0.1em;
  font-size: 0.8rem;
}

.article-content ol {
  counter-reset: step-counter;
}

/* Enhanced Blockquotes and Callouts */
.science-note, .pro-tip, .warning-note, .deep-dive {
  margin: var(--space-xl) 0;
  padding: var(--space-lg);
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.science-note {
  background: linear-gradient(135deg, rgba(0,169,224,0.05) 0%, rgba(255,62,138,0.05) 100%);
  border-left: 4px solid var(--scientific-cyan);
}

.pro-tip {
  background: linear-gradient(135deg, rgba(87,204,153,0.05) 0%, rgba(255,155,66,0.05) 100%);
  border-left: 4px solid var(--flash-green);
}

.warning-note {
  background: linear-gradient(135deg, rgba(251,191,36,0.05) 0%, rgba(239,68,68,0.05) 100%);
  border-left: 4px solid var(--warning-yellow);
}

.deep-dive {
  background: linear-gradient(135deg, rgba(139,92,246,0.05) 0%, rgba(45,49,66,0.05) 100%);
  border-left: 4px solid var(--accent-purple);
}

/* Enhanced Demo Integration */
.demo-preview-card {
  margin: var(--space-xl) 0;
  border-radius: 20px;
  overflow: hidden;
  background: white;
  box-shadow: var(--shadow-xl);
  cursor: pointer;
  transition: all var(--transition-normal);
  border: 1px solid rgba(0, 169, 224, 0.1);
}

.demo-preview-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-cyber);
}

.demo-preview {
  position: relative;
  height: 320px;
  background: var(--gradient-cosmic);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.demo-preview::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(255,255,255,0.03) 10px,
      rgba(255,255,255,0.03) 20px
    );
  animation: slidePattern 20s linear infinite;
}

@keyframes slidePattern {
  0% { transform: translateX(0); }
  100% { transform: translateX(28px); }
}

.demo-play-button {
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.95);
  color: var(--laboratory-dark);
  border: none;
  padding: var(--space-lg) var(--space-xl);
  border-radius: 60px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
}

.demo-play-button:hover {
  background: white;
  transform: scale(1.05);
  box-shadow: var(--shadow-xl);
}

.demo-play-button .icon {
  font-size: 1.5rem;
  color: var(--mad-magenta);
}

.demo-description {
  padding: var(--space-lg) var(--space-xl);
}

.demo-description h3 {
  color: var(--laboratory-dark);
  margin-bottom: var(--space-sm);
  font-family: var(--font-heading);
  font-size: 1.5rem;
}

.demo-description p {
  color: var(--lab-gray);
  font-size: 1rem;
  margin: 0;
}

/* Enhanced Pull Quotes */
.pull-quote {
  font-size: 1.75rem;
  font-weight: 300;
  color: var(--scientific-cyan);
  text-align: center;
  margin: var(--space-3xl) 0;
  padding: var(--space-xl);
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  border-image: var(--gradient-vibrant) 1;
  font-style: italic;
  position: relative;
  background: rgba(0, 169, 224, 0.02);
  border-radius: 16px;
}

.pull-quote::before,
.pull-quote::after {
  content: '"';
  font-size: 4rem;
  color: rgba(0,169,224,0.2);
  position: absolute;
  font-family: Georgia, serif;
  font-weight: 900;
}

.pull-quote::before {
  top: -10px;
  left: 20px;
}

.pull-quote::after {
  bottom: -40px;
  right: 20px;
}

/* Article Actions Sidebar */
.article-actions {
  position: fixed;
  right: var(--space-lg);
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.action-buttons button,
.action-buttons a {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 169, 224, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
  color: var(--laboratory-dark);
  text-decoration: none;
}

.action-buttons button:hover,
.action-buttons a:hover {
  background: var(--scientific-cyan);
  color: white;
  transform: scale(1.1);
  box-shadow: var(--shadow-cyber);
}

/* Related Articles */
.related-articles {
  background: linear-gradient(135deg, rgba(0,169,224,0.03) 0%, rgba(255,62,138,0.03) 100%);
  padding: var(--space-3xl) 0;
  margin-top: var(--space-3xl);
}

.related-articles h2 {
  text-align: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 2.5rem;
  margin-bottom: var(--space-xl);
  background: var(--gradient-vibrant);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-xl);
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* Article Footer */
.article-footer {
  background: var(--laboratory-dark);
  color: var(--paper-white);
  padding: var(--space-3xl) 0 var(--space-lg);
  margin-top: var(--space-3xl);
}

.footer-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-3xl);
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.author-section {
  display: flex;
  gap: var(--space-lg);
  align-items: flex-start;
}

.author-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--gradient-vibrant);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
  color: white;
  flex-shrink: 0;
}

.social-sharing h4 {
  color: var(--scientific-cyan);
  margin-bottom: var(--space-md);
}

.share-buttons {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.share-buttons a {
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  text-decoration: none;
  border-radius: 25px;
  font-size: 0.9rem;
  transition: all var(--transition-normal);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.share-buttons a:hover {
  background: var(--scientific-cyan);
  transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 1200px) {
  .table-of-contents {
    display: none;
  }
  
  .article-content {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .article-container {
    padding: var(--space-lg) var(--space-md);
  }
  
  .article-actions {
    position: static;
    transform: none;
    margin: var(--space-xl) 0;
  }
  
  .action-buttons {
    flex-direction: row;
    justify-content: center;
  }
  
  .footer-content {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }
  
  .author-section {
    flex-direction: column;
    text-align: center;
  }
  
  .pull-quote {
    font-size: 1.5rem;
    padding: var(--space-lg);
  }
}

/* Print Styles */
@media print {
  .header,
  .table-of-contents,
  .article-actions,
  .related-articles,
  .demo-preview-card {
    display: none;
  }
  
  .article-container {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  
  .article-content {
    font-size: 12pt;
    line-height: 1.6;
  }
}

/* Accessibility Enhancements */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

*:focus-visible {
  outline: 3px solid var(--scientific-cyan);
  outline-offset: 2px;
}